Skip to content

Commit efbbba9

Browse files
committed
ugh
1 parent 93d13d3 commit efbbba9

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎v4-cokapi/backends/ruby/pg_logger.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# - limit execution to N steps -- use instruction_limit_reached event type
1313
# - catch the execution of the LAST line in a user's script
1414
# - 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
1618
#
1719
# Limitations:
1820
# - no support for (lexical) environment pointers, since MRI doesn't seem to
@@ -24,6 +26,7 @@
2426

2527
require 'json'
2628
require 'debug_inspector' # gem install debug_inspector, use on Ruby 2.X
29+
require 'binding_of_caller' # gem install binding_of_caller
2730

2831
script_name = ARGV[0]
2932
cod = File.open(script_name).read
@@ -43,6 +46,15 @@
4346
# inject a frame_id variable into the function's frame
4447
if tp.event == :call || tp.event == :b_call
4548
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
4658
end
4759

4860
p [tp.event, tp.lineno, tp.path, tp.defined_class, tp.method_id]

‎v4-cokapi/backends/ruby/tests/recursive-fact.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ def fact n
88
end
99
end
1010

11-
puts fact 5
11+
puts fact 4

0 commit comments

Comments
 (0)