Lldb functionality for debugging windows binaries when the path to pdb file is different from one embedded into the .exe file

I am new to this forum and apologies if I am posting in the wrong channel. I did post this question on discord but haven’t got any response.

The exe is located in samplec directory but the pdb is moved to samplec\temp

(lldb) target symbols add D:\repos\samplec\temp\test.pdb
(lldb) target module list
[  0] A5F2D169-7CD0-40B6-91BE-64F189ACBB57-00000001 0x0000000140000000 D:\repos\samplec\test.exe
      D:\repos\samplec\temp\test.pdb
(lldb) target modules lookup -A -n main

Unable to find the main symbol. Looking at the symfile it shows nothing.

(lldb)  target module  dump symfile
Dumping debug symbols for 1 modules.
SymbolFile pdb (D:\repos\samplec\test.exe)
Types:

Compile units:

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

The pdb file indeed have symbols. So when I copy the pdb file back to the place where .exe is everything works fine.

Thanks in advance.

Try setting this:

  target.debug-file-search-paths -- List of directories to be searched when locating debug symbol files. See also symbols.enable-external-lookup.

settings set target.debug-file-search-paths <some path>. This may not have an effect if:

  1. The PDB plugin is mistakenly ignoring this setting or -
  2. The .exe file has an absolute path to the PDB file embedded in it.

If that does not solve the problem, please open an issue (GitHub · Where software is built) explaining how to reproduce the problem, so someone can look for the cause.

Thanks for the suggestion. I tried building the exe with relative PDB file name embedded in it.

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

  Debug Directories

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

But still I don’t see the symbols listed. Created an issue LLDB cannot load PDB symbols if the PDB path differs from the one embedded in the .exe · Issue #169628 · llvm/llvm-project · GitHub with the repro steps.

(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 modules.
SymbolFile pdb (D:\repos\samplec\test.exe)
Types:

Compile units:

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

Just to update the thread. Setting LLDB_USE_NATIVE_PDB_READER to 1 made it work as described in the issue.