microsoft / v8-jsi

React Native V8 JSI adapter
Other
157 stars 36 forks source link

Ensure source links work #156

Open aeulitz opened 1 year ago

aeulitz commented 1 year ago

Replacing VSO:5259293 in an effort to create bugs that are more specific and further upstream.

Among the things that VSO:5259293 asked for was for V8 source code to resolve in the debugger. As I understand it, we attempted to address this by the addition of source links (scripts\fetch_code.ps1). However, as per a quick check with a devinstalled Office ( lkg/main/dev 16.0.16012.15010 (b7ab2e58b0)), symbols get loaded ...

0:106> lmDvmv8jsi Browse full module list start end module name 00007ffad7f30000 00007ffada104000 v8jsi (private pdb symbols) c:\symbols\v8jsi.dll.pdb\130A78201C1243A0B45DA03F4F31012D1\v8jsi.dll.pdb Loaded symbol image file: C:\Program Files\Microsoft Office\root\Office16\v8jsi.dll

However, sources do not appear to get resolved (using v8runtime::V8Runtime::ExecuteString as an example, WinDbg does not open any source file):

0:093> bl 0 e Disable Clear 00007ffad7f82a10 [D:\a\_work\1\s\build\v8build\v8\jsi\V8JsiRuntime.cpp @ 710] 0001 (0001) 0:**** v8jsi!v8runtime::V8Runtime::ExecuteString 0:093> g ... Breakpoint 0 hit v8jsi!v8runtime::V8Runtime::ExecuteString: 00007ffad7f82a10 4c894c2420 mov qword ptr [rsp+20h],r9 ss:000000f0`c6dc

aeulitz commented 1 year ago

I found that the following sequence of commands can be used to show the source links embedded in the PDB.

  1. Display sourcelink string names in the PDB via
    pdbdump v8jsi.dll.pdb strnames | findstr "sourcelink

This outputs something like

892:     297  sourcelink$1
894:       0  sourcelink$2

I found pdbdump.exe on the \vcfs\builds\msvc\main\20221214.01\binaries.amd64ret\bin\amd64 release share (path probably needs to be adjusted for current releases).

  1. Pass the string names displayed by the above command into pdbstr
pdbstr -p:v8jsi.dll.pdb -r -i:d:\temp\out.txt -s:'sourcelink$1

I found pdbstr.exe in d:\nugetcache\microsoft.windows.dbg.srcsrv.10.0.17074.10021\lib\amd64

The output file generated by the above command (d:\temp\out.txt) shows the JSON sourcelink map:

{
    "documents": {
        "D:\a\_work\1\s\\build\\v8build\\v8\\*" : "https://raw.githubusercontent.com/v8/v8/10.6.194.10/*",
        "D:\a\_work\1\s\\build\\v8build\\v8\\jsi\\*" : "https://raw.githubusercontent.com/microsoft/v8-jsi/0492cb64ee645a2796ff0f1eb768a46611f2bc2c/src/*"
    }
}

It seems that the local paths in the above map contain a mix of '\' and '\\' path separators. I'm guessing that in order to be valid JSON, all local path separators should be '\\'.