xref: /llvm-project/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp (revision cf3464bbb796d492bcd4e764ada945304e0c874f)
1242e1e99SZequan Wu // clang-format off
2242e1e99SZequan Wu // REQUIRES: lld, x86
3242e1e99SZequan Wu 
4242e1e99SZequan Wu // Test that lldb load PDB file by command `target symbols add`
5242e1e99SZequan Wu 
6242e1e99SZequan Wu // RUN: mkdir -p %t/executable
7242e1e99SZequan Wu // RUN: rm -f %t/executable/foo.exe %t/executable/bar.pdb
8242e1e99SZequan Wu // RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t/executable/foo.obj -- %s
9242e1e99SZequan Wu // RUN: lld-link -debug:full -nodefaultlib -entry:main %t/executable/foo.obj \
10242e1e99SZequan Wu // RUN:     -out:%t/executable/foo.exe -pdb:%t/executable/foo.pdb
11242e1e99SZequan Wu // Rename the PDB file so that the name is different from the name inside the executable (foo.exe).
12242e1e99SZequan Wu // RUN: mv %t/executable/foo.pdb %t/executable/bar.pdb
13*cf3464bbSJonas Devlieghere // RUN: %lldb %t/executable/foo.exe \
14242e1e99SZequan Wu // RUN: -o "target symbols add %t/executable/bar.pdb" \
15242e1e99SZequan Wu // RUN: -o "b main" \
16242e1e99SZequan Wu // RUN: -o "image dump symfile" -o "quit" | FileCheck %s
17242e1e99SZequan Wu 
18242e1e99SZequan Wu int main(int argc, char** argv) {
19242e1e99SZequan Wu   return 0;
20242e1e99SZequan Wu }
21242e1e99SZequan Wu 
22242e1e99SZequan Wu // CHECK: (lldb) target symbols add {{.*}}bar.pdb
23779deb97SZequan Wu // CHECK: symbol file '{{.*}}bar.pdb' has been added to '{{.*}}foo.exe'
24242e1e99SZequan Wu // CHECK: (lldb) b main
25c161775dSPaul Robinson // CHECK: Breakpoint 1: where = foo.exe`main + 21 at load-pdb.cpp:19, address = 0x0000000140001015
26242e1e99SZequan Wu // CHECK: (lldb) image dump symfile
27242e1e99SZequan Wu // CHECK: Types:
28242e1e99SZequan Wu // CHECK: {{.*}}: Type{0x00010024} , size = 0, compiler_type = {{.*}} int (int, char **)
29242e1e99SZequan Wu // CHECK: Compile units:
30779deb97SZequan Wu // CHECK: {{.*}}: CompileUnit{0x00000000}, language = "c++", file = '{{.*}}load-pdb.cpp'
314b83747aSZequan Wu // CHECK: {{.*}}:   Function{{{.*}}}, demangled = main, type = {{.*}}
324b83747aSZequan Wu // CHECK: {{.*}}:   Block{{{.*}}}
33