Search code examples
v8

How to debug V8 with source code view using WinDbg?


I was looking into learning more about V8 internals and I have tired to set up a debug environment to help me with that, but I'm relatively new to all that so I'm not sure if I'm doing it right.

I have compiled V8 with the debug flag set to true and have run D8 to test the build out. After attaching WinDbg to the D8 process, I have set a breakpoints on Math.hypot (v8!Builtins_MathHypot) function to try to see how it works:

enter image description here

My question is: the source code for most of the functions in the call stack is linked and I can debug them by navigating through either assembly or source code (you can also see the path to the source code in the call stack next to the function). But for v8!Builtins_*, there is no source code displayed. Am I doing something wrong or is that intended? Is there a way to make the source code view work for these functions too?


Solution

  • V8 developer here. There are different kinds of builtins: some of them are handwritten assembly, or generated at compile time using the "CodeStubAssembler" infrastructure; others are implemented in C++. For the latter, you should be able to see the source. MathHypot is among them, so I don't know why that isn't working (I don't use WinDbg). Maybe it's because the function entry is generated from a macro; try setting your breakpoint to a line of actual C++ source code, in this case builtins-math.cc:18.

    For JSEntry, JSEntryTrampoline, and InterpreterEntryTrampoline, it's expected that there is no source.

    You can see the list of builtins, including their type, in src/builtins/builtins-definitions.h.