I recently started to swap out all my debugger
statements with eval('debugger')
statements. The reason is that with the plain version, not all "factually/theoretically" visible variables are "practically" visible. This happens because of optimization (see earlier SO question).
With this trick, the problem is like "90% solved" - there are some drawbacks. Apart from longer source code, those are:
- When third party libraries are involved, it is not feasible, maybe not even possible to have the
debugger
->eval('debugger')
transformation done there also. - When I would rather set a break point in the debugger itself, instead of changing the code, that cannot be done - or can it?
- When I'm already stopped at a "normal"
debugger
statement (in third party code, or where I forgot one), there is no way to switch to the desired mode - certainly typingeval('debugger')
on the console doesn't help. If I want the functionality, I have to change the debugger statement, and run the code again, which might be a whole lot of work - When I stopped at an
eval('debugger')
statement, but then use the debugger 'step over/into/out' functionality, I 'lost my special status'.
How can I work around this? Is there a way to tell v8 to interpret all debugger statements by eval('debugger')? Is there a trick with which you can 'go into the other mode' - as if the eval('debugger') statement would magically appear as the next statement after the debugger statement where you're stopped? Do command line options to the chrome executable help? Maybe there is a way in firefox?
I learned about the eval('debugger')
trick in an answer to a recent SO question of my own
ANNOUNCEMENT
What I'm going to do next is write a little transpiler for usage within node webserver. The transpiler will insert eval('')
statements all over the place (by default once at the beginning/body of every function, and more or fewer of them if so specified in the query string.) Then I can set a breakpoint where the eval statement is, do "step into" and then I got what I want. Then I'm going to answer my own question.
Unless of course, someone will beat me to it. That would be most delightful, as I do have other things to do.