|
12 | 12 | # - limit execution to N steps -- use instruction_limit_reached event type |
13 | 13 | # - catch the execution of the LAST line in a user's script |
14 | 14 | # - display TRUE global $variables rather than just locals of the top-most frame |
15 | | -# - support recursive calls with function ids |
| 15 | +# - support recursive calls with function frame ids |
| 16 | +# - maybe i need a stupid C extension to expose the pointer address of |
| 17 | +# each frame object in the interpreter?!? ugh that would be a giant pain |
16 | 18 | # |
17 | 19 | # Limitations: |
18 | 20 | # - no support for (lexical) environment pointers, since MRI doesn't seem to |
|
24 | 26 |
|
25 | 27 | require 'json' |
26 | 28 | require 'debug_inspector' # gem install debug_inspector, use on Ruby 2.X |
| 29 | +require 'binding_of_caller' # gem install binding_of_caller |
27 | 30 |
|
28 | 31 | script_name = ARGV[0] |
29 | 32 | cod = File.open(script_name).read |
|
43 | 46 | # inject a frame_id variable into the function's frame |
44 | 47 | if tp.event == :call || tp.event == :b_call |
45 | 48 | puts 'CALLLL' |
| 49 | + # ughhhh, I can't seem to create a new local variable using |
| 50 | + # of_caller, although I can modify existing locals |
| 51 | + # crappp instance variables are kinda 'global' |
| 52 | + binding.of_caller(1).eval('@frame_id = ' + cur_frame_id.to_s) |
| 53 | + puts binding.of_caller(1).eval('@frame_id') |
| 54 | + #puts b.methods - Object.methods |
| 55 | + #puts b.frame_type, b.frame_description, b.callers |
| 56 | + #puts |
| 57 | + cur_frame_id += 1 |
46 | 58 | end |
47 | 59 |
|
48 | 60 | p [tp.event, tp.lineno, tp.path, tp.defined_class, tp.method_id] |
|
0 commit comments