| Class | Ruva::Utils::PrintTracer |
| In: |
lib/ruva/utils/exec_trace.rb
|
| Parent: | Object |
Prints out the execution trace of a VM as it runs. To use, pass an instance of this class to the vm, e.g. via the :trace option to Ruva::JVM.create.
# File lib/ruva/utils/exec_trace.rb, line 12
12: def initialize(stream = STDOUT, show_code = true)
13: @stream = stream
14: @code = show_code
15: @frame = nil
16: end
# File lib/ruva/utils/exec_trace.rb, line 18
18: def trace(frame, noperands, opnum, operands)
19: if frame != @frame
20: @frame = frame
21: @stream.puts("In: #{frame.clz.name}.#{frame.method.name}#{frame.method.desc}")
22: end
23:
24: if @code
25: @stream.puts(sprintf(" @%-5d::%-15s -> %10s ; S: %s ; L: %s",
26: frame.pc - noperands - 1, Ruva::VM::OPMAP[opnum].first, operands.inspect,
27: print_stack(frame.stack), print_locals(frame.locals)))
28: end
29: end