Kernel#caller for non-current thread

Looks like it can be done in C by: set ruby_frame to the particular
th->frame, call backtrace(), and set it back. Is there a better way or
has anybody already done it?

Steve

Steven L. wrote:

Looks like it can be done in C by: set ruby_frame to the particular
th->frame, call backtrace(), and set it back. Is there a better way or
has anybody already done it?

Hm, is there anything in the implementation of #backtrace that could
cause another thread to run? Maybe Thread.critical=true is needed…

This would be nice to have, if it works.

Joel VanderWerf [email protected] writes:

Steven L. wrote:

Looks like it can be done in C by: set ruby_frame to the particular
th->frame, call backtrace(), and set it back. Is there a better way or
has anybody already done it?

Hm, is there anything in the implementation of #backtrace that could
cause another thread to run? Maybe Thread.critical=true is needed…

This would be nice to have, if it works.

Unfortunately my initial scan of the source turned out to be too
quick. structs that I assumed would be defined in one of the header
files (struct thread) are actually defined in eval.c. I believe a lot
was opened up in 1.8.5 for Sandbox, but I haven’t checked it yet.

Steve

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs