James Ross wrote:
John J. Barton wrote:
Thanks to hints from people here, I found a way to debug eval() code
using the current JSD interface. I track all jsdIScript objects created
using onScriptCreated. For objects from eval() calls I create a maps
indexed by jsdIScript.tag giving the eval() source buffer and new
baseLineNumber. Then whenever the debugger needs source (and would use
jdsIScript.fileName) I check these maps. Details are here:
I don't have the time to read any details right now (at work), but is
this the same as using the pretty print source option in JSD, or is
there some other method you use for obtaining the source to these
virtual files?
I use jsdIStackFrame.eval("new String("+evalExpr+");") to get the
source. I construct the evalExpr by looking at the source of the caller
of the eval(), relying on the supposed immutable name "eval". Surely
there are cases where the evalExpr will be tough to extract without
a full parser (I'm just using regexp), but I guess most cases that
programmers write will work.
|