Skip to content

LLDB cannot load PDB symbols if the PDB path differs from the one embedded in the .exe #169628

@ntoslinux

Description

@ntoslinux

I am trying to debug a Windows PE file (.exe) using LLDB(lldb version 21.1.3) but am unable to get LLDB to load the PDB file, which is located in a different directory (D:\repos\samplec\temp) than the source directory (D:\repos\samplec\). test.c is a simple C file(attached) with a trivial main function.

cl test.c /Zi /sdl- /GS- /link /INCREMENTAL:NO /PDBALTPATH:test.pdb  <-- VS2022

  Debug Directories

        Time Type        Size      RVA  Pointer
    -------- ------- -------- -------- --------
    6926D0DD cv            21 000693B0    67BB0    Format: RSDS, {D1494573-763E-4AB6-9F01-61F1A74097B4}, 6, test.pdb

I tried the following but could not get LLDB to load the symbols from the PDB file:

(lldb) settings show target.debug-file-search-paths
target.debug-file-search-paths (file-list) =
  [0]: D:\repos\samplec\temp
(lldb) target symbols add D:\repos\samplec\temp\test.pdb
symbol file 'D:\repos\samplec\temp\test.pdb' has been added to 'D:\repos\samplec\test.exe'
(lldb) target module list
[  0] D1494573-763E-4AB6-9F01-61F1A74097B4-00000006 0x0000000140000000 D:\repos\samplec\test.exe
      D:\repos\samplec\temp\test.pdb
(lldb) target modules lookup -A -n main
(lldb) target module dump symfile
Dumping debug symbols for 1 module.
SymbolFile pdb (D:\repos\samplec\test.exe)
Types:

Compile units:

Symtab, file = D:\repos\samplec\test.exe, num_symbols = 0

The first time when I try to add the symbol I am hitting with below error.

D:\repos\samplec>lldb test.exe
(lldb) target create "test.exe"
Current executable set to 'D:\repos\samplec\test.exe' (x86_64).
(lldb) target symbols add D:\repos\samplec\temp\test.pdb
symbol file 'D:\repos\samplec\temp\test.pdb' has been added to 'D:\repos\samplec\test.exe'
(lldb) error: Assertion failed: (obj_load_address && obj_load_address != LLDB_INVALID_ADDRESS), function virtual SymbolFilePDB::InitializeObject, file SymbolFilePDB.cpp, line 205
 #0 0x00007ff9525a0441 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0x2800441)
 #1 0x00007ff9509c9458 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xc29458)
 #2 0x00007ff950b978c9 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xdf78c9)
 #3 0x00007ff95100740f PyInit__lldb (C:\LLVM\bin\liblldb.dll+0x126740f)
 #4 0x00007ff950d37ca2 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xf97ca2)
 #5 0x00007ff950d37bbd PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xf97bbd)
 #6 0x00007ff95088dd08 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xaedd08)
 #7 0x00007ff950de3e73 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0x1043e73)
 #8 0x00007ff950de1d70 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0x1041d70)
 #9 0x00007ff9508b30f0 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xb130f0)
#10 0x00007ff9508c90b6 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xb290b6)
#11 0x00007ff9508ce076 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xb2e076)
#12 0x00007ff950d254e2 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xf854e2)
#13 0x00007ff9508488b2 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xaa88b2)
#14 0x00007ff9508cfb10 PyInit__lldb (C:\LLVM\bin\liblldb.dll+0xb2fb10)
#15 0x00007ff95060a385 lldb::SBDebugger::RunCommandInterpreter(bool, bool) (C:\LLVM\bin\liblldb.dll+0x86a385)
#16 0x00007ff6e26d0de8 (C:\LLVM\bin\lldb.exe+0x20de8)
#17 0x00007ff6e26d1f11 (C:\LLVM\bin\lldb.exe+0x21f11)
#18 0x00007ff6e26e9488 (C:\LLVM\bin\lldb.exe+0x39488)
#19 0x00007ffa7734e8d7 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e8d7)
#20 0x00007ffa78cec53c (C:\WINDOWS\SYSTEM32\ntdll.dll+0x8c53c)
lldb version 21.1.3
Please file a bug report against lldb and include the backtrace, the version and as many details as possible.
(lldb) target module list
[  0] 75D75A0C-2477-4703-990B-71969B0B150D-00000001 0x0000000140000000 D:\repos\samplec\test.exe
      D:\repos\samplec\temp\test.pdb
(lldb) target symbols add D:\repos\samplec\temp\test.pdb
symbol file 'D:\repos\samplec\temp\test.pdb' has been added to 'D:\repos\samplec\test.exe'

It works if I don't move the PDB file to a different directory:

D:\repos\samplec>lldb test.exe
(lldb) target create "test.exe"
Current executable set to 'D:\repos\samplec\test.exe' (x86_64).
(lldb) target modules lookup -A -n main
1 match found in D:\repos\samplec\test.exe:
        Address: test.exe[0x00000001400010e0] (test.exe..text + 224)
        Summary: test.exe`main at test.c:28

Reference: https://discourse.llvm.org/t/lldb-functionality-for-debugging-windows-binaries-when-the-path-to-pdb-file-is-different-from-one-embedded-into-the-exe-file/88969

test.c

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions