Comment #3 on issue 3960 by [email protected]: Problems with Debug.setBreakPoint on node.js/io.js
https://code.google.com/p/v8/issues/detail?id=3960

I did some debugging, and here is what happens:

When you run the script, at first, the debugger is not loaded. The whole script is compiled without debug break points. Function f is hoisted to the top: we create a JSFunction object from the function literal and assign it to the global value "f". The JSFunction object points to a shared function object.

Then we load the debugger and keep it loaded by setting a listener.

Then we set a break point. Before doing so, we prepare for break points. This means that we we require all code to have debug break slots, so we recompile every JSFunction we find. This somehow includes the top-level script as well (we'll come to that later).

Then, we set the break point by script ID and position (we do it this way so that the devtools can find the same positions on reload). The problem here is that we try to find the shared function info corresponding to the script ID and position, and find the new one created when we recompiled. The break point is set to that new shared function info.

When we check for break points in f (via showBreakPoints), we use f's shared function info, which is the old one from before recompilation. Function f simply has no break points.

If you have --expose-debug-as, the debugger is active from the start, and everything is already prepared for break points, so this issue does not occur.

The curious thing is that we actually have protection against this: top-level scripts are not recompiled when preparing for break points in Debug::PrepareForBreakPoints. However, for some reason the script function is not marked as toplevel. In fact, the script doesn't seem to be compiled via CompileToplevel at all. I suspect that its wrapped into an anonymous function by node.js/io.js.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to