hacks/call_stack

This is a hack for accessing the call stack. It uses set_trace_func, so using this hack may degrade performance. The result will be a global variable $call_stack, which is an array containing information about the caller. Each element of the array is itself an array containing the same information as would be returned by set_trace_func. The current call information is stored in $current_call.

TODO: I need some good tests for this.

Eg.:

  def foo; eval("x = 42", $call_stack[1][4]); end
  def bar; foo; end
  x = nil
  bar
  puts x

class CallStack < Object

Public Methods

caller_file(level = 0)

caller_lineno(level = 0)

caller_func(level = 0)

caller_binding(level = 0)

caller_class(level = 0)

caller_self(level = 0)

Requires

call_stack.so
loaders
fix_trace_func