From: Reginald Tan Date: 2012-07-03T15:05:09+09:00 Subject: Re: Using binding + set trace func to capture execution state > > To achieve your goal you'd need to copy the state of variables at each > tracefunc invocation. Even worse, as the objects themselves may change, > you will need to do a deep copy each time (otherwise you'll pluck into > exactly the same problem with object instance variables). I would > suggest > marshalling the objects and writing them to something like tmpfs, then > using a special tool to navigate the captured information. > > This is going to consume a lot of memory. I repeat: a lot. Like tens > of gigabytes for a complex thing like... Sinatra. And probably > terabytes > for Rails. Hmm, you're right, it would not be efficient at all to store all those variables especially in a large program. I guess another possible approach is to rerun the program every time i want to inspect a variable. Since I know which file and line the variable is, I can use that as a condition on set_trace_func handler on when to output that variable. set_trace_func proc { |event, file, line, id, binding, classname| if event == "line" && file == "myfile.rb" && line == 4 puts eval("@myvar", binding) end } -- Posted via http://www.ruby-forum.com/.