diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 19:22:02 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 19:22:02 +0000 |
commit | 87aa9c9e4d41ed881453e2fab85b3d25f648bb55 (patch) | |
tree | 63efe79832bf3de4f63e4e81c62e73923947b882 /lldb/test/Shell/SymbolFile | |
parent | fd18e94697c987d5f24e25aa4e27adaffff3cce4 (diff) | |
download | bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.tar.gz bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.zip |
Re-land "[test] Split LLDB tests into API, Shell & Unit"
The original patch got reverted because it broke `check-lldb` on a clean
build. This fixes that.
llvm-svn: 374201
Diffstat (limited to 'lldb/test/Shell/SymbolFile')
166 files changed, 9456 insertions, 0 deletions
diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-elf.yaml b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-elf.yaml new file mode 100644 index 00000000000..905dc25c3a6 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-elf.yaml @@ -0,0 +1,33 @@ +# A very basic ELF file to serve as a recipient of breakpad info + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400000 +Sections: + - Name: .text1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400000 + AddressAlign: 0x0000000000001000 + Size: 0xb0 + - Name: .text2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004000B0 + AddressAlign: 0x0000000000000010 + Size: 0x42 +Symbols: +DynamicSymbols: +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x400000 + Align: 0x1000 + Sections: + - Section: .text1 + - Section: .text2 +... diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-macho.yaml b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-macho.yaml new file mode 100644 index 00000000000..9a4505c204d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-macho.yaml @@ -0,0 +1,50 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000002 + ncmds: 9 + sizeofcmds: 520 + flags: 0x00000085 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __PAGEZERO + vmaddr: 0 + vmsize: 4294967296 + fileoff: 0 + filesize: 0 + maxprot: 0 + initprot: 0 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 0 + filesize: 4096 + maxprot: 7 + initprot: 5 + nsects: 1 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100000FF0 + size: 6 + offset: 0x00000FF0 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_UUID + cmdsize: 24 + uuid: B3051760-22B1-7D7B-39F9-240E077D625B +... diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-discontinuous-file-ids.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-discontinuous-file-ids.syms new file mode 100644 index 00000000000..f19d5374056 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-discontinuous-file-ids.syms @@ -0,0 +1,8 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 1 /tmp/a.c +FILE 3 /tmp/c.c +FUNC b0 10 0 func +b0 1 1 1 +b1 1 2 1 +b2 1 2 3 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms new file mode 100644 index 00000000000..069b79cc57d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms @@ -0,0 +1,7 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +a0 1 1 0 +FUNC b0 10 0 func +FUNC c0 10 0 func2 +c0 2 2 0 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-missing-file.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-missing-file.syms new file mode 100644 index 00000000000..635716c6b06 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-missing-file.syms @@ -0,0 +1,7 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +FUNC b0 10 0 func +b0 1 1 0 +b1 1 2 0 +b2 1 2 1 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms new file mode 100644 index 00000000000..a0708e54dc0 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms @@ -0,0 +1,7 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +FILE 1 c:\tmp\b.c +FUNC b0 10 0 func +b0 1 1 0 +b1 1 1 1 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table.syms new file mode 100644 index 00000000000..e608eb8033e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/line-table.syms @@ -0,0 +1,17 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +FILE 1 /tmp/c.c +FILE 2 /tmp/d.c +FUNC b0 10 0 func +b0 1 1 0 +b1 1 2 0 +b2 1 2 1 +b4 1 3 1 +FUNC c0 10 0 func2 +c0 2 1 1 +c2 2 2 0 +FUNC d0 10 0 func3 +d0 2 1 2 +FUNC e0 10 0 func4 +e0 2 2 2 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.syms new file mode 100644 index 00000000000..1ebecb48022 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.syms @@ -0,0 +1,20 @@ +MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 linux.out +INFO CODE_ID E35C283BC327C28762DB788BF5A4078BE2351448 +FUNC 0 2 0 func0 +FUNC 2 1 0 func2 +FUNC 3 1 0 func3 +FUNC 4 1 0 func4 +FUNC 5 1 0 func5 +FUNC 6 1 0 func6 +FUNC 7 2 0 func7 +FUNC 9 1 0 func9 +STACK CFI INIT 0 2 .cfa: $rsp .ra: .cfa $rbp: $rsp +STACK CFI 1 $rbp: $rax $rbx: $rcx +STACK CFI INIT 2 1 $r47: $r42 +STACK CFI INIT 3 1 $rbp: +STACK CFI INIT 4 1 $rbp +STACK CFI INIT 5 1 $rbp: $rbx $rsp: +STACK CFI INIT 6 1 $rbp: $rsp: +STACK CFI INIT 7 1 .cfa: $rsp +STACK CFI bogus +STACK CFI INIT 9 1 .cfa: $rbp .ra: $rax diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.yaml b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.yaml new file mode 100644 index 00000000000..9f3a6316986 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/stack-cfi-parsing.yaml @@ -0,0 +1,36 @@ +--- !minidump +Streams: + - Type: ThreadList + Threads: + - Thread Id: 0x00003E81 + Context: DEAD + Stack: + Start of Memory Range: 0x00007FFCEB34A000 + Content: DEAD + - Type: ModuleList + Modules: + - Base of Image: 0x0000000000400000 + Size of Image: 0x00001000 + Module Name: '/tmp/stack-cfi-parsing.out' + CodeView Record: 4C457042E35C283BC327C28762DB788BF5A4078BE2351448 + - Type: SystemInfo + Processor Arch: AMD64 + Processor Level: 6 + Processor Revision: 15876 + Number of Processors: 40 + Platform ID: Linux + CSD Version: 'Linux 3.13.0-91-generic' + CPU: + Vendor ID: GenuineIntel + Version Info: 0x00000000 + Feature Info: 0x00000000 + - Type: LinuxProcStatus + Text: | + Name: linux-x86_64 + State: t (tracing stop) + Tgid: 29917 + Ngid: 0 + Pid: 29917 + PPid: 29370 + +... diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab-macho.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab-macho.syms new file mode 100644 index 00000000000..da6a7568698 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab-macho.syms @@ -0,0 +1,2 @@ +MODULE mac x86_64 B305176022B17D7B39F9240E077D625B0 mac.out +PUBLIC ff0 0 _start diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab.syms new file mode 100644 index 00000000000..3fd14643bb0 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/symtab.syms @@ -0,0 +1,9 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +PUBLIC b0 0 f1 +PUBLIC m c0 0 f2 +PUBLIC d0 0 _start +PUBLIC ff 0 _out_of_range_ignored +FUNC b0 c 0 f1_func +FUNC m a0 d 0 func_only diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-raSearch.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-raSearch.syms new file mode 100644 index 00000000000..329a280bde8 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-raSearch.syms @@ -0,0 +1,15 @@ +MODULE windows x86 897DD83EA8C8411897F3A925EE4BF7411 unwind-via-stack-win.pdb +INFO CODE_ID 5D499B5C5000 unwind-via-stack-win.exe +PUBLIC 0 0 dummy +PUBLIC 10 0 call_many +PUBLIC 80 0 main +PUBLIC 90 0 many_pointer_args +PUBLIC 100 0 complex_rasearch +PUBLIC 110 0 esp_rasearch +PUBLIC 120 0 nonzero_frame_size +STACK WIN 4 10 6d 0 0 0 0 0 0 1 $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 80 8 0 0 0 0 0 0 1 $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 90 5 0 0 50 0 0 0 1 $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 100 4 0 0 0 0 0 0 1 $T0 .raSearch 80 + = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 110 4 0 0 0 0 0 0 1 $T0 .raSearch = $eip $T0 ^ = $esp .raSearch 4 + = +STACK WIN 4 120 4 0 0 0 4 8 0 1 $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.syms new file mode 100644 index 00000000000..d4c8287e68a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.syms @@ -0,0 +1,6 @@ +MODULE Linux x86_64 603FCF6CA7FF4BCC86AE8FF44DB2576A0 linux-x86_64_not_crashed +INFO CODE_ID 6CCF3F60FFA7CC4B86AE8FF44DB2576A68983611 +PUBLIC 420 0 bar +PUBLIC 450 0 foo +PUBLIC 480 0 _start +STACK CFI INIT 420 29 .cfa: $rbp ^ .ra: .cfa 8 + ^ $rsp: .cfa 16 + $rbp: .cfa ^ diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.yaml b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.yaml new file mode 100644 index 00000000000..0672f9e6123 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-cfi.yaml @@ -0,0 +1,43 @@ +--- !minidump +Streams: + - Type: ThreadList + Threads: + - Thread Id: 0x000074F3 + Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B001000000000006CAE000000006B7FC05A0000C81D415A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A2BF9E5A6B7F0000000000000000000000000000000000008850C14BFD7F00009850C14BFD7F00000100000000000000B04AC14BFD7F0000000000000000000060812D01000000000800000000000000B065E05A6B7F00008004400000000000E050C14BFD7F00000000000000000000000000000000000030044000000000007F03FFFF0000FFFFFFFFFFFF000000000000000000000000801F00006B7F00000400000000000000B84CC14BFD7F0000304D405A6B7F0000C84DC14BFD7F0000C0AA405A6B7F00004F033D0000000000B84DC14BFD7F0000E84DC14BFD7F0000000000000000000000000000000000000070E05A6B7F000078629E5A6B7F0000C81D415A6B7F0000804F9E5A6B7F00000000000001000000E603000001000000E093115A6B7F0000804EC14BFD7F0000584EC14BFD7F000099ADC05A6B7F00000100000000000000AAAAD77D0000000002000000000000000800000000000000B065E05A6B7F0000E6B7C05A6B7F0000010000006B7F0000884DC14BFD7F0000106F7C5A6B7F0000984EC14BFD7F0000488B7C5A6B7F0000C4A71CB90000000001000000000000000800000000000000B065E05A6B7F000048B6C05A6B7F0000702AE25A6B7F0000D84DC14BFD7F000030489E5A6B7F0000E84EC14BFD7F0000E05E9E5A6B7F00000991F0460000000001000000000000000800000000000000B065E05A6B7F000048B6C05A6B7F00000100000000000000284EC14BFD7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Stack: + Start of Memory Range: 0x00007FFD4BC15080 + Content: 30044000000000000000000000000000FFFFFFFF03000000B850C14BFD7F0000670440000000000000000000000000000000000001000000D850C14BFD7F0000970440000000000000000000000000000000000000000000000000000000000001000000000000009F67C14BFD7F00000000000000000000BA67C14BFD7F0000 + - Type: ModuleList + Modules: + - Base of Image: 0x0000000000400000 + Size of Image: 0x00001000 + Module Name: '/tmp/unwind-via-stack-cfi' + CodeView Record: 4C4570426CCF3F60FFA7CC4B86AE8FF44DB2576A68983611 + - Type: MemoryList + Memory Ranges: + - Start of Memory Range: 0x00007FFD4BC15080 + Content: 30044000000000000000000000000000FFFFFFFF03000000B850C14BFD7F0000670440000000000000000000000000000000000001000000D850C14BFD7F0000970440000000000000000000000000000000000000000000000000000000000001000000000000009F67C14BFD7F00000000000000000000BA67C14BFD7F0000 + - Type: SystemInfo + Processor Arch: AMD64 + Processor Level: 6 + Processor Revision: 15876 + Number of Processors: 40 + Platform ID: Linux + CSD Version: 'Linux 3.13.0-91-generic' + CPU: + Vendor ID: GenuineIntel + Version Info: 0x00000000 + Feature Info: 0x00000000 + - Type: LinuxProcStatus + Text: | + Name: unwind-via-stack-cfi + State: t (tracing stop) + Tgid: 29939 + Ngid: 0 + Pid: 29939 + PPid: 29370 + TracerPid: 29940 + Uid: 1001 1001 1001 1001 + Gid: 1001 1001 1001 1001 + +... diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms new file mode 100644 index 00000000000..b9b8a67095f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms @@ -0,0 +1,17 @@ +MODULE windows x86 897DD83EA8C8411897F3A925EE4BF7411 unwind-via-stack-win.pdb +INFO CODE_ID 5D499B5C5000 unwind-via-stack-win.exe +PUBLIC 0 0 dummy +PUBLIC 10 0 call_many +PUBLIC 80 0 main +PUBLIC 90 0 many_pointer_args +PUBLIC 100 0 bogus_rule +PUBLIC 110 0 bogus_cfa_rhs +PUBLIC 120 0 bogus_esp_rhs +PUBLIC 130 0 temporary_var +STACK WIN 4 10 6d 0 0 0 0 0 0 1 $T0 $esp 80 + = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 80 8 0 0 0 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 90 5 0 0 50 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 100 4 0 0 0 0 0 0 1 bogus +STACK WIN 4 110 4 0 0 0 0 0 0 1 $T0 $bogus = $eip $T0 ^ = $esp $T0 4 + = +STACK WIN 4 120 4 0 0 0 0 0 0 1 $T0 $esp = $eip $T0 ^ = $esp $bogus 4 + = +STACK WIN 4 130 4 0 0 0 0 0 0 1 $T0 $esp = $bogus $T0 = $eip $bogus ^ = $esp $T0 4 + = diff --git a/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml new file mode 100644 index 00000000000..399cf2bbaa3 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml @@ -0,0 +1,37 @@ +--- !minidump +Streams: + - Type: ThreadList + Threads: + - Thread Id: 0x0000290C + Priority Class: 0x00000020 + Environment Block: 0x0000000000A98000 + Context: 3F0001000000000000000000000000000000000000000000000000007F02000000000000FFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002B000000530000002B0000002B00000080100B0080100B000050A90080100B0080100B0000000000E4FECF0092100B0023000000440301007CFECF002B0000007F0200000000000000000000000000000000000000000000801F0000FFFF020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000144E3D6C2000000001000000EA1E00F4C000E50700000000FC0100002CE3C014D8E202010000E507880F401D839DC60100000000400000007F00000000000000880F401D0A000000900F401D0000000000000100EA1E00009808E5077F00000000000000000000009008E507990100006002E5072CABC87708346474B42300000100000044E3C014200000000000000020532777A80F401D4F346474D00F401D6F378CCC5C4CD5010000000000000000000000000000000000000000000000003AFCD72F90E3C01418CE3470B4230000B80F401DC00F401DC80F401DD00F401D + Stack: + Start of Memory Range: 0x0000000000CFFE78 + Content: 0000000079100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0085100B0094842777 + - Type: ModuleList + Modules: + - Base of Image: 0x00000000000B1000 + Size of Image: 0x00004000 + Module Name: 'unwind-via-stack-win.exe' + CodeView Record: 525344533ED87D89C8A8184197F3A925EE4BF74101000000433A5C70726F6A656374735C746573745F6170705C436F6E736F6C654170706C69636174696F6E315C44656275675C436F6E736F6C654170706C69636174696F6E312E70646200 + - Base of Image: 0x0000000077260000 + Size of Image: 0x000E0000 + Module Name: 'C:\Windows\System32\kernel32.dll' + CodeView Record: 5253445300F90A57CF8DED8A463A90390318CD4401000000776B65726E656C33322EFFFFFFFF + - Type: MemoryList + Memory Ranges: + - Start of Memory Range: 0x0000000000CFFE78 + Content: 0000000079100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0000100B0085100B0094842777 + - Type: MemoryInfoList + Content: 1000000030000000020000000000000000100B00000000000000000000000000000000000000000000400000000000000010000010000000000000010000000000002677000000000000000000000000000000000000000000000E000000000000100000100000000000000100000000 + - Type: SystemInfo + Processor Arch: X86 + Platform ID: Win32NT + CPU: + Vendor ID: AuthenticAMD + Version Info: 0x00800F82 + Feature Info: 0x178BFBFF + - Type: MiscInfo + Content: 54050000F703000008290000C883495D0000000000000000AC0D000098080000AC0D00000200000002000000002000000D0000000000000002000000C4FFFFFF430065006E007400720061006C0020004500750072006F007000650020005300740061006E0064006100720064002000540069006D006500000000000000000000000A0000000500030000000000000000000000430065006E007400720061006C0020004500750072006F00700065002000530075006D006D00650072002000540069006D00650000000000000000000000000000000300000005000200000000000000C4FFFFFF310037003100330034002E0031002E007800380036006600720065002E007200730034005F00720065006C0065006100730065002E003100380030003400310030002D00310038003000340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064006200670063006F00720065002E0069003300380036002C00310030002E0030002E00310037003100330034002E0031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C816B92 +... diff --git a/lldb/test/Shell/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test b/lldb/test/Shell/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test new file mode 100644 index 00000000000..3b48f4f3c5a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test @@ -0,0 +1,13 @@ +# Test that we handle files which has gaps in the FILE record IDs. + +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-discontinuous-file-ids.out +# RUN: %lldb %T/line-table-discontinuous-file-ids.out \ +# RUN: -o "target symbols add -s line-table-discontinuous-file-ids.out %S/Inputs/line-table-discontinuous-file-ids.syms" \ +# RUN: -s %s -o exit | FileCheck %s + +image dump line-table a.c +# CHECK-LABEL: Line table for /tmp/a.c +# CHECK-NEXT: 0x00000000004000b0: /tmp/a.c:1 +# CHECK-NEXT: 0x00000000004000b1: /tmp/a.c:2 +# CHECK-NEXT: 0x00000000004000b2: /tmp/c.c:2 +# CHECK-NEXT: 0x00000000004000b3: diff --git a/lldb/test/Shell/SymbolFile/Breakpad/line-table-edgecases.test b/lldb/test/Shell/SymbolFile/Breakpad/line-table-edgecases.test new file mode 100644 index 00000000000..3a097725a97 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/line-table-edgecases.test @@ -0,0 +1,21 @@ +# Test handling of breakpad files with some unusual or erroneous constructs. The +# input contains a LINE record which does not belong to any function as well as +# a FUNC record without any LINE records. + +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-edgecases.out +# RUN: %lldb %T/line-table-edgecases.out \ +# RUN: -o "target symbols add -s line-table-edgecases.out %S/Inputs/line-table-edgecases.syms" \ +# RUN: -s %s -o exit | FileCheck %s + +# Test that line table for func2 was parsed properly: +image dump line-table a.c +# CHECK-LABEL: Line table for /tmp/a.c +# CHECK-NEXT: 0x00000000004000c0: /tmp/a.c:2 +# CHECK-NEXT: 0x00000000004000c2: +# CHECK-EMPTY: + +# Looking up an address inside func should still work even if it does not result +# in a line entry. +image lookup -a 0x4000b2 -v +# CHECK-LABEL: image lookup -a 0x4000b2 -v +# CHECK: Summary: line-table-edgecases.out`func + 2 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/line-table-missing-file.test b/lldb/test/Shell/SymbolFile/Breakpad/line-table-missing-file.test new file mode 100644 index 00000000000..0c0fb3f8ea8 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/line-table-missing-file.test @@ -0,0 +1,17 @@ +# Test that we do something reasonable if a LINE record references a +# non-existing FILE record. +# Right now, "something reasonable" means creating a line entry with an empty +# file. + +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-missing-file.out +# RUN: %lldb %T/line-table-missing-file.out \ +# RUN: -o "target symbols add -s line-table-missing-file.out %S/Inputs/line-table-missing-file.syms" \ +# RUN: -s %s -o exit | FileCheck %s + +image dump line-table a.c +# CHECK-LABEL: Line table for /tmp/a.c +# CHECK-NEXT: 0x00000000004000b0: /tmp/a.c:1 +# CHECK-NEXT: 0x00000000004000b1: /tmp/a.c:2 +# CHECK-NEXT: 0x00000000004000b2: :2 +# CHECK-NEXT: 0x00000000004000b3: +# CHECK-EMPTY: diff --git a/lldb/test/Shell/SymbolFile/Breakpad/line-table-mixed-path-styles.test b/lldb/test/Shell/SymbolFile/Breakpad/line-table-mixed-path-styles.test new file mode 100644 index 00000000000..617b5eb6a9f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/line-table-mixed-path-styles.test @@ -0,0 +1,11 @@ +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-mixed-path-styles.out +# RUN: %lldb %T/line-table-mixed-path-styles.out \ +# RUN: -o "target symbols add -s line-table-mixed-path-styles.out %S/Inputs/line-table-mixed-path-styles.syms" \ +# RUN: -s %s -o exit | FileCheck %s + +image dump line-table a.c +# CHECK-LABEL: Line table for /tmp/a.c +# CHECK-NEXT: 0x00000000004000b0: /tmp/a.c:1 +# CHECK-NEXT: 0x00000000004000b1: c:\tmp\b.c:1 +# CHECK-NEXT: 0x00000000004000b2: +# CHECK-EMPTY: diff --git a/lldb/test/Shell/SymbolFile/Breakpad/line-table.test b/lldb/test/Shell/SymbolFile/Breakpad/line-table.test new file mode 100644 index 00000000000..f5661cf7ee9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/line-table.test @@ -0,0 +1,45 @@ +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table.out +# RUN: %lldb %T/line-table.out -o "target symbols add -s line-table.out %S/Inputs/line-table.syms" \ +# RUN: -s %s -o exit | FileCheck %s + +# We create a compile unit for each function. The compile unit name is the first +# line table entry in that function. +# This symbol file contains a single function in the "compile unit" a.c. This +# function has two line table sequences. +image dump line-table a.c +# CHECK-LABEL: Line table for /tmp/a.c +# CHECK-NEXT: 0x00000000004000b0: /tmp/a.c:1 +# CHECK-NEXT: 0x00000000004000b1: /tmp/a.c:2 +# CHECK-NEXT: 0x00000000004000b2: /tmp/c.c:2 +# CHECK-NEXT: 0x00000000004000b3: +# CHECK-EMPTY: +# CHECK-NEXT: 0x00000000004000b4: /tmp/c.c:3 +# CHECK-NEXT: 0x00000000004000b5: +# CHECK-EMPTY: + +# Single compile unit for c.c with a single line sequence. +image dump line-table c.c +# CHECK-LABEL: Line table for /tmp/c.c +# CHECK-NEXT: 0x00000000004000c0: /tmp/c.c:1 +# CHECK-NEXT: 0x00000000004000c2: /tmp/a.c:2 +# CHECK-NEXT: 0x00000000004000c4: +# CHECK-EMPTY: + +# There are two compile units called "d.c". Hence, two line tables. +image dump line-table d.c +# CHECK-LABEL: Line table for /tmp/d.c +# CHECK-NEXT: 0x00000000004000d0: /tmp/d.c:1 +# CHECK-NEXT: 0x00000000004000d2: +# CHECK-EMPTY: +# CHECK-LABEL: Line table for /tmp/d.c +# CHECK-NEXT: 0x00000000004000e0: /tmp/d.c:2 +# CHECK-NEXT: 0x00000000004000e2: +# CHECK-EMPTY: + +image lookup -a 0x4000b2 -v +# CHECK-LABEL: image lookup -a 0x4000b2 -v +# CHECK: Summary: line-table.out`func + 2 + +breakpoint set -f c.c -l 2 +# CHECK-LABEL: breakpoint set -f c.c -l 2 +# CHECK: Breakpoint 1: where = line-table.out`func + 2, address = 0x00000000004000b2 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test new file mode 100644 index 00000000000..ffb64602c15 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/stack-cfi-parsing.test @@ -0,0 +1,52 @@ +# RUN: yaml2obj %S/Inputs/stack-cfi-parsing.yaml > %t +# RUN: %lldb -c %t -o "target symbols add %S/Inputs/stack-cfi-parsing.syms" \ +# RUN: -s %s -b | FileCheck %s + +image show-unwind -n func0 +# CHECK-LABEL: image show-unwind -n func0 +# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Synchronous (restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Symbol file UnwindPlan: +# CHECK-NEXT: This UnwindPlan originally sourced from breakpad STACK CFI +# CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes. +# CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no. +# CHECK-NEXT: Address range of this UnwindPlan: [stack-cfi-parsing.out..module_image + 0-0x0000000000000002) +# CHECK-NEXT: row[0]: 0: CFA=DW_OP_breg7 +0 => rbp=DW_OP_breg7 +0 rip=DW_OP_pick 0x00 +# CHECK-NEXT: row[1]: 1: CFA=DW_OP_breg7 +0 => rbx=DW_OP_breg2 +0 rbp=DW_OP_breg0 +0 rip=DW_OP_pick 0x00 + +# The following plans are all (syntactically) invalid for various reasons. +# Processing those should not cause a crash. + +image show-unwind -n func2 +# CHECK-LABEL: image show-unwind -n func2 +# CHECK-NOT: Symbol file + +image show-unwind -n func3 +# CHECK-LABEL: image show-unwind -n func3 +# CHECK-NOT: Symbol file + +image show-unwind -n func4 +# CHECK-LABEL: image show-unwind -n func4 +# CHECK-NOT: Symbol file + +image show-unwind -n func5 +# CHECK-LABEL: image show-unwind -n func5 +# CHECK-NOT: Symbol file + +image show-unwind -n func6 +# CHECK-LABEL: image show-unwind -n func6 +# CHECK-NOT: Symbol file + +image show-unwind -n func7 +# CHECK-LABEL: image show-unwind -n func7 +# CHECK-NOT: Symbol file + +# Finally, try an unwind plan with just a single row +image show-unwind -n func9 +# CHECK-LABEL: image show-unwind -n func9 +# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Synchronous (restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Symbol file UnwindPlan: +# CHECK: Address range of this UnwindPlan: [stack-cfi-parsing.out..module_image + 9-0x000000000000000a) +# CHECK: row[0]: 0: CFA=DW_OP_breg6 +0 => rip=DW_OP_breg0 +0 + diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-macho.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab-macho.test new file mode 100644 index 00000000000..59538649d8f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab-macho.test @@ -0,0 +1,21 @@ +# RUN: yaml2obj %S/Inputs/basic-macho.yaml > %T/symtab-macho.out +# RUN: %lldb %T/symtab-macho.out -o "target symbols add %S/Inputs/symtab-macho.syms" \ +# RUN: -s %s | FileCheck %s + +image dump symtab symtab-macho.out +# CHECK-LABEL: (lldb) image dump symtab symtab-macho.out +# CHECK: Symtab, file = {{.*}}symtab-macho.out, num_symbols = 1: +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK: [ 0] 0 X Code 0x0000000100000ff0 0x0000000000000006 0x00000000 _start + +# CHECK-LABEL: (lldb) image lookup -a 0x100000ff0 -v +# CHECK: Address: symtab-macho.out[0x0000000100000ff0] (symtab-macho.out.__TEXT.__text + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x0000000100000ff0-0x0000000100000ff6), name="_start" + +# CHECK-LABEL: (lldb) image lookup -n _start -v +# CHECK: Address: symtab-macho.out[0x0000000100000ff0] (symtab-macho.out.__TEXT.__text + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x0000000100000ff0-0x0000000100000ff6), name="_start" + +image lookup -a 0x100000ff0 -v +image lookup -n _start -v +exit diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test new file mode 100644 index 00000000000..65bf9517461 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test @@ -0,0 +1,25 @@ +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/symtab.out +# RUN: %lldb %T/symtab.out -o "target symbols add -s symtab.out %S/Inputs/symtab.syms" \ +# RUN: -s %s | FileCheck %s + +# CHECK-LABEL: (lldb) image dump symtab symtab.out +# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5: +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK: [ 0] 0 SX Code 0x0000000000400000 0x00000000000000b0 0x00000000 ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out +# CHECK: [ 1] 0 X Code 0x00000000004000c0 0x0000000000000010 0x00000000 f2 +# CHECK: [ 2] 0 X Code 0x00000000004000d0 0x0000000000000022 0x00000000 _start +# CHECK: [ 3] 0 X Code 0x00000000004000a0 0x000000000000000d 0x00000000 func_only +# CHECK: [ 4] 0 X Code 0x00000000004000b0 0x000000000000000c 0x00000000 f1_func + +# CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v +# CHECK: Address: symtab.out[0x00000000004000b0] (symtab.out.PT_LOAD[0]..text2 + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x00000000004000b0-0x00000000004000bc), name="f1_func" + +# CHECK-LABEL: (lldb) image lookup -n f2 -v +# CHECK: Address: symtab.out[0x00000000004000c0] (symtab.out.PT_LOAD[0]..text2 + 16) +# CHECK: Symbol: id = {0x00000000}, range = [0x00000000004000c0-0x00000000004000d0), name="f2" + +image dump symtab symtab.out +image lookup -a 0x4000b0 -v +image lookup -n f2 -v +exit diff --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test new file mode 100644 index 00000000000..ea259a9de7e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test @@ -0,0 +1,43 @@ +# RUN: yaml2obj %S/Inputs/unwind-via-stack-win.yaml > %t +# RUN: %lldb -c %t \ +# RUN: -o "target symbols add %S/Inputs/unwind-via-raSearch.syms" \ +# RUN: -s %s -b | FileCheck %s + +# First check that unwind plan generation works correctly. +# This function has a "typical" unwind rule. +image show-unwind -n call_many +# CHECK-LABEL: image show-unwind -n call_many +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`call_many +# CHECK: Symbol file UnwindPlan: +# CHECK: This UnwindPlan originally sourced from breakpad STACK WIN +# CHECK: This UnwindPlan is sourced from the compiler: yes. +# CHECK: This UnwindPlan is valid at all instruction locations: no. +# CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 16-0x0000007d) +# CHECK: row[0]: 0: CFA=RaSearch@SP+0 => esp=DW_OP_pick 0x00, DW_OP_consts +4, DW_OP_plus eip=DW_OP_pick 0x00, DW_OP_deref + +image show-unwind -n nonzero_frame_size +# CHECK-LABEL: image show-unwind -n nonzero_frame_size +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`nonzero_frame_size +# CHECK: Symbol file UnwindPlan: +# CHECK: row[0]: 0: CFA=RaSearch@SP+12 => esp=DW_OP_pick 0x00, DW_OP_consts +4, DW_OP_plus eip=DW_OP_pick 0x00, DW_OP_deref + +# Then, some invalid rules. +image show-unwind -n complex_rasearch +# CHECK-LABEL: image show-unwind -n complex_rasearch +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`complex_rasearch +# CHECK-NOT: Symbol file + +image show-unwind -n esp_rasearch +# CHECK-LABEL: image show-unwind -n esp_rasearch +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`esp_rasearch +# CHECK-NOT: Symbol file + +# And finally, check that backtracing works as a whole by unwinding a simple +# stack. +thread backtrace +# CHECK-LABEL: thread backtrace +# CHECK: frame #0: 0x000b1092 unwind-via-stack-win.exe`many_pointer_args +# CHECK: frame #1: 0x000b1079 unwind-via-stack-win.exe`call_many + 105 +# CHECK: frame #2: 0x000b1085 unwind-via-stack-win.exe`main + 5 +# CHECK: frame #3: 0x77278494 kernel32.dll +# CHECK-NOT: frame diff --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test new file mode 100644 index 00000000000..9a6c2166c13 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-cfi.test @@ -0,0 +1,20 @@ +# RUN: yaml2obj %S/Inputs/unwind-via-stack-cfi.yaml > %t +# RUN: %lldb -c %t -o "target symbols add %S/Inputs/unwind-via-stack-cfi.syms" \ +# RUN: -s %s -b | FileCheck %s + +image show-unwind -n bar +# CHECK-LABEL: image show-unwind -n bar +# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Synchronous (restricted to call-sites) UnwindPlan is 'breakpad STACK CFI' +# CHECK: Symbol file UnwindPlan: +# CHECK-NEXT: This UnwindPlan originally sourced from breakpad STACK CFI +# CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes. +# CHECK-NEXT: This UnwindPlan is valid at all instruction locations: no. +# CHECK-NEXT: Address range of this UnwindPlan: [unwind-via-stack-cfi..module_image + 1056-0x0000000000000449) +# CHECK-NEXT: row[0]: 0: CFA=DW_OP_breg6 +0, DW_OP_deref => rbp=DW_OP_pick 0x00, DW_OP_deref rsp=DW_OP_pick 0x00, DW_OP_consts +16, DW_OP_plus rip=DW_OP_pick 0x00, DW_OP_consts +8, DW_OP_plus , DW_OP_deref + +thread backtrace +# CHECK-LABEL: thread backtrace +# CHECK: frame #0: 0x0000000000400430 unwind-via-stack-cfi`bar + 16 +# CHECK: frame #1: 0x0000000000400497 unwind-via-stack-cfi`_start + 23 +# CHECK-NOT: frame diff --git a/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test new file mode 100644 index 00000000000..2e04ed68844 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win.test @@ -0,0 +1,54 @@ +# RUN: yaml2obj %S/Inputs/unwind-via-stack-win.yaml > %t +# RUN: %lldb -c %t \ +# RUN: -o "target symbols add %S/Inputs/unwind-via-stack-win.syms" \ +# RUN: -s %s -b | FileCheck %s + +# First check that unwind plan generation works correctly. +# This function has a "typical" unwind rule. +image show-unwind -n call_many +# CHECK-LABEL: image show-unwind -n call_many +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`call_many +# CHECK: Symbol file UnwindPlan: +# CHECK: This UnwindPlan originally sourced from breakpad STACK WIN +# CHECK: This UnwindPlan is sourced from the compiler: yes. +# CHECK: This UnwindPlan is valid at all instruction locations: no. +# CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 16-0x0000007d) +# CHECK: row[0]: 0: CFA=DW_OP_breg7 +0, DW_OP_consts +80, DW_OP_plus => esp=DW_OP_pick 0x00, DW_OP_consts +4, DW_OP_plus eip=DW_OP_pick 0x00, DW_OP_deref + +# Then, some invalid rules. +image show-unwind -n bogus_rule +# CHECK-LABEL: image show-unwind -n bogus_rule +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`bogus_rule +# CHECK-NOT: Symbol file + +image show-unwind -n bogus_cfa_rhs +# CHECK-LABEL: image show-unwind -n bogus_cfa_rhs +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`bogus_cfa_rhs +# CHECK-NOT: Symbol file + +image show-unwind -n bogus_esp_rhs +# CHECK-LABEL: image show-unwind -n bogus_esp_rhs +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`bogus_esp_rhs +# CHECK-NOT: Symbol file + +# We don't treat unknown lhs as an error, as it can be just a temporary +# variable used in other rules. +image show-unwind -n temporary_var +# CHECK-LABEL: image show-unwind -n temporary_var +# CHECK: UNWIND PLANS for unwind-via-stack-win.exe`temporary_var +# CHECK: Symbol file UnwindPlan: +# CHECK: This UnwindPlan originally sourced from breakpad STACK WIN +# CHECK: This UnwindPlan is sourced from the compiler: yes. +# CHECK: This UnwindPlan is valid at all instruction locations: no. +# CHECK: Address range of this UnwindPlan: [unwind-via-stack-win.exe..module_image + 304-0x00000134) +# CHECK: row[0]: 0: CFA=DW_OP_breg7 +0 => esp=DW_OP_pick 0x00, DW_OP_consts +4, DW_OP_plus eip=DW_OP_pick 0x00, DW_OP_deref + +# And finally, check that backtracing works as a whole by unwinding a simple +# stack. +thread backtrace +# CHECK-LABEL: thread backtrace +# CHECK: frame #0: 0x000b1092 unwind-via-stack-win.exe`many_pointer_args +# CHECK: frame #1: 0x000b1079 unwind-via-stack-win.exe`call_many + 105 +# CHECK: frame #2: 0x000b1085 unwind-via-stack-win.exe`main + 5 +# CHECK: frame #3: 0x77278494 kernel32.dll +# CHECK-NOT: frame diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script new file mode 100644 index 00000000000..7f3a1b9c2ff --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-line-basic.script @@ -0,0 +1,14 @@ +PHDRS { + text PT_LOAD; +} +SECTIONS { + .shstrtab : { *(.shstrtab ) } + .debug_info : { *(.debug_info ) } + .debug_line : { *(.debug_line ) } + .debug_str : { *(.debug_str ) } + .debug_abbrev : { *(.debug_abbrev) } + + . = 0x201000; + .text : { *(.text .text.f) } :text + /DISCARD/ : { *(*) } +} diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-basic.cpp b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-basic.cpp new file mode 100644 index 00000000000..defa8ba5c69 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-basic.cpp @@ -0,0 +1,15 @@ +enum E { e1, e2, e3 }; +enum class EC { e1, e2, e3 }; + +struct A { + int i; + long l; + float f; + double d; + E e; + EC ec; +}; + +extern constexpr A a{42, 47l, 4.2f, 4.7, e1, EC::e3}; +extern constexpr E e(e2); +extern constexpr EC ec(EC::e2); diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-expressions.cpp b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-expressions.cpp new file mode 100644 index 00000000000..fe728cf040d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/debug-types-expressions.cpp @@ -0,0 +1,33 @@ +struct A { + int i = 47; + int f() { return i; } + virtual ~A() = default; +}; + +struct B: public A { + int j = 42; +}; + +namespace ns { +struct A { + int i = 147; + ::A getA(); + A(); +}; +A::A() = default; + +::A A::getA() { + ::A a; + a.i = i - 1; + return a; +} + +} // namespace ns + +int foo(A *a) { + return a->f(); +} + +int main() { + return foo(new B); +} diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit new file mode 100644 index 00000000000..390408ec8cc --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit @@ -0,0 +1,3 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f foo/b.c -l 1 diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit new file mode 100644 index 00000000000..73a8a491bb2 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit @@ -0,0 +1,3 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f /tmp/b.c -l 1 diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit new file mode 100644 index 00000000000..8737aafc8a2 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit @@ -0,0 +1,7 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f C:/tmp/b.c -l 1 + +# This will fail on non-windows systems because the path will by parsed +# according to posix rules +# breakpoint set -f 'C:\tmp\b.c' -l 1 diff --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp b/lldb/test/Shell/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp new file mode 100644 index 00000000000..cd02cb07c62 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/find-variable-file-2.cpp @@ -0,0 +1,3 @@ +namespace two { +int foo; +} diff --git a/lldb/test/Shell/SymbolFile/DWARF/apple-index-is-used.cpp b/lldb/test/Shell/SymbolFile/DWARF/apple-index-is-used.cpp new file mode 100644 index 00000000000..00440531e99 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/apple-index-is-used.cpp @@ -0,0 +1,8 @@ +// Test that we use the apple indexes. +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols %t | FileCheck %s + +// CHECK: .apple_names index present +// CHECK: .apple_types index present + +int foo; diff --git a/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s b/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s new file mode 100644 index 00000000000..f00fe2ad005 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/array-sizes.s @@ -0,0 +1,147 @@ +# This tests a bug where we would incorrectly parse the size of an array if that +# size happened to match an existing DIE offset. This happened because we +# misinterpreted that value as a reference to a DIE specifying the VLA size even +# though the form was a data form (as it should be). + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: lldb-test symbols %t | FileCheck %s + +# CHECK: Variable{0x7fffffff0000001e}, name = "X" +# CHECK-SAME: type = {7fffffff00000033} 0x{{[0-9a-f]*}} (char [56]) + + +# Generated from "char X[47];" +# The array size was modified by hand. + + .text + .file "-" + .file 1 "/tmp" "<stdin>" + .type X,@object # @X + .comm X,63,16 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 8.0.0 (trunk 349604) (llvm/trunk 349608)" # string offset=0 +.Linfo_string1: + .asciz "-" # string offset=55 +.Linfo_string2: + .asciz "/tmp" # string offset=57 +.Linfo_string3: + .asciz "X" # string offset=62 +.Linfo_string4: + .asciz "char" # string offset=64 +.Linfo_string5: + .asciz "__ARRAY_SIZE_TYPE__" # string offset=69 + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 1 # DW_TAG_array_type + .byte 1 # DW_CHILDREN_yes + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 33 # DW_TAG_subrange_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 55 # DW_AT_count + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x43 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long 0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .byte 2 # Abbrev [2] 0x1e:0x15 DW_TAG_variable + .long .Linfo_string3 # DW_AT_name + .long 51 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad X + .byte 3 # Abbrev [3] 0x33:0xc DW_TAG_array_type + .long 63 # DW_AT_type +.Ldie: + .byte 4 # Abbrev [4] 0x38:0x6 DW_TAG_subrange_type + .long 70 # DW_AT_type + .byte .Ldie-.Lcu_begin0 # DW_AT_count - should match the offset of an existing die + .byte 0 # End Of Children Mark + .byte 5 # Abbrev [5] 0x3f:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 6 # DW_AT_encoding + .byte 1 # DW_AT_byte_size + .byte 6 # Abbrev [6] 0x46:0x7 DW_TAG_base_type + .long .Linfo_string5 # DW_AT_name + .byte 8 # DW_AT_byte_size + .byte 7 # DW_AT_encoding + .byte 0 # End Of Children Mark +.Ldebug_info_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/childless-compile-unit.s b/lldb/test/Shell/SymbolFile/DWARF/childless-compile-unit.s new file mode 100644 index 00000000000..a47c378ffe3 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/childless-compile-unit.s @@ -0,0 +1,47 @@ +# Test that we don't crash when parsing slightly invalid DWARF. The compile +# unit in this file sets DW_CHILDREN_no, but it still includes an +# end-of-children marker in its contribution. + +# REQUIRES: x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: lldb-test symbols %t.o + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Linfo_string1: + .asciz "-" +.Linfo_string2: + .asciz "/tmp" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_length_end-.Lcu_length_start # Length of Unit +.Lcu_length_start: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x30 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Linfo_string2 # DW_AT_comp_dir + .byte 0 # Bogus End Of Children Mark +.Lcu_length_end: diff --git a/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll b/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll new file mode 100644 index 00000000000..6097345bd99 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll @@ -0,0 +1,52 @@ +; Test finding types by CompilerContext. +; RUN: llc %s -filetype=obj -o %t.o +; RUN: lldb-test symbols %t.o -find=type --language=C99 \ +; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmoduleX" \ +; RUN: | FileCheck %s --check-prefix=NORESULTS +; RUN: lldb-test symbols %t.o -find=type --language=C++ \ +; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \ +; RUN: | FileCheck %s --check-prefix=NORESULTS +; RUN: lldb-test symbols %t.o -find=type --language=C99 \ +; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \ +; RUN: | FileCheck %s +; RUN: lldb-test symbols %t.o -find=type --language=C99 \ +; RUN: -compiler-context="Module:CModule,AnyModule:*,Struct:FromSubmodule" \ +; RUN: | FileCheck %s +; RUN: lldb-test symbols %t.o -find=type --language=C99 \ +; RUN: -compiler-context="AnyModule:*,Struct:FromSubmodule" \ +; RUN: | FileCheck %s +; RUN: lldb-test symbols %t.o -find=type --language=C99 \ +; RUN: -compiler-context="Module:CModule,Module:SubModule,AnyType:FromSubmodule" \ +; RUN: | FileCheck %s +; +; NORESULTS: Found 0 types +; CHECK: Found 1 types: +; CHECK: struct FromSubmodule { +; CHECK-NEXT: unsigned int x; +; CHECK-NEXT: unsigned int y; +; CHECK-NEXT: unsigned int z; +; CHECK-NEXT: } + +source_filename = "/t.c" +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.14.0" + +!llvm.dbg.cu = !{!2} +!llvm.linker.options = !{} +!llvm.module.flags = !{!18, !19} +!llvm.ident = !{!22} + +; This simulates the debug info for a Clang module. +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: GNU, retainedTypes: !{!11}) +!3 = !DIFile(filename: "t.c", directory: "/") +!8 = !DIModule(scope: !9, name: "SubModule", includePath: "", isysroot: "/") +!9 = !DIModule(scope: null, name: "CModule", includePath: "", isysroot: "/") +!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "FromSubmodule", scope: !8, file: !3, line: 1, size: 96, elements: !13) +!13 = !{!14, !16, !17} +!14 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !3, line: 2, baseType: !15, size: 32) +!15 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) +!16 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !3, line: 2, baseType: !15, size: 32, offset: 32) +!17 = !DIDerivedType(tag: DW_TAG_member, name: "z", scope: !11, file: !3, line: 2, baseType: !15, size: 32, offset: 64) +!18 = !{i32 2, !"Dwarf Version", i32 4} +!19 = !{i32 2, !"Debug Info Version", i32 3} +!22 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project 056f1b5cc7c2133f0cb3e30e7f24808d321096d7)"} diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-line-basic.s b/lldb/test/Shell/SymbolFile/DWARF/debug-line-basic.s new file mode 100644 index 00000000000..a1100ba8d9c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-line-basic.s @@ -0,0 +1,86 @@ +# Test basics of debug_line parsing. This test uses a linker script which +# ensures the code is placed at the end of a module to test the boundary +# condition when the final end-of-sequence line table entry points to an address +# that is outside the range of memory covered by the module. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld --script=%S/Inputs/debug-line-basic.script %t.o -o %t +# RUN: %lldb %t -o "image dump line-table -v a.c" -o exit | FileCheck %s + + .text + .globl _start +_start: +# CHECK: Line table for /tmp/a.c + .file 1 "/tmp/b.c" + .loc 1 0 0 + nop +# CHECK-NEXT: 0x0000000000201000: /tmp/b.c, is_start_of_statement = TRUE{{$}} + .loc 1 1 0 + nop +# CHECK-NEXT: 0x0000000000201001: /tmp/b.c:1, is_start_of_statement = TRUE{{$}} + .loc 1 1 1 + nop +# CHECK-NEXT: 0x0000000000201002: /tmp/b.c:1:1, is_start_of_statement = TRUE{{$}} + .loc 1 2 0 is_stmt 0 + nop +# CHECK-NEXT: 0x0000000000201003: /tmp/b.c:2{{$}} + .loc 1 2 0 is_stmt 0 basic_block + nop +# CHECK-NEXT: 0x0000000000201004: /tmp/b.c:2, is_start_of_basic_block = TRUE{{$}} + .loc 1 2 0 is_stmt 0 prologue_end + nop +# CHECK-NEXT: 0x0000000000201005: /tmp/b.c:2, is_prologue_end = TRUE{{$}} + .loc 1 2 0 is_stmt 0 epilogue_begin + nop +# CHECK-NEXT: 0x0000000000201006: /tmp/b.c:2, is_epilogue_begin = TRUE{{$}} + .file 2 "/tmp/c.c" + .loc 2 1 0 is_stmt 0 + nop +# CHECK-NEXT: 0x0000000000201007: /tmp/c.c:1{{$}} +# CHECK-NEXT: 0x0000000000201008: /tmp/c.c:1, is_terminal_entry = TRUE{{$}} + + .section .text.f,"ax",@progbits +f: + .loc 1 3 0 is_stmt 0 + nop +# CHECK-NEXT: 0x0000000000201008: /tmp/b.c:3{{$}} +# CHECK-NEXT: 0x0000000000201009: /tmp/b.c:3, is_terminal_entry = TRUE{{$}} + + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "/tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-names-compressed.cpp b/lldb/test/Shell/SymbolFile/DWARF/debug-names-compressed.cpp new file mode 100644 index 00000000000..aeb0ff1d01b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-names-compressed.cpp @@ -0,0 +1,14 @@ +// Test for a bug where we crashed while processing a compressed debug_names +// section (use after free). + +// REQUIRES: lld, zlib + +// RUN: %clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s +// RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib +// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s + +// CHECK: Found 1 variables: +int foo; +// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = debug-names-compressed.cpp:[[@LINE-1]] + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s new file mode 100644 index 00000000000..e87f8c8569d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-address-ranges.s @@ -0,0 +1,340 @@ +# Check address lookup works correctly in the presence of type units. +# Specifically check that we don't use the line table pointed to by the +# DW_AT_stmt_list of the type unit (which used only for the file names) to +# compute address range for the type unit as type units don't describe any +# addresses. The addresses should always resolve to the relevant compile units. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -dwarf-version=5 -triple x86_64-pc-linux %s -filetype=obj >%t.o +# RUN: ld.lld %t.o -o %t -image-base=0x47000 -z separate-code +# RUN: %lldb %t -o "image lookup -a 0x48000 -v" -o exit | FileCheck %s + +# CHECK: CompileUnit: id = {0x00000001}, file = "/tmp/a.cc", language = "c++" +# CHECK: Function: id = {0x7fffffff0000006a}, name = "::_start({{.*}})", range = [0x0000000000048000-0x000000000004800c) +# CHECK: LineEntry: [0x0000000000048000-0x000000000004800a): /tmp/a.cc:4 +# CHECK: Symbol: id = {0x00000002}, range = [0x0000000000048000-0x000000000004800c), name="_start" +# CHECK: Variable: id = {0x7fffffff00000075}, name = "v1", {{.*}} decl = a.cc:4 +# CHECK: Variable: id = {0x7fffffff00000080}, name = "v2", {{.*}} decl = a.cc:4 + + +# Output generated via +# clang -g -fdebug-types-section -gdwarf-5 -S +# from +# enum E1 { e1 }; +# enum E2 { e2 }; +# extern "C" void _start(E1 v1, E2 v2) {} +# The output was modified to place the compile unit in between the two type +# units. + + .text + .file "a.cc" + .file 0 "/tmp" "a.cc" + + .text + .globl _start # -- Begin function _start + .p2align 4, 0x90 + .type _start,@function +_start: # @_start +.Lfunc_begin0: + .loc 0 4 0 # /tmp/a.cc:4:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl %edi, -4(%rbp) + movl %esi, -8(%rbp) +.Ltmp0: + .loc 0 4 23 prologue_end # /tmp/a.cc:4:23 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp1: +.Lfunc_end0: + .size _start, .Lfunc_end0-_start + .cfi_endproc + # -- End function + .section .debug_str_offsets,"",@progbits + .long 52 + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 9.0.0 (trunk 360907) (llvm/trunk 360908)" +.Linfo_string1: + .asciz "a.cc" +.Linfo_string2: + .asciz "/tmp" +.Linfo_string3: + .asciz "unsigned int" +.Linfo_string4: + .asciz "e1" +.Linfo_string5: + .asciz "E1" +.Linfo_string6: + .asciz "e2" +.Linfo_string7: + .asciz "E2" +.Linfo_string8: + .asciz "_start" +.Linfo_string9: + .asciz "f" +.Linfo_string10: + .asciz "v1" +.Linfo_string11: + .asciz "v2" + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .long .Linfo_string6 + .long .Linfo_string7 + .long .Linfo_string8 + .long .Linfo_string9 + .long .Linfo_string10 + .long .Linfo_string11 + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 1 # DW_CHILDREN_yes + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 40 # DW_TAG_enumerator + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 28 # DW_AT_const_value + .byte 15 # DW_FORM_udata + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 37 # DW_FORM_strx1 + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 37 # DW_FORM_strx1 + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 0 # DW_CHILDREN_no + .byte 60 # DW_AT_declaration + .byte 25 # DW_FORM_flag_present + .byte 105 # DW_AT_signature + .byte 32 # DW_FORM_ref_sig8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 7 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 2 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .quad -6180787752776176174 # Type Signature + .long 35 # Type DIE Offset + .byte 1 # Abbrev [1] 0x18:0x1d DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .byte 2 # Abbrev [2] 0x23:0xd DW_TAG_enumeration_type + .long 48 # DW_AT_type + .byte 5 # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 3 # Abbrev [3] 0x2c:0x3 DW_TAG_enumerator + .byte 4 # DW_AT_name + .byte 0 # DW_AT_const_value + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x30:0x4 DW_TAG_base_type + .byte 3 # DW_AT_name + .byte 7 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + + .long .Ldebug_info_end2-.Ldebug_info_start2 # Length of Unit +.Ldebug_info_start2: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 5 # Abbrev [5] 0xc:0x4d DW_TAG_compile_unit + .byte 0 # DW_AT_producer + .short 4 # DW_AT_language + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .long .Lline_table_start0 # DW_AT_stmt_list + .byte 2 # DW_AT_comp_dir + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Laddr_table_base0 # DW_AT_addr_base + .byte 6 # Abbrev [6] 0x23:0x9 DW_TAG_enumeration_type + # DW_AT_declaration + .quad -6180787752776176174 # DW_AT_signature + .byte 6 # Abbrev [6] 0x2c:0x9 DW_TAG_enumeration_type + # DW_AT_declaration + .quad 7818257750321376053 # DW_AT_signature + .byte 7 # Abbrev [7] 0x35:0x23 DW_TAG_subprogram + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 8 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + # DW_AT_external + .byte 8 # Abbrev [8] 0x41:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 124 + .byte 10 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .long 35 # DW_AT_type + .byte 8 # Abbrev [8] 0x4c:0xb DW_TAG_formal_parameter + .byte 2 # DW_AT_location + .byte 145 + .byte 120 + .byte 11 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .long 44 # DW_AT_type + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end2: + + .long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .short 5 # DWARF version number + .byte 2 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .quad 7818257750321376053 # Type Signature + .long 35 # Type DIE Offset + .byte 1 # Abbrev [1] 0x18:0x1d DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .byte 2 # Abbrev [2] 0x23:0xd DW_TAG_enumeration_type + .long 48 # DW_AT_type + .byte 7 # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 0 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 3 # Abbrev [3] 0x2c:0x3 DW_TAG_enumerator + .byte 6 # DW_AT_name + .byte 0 # DW_AT_const_value + .byte 0 # End Of Children Mark + .byte 4 # Abbrev [4] 0x30:0x4 DW_TAG_base_type + .byte 3 # DW_AT_name + .byte 7 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end1: + .section .debug_macinfo,"",@progbits + .byte 0 # End Of Macro List Mark + .section .debug_addr,"",@progbits + .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution +.Ldebug_addr_start0: + .short 5 # DWARF version number + .byte 8 # Address size + .byte 0 # Segment selector size +.Laddr_table_base0: + .quad .Lfunc_begin0 +.Ldebug_addr_end0: + + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-basic.test b/lldb/test/Shell/SymbolFile/DWARF/debug-types-basic.test new file mode 100644 index 00000000000..24a6a651d5f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-basic.test @@ -0,0 +1,66 @@ +# REQUIRES: lld + +# Make sure DWARF v4 type units work. +# RUN: %clangxx -target x86_64-pc-linux %S/Inputs/debug-types-basic.cpp \ +# RUN: -g -gdwarf-4 -fdebug-types-section -c -o %t4.o +# RUN: ld.lld %t4.o -o %t4 +# RUN: %lldb %t4 -s %s -o exit | FileCheck %s + +# Now do the same for DWARF v5. +# RUN: %clangxx -target x86_64-pc-linux %S/Inputs/debug-types-basic.cpp \ +# RUN: -g -gdwarf-5 -fdebug-types-section -c -o %t5.o +# RUN: ld.lld %t5.o -o %t5 +# RUN: %lldb %t5 -s %s -o exit | FileCheck %s + +# Test type units in dwo files. +# RUN: %clangxx -target x86_64-pc-linux %S/Inputs/debug-types-basic.cpp \ +# RUN: -g -gdwarf-4 -fdebug-types-section -gsplit-dwarf -c -o %t4dwo.o +# RUN: ld.lld %t4dwo.o -o %t4dwo +# RUN: %lldb %t4dwo -s %s -o exit | FileCheck %s + +# And type units+dwo+dwarf5. +# RUN: %clangxx -target x86_64-pc-linux %S/Inputs/debug-types-basic.cpp \ +# RUN: -g -gdwarf-5 -fdebug-types-section -c -o %t5dwo.o +# RUN: ld.lld %t5dwo.o -o %t5dwo +# RUN: %lldb %t5dwo -s %s -o exit | FileCheck %s + +type lookup A +# CHECK-LABEL: type lookup A +# CHECK: struct A { +# CHECK-NEXT: int i; +# CHECK-NEXT: long l; +# CHECK-NEXT: float f; +# CHECK-NEXT: double d; +# CHECK-NEXT: E e; +# CHECK-NEXT: EC ec; +# CHECK-NEXT: } + +type lookup E +# CHECK-LABEL: type lookup E +# CHECK: enum E { +# CHECK-NEXT: e1, +# CHECK-NEXT: e2, +# CHECK-NEXT: e3 +# CHECK-NEXT: } + +type lookup EC +# CHECK-LABEL: type lookup EC +# CHECK: enum class EC { +# CHECK-NEXT: e1, +# CHECK-NEXT: e2, +# CHECK-NEXT: e3 +# CHECK-NEXT: } + +print (E) 1 +# CHECK-LABEL: print (E) 1 +# CHECK: (E) $0 = e2 + +print (EC) 1 +# CHECK-LABEL: print (EC) 1 +# CHECK: (EC) $1 = e2 + +target variable a e ec +# CHECK-LABEL: target variable a e ec +# CHECK: (const A) a = (i = 42, l = 47, f = 4.{{[12].*}}, d = 4.{{[67].*}}, e = e1, ec = e3) +# CHECK: (const E) e = e2 +# CHECK: (const EC) ec = e2 diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s new file mode 100644 index 00000000000..9de61e48ef7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s @@ -0,0 +1,94 @@ +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: %lldb %t -o "image lookup -v -s f1" -o exit | FileCheck %s + +# CHECK: Function: id = {0x7fffffff0000003c}, name = "f1", range = [0x0000000000000000-0x0000000000000001) +# CHECK: Blocks: id = {0x7fffffff0000003c}, range = [0x00000000-0x00000001) + + + .text + .globl f1 + .type f1,@function +f1: + nop +.Lfunc_end0: + .size f1, .Lfunc_end0-f1 + # -- End function + .section .debug_str,"MS",@progbits,1 +.Lproducer: + .asciz "Hand-written DWARF" +.Lf1: + .asciz "f1" +.Le1: + .asciz "e1" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Ltu_begin0: + .long .Ltu_end0-.Ltu_start0 # Length of Unit +.Ltu_start0: + .short 5 # DWARF version number + .byte 2 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .quad 47 # Type Signature + .long .Ltype-.Ltu_begin0 # Type DIE Offset + .byte 3 # Abbrev [1] 0x18:0x1d DW_TAG_type_unit +.Ltype: + .byte 5 # Abbrev [5] 0x2e:0x9 DW_TAG_enumeration_type + .long .Le1 # DW_AT_name + .byte 0 # End Of Children Mark +.Ltu_end0: + +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit + .long .Lproducer # DW_AT_producer + .quad f1 # DW_AT_low_pc + .long .Lfunc_end0-f1 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2b:0x37 DW_TAG_subprogram + .quad f1 # DW_AT_low_pc + .long .Lfunc_end0-f1 # DW_AT_high_pc + .long .Lf1 # DW_AT_name + .byte 0 # End Of Children Mark +.Ldebug_info_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp b/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp new file mode 100644 index 00000000000..29adff62cd1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp @@ -0,0 +1,37 @@ +// Test that we can jump from a type unit in one dwo file into a type unit in a +// different dwo file. + +// REQUIRES: lld + +// RUN: %clang %s -target x86_64-pc-linux -fno-standalone-debug -g \ +// RUN: -fdebug-types-section -gsplit-dwarf -c -o %t1.o -DONE +// RUN: %clang %s -target x86_64-pc-linux -fno-standalone-debug -g \ +// RUN: -fdebug-types-section -gsplit-dwarf -c -o %t2.o -DTWO +// RUN: llvm-dwarfdump %t1.dwo -debug-types | FileCheck --check-prefix=ONEUNIT %s +// RUN: llvm-dwarfdump %t2.dwo -debug-types | FileCheck --check-prefix=ONEUNIT %s +// RUN: ld.lld %t1.o %t2.o -o %t +// RUN: %lldb %t -o "target var a b **b.a" -b | FileCheck %s + +// ONEUNIT-COUNT-1: DW_TAG_type_unit + +// CHECK: (const A) a = (a = 42) +// CHECK: (const B) b = { +// CHECK-NEXT: a = 0x{{.*}} +// CHECK-NEXT: } +// CHECK: (const A) **b.a = (a = 42) + +struct A; + +extern const A *a_ptr; +#ifdef ONE +struct A { + int a = 42; +}; +constexpr A a{}; +const A *a_ptr = &a; +#else +struct B { + const A **a; +}; +extern constexpr B b{&a_ptr}; +#endif diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-expressions.test b/lldb/test/Shell/SymbolFile/DWARF/debug-types-expressions.test new file mode 100644 index 00000000000..6da06d7b74f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-expressions.test @@ -0,0 +1,53 @@ +# UNSUPPORTED: system-darwin, system-windows + +# Make sure DWARF v4 type units work. +# RUN: %clangxx %S/Inputs/debug-types-expressions.cpp \ +# RUN: -g -gdwarf-4 -fdebug-types-section -o %t4 +# RUN: %lldb %t4 -s %s -o exit | FileCheck %s + +# Now do the same for DWARF v5. +# RUN: %clangxx %S/Inputs/debug-types-expressions.cpp \ +# RUN: -g -gdwarf-5 -fdebug-types-section -o %t5 +# RUN: %lldb %t5 -s %s -o exit | FileCheck %s + +# Test type units in dwo files. +# RUN: %clangxx %S/Inputs/debug-types-expressions.cpp \ +# RUN: -g -gdwarf-4 -fdebug-types-section -o %t4dwo +# RUN: %lldb %t4dwo -s %s -o exit | FileCheck %s + +# And type units+dwo+dwarf5. +# RUN: %clangxx %S/Inputs/debug-types-expressions.cpp \ +# RUN: -g -gdwarf-5 -fdebug-types-section -o %t5dwo +# RUN: %lldb %t5dwo -s %s -o exit | FileCheck %s + +breakpoint set -n foo +process launch + +# CHECK: Process {{.*}} stopped + +frame variable a +# CHECK-LABEL: frame variable a +# CHECK: (B *) a = + +frame variable *a +# CHECK-LABEL: frame variable *a +# CHECK: (B) *a = { +# CHECK-NEXT: A = (i = 47) +# CHECK-NEXT: j = 42 +# CHECK-NEXT: } + +print a->f() +# CHECK-LABEL: print a->f() +# CHECK: (int) $0 = 47 + +print ns::A() +# CHECK-LABEL: print ns::A() +# CHECK: (ns::A) $1 = (i = 147) + +print ns::A().i + a->i +# CHECK-LABEL: print ns::A().i + a->i +# CHECK: (int) $2 = 194 + +print ns::A().getA() +# CHECK-LABEL: ns::A().getA() +# CHECK: (A) $3 = (i = 146) diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-line-tables.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-line-tables.s new file mode 100644 index 00000000000..803f93ff679 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-line-tables.s @@ -0,0 +1,202 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t +# RUN: lldb-test symbols %t | FileCheck %s + + .file 1 "/tmp" "b.cc" + + .section .debug_types,"",@progbits + +# CHECK: Types: +# Type unit one: "struct A" defined at b.cc:1 +# CHECK-DAG: name = "A", size = 4, decl = b.cc:1 +1: + .long 4f-2f # Length of Unit +2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad 5390450678491038984 # Type Signature + .long 3f-1b # Type DIE Offset + .byte 1 # Abbrev [1] 0x17:0x1b DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0 # DW_AT_stmt_list +3: + .byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_structure_type + .long .LA # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 0 # End Of Children Mark +4: + +# Type unit two: "struct B" defined at b.cc:2 +# It shares the same line table as unit one. +# CHECK-DAG: name = "B", size = 4, decl = b.cc:2 +1: + .long 4f-2f # Length of Unit +2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad 5390450678491038985 # Type Signature + .long 3f-1b # Type DIE Offset + .byte 1 # Abbrev [1] 0x17:0x1b DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0 # DW_AT_stmt_list +3: + .byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_structure_type + .long .LB # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 0 # End Of Children Mark +4: + +# Type unit three: "struct C". +# DW_AT_stmt_list missing +# CHECK-DAG: name = "C", size = 4, line = 3 +1: + .long 4f-2f # Length of Unit +2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad 5390450678491038986 # Type Signature + .long 3f-1b # Type DIE Offset + .byte 4 # Abbrev [4] 0x17:0x1b DW_TAG_type_unit + .short 4 # DW_AT_language +3: + .byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_structure_type + .long .LC # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 1 # DW_AT_decl_file + .byte 3 # DW_AT_decl_line + .byte 0 # End Of Children Mark +4: + +# Type unit four: "struct D". +# DW_AT_stmt_list invalid +# CHECK-DAG: name = "D", size = 4, line = 4 +1: + .long 4f-2f # Length of Unit +2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad 5390450678491038987 # Type Signature + .long 3f-1b # Type DIE Offset + .byte 1 # Abbrev [1] 0x17:0x1b DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0+47 # DW_AT_stmt_list +3: + .byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_structure_type + .long .LD # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 1 # DW_AT_decl_file + .byte 4 # DW_AT_decl_line + .byte 0 # End Of Children Mark +4: + +# Type unit five: "struct E". +# DW_AT_decl_file invalid +# CHECK-DAG: name = "E", size = 4, line = 5 +1: + .long 4f-2f # Length of Unit +2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .quad 5390450678491038988 # Type Signature + .long 3f-1b # Type DIE Offset + .byte 1 # Abbrev [1] 0x17:0x1b DW_TAG_type_unit + .short 4 # DW_AT_language + .long .Lline_table_start0 # DW_AT_stmt_list +3: + .byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_structure_type + .long .LE # DW_AT_name + .byte 4 # DW_AT_byte_size + .byte 47 # DW_AT_decl_file + .byte 5 # DW_AT_decl_line + .byte 0 # End Of Children Mark +4: + + + .section .debug_str,"MS",@progbits,1 +.LA: + .asciz "A" +.LB: + .asciz "B" +.LC: + .asciz "C" +.LD: + .asciz "D" +.LE: + .asciz "E" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 0 # DW_CHILDREN_no + .byte 105 # DW_AT_signature + .byte 32 # DW_FORM_ref_sig8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 4 # Abbrev [4] 0xb:0x32 DW_TAG_compile_unit + .byte 5 # Abbrev [5] DW_TAG_structure_type + .quad 5390450678491038984 # DW_AT_signature + .byte 5 # Abbrev [5] DW_TAG_structure_type + .quad 5390450678491038985 # DW_AT_signature + .byte 5 # Abbrev [5] DW_TAG_structure_type + .quad 5390450678491038986 # DW_AT_signature + .byte 5 # Abbrev [5] DW_TAG_structure_type + .quad 5390450678491038987 # DW_AT_signature + .byte 5 # Abbrev [5] DW_TAG_structure_type + .quad 5390450678491038988 # DW_AT_signature + .byte 0 # End Of Children Mark +.Ldebug_info_end1: + + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test b/lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test new file mode 100644 index 00000000000..f9c02061fc8 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test @@ -0,0 +1,26 @@ +Create a dangling DW_AT_signature reference by stripping the debug_types +section, and make sure lldb does something reasonable. +RUN: %clangxx -target x86_64-pc-linux %S/Inputs/debug-types-basic.cpp \ +RUN: -g -gdwarf-4 -fdebug-types-section -c -o %t.o +RUN: llvm-objcopy --remove-section=.debug_types %t.o %t + + +RUN: %lldb %t -b -o "type lookup A" | FileCheck --check-prefix=LOOKUPA %s +LOOKUPA: no type was found matching 'A' + +RUN: %lldb %t -b -o "type lookup E" | FileCheck --check-prefix=LOOKUPE %s +LOOKUPE: no type was found matching 'E' + +RUN: %lldb %t -b -o "type lookup EC" | FileCheck --check-prefix=LOOKUPEC %s +LOOKUPEC: no type was found matching 'EC' + +RUN: %lldb %t -b -o "print (E) 1" 2>&1 | FileCheck --check-prefix=PRINTE %s +PRINTE: use of undeclared identifier 'E' + +RUN: %lldb %t -b -o "print (EC) 1" 2>&1 | FileCheck --check-prefix=PRINTEC %s +PRINTEC: use of undeclared identifier 'EC' + +RUN: %lldb %t -b -o "target variable a e ec" | FileCheck --check-prefix=VARS %s +VARS: (const (anonymous struct)) a = {} +VARS: (const (anonymous enum)) e = 0x1 +VARS: (const (anonymous enum)) ec = 0x1 diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug-types-signature-loop.s b/lldb/test/Shell/SymbolFile/DWARF/debug-types-signature-loop.s new file mode 100644 index 00000000000..addab83ddcc --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug-types-signature-loop.s @@ -0,0 +1,115 @@ +# REQUIRES: lld, x86 + +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux -o %t.o %s +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -o "target variable e" -b | FileCheck %s + +# CHECK: e = <could not resolve type> + + .type e,@object # @e + .section .rodata,"a",@progbits + .globl e + .p2align 2 +e: + .long 0 # 0x0 + .size e, 4 + +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Linfo_string1: + .asciz "a.cpp" +.Linfo_string3: + .asciz "e" +.Linfo_string4: + .asciz "unsigned int" +.Linfo_string5: + .asciz "e1" +.Linfo_string6: + .asciz "E" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 65 # DW_TAG_type_unit + .byte 1 # DW_CHILDREN_yes + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 4 # DW_TAG_enumeration_type + .byte 0 # DW_CHILDREN_no + .byte 60 # DW_AT_declaration + .byte 25 # DW_FORM_flag_present + .byte 105 # DW_AT_signature + .byte 32 # DW_FORM_ref_sig8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Ltu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 2 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .quad 5390450678491038984 # Type Signature + .long .LE-.Ltu_begin0 # Type DIE Offset + .byte 1 # Abbrev [1] 0x18:0x1d DW_TAG_type_unit + .short 4 # DW_AT_language +.LE: + .byte 8 # Abbrev [8] 0x23:0xd DW_TAG_enumeration_type + # DW_AT_declaration + .quad 5390450678491038984 # DW_AT_signature +.Lbase: + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + +.Lcu_begin0: + .long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 5 # Abbrev [5] 0xc:0x2c DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 4 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .byte 6 # Abbrev [6] 0x1e:0xb DW_TAG_variable + .long .Linfo_string3 # DW_AT_name + .long .LE_sig-.Lcu_begin0 # DW_AT_type + .byte 9 # DW_AT_location + .byte 3 + .quad e +.LE_sig: + .byte 8 # Abbrev [8] 0x2e:0x9 DW_TAG_enumeration_type + # DW_AT_declaration + .quad 5390450678491038984 # DW_AT_signature + .byte 0 # End Of Children Mark +.Ldebug_info_end1: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_aranges-empty-section.s b/lldb/test/Shell/SymbolFile/DWARF/debug_aranges-empty-section.s new file mode 100644 index 00000000000..4e9fabdf64a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_aranges-empty-section.s @@ -0,0 +1,65 @@ +# Test that an empty .debug_aranges section doesn't confuse (or crash) us. + +# REQUIRES: x86 + +# RUN: llvm-mc %s -triple x86_64-pc-linux -filetype=obj >%t +# RUN: lldb %t -o "breakpoint set -n f" -b | FileCheck %s + +# CHECK: Breakpoint 1: where = {{.*}}`f, address = 0x0000000000000047 + + .text + .globl f # -- Begin function f + .type f,@function + .rept 0x47 + nop + .endr +f: # @f +.Lfunc_begin0: + retq +.Lfunc_end0: + .size f, .Lfunc_end0-f + # -- End function + .section .debug_str,"MS",@progbits,1 +.Linfo_string3: + .asciz "f" # string offset=83 + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x35 DW_TAG_compile_unit + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Linfo_string3 # DW_AT_name + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + + .section ".note.GNU-stack","",@progbits + .section .debug_aranges,"",@progbits diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s b/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s new file mode 100644 index 00000000000..8dec979f694 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s @@ -0,0 +1,143 @@ +# Test debug_loc parsing, including the cases of invalid input. The exact +# behavior in the invalid cases is not particularly important, but it should be +# "reasonable". + +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" -o exit \ +# RUN: | FileCheck %s + +# CHECK-LABEL: image lookup -v -a 0 +# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg5 RDI, +# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = , +# CHECK: Variable: {{.*}}, name = "x2", type = "int", location = , + +# CHECK-LABEL: image lookup -v -a 2 +# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX, +# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = , +# CHECK: Variable: {{.*}}, name = "x2", type = "int", location = , + + .type f,@function +f: # @f +.Lfunc_begin0: + movl %edi, %eax +.Ltmp0: + retq +.Ltmp1: +.Lfunc_end0: + .size f, .Lfunc_end0-f + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Linfo_string3: + .asciz "f" +.Linfo_string4: + .asciz "int" +.Lx0: + .asciz "x0" +.Lx1: + .asciz "x1" +.Lx2: + .asciz "x2" + + .section .debug_loc,"",@progbits +.Ldebug_loc0: + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Ltmp0-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .quad .Ltmp0-.Lfunc_begin0 + .quad .Lfunc_end0-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 80 # super-register DW_OP_reg0 + .quad 0 + .quad 0 +.Ldebug_loc2: + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Lfunc_end0-.Lfunc_begin0 + .short 0xdead # Loc expr size + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 5 # DW_TAG_formal_parameter + .byte 0 # DW_CHILDREN_no + .byte 2 # DW_AT_location + .byte 23 # DW_FORM_sec_offset + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x50 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .byte 2 # Abbrev [2] 0x2a:0x29 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Linfo_string3 # DW_AT_name + .long .Lint # DW_AT_type + .byte 3 # Abbrev [3] DW_TAG_formal_parameter + .long .Ldebug_loc0 # DW_AT_location + .long .Lx0 # DW_AT_name + .long .Lint-.Lcu_begin0 # DW_AT_type + .byte 3 # Abbrev [3] DW_TAG_formal_parameter + .long 0xdeadbeef # DW_AT_location + .long .Lx1 # DW_AT_name + .long .Lint-.Lcu_begin0 # DW_AT_type + .byte 3 # Abbrev [3] DW_TAG_formal_parameter + .long .Ldebug_loc2 # DW_AT_location + .long .Lx2 # DW_AT_name + .long .Lint-.Lcu_begin0 # DW_AT_type + .byte 0 # End Of Children Mark +.Lint: + .byte 4 # Abbrev [4] 0x53:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s new file mode 100644 index 00000000000..98d4e91c3e1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges-missing-section.s @@ -0,0 +1,80 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit 2>&1 | FileCheck %s + +# CHECK: DIE has DW_AT_ranges(0x47) attribute, but range extraction failed (No debug_ranges section), +# CHECK: Function: id = {0x7fffffff0000001c}, name = "ranges", range = [0x0000000000000000-0x0000000000000004) +# CHECK: Blocks: id = {0x7fffffff0000001c}, range = [0x00000000-0x00000004) + + .text + .p2align 12 + .globl ranges + .type ranges,@function +ranges: # @ranges + nop +lookup_ranges: + nop + nop + nop +.Lranges_end: + .size ranges, .Lranges_end-ranges + # -- End function + .section .debug_str,"MS",@progbits,1 +.Lproducer: + .asciz "Hand-written DWARF" +.Lranges: + .asciz "ranges" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 11 # DW_TAG_lexical_block + .byte 0 # DW_CHILDREN_no + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x7b DW_TAG_compile_unit + .long .Lproducer # DW_AT_producer + .quad ranges # DW_AT_low_pc + .long .Lranges_end-ranges # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x4d DW_TAG_subprogram + .quad ranges # DW_AT_low_pc + .long .Lranges_end-ranges # DW_AT_high_pc + .long .Lranges # DW_AT_name + .byte 5 # Abbrev [5] 0x61:0x15 DW_TAG_lexical_block + .long 0x47 # DW_AT_ranges + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s new file mode 100644 index 00000000000..bbe5cb220c2 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges.s @@ -0,0 +1,94 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit | FileCheck %s + +# CHECK: Function: id = {0x7fffffff0000001c}, name = "ranges", range = [0x0000000000000000-0x0000000000000004) +# CHECK: Blocks: id = {0x7fffffff0000001c}, range = [0x00000000-0x00000004) +# CHECK-NEXT: id = {0x7fffffff0000002d}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004) + + .text + .p2align 12 + .globl ranges + .type ranges,@function +ranges: # @ranges +.Lfoo_begin: + nop +.Lblock1_begin: +lookup_ranges: + nop +.Lblock1_end: + nop +.Lblock2_begin: + nop +.Lblock2_end: +.Lfunc_end0: + .size ranges, .Lfunc_end0-ranges + # -- End function + .section .debug_str,"MS",@progbits,1 +.Lproducer: + .asciz "Hand-written DWARF" +.Lranges: + .asciz "ranges" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 11 # DW_TAG_lexical_block + .byte 0 # DW_CHILDREN_no + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x7b DW_TAG_compile_unit + .long .Lproducer # DW_AT_producer + .quad .Lfoo_begin # DW_AT_low_pc + .long .Lfunc_end0-.Lfoo_begin # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x4d DW_TAG_subprogram + .quad .Lfoo_begin # DW_AT_low_pc + .long .Lfunc_end0-.Lfoo_begin # DW_AT_high_pc + .long .Lranges # DW_AT_name + .byte 5 # Abbrev [5] 0x61:0x15 DW_TAG_lexical_block + .long .Ldebug_ranges0 # DW_AT_ranges + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lblock1_begin-.Lfoo_begin + .quad .Lblock1_end-.Lfoo_begin + .quad .Lblock2_begin-.Lfoo_begin + .quad .Lblock2_end-.Lfoo_begin + .quad 0 + .quad 0 diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_ranges_and_rnglists.test b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges_and_rnglists.test new file mode 100644 index 00000000000..49bb4e7a189 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_ranges_and_rnglists.test @@ -0,0 +1,18 @@ +# REQUIRES: lld + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %S/debug_ranges.s > %t-ranges.o +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %S/debug_rnglists.s > %t-rnglists.o +# RUN: ld.lld -r %t-ranges.o %t-rnglists.o -o %t +# RUN: %lldb %t -s %s | FileCheck %s + +image lookup -v -s lookup_ranges +# CHECK-LABEL: image lookup -v -s lookup_ranges +# CHECK: Function: {{.*}} name = "ranges", range = [0x0000000000000000-0x0000000000000004) +# CHECK: Blocks: {{.*}} range = [0x00000000-0x00000004) +# CHECK-NEXT: {{.*}} ranges = [0x00000001-0x00000002)[0x00000003-0x00000004) + +image lookup -v -s lookup_rnglists +# CHECK-LABEL: image lookup -v -s lookup_rnglists +# CHECK: Function: {{.*}} name = "rnglists", range = [0x0000000000001000-0x0000000000001004) +# CHECK: Blocks: {{.*}} range = [0x00001000-0x00001004) +# CHECK-NEXT: {{.*}} ranges = [0x00001001-0x00001002)[0x00001003-0x00001004) diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s new file mode 100644 index 00000000000..5d95b80e8da --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/debug_rnglists.s @@ -0,0 +1,110 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: %lldb %t -o "image lookup -v -s lookup_rnglists" -o exit | FileCheck %s + +# CHECK: Function: id = {0x7fffffff00000021}, name = "rnglists", range = [0x0000000000000000-0x0000000000000004) +# CHECK: Blocks: id = {0x7fffffff00000021}, range = [0x00000000-0x00000004) +# CHECK-NEXT: id = {0x7fffffff00000032}, ranges = [0x00000001-0x00000002)[0x00000003-0x00000004) + + .text + .p2align 12 + .globl rnglists + .type rnglists,@function +rnglists: # @rnglists +.Lfoo_begin: + nop +.Lblock1_begin: +lookup_rnglists: + nop +.Lblock1_end: + nop +.Lblock2_begin: + nop +.Lblock2_end: +.Lfunc_end0: + .size rnglists, .Lfunc_end0-rnglists + # -- End function + .section .debug_str,"MS",@progbits,1 +.Lproducer: + .asciz "Hand-written DWARF" +.Lrnglists: + .asciz "rnglists" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 116 # DW_AT_rnglists_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 11 # DW_TAG_lexical_block + .byte 0 # DW_CHILDREN_no + .byte 85 # DW_AT_ranges + .byte 35 # DW_FORM_rnglistx + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit + .long .Lproducer # DW_AT_producer + .quad .Lfoo_begin # DW_AT_low_pc + .long .Lfunc_end0-.Lfoo_begin # DW_AT_high_pc + .long .Lrnglists_table_base0 # DW_AT_rnglists_base + .byte 2 # Abbrev [2] 0x2b:0x37 DW_TAG_subprogram + .quad .Lfoo_begin # DW_AT_low_pc + .long .Lfunc_end0-.Lfoo_begin # DW_AT_high_pc + .long .Lrnglists # DW_AT_name + .byte 5 # Abbrev [5] 0x52:0xf DW_TAG_lexical_block + .byte 0 # DW_AT_ranges + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + + .section .debug_rnglists,"",@progbits + .long .Ldebug_rnglist_table_end0-.Ldebug_rnglist_table_start0 # Length +.Ldebug_rnglist_table_start0: + .short 5 # Version + .byte 8 # Address size + .byte 0 # Segment selector size + .long 1 # Offset entry count +.Lrnglists_table_base0: + .long .Ldebug_ranges0-.Lrnglists_table_base0 +.Ldebug_ranges0: + .byte 4 # DW_RLE_offset_pair + .uleb128 .Lblock1_begin-.Lfoo_begin # starting offset + .uleb128 .Lblock1_end-.Lfoo_begin # ending offset + .byte 4 # DW_RLE_offset_pair + .uleb128 .Lblock2_begin-.Lfoo_begin # starting offset + .uleb128 .Lblock2_end-.Lfoo_begin # ending offset + .byte 0 # DW_RLE_end_of_list +.Ldebug_rnglist_table_end0: + .section .debug_macinfo,"",@progbits + .byte 0 # End Of Macro List Mark diff --git a/lldb/test/Shell/SymbolFile/DWARF/deterministic-build.cpp b/lldb/test/Shell/SymbolFile/DWARF/deterministic-build.cpp new file mode 100644 index 00000000000..576c4ab7244 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/deterministic-build.cpp @@ -0,0 +1,11 @@ +// Test that binaries linked deterministically (N_OSO has timestamp 0) can still +// have their object files loaded by lldb. Note that the env var ZERO_AR_DATE +// requires the ld64 linker, which clang invokes by default. +// REQUIRES: system-darwin +// RUN: %clang %s -g -c -o %t.o +// RUN: ZERO_AR_DATE=1 %clang %t.o -g -o %t +// RUN: %lldb %t -o "breakpoint set -f %s -l 11" -o run -o exit | FileCheck %s +// CHECK: stop reason = breakpoint + + +int main() { return 0; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s new file mode 100644 index 00000000000..7fee15d65ca --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s @@ -0,0 +1,63 @@ +# Test that parsing of line tables works reasonably. In this case the debug info +# does not have enough information for our heuristics to determine the path +# style, so we will just treat them as native host paths. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t -z separate-code +# RUN: %lldb %t -s %S/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for foo{{.}}a.c +# CHECK-NEXT: 0x0000000000201000: foo{{.}}a.c:1 +# CHECK-NEXT: 0x0000000000201001: foo{{.}}b.c:1 +# CHECK-NEXT: 0x0000000000201002: foo{{.}}b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f foo/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "foo/a.c" + .loc 1 1 0 + nop + .file 2 "foo/b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "foo/a.c" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir.s b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir.s new file mode 100644 index 00000000000..de6bde9b5c6 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-no-comp-dir.s @@ -0,0 +1,62 @@ +# Test that we properly determine the path syntax of a compile unit even if the +# compile unit does not have a DW_AT_comp_dir attribute. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t -z separate-code +# RUN: %lldb %t -s %S/Inputs/dir-separator-windows.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for C:\tmp\a.c +# CHECK-NEXT: 0x0000000000201000: C:\tmp\a.c:1 +# CHECK-NEXT: 0x0000000000201001: C:\tmp\b.c:1 +# CHECK-NEXT: 0x0000000000201002: C:\tmp\b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f C:/tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "C:\\tmp\\a.c" + .loc 1 1 0 + nop + .file 2 "C:\\tmp\\b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "C:\\tmp\\a.c" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/dir-separator-posix.s b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-posix.s new file mode 100644 index 00000000000..d6466708919 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-posix.s @@ -0,0 +1,67 @@ +# Test that parsing of line tables works reasonably, even if the host directory +# separator does not match the separator of the compile unit. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t -z separate-code +# RUN: %lldb %t -s %S/Inputs/dir-separator-posix.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for /tmp/a.c +# CHECK-NEXT: 0x0000000000201000: /tmp/a.c:1 +# CHECK-NEXT: 0x0000000000201001: /tmp/b.c:1 +# CHECK-NEXT: 0x0000000000201002: /tmp/b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f /tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "/tmp/a.c" + .loc 1 1 0 + nop + .file 2 "/tmp/b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "/tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/dir-separator-windows.s b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-windows.s new file mode 100644 index 00000000000..d64033546f7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dir-separator-windows.s @@ -0,0 +1,67 @@ +# Test that parsing of line tables works reasonably, even if the host directory +# separator does not match the separator of the compile unit. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t -z separate-code +# RUN: %lldb %t -s %S/Inputs/dir-separator-windows.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for C:\tmp\a.c +# CHECK-NEXT: 0x0000000000201000: C:\tmp\a.c:1 +# CHECK-NEXT: 0x0000000000201001: C:\tmp\b.c:1 +# CHECK-NEXT: 0x0000000000201002: C:\tmp\b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f C:/tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "C:\\tmp\\a.c" + .loc 1 1 0 + nop + .file 2 "C:\\tmp\\b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "C:\\tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-index-is-used.cpp b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-index-is-used.cpp new file mode 100644 index 00000000000..f5122ebadae --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-index-is-used.cpp @@ -0,0 +1,13 @@ +// Test that we use the DWARF v5 name indexes. + +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols %t | FileCheck %s + +// CHECK: Name Index +// CHECK: String: 0x{{.*}} "_start" +// CHECK: Tag: DW_TAG_subprogram + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-partial-index.cpp b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-partial-index.cpp new file mode 100644 index 00000000000..84e3b62e17b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-partial-index.cpp @@ -0,0 +1,23 @@ +// Test that we return complete results when only a part of the binary is built +// with an index. + +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s + +// CHECK: Found 2 variables: +#ifdef ONE +namespace one { +int foo; +// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]] +} // namespace one +extern "C" void _start() {} +#else +namespace two { +int foo; +// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]] +} // namespace two +#endif diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s b/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s new file mode 100644 index 00000000000..4093ea05980 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwarf5_locations.s @@ -0,0 +1,68 @@ +# This tests that lldb is able to process DW_OP_addrx tags introduced in dwarf5. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -g -dwarf-version=5 -triple x86_64-unknown-linux-gnu %s -filetype=obj > %t.o +# RUN: ld.lld -m elf_x86_64 %t.o -o %t +# RUN: lldb-test symbols %t | FileCheck %s + +# CHECK: Variable{0x7fffffff00000011}, name = "color" +# CHECK-SAME: location = DW_OP_addrx 0x0 + + .text + .section .debug_str,"MS",@progbits,1 +.Lstr_offsets_base0: + .asciz "color" + + .section .debug_str_offsets,"",@progbits + .long .Lstr_offsets_base0 + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .byte 0 # EOM(4) + + .section .debug_info,"",@progbits + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x22 DW_TAG_compile_unit + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .byte 2 # Abbrev [2] 0x1e:0xb DW_TAG_variable + .byte 0 # DW_AT_name + # DW_AT_external + .byte 2 # DW_AT_location + .byte 161 + .byte 0 + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + + .section .debug_addr,"",@progbits + .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution +.Ldebug_addr_start0: + .short 5 # DWARF version number + .byte 8 # Address size + .byte 0 # Segment selector size + .quad color +.Ldebug_addr_end0: + diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp new file mode 100644 index 00000000000..3d175f63e04 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp @@ -0,0 +1,106 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=BASE %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=function %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=BASE %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=function %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=BASE %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck --check-prefix=METHOD %s +// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL %s +// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \ +// RUN: FileCheck --check-prefix=FULL-MANGLED %s +// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=function %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// BASE: Found 4 functions: +// BASE-DAG: name = "foo()", mangled = "_Z3foov" +// BASE-DAG: name = "foo(int)", mangled = "_Z3fooi" +// BASE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" +// BASE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv" + +// METHOD: Found 3 functions: +// METHOD-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi" +// METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv" + +// FULL: Found 7 functions: +// FULL-DAG: name = "foo()", mangled = "_Z3foov" +// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi" +// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" +// FULL-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv" +// FULL-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// FULL-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi" +// FULL-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv" + +// FULL-MANGLED: Found 1 functions: +// FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi" + +// CONTEXT: Found 1 functions: +// CONTEXT-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" + +// EMPTY: Found 0 functions: + +void foo() {} +void foo(int) {} + +namespace bar { +int context; +void foo() {} +namespace baz { +void foo() {} +} // namespace baz +} // namespace bar + +struct foo {}; +void fbar(struct foo) {} + +void Foo() {} + +struct sbar { + void foo(); + static void foo(int); +}; +void sbar::foo() {} +void sbar::foo(int) {} + +void ffbar() { + struct sbaz { + void foo() {} + }; + sbaz a; + a.foo(); +} + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-basic-namespace.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-basic-namespace.cpp new file mode 100644 index 00000000000..e7655a37053 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-basic-namespace.cpp @@ -0,0 +1,46 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=namespace %t | \ +// RUN: FileCheck --check-prefix=FOO %s +// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=namespace %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=namespace %t | \ +// RUN: FileCheck --check-prefix=FOO %s +// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=namespace %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=namespace %t | \ +// RUN: FileCheck --check-prefix=FOO %s +// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=namespace %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// FOO: Found namespace: foo + +// CONTEXT: Found namespace: bar::foo + +// EMPTY: Namespace not found. + +namespace foo { +int X; +} + +namespace bar { +int context; +namespace foo { +int X; +} +} // namespace bar + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-basic-type.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-basic-type.cpp new file mode 100644 index 00000000000..060a5b41eeb --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-basic-type.cpp @@ -0,0 +1,55 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=type %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=type %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=type %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=type %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=type %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=not_there --find=type %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// EMPTY: Found 0 types: +// NAME: Found 4 types: +// CONTEXT: Found 1 types: +struct foo { }; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] + +namespace bar { +int context; +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +// CONTEXT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]] +namespace baz { +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +} +} + +struct sbar { + struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]] +}; + +struct foobar {}; + +struct Foo {}; + +extern "C" void _start(foo, bar::foo, bar::baz::foo, sbar::foo, foobar, Foo) {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-basic-variable.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-basic-variable.cpp new file mode 100644 index 00000000000..bca8f27e1d4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-basic-variable.cpp @@ -0,0 +1,76 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// RUN: lldb-test symbols --name=not_there --find=variable %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// RUN: lldb-test symbols --name=not_there --find=variable %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s +// +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ +// RUN: FileCheck --check-prefix=CONTEXT %s +// RUN: lldb-test symbols --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=NAME %s +// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ +// RUN: FileCheck --check-prefix=REGEX %s +// RUN: lldb-test symbols --name=not_there --find=variable %t | \ +// RUN: FileCheck --check-prefix=EMPTY %s + +// EMPTY: Found 0 variables: +// NAME: Found 4 variables: +// CONTEXT: Found 1 variables: +// REGEX: Found 5 variables: +int foo; +// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +namespace bar { +int context; +long foo; +// NAME-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// CONTEXT-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +// REGEX-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-3]] +namespace baz { +static short foo; +// NAME-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +} +} + +struct sbar { + static int foo; +// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] +// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] +}; +int sbar::foo; + +int foobar; +// REGEX-DAG: name = "foobar", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] + +int fbar() { + static int foo; + return foo + bar::baz::foo; +} + +int Foo; + +struct ssbar { + int foo; +}; + +extern "C" void _start(sbar, ssbar) {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-function-regex.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-function-regex.cpp new file mode 100644 index 00000000000..b1e9d10e82a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-function-regex.cpp @@ -0,0 +1,26 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s + +// CHECK: Found 3 functions: +// CHECK-DAG: name = "foo()", mangled = "_Z3foov" +// CHECK-DAG: name = "ffo()", mangled = "_Z3ffov" +// CHECK-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv" + +void foo() {} +void ffo() {} +namespace bar { +void foo() {} +} // namespace bar +void fof() {} + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-inline-method.s b/lldb/test/Shell/SymbolFile/DWARF/find-inline-method.s new file mode 100644 index 00000000000..cfc5ef01dd3 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-inline-method.s @@ -0,0 +1,152 @@ +# REQUIRES: lld, x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t -z separate-code +# RUN: lldb-test symbols --find=function --name=inl --function-flags=method %t \ +# RUN: | FileCheck %s + +# CHECK: Function: {{.*}} mangled = "_Z8externali" +# CHECK: Blocks: {{.*}} range = [0x00201000-0x00201002) +# CHECK-NEXT: range = [0x00201000-0x00201002), name = "inl", mangled = _ZN1S3inlEi + + +# Generated via: +# clang -O2 -g -S + +# from file: +# int forward(int); +# struct S { +# static int inl(int a) { return forward(a); } +# }; +# int external(int a) { return S::inl(a); } + +# and then simplified. + + .text +_Z8externali: +.Lfunc_begin0: + jmp _Z7forwardi +.Lfunc_end0: + +.globl _start +_start: +_Z7forwardi: + ret + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 7.0.0 (trunk 332830) (llvm/trunk 332835) with manual modifications" +.Linfo_string3: + .asciz "_ZN1S3inlEi" +.Linfo_string4: + .asciz "inl" +.Linfo_string6: + .asciz "S" +.Linfo_string8: + .asciz "_Z8externali" +.Linfo_string9: + .asciz "external" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 1 # DW_CHILDREN_yes + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 71 # DW_AT_specification + .byte 19 # DW_FORM_ref4 + .byte 32 # DW_AT_inline + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 8 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 110 # DW_AT_linkage_name + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 10 # Abbreviation Code + .byte 29 # DW_TAG_inlined_subroutine + .byte 1 # DW_CHILDREN_yes + .byte 49 # DW_AT_abstract_origin + .byte 19 # DW_FORM_ref4 + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x9e DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 4 # DW_AT_language + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x1f DW_TAG_structure_type + .long .Linfo_string6 # DW_AT_name + .byte 1 # DW_AT_byte_size +.Linl_spec: + .byte 3 # Abbrev [3] 0x33:0x15 DW_TAG_subprogram + .long .Linfo_string3 # DW_AT_linkage_name + .long .Linfo_string4 # DW_AT_name + .byte 0 # End Of Children Mark +.Linl_abstract: + .byte 6 # Abbrev [6] 0x50:0x12 DW_TAG_subprogram + .long .Linl_spec # DW_AT_specification + .byte 1 # DW_AT_inline +.Linl_a_abstract: + .byte 8 # Abbrev [8] 0x62:0x46 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Linfo_string8 # DW_AT_linkage_name + .long .Linfo_string9 # DW_AT_name + .byte 10 # Abbrev [10] 0x8c:0x1b DW_TAG_inlined_subroutine + .long .Linl_abstract # DW_AT_abstract_origin + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.Lcu_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-method-local-struct.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-method-local-struct.cpp new file mode 100644 index 00000000000..3da4a4a23f8 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-method-local-struct.cpp @@ -0,0 +1,19 @@ +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck %s + +// CHECK-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv" +// CHECK-DAG: name = "ffbar()::sbar::foo()", mangled = "_ZZ5ffbarvEN4sbar3fooEv" + +struct sbar { + void foo(); +}; +void sbar::foo() {} + +void ffbar() { + struct sbar { + void foo() {} + }; + sbar a; + a.foo(); +} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-method.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-method.cpp new file mode 100644 index 00000000000..7e7710fd472 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-method.cpp @@ -0,0 +1,31 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck %s +// +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ +// RUN: FileCheck %s + +// CHECK-DAG: name = "A::foo()", mangled = "_ZN1A3fooEv" +// CHECK-DAG: name = "B::foo()", mangled = "_ZN1B3fooEv" +// CHECK-DAG: name = "C::foo()", mangled = "_ZN1C3fooEv" + +struct A { + void foo(); +}; +void A::foo() {} + +class B { + void foo(); +}; +void B::foo() {} + +union C { + void foo(); +}; +void C::foo() {} + +extern "C" void _start() {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-qualified-variable.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-qualified-variable.cpp new file mode 100644 index 00000000000..1ad3e7fbadf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-qualified-variable.cpp @@ -0,0 +1,15 @@ +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: lldb-test symbols --name=A::foo --find=variable %t | FileCheck %s + +// CHECK: Found 1 variables: + +struct A { + static int foo; +}; +int A::foo; +// NAME-DAG: name = "foo", {{.*}} decl = find-qualified-variable.cpp:[[@LINE-1]] + +struct B { + static int foo; +}; +int B::foo; diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-type-in-function.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-type-in-function.cpp new file mode 100644 index 00000000000..5c1b4b44523 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-type-in-function.cpp @@ -0,0 +1,24 @@ +// REQUIRES: lld + +// XFAIL: * + +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux +// RUN: ld.lld %t.o -o %t +// RUN: lldb-test symbols --name=foo --find=type %t | \ +// RUN: FileCheck --check-prefix=NAME %s + +// Lookup for "foo" should find either both "struct foo" types or just the +// global one. Right now, it finds the definition inside bar(), which is +// definitely wrong. + +// NAME: Found 2 types: +struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-type-in-function.cpp:[[@LINE-1]] + +void bar() { + struct foo {}; +// NAME-DAG: name = "foo", {{.*}} decl = find-type-in-function.cpp:[[@LINE-1]] + foo a; +} + +extern "C" void _start(foo) {} diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp new file mode 100644 index 00000000000..b2fb1a375cf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp @@ -0,0 +1,25 @@ +// REQUIRES: lld + +// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \ +// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-1.dwo -o %t-1.o +// RUN: llvm-objcopy --split-dwo=%t-1.dwo %t-1.o +// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \ +// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-2.dwo -o %t-2.o +// RUN: llvm-objcopy --split-dwo=%t-2.dwo %t-2.o +// RUN: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --name=foo --find=variable %t | FileCheck %s + +// CHECK: Found 2 variables: +#ifdef ONE +namespace one { +int foo; +// CHECK-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-dwo.cpp:[[@LINE-1]] +} // namespace one + +extern "C" void _start() {} +#else +namespace two { +int foo; +// CHECK-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-dwo.cpp:[[@LINE-1]] +} // namespace two +#endif diff --git a/lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp b/lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp new file mode 100644 index 00000000000..550896cc707 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp @@ -0,0 +1,38 @@ +// REQUIRES: lld + +// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s +// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp +// RUN: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=ONE %s +// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=TWO %s + +// Run the same test with split-dwarf. This is interesting because the two +// split compile units will have the same offset (0). +// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -gsplit-dwarf %s +// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -gsplit-dwarf %S/Inputs/find-variable-file-2.cpp +// RUN: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=ONE %s +// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=TWO %s + +// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s +// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp +// RUN: ld.lld %t-1.o %t-2.o -o %t +// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=ONE %s +// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \ +// RUN: FileCheck --check-prefix=TWO %s + +// ONE: Found 1 variables: +namespace one { +int foo; +// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-variable-file.cpp:[[@LINE-1]] +} // namespace one + +extern "C" void _start() {} + +// TWO: Found 1 variables: +// TWO-DAG: name = "foo", {{.*}} decl = find-variable-file-2.cpp:2 diff --git a/lldb/test/Shell/SymbolFile/DWARF/forward-declarations.s b/lldb/test/Shell/SymbolFile/DWARF/forward-declarations.s new file mode 100644 index 00000000000..952c4ee7f87 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/forward-declarations.s @@ -0,0 +1,111 @@ +# Test handling of the situation (including the error message) where a structure +# has a incomplete member. + +# REQUIRES: x86 + +# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t +# RUN: %lldb %t -o "target var b" -b 2>&1 | FileCheck %s + +# CHECK: error: {{.*}} DWARF DIE at 0x0000002b (class B) has a member variable 0x00000030 (a) whose type is a forward declaration, not a complete definition. +# CHECK-NEXT: Please file a bug against the compiler and include the preprocessed output for /tmp/a.cc + +# CHECK: b = (a = A @ 0x0000000000000001) + + .type b,@object # @b + .comm b,1,1 + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Lcu_name: + .asciz "/tmp/a.cc" +.Lcu_compdir: + .asciz "/foo/bar" +.Lb: + .asciz "b" +.La: + .asciz "a" +.LA: + .asciz "A" +.LB: + .asciz "B" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 1 # DW_CHILDREN_yes + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 13 # DW_TAG_member + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 19 # DW_TAG_structure_type + .byte 0 # DW_CHILDREN_no + .byte 60 # DW_AT_declaration + .byte 25 # DW_FORM_flag_present + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x46 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .long .Lcu_name # DW_AT_name + .long .Lcu_compdir # DW_AT_comp_dir + .byte 2 # Abbrev [2] 0x1e:0x15 DW_TAG_variable + .long .Lb # DW_AT_name + .long .LB_die-.Lcu_begin0 # DW_AT_type + .byte 9 # DW_AT_location + .byte 3 + .quad b +.LB_die: + .byte 3 # Abbrev [3] 0x33:0x15 DW_TAG_structure_type + .long .LB # DW_AT_name + .byte 4 # Abbrev [4] 0x3b:0xc DW_TAG_member + .long .La # DW_AT_name + .long .LA_die-.Lcu_begin0 # DW_AT_type + .byte 0 # End Of Children Mark +.LA_die: + .byte 5 # Abbrev [5] 0x48:0x8 DW_TAG_structure_type + # DW_AT_declaration + .long .LA # DW_AT_name + .byte 0 # End Of Children Mark +.Ldebug_info_end0: diff --git a/lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp b/lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp new file mode 100644 index 00000000000..9dc87303ba9 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp @@ -0,0 +1,14 @@ +// REQUIRES: zlib + +// RUN: %clang %s -target x86_64-pc-linux -g -gsplit-dwarf -c -o %t \ +// RUN: -Wa,--compress-debug-sections=zlib-gnu +// RUN: %lldb %t -o "target var s a" -b | FileCheck %s + +// CHECK: (const short) s = 47 +// CHECK: (const A) a = (a = 42) + +struct A { + long a = 42; +}; +extern constexpr short s = 47; +extern constexpr A a{}; diff --git a/lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg b/lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg new file mode 100644 index 00000000000..d7ddcbf641c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.cpp', '.s', '.test', '.ll'] diff --git a/lldb/test/Shell/SymbolFile/DWARF/parallel-indexing-stress.s b/lldb/test/Shell/SymbolFile/DWARF/parallel-indexing-stress.s new file mode 100644 index 00000000000..94b35e5c114 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/parallel-indexing-stress.s @@ -0,0 +1,84 @@ +# Stress-test the parallel indexing of compile units. + +# REQUIRES: x86 + +# RUN: llvm-mc -triple x86_64-pc-linux %s -o %t -filetype=obj +# RUN: %lldb %t -o "target variable A" -b | FileCheck %s + +# CHECK-COUNT-256: A = 47 + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Lname: + .asciz "A" +.Linfo_string4: + .asciz "int" # string offset=95 + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + +.macro generate_unit + .data +A\@: + .long 47 + + .section .debug_str,"MS",@progbits,1 + + .section .debug_info,"",@progbits +.Lcu_begin\@: + .long .Ldebug_info_end\@-.Ldebug_info_start\@ # Length of Unit +.Ldebug_info_start\@: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x30 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .byte 2 # Abbrev [2] 0x1e:0x15 DW_TAG_variable + .long .Lname # DW_AT_name + .long .Ltype\@-.Lcu_begin\@ # DW_AT_type + .byte 9 # DW_AT_location + .byte 3 + .quad A\@ +.Ltype\@: + .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end\@: + +.endm + +.rept 256 +generate_unit +.endr diff --git a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp new file mode 100644 index 00000000000..5873d896b19 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp @@ -0,0 +1,8 @@ +// RUN: %clangxx -target x86_64-pc-linux -gsplit-dwarf -fsplit-dwarf-inlining \ +// RUN: -c %s -o %t +// RUN: %lldb %t -o "breakpoint set -n foo" -b | FileCheck %s + +// CHECK: Breakpoint 1: 2 locations + +__attribute__((always_inline)) int foo(int x) { return x; } +int bar(int x) { return foo(x); } diff --git a/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll new file mode 100644 index 00000000000..9c2348750cf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll @@ -0,0 +1,40 @@ +; Check handling of dwo files with multiple compile units. Right now this is not +; supported, but it should not cause us to crash or misbehave either... + +; RUN: llc %s -filetype=obj -o %t.o --split-dwarf-file=%t.o +; RUN: %lldb %t.o -o "image lookup -s x1 -v" -o "image lookup -s x2 -v" -b | FileCheck %s + +; CHECK: image lookup -s x1 +; CHECK: 1 symbols match 'x1' +; CHECK-NOT: CompileUnit: +; CHECK-NOT: Variable: + +; CHECK: image lookup -s x2 +; CHECK: 1 symbols match 'x2' +; CHECK-NOT: CompileUnit: +; CHECK-NOT: Variable: + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@x1 = dso_local global i32 42, align 4, !dbg !10 +@x2 = dso_local global i32 47, align 4, !dbg !20 + +!llvm.dbg.cu = !{!12, !22} +!llvm.module.flags = !{!8, !9, !1} + +!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression()) +!11 = distinct !DIGlobalVariable(name: "x1", scope: !12, type: !7) +!12 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !15) +!15 = !{!10} + +!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression()) +!21 = distinct !DIGlobalVariable(name: "x2", scope: !22, type: !7) +!22 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !25) +!25 = !{!20} + +!3 = !DIFile(filename: "-", directory: "/tmp") +!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{i32 2, !"Dwarf Version", i32 4} +!9 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !{i32 1, !"wchar_size", i32 4} diff --git a/lldb/test/Shell/SymbolFile/Inputs/sizeless-symbol.s b/lldb/test/Shell/SymbolFile/Inputs/sizeless-symbol.s new file mode 100644 index 00000000000..ac08dddb0e2 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Inputs/sizeless-symbol.s @@ -0,0 +1,8 @@ + .text + .byte 0 +sizeless: +sizeful: + .byte 0 + .byte 0 +sizeend: + .size sizeful, sizeend - sizeful diff --git a/lldb/test/Shell/SymbolFile/Inputs/target-symbols-add-unwind.c b/lldb/test/Shell/SymbolFile/Inputs/target-symbols-add-unwind.c new file mode 100644 index 00000000000..237c8ce1817 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Inputs/target-symbols-add-unwind.c @@ -0,0 +1 @@ +int main() {} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit new file mode 100644 index 00000000000..c25d96c531d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit @@ -0,0 +1,8 @@ + +break set -n main +break set -n static_fn +break set -n varargs_fn + +target modules dump ast + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit new file mode 100644 index 00000000000..6d593589c4a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit @@ -0,0 +1,5 @@ +target variable s + +target modules dump ast + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-types.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-types.lldbinit new file mode 100644 index 00000000000..b317c4ab343 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/ast-types.lldbinit @@ -0,0 +1,25 @@ +target variable TC +target variable TS +target variable TU +target variable TE + +target variable ABCInt +target variable ABCFloat +target variable ABCVoid + +target variable AC0 +target variable ACNeg1 + +target variable AC1D +target variable AC0D +target variable ACNeg1D +target variable AD +target variable ADE + +target variable AnonInt +target variable AnonABCVoid +target variable AnonABCVoidD + +target modules dump ast + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/bitfields.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/bitfields.lldbinit new file mode 100644 index 00000000000..cf06c494e67 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/bitfields.lldbinit @@ -0,0 +1,5 @@ +settings set auto-one-line-summaries false + +target variable -T TheStruct + +target modules dump ast diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit new file mode 100644 index 00000000000..ff9bf21a886 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit @@ -0,0 +1,6 @@ +break set -n main +break set -n OvlGlobalFn +break set -n StaticFn +break set -n DoesntExist +break list +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit new file mode 100644 index 00000000000..7daa53ba24e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit @@ -0,0 +1,3 @@ +break set -f break-by-line.cpp -l 14 +break list +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/disassembly.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/disassembly.lldbinit new file mode 100644 index 00000000000..2b552a0b01d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/disassembly.lldbinit @@ -0,0 +1,2 @@ +disassemble --flavor=intel -m -n main +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit new file mode 100644 index 00000000000..fe29896b5f5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit @@ -0,0 +1,70 @@ +command alias dv target variable + +dv aa +dv ab +dv ac +dv ad +dv ae +dv af +dv ag +dv ah +dv ai +dv aj +dv ak +dv al +dv am +dv an +dv ao +dv aq +dv ar +dv as +dv at +dv au +dv av +dv aw +dv ax +dv ay +dv az +dv aaa +dv aab +dv aac +dv aad +dv ra +dv rb +dv rc +dv rd +dv re +dv rf +dv rg +dv rh +dv ri +dv rj +dv rk +dv rl +dv rm +dv rn +dv ro +dv rq +dv rr +dv rs +dv rt +dv ru +dv rv +dv rw +dv rx +dv ry +dv rz +dv raa +dv rab +dv rac +dv rad +dv ref +dv ref2 +dv ref3 +dv binp +dv binr +dv null +dv rae +dv aae + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit new file mode 100644 index 00000000000..8664881b262 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit @@ -0,0 +1,7 @@ +target variable sfn +target variable ffn +target variable tfn +target variable cfn +target variable vfn + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit new file mode 100644 index 00000000000..c06c650e1c4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit @@ -0,0 +1,14 @@ +target variable a +target variable b +target variable c +target variable d +target variable e +target variable f +target variable g +target variable h +target variable i +target variable incomplete + +target modules dump ast + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit new file mode 100644 index 00000000000..9bf066ee2af --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit @@ -0,0 +1,3 @@ +target variable GlobalVariable + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit new file mode 100644 index 00000000000..cafb863d85f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit @@ -0,0 +1,16 @@ +settings set auto-one-line-summaries false + +target variable -T ClassWithPaddingInstance +target variable -T ClassNoPaddingInstance +target variable -T DC +target variable -T EBOC +target variable -T PBC + +target variable -T UnnamedClassInstance + +target variable -T PointersInstance +target variable -T ReferencesInstance + +target modules dump ast + +quit
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit new file mode 100644 index 00000000000..4af8b658742 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit @@ -0,0 +1,222 @@ +target variable BFalse +target variable BTrue +target variable CA +target variable CZ +target variable SCa +target variable SCz +target variable UC24 +target variable UC42 +target variable C16_24 +target variable C32_42 +target variable WC1 +target variable WCP +target variable SMax +target variable SMin +target variable USMax +target variable USMin +target variable IMax +target variable IMin +target variable UIMax +target variable UIMin +target variable LMax +target variable LMin +target variable ULMax +target variable ULMin +target variable LLMax +target variable LLMin +target variable ULLMax +target variable ULLMin +target variable F +target variable D + +target variable CBFalse +target variable CBTrue +target variable CCA +target variable CCZ +target variable CSCa +target variable CSCz +target variable CUC24 +target variable CUC42 +target variable CC16_24 +target variable CC32_42 +target variable CWC1 +target variable CWCP +target variable CSMax +target variable CSMin +target variable CUSMax +target variable CUSMin +target variable CIMax +target variable CIMin +target variable CUIMax +target variable CUIMin +target variable CLMax +target variable CLMin +target variable CULMax +target variable CULMin +target variable CLLMax +target variable CLLMin +target variable CULLMax +target variable CULLMin +target variable CF +target variable CD + +target variable ConstexprBFalse +target variable ConstexprBTrue +target variable ConstexprCA +target variable ConstexprCZ +target variable ConstexprSCa +target variable ConstexprSCz +target variable ConstexprUC24 +target variable ConstexprUC42 +target variable ConstexprC16_24 +target variable ConstexprC32_42 +target variable ConstexprWC1 +target variable ConstexprWCP +target variable ConstexprSMax +target variable ConstexprSMin +target variable ConstexprUSMax +target variable ConstexprUSMin +target variable ConstexprIMax +target variable ConstexprIMin +target variable ConstexprUIMax +target variable ConstexprUIMin +target variable ConstexprLMax +target variable ConstexprLMin +target variable ConstexprULMax +target variable ConstexprULMin +target variable ConstexprLLMax +target variable ConstexprLLMin +target variable ConstexprULLMax +target variable ConstexprULLMin +target variable ConstexprF +target variable ConstexprD + +target variable PBFalse +target variable PBTrue +target variable PCA +target variable PCZ +target variable PSCa +target variable PSCz +target variable PUC24 +target variable PUC42 +target variable PC16_24 +target variable PC32_42 +target variable PWC1 +target variable PWCP +target variable PSMax +target variable PSMin +target variable PUSMax +target variable PUSMin +target variable PIMax +target variable PIMin +target variable PUIMax +target variable PUIMin +target variable PLMax +target variable PLMin +target variable PULMax +target variable PULMin +target variable PLLMax +target variable PLLMin +target variable PULLMax +target variable PULLMin +target variable PF +target variable PD + +target variable CPBFalse +target variable CPBTrue +target variable CPCA +target variable CPCZ +target variable CPSCa +target variable CPSCz +target variable CPUC24 +target variable CPUC42 +target variable CPC16_24 +target variable CPC32_42 +target variable CPWC1 +target variable CPWCP +target variable CPSMax +target variable CPSMin +target variable CPUSMax +target variable CPUSMin +target variable CPIMax +target variable CPIMin +target variable CPUIMax +target variable CPUIMin +target variable CPLMax +target variable CPLMin +target variable CPULMax +target variable CPULMin +target variable CPLLMax +target variable CPLLMin +target variable CPULLMax +target variable CPULLMin +target variable CPF +target variable CPD + +target variable RBFalse +target variable RBTrue +target variable RCA +target variable RCZ +target variable RSCa +target variable RSCz +target variable RUC24 +target variable RUC42 +target variable RSMax +target variable RSMin +target variable RUSMax +target variable RUSMin +target variable RIMax +target variable RIMin +target variable RUIMax +target variable RUIMin +target variable RLMax +target variable RLMin +target variable RULMax +target variable RULMin +target variable RLLMax +target variable RLLMin +target variable RULLMax +target variable RULLMin +target variable RF +target variable RD + +target variable CRBFalse +target variable CRBTrue +target variable CRCA +target variable CRCZ +target variable CRSCa +target variable CRSCz +target variable CRUC24 +target variable CRUC42 +target variable CRSMax +target variable CRSMin +target variable CRUSMax +target variable CRUSMin +target variable CRIMax +target variable CRIMin +target variable CRUIMax +target variable CRUIMin +target variable CRLMax +target variable CRLMin +target variable CRULMax +target variable CRULMin +target variable CRLLMax +target variable CRLLMin +target variable CRULLMax +target variable CRULLMin +target variable CRF +target variable CRD + +target variable RC16_24 +target variable RC32_42 +target variable RWC1 +target variable RWCP +target variable CRC16_24 +target variable CRC32_42 +target variable CRWC1 +target variable CRWCP + +target modules dump ast + + +quit
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables.lldbinit new file mode 100644 index 00000000000..0d7371e86f1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables.lldbinit @@ -0,0 +1,32 @@ +break set -n main +run a b c d e f g +p argc +step +p SomeLocal +step +p Param1 +p Param2 +step +p Param1 +p Param2 +p Local1 +step +p Param1 +p Param2 +p Local1 +p Local2 +step +p Param1 +p Param2 +p Local1 +p Local2 +step +p Param1 +p Param2 +p Local1 +p Local2 +continue + +target modules dump ast + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/nested-types.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/nested-types.lldbinit new file mode 100644 index 00000000000..466df81fc42 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/nested-types.lldbinit @@ -0,0 +1,13 @@ +settings set auto-one-line-summaries false + +target variable -T GlobalA +target variable -T GlobalB +target variable -T GlobalC +target variable -T GlobalD +target variable -T GlobalE +target variable -T GlobalF +target variable -T GlobalG +target variable -T GlobalH +target variable -T GlobalEnum + +target modules dump ast diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.lldbinit new file mode 100644 index 00000000000..1a50d808cdc --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.lldbinit @@ -0,0 +1,25 @@ +target variable GlobalLUEA +target variable GlobalLUEB +target variable GlobalLUEC + +target variable GlobalLSEA +target variable GlobalLSEB +target variable GlobalLSEC + +target variable GlobalUEA +target variable GlobalUEB +target variable GlobalUEC + +target variable GlobalSEA +target variable GlobalSEB +target variable GlobalSEC + +target variable GlobalSUEA +target variable GlobalSUEB +target variable GlobalSUEC + +target variable GlobalSSEA +target variable GlobalSSEB +target variable GlobalSSEC + +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.s b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.s new file mode 100644 index 00000000000..6eaa80cf850 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/s_constant.s @@ -0,0 +1,971 @@ + .text + .def @feat.00; + .scl 3; + .type 0; + .endef + .globl @feat.00 +.set @feat.00, 0 + .intel_syntax noprefix + .def main; + .scl 2; + .type 32; + .endef + .globl main # -- Begin function main + .p2align 4, 0x90 +main: # @main +.Lfunc_begin0: + .cv_func_id 0 + .cv_file 1 "D:\\src\\llvm-mono\\lldb\\lit\\SymbolFile\\NativePDB\\s_constant.cpp" "7F1DA683A9B72A1360C1FDEDD7550E06" 1 + .cv_loc 0 1 79 0 # D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp:79:0 +.seh_proc main +# %bb.0: # %entry + sub rsp, 24 + .seh_stackalloc 24 + .seh_endprologue + xor eax, eax + mov dword ptr [rsp + 20], 0 + mov qword ptr [rsp + 8], rdx + mov dword ptr [rsp + 4], ecx +.Ltmp0: + .cv_loc 0 1 80 0 # D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp:80:0 + add rsp, 24 + ret +.Ltmp1: +.Lfunc_end0: + .seh_handlerdata + .text + .seh_endproc + # -- End function + .section .rdata,"dr" + .p2align 3 # @GlobalLUEA +GlobalLUEA: + .quad 0 # 0x0 + + .p2align 3 # @GlobalLUEB +GlobalLUEB: + .quad 1000 # 0x3e8 + + .p2align 3 # @GlobalLUEC +GlobalLUEC: + .quad -16 # 0xfffffffffffffff0 + + .p2align 3 # @GlobalLSEA +GlobalLSEA: + .quad 0 # 0x0 + + .p2align 3 # @GlobalLSEB +GlobalLSEB: + .quad 9223372036854775000 # 0x7ffffffffffffcd8 + + .p2align 3 # @GlobalLSEC +GlobalLSEC: + .quad -9223372036854775000 # 0x8000000000000328 + + .p2align 2 # @GlobalUEA +GlobalUEA: + .long 0 # 0x0 + + .p2align 2 # @GlobalUEB +GlobalUEB: + .long 1000 # 0x3e8 + + .p2align 2 # @GlobalUEC +GlobalUEC: + .long 4294000000 # 0xfff13d80 + + .p2align 2 # @GlobalSEA +GlobalSEA: + .long 0 # 0x0 + + .p2align 2 # @GlobalSEB +GlobalSEB: + .long 2147000000 # 0x7ff89ec0 + + .p2align 2 # @GlobalSEC +GlobalSEC: + .long 2147967296 # 0x80076140 + +GlobalSUEA: # @GlobalSUEA + .byte 0 # 0x0 + +GlobalSUEB: # @GlobalSUEB + .byte 100 # 0x64 + +GlobalSUEC: # @GlobalSUEC + .byte 200 # 0xc8 + +GlobalSSEA: # @GlobalSSEA + .byte 0 # 0x0 + +GlobalSSEB: # @GlobalSSEB + .byte 100 # 0x64 + +GlobalSSEC: # @GlobalSSEC + .byte 156 # 0x9c + + .section .drectve,"yn" + .ascii " /DEFAULTLIB:libcmt.lib" + .ascii " /DEFAULTLIB:oldnames.lib" + .section .debug$S,"dr" + .p2align 2 + .long 4 # Debug section magic + .long 241 + .long .Ltmp3-.Ltmp2 # Subsection size +.Ltmp2: + .short .Ltmp5-.Ltmp4 # Record length +.Ltmp4: + .short 4412 # Record kind: S_COMPILE3 + .long 1 # Flags and language + .short 208 # CPUType + .short 8 # Frontend version + .short 0 + .short 0 + .short 0 + .short 8000 # Backend version + .short 0 + .short 0 + .short 0 + .asciz "clang version 8.0.0 " # Null-terminated compiler version string +.Ltmp5: +.Ltmp3: + .p2align 2 + .long 241 # Symbol subsection for main + .long .Ltmp7-.Ltmp6 # Subsection size +.Ltmp6: + .short .Ltmp9-.Ltmp8 # Record length +.Ltmp8: + .short 4423 # Record kind: S_GPROC32_ID + .long 0 # PtrParent + .long 0 # PtrEnd + .long 0 # PtrNext + .long .Lfunc_end0-main # Code size + .long 0 # Offset after prologue + .long 0 # Offset before epilogue + .long 4099 # Function type index + .secrel32 main # Function section relative address + .secidx main # Function section index + .byte 0 # Flags + .asciz "main" # Function name +.Ltmp9: + .short .Ltmp11-.Ltmp10 # Record length +.Ltmp10: + .short 4114 # Record kind: S_FRAMEPROC + .long 24 # FrameSize + .long 0 # Padding + .long 0 # Offset of padding + .long 0 # Bytes of callee saved registers + .long 0 # Exception handler offset + .short 0 # Exception handler section + .long 81920 # Flags (defines frame register) +.Ltmp11: + .short .Ltmp13-.Ltmp12 # Record length +.Ltmp12: + .short 4414 # Record kind: S_LOCAL + .long 116 # TypeIndex + .short 1 # Flags + .asciz "argc" +.Ltmp13: + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 4 + .short .Ltmp15-.Ltmp14 # Record length +.Ltmp14: + .short 4414 # Record kind: S_LOCAL + .long 4096 # TypeIndex + .short 1 # Flags + .asciz "argv" +.Ltmp15: + .cv_def_range .Ltmp0 .Ltmp1, frame_ptr_rel, 8 + .short 2 # Record length + .short 4431 # Record kind: S_PROC_ID_END +.Ltmp7: + .p2align 2 + .cv_linetable 0, main, .Lfunc_end0 + .long 241 # Symbol subsection for globals + .long .Ltmp17-.Ltmp16 # Subsection size +.Ltmp16: + .short .Ltmp19-.Ltmp18 # Record length +.Ltmp18: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .short 0 # Value + .asciz "GlobalLUEA" # Name +.Ltmp19: + .short .Ltmp21-.Ltmp20 # Record length +.Ltmp20: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .short 1000 # Value + .asciz "GlobalLUEB" # Name +.Ltmp21: + .short .Ltmp23-.Ltmp22 # Record length +.Ltmp22: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .byte 0x00, 0x80, 0xf0 # Value + .asciz "GlobalLUEC" # Name +.Ltmp23: + .short .Ltmp25-.Ltmp24 # Record length +.Ltmp24: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalLSEA" # Name +.Ltmp25: + .short .Ltmp27-.Ltmp26 # Record length +.Ltmp26: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x0A, 0x80, 0xD8, 0xFC # Value + .byte 0xFF, 0xFF, 0xFF, 0xFF + .byte 0xFF, 0x7F + .asciz "GlobalLSEB" # Name +.Ltmp27: + .short .Ltmp29-.Ltmp28 # Record length +.Ltmp28: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x09, 0x80, 0x28, 0x03 # Value + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80 + .asciz "GlobalLSEC" # Name +.Ltmp29: + .short .Ltmp31-.Ltmp30 # Record length +.Ltmp30: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalUEA" # Name +.Ltmp31: + .short .Ltmp33-.Ltmp32 # Record length +.Ltmp32: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0xe8, 0x03 # Value + .asciz "GlobalUEB" # Name +.Ltmp33: + .short .Ltmp35-.Ltmp34 # Record length +.Ltmp34: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0x04, 0x80, 0x80, 0x3d # Value + .byte 0xf1, 0xff + .asciz "GlobalUEC" # Name +.Ltmp35: + .short .Ltmp37-.Ltmp36 # Record length +.Ltmp36: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSEA" # Name +.Ltmp37: + .short .Ltmp39-.Ltmp38 # Record length +.Ltmp38: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x04, 0x80, 0xc0, 0x9e # Value + .byte 0xf8, 0x7f + .asciz "GlobalSEB" # Name +.Ltmp39: + .short .Ltmp41-.Ltmp40 # Record length +.Ltmp40: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x03, 0x80, 0x40, 0x61 # Value + .byte 0x07, 0x80 + .asciz "GlobalSEC" # Name +.Ltmp41: + .short .Ltmp43-.Ltmp42 # Record length +.Ltmp42: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSUEA" # Name +.Ltmp43: + .short .Ltmp45-.Ltmp44 # Record length +.Ltmp44: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0x64, 0x00 # Value + .asciz "GlobalSUEB" # Name +.Ltmp45: + .short .Ltmp47-.Ltmp46 # Record length +.Ltmp46: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0xc8, 0x00 # Value + .asciz "GlobalSUEC" # Name +.Ltmp47: + .short .Ltmp49-.Ltmp48 # Record length +.Ltmp48: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSSEA" # Name +.Ltmp49: + .short .Ltmp51-.Ltmp50 # Record length +.Ltmp50: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x64, 0x00 # Value + .asciz "GlobalSSEB" # Name +.Ltmp51: + .short .Ltmp53-.Ltmp52 # Record length +.Ltmp52: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x00, 0x80, 0x9c # Value + .asciz "GlobalSSEC" # Name +.Ltmp53: +.Ltmp17: + .p2align 2 + .cv_filechecksums # File index to string table offset subsection + .cv_stringtable # String table + .long 241 + .long .Ltmp55-.Ltmp54 # Subsection size +.Ltmp54: + .short 6 # Record length + .short 4428 # Record kind: S_BUILDINFO + .long 4127 # LF_BUILDINFO index +.Ltmp55: + .p2align 2 + .section .debug$T,"dr" + .p2align 2 + .long 4 # Debug section magic + # Pointer (0x1000) { + # TypeLeafKind: LF_POINTER (0x1002) + # PointeeType: char* (0x670) + # PointerAttributes: 0x1000C + # PtrType: Near64 (0xC) + # PtrMode: Pointer (0x0) + # IsFlat: 0 + # IsConst: 0 + # IsVolatile: 0 + # IsUnaligned: 0 + # IsRestrict: 0 + # SizeOf: 8 + # } + .byte 0x0a, 0x00, 0x02, 0x10 + .byte 0x70, 0x06, 0x00, 0x00 + .byte 0x0c, 0x00, 0x01, 0x00 + # ArgList (0x1001) { + # TypeLeafKind: LF_ARGLIST (0x1201) + # NumArgs: 2 + # Arguments [ + # ArgType: int (0x74) + # ArgType: char** (0x1000) + # ] + # } + .byte 0x0e, 0x00, 0x01, 0x12 + .byte 0x02, 0x00, 0x00, 0x00 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x00, 0x10, 0x00, 0x00 + # Procedure (0x1002) { + # TypeLeafKind: LF_PROCEDURE (0x1008) + # ReturnType: int (0x74) + # CallingConvention: NearC (0x0) + # FunctionOptions [ (0x0) + # ] + # NumParameters: 2 + # ArgListType: (int, char**) (0x1001) + # } + .byte 0x0e, 0x00, 0x08, 0x10 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x02, 0x00 + .byte 0x01, 0x10, 0x00, 0x00 + # FuncId (0x1003) { + # TypeLeafKind: LF_FUNC_ID (0x1601) + # ParentScope: 0x0 + # FunctionType: int (int, char**) (0x1002) + # Name: main + # } + .byte 0x12, 0x00, 0x01, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x02, 0x10, 0x00, 0x00 + .byte 0x6d, 0x61, 0x69, 0x6e + .byte 0x00, 0xf3, 0xf2, 0xf1 + # FieldList (0x1004) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: LUE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 1000 + # Name: LUE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744073709551600 + # Name: LUE_C + # } + # } + .byte 0x2e, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xe8, 0x03, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0xf0, 0xff + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0xff, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x1005) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned __int64 (0x23) + # FieldListType: <field list> (0x1004) + # Name: A::B::C::LargeUnsignedEnum + # LinkageName: .?AW4LargeUnsignedEnum@C@B@A@@ + # } + .byte 0x4a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x23, 0x00, 0x00, 0x00 + .byte 0x04, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x4c, 0x61, 0x72 + .byte 0x67, 0x65, 0x55, 0x6e + .byte 0x73, 0x69, 0x67, 0x6e + .byte 0x65, 0x64, 0x45, 0x6e + .byte 0x75, 0x6d, 0x00, 0x2e + .byte 0x3f, 0x41, 0x57, 0x34 + .byte 0x4c, 0x61, 0x72, 0x67 + .byte 0x65, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # StringId (0x1006) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp + # } + .byte 0x46, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x73 + .byte 0x72, 0x63, 0x5c, 0x6c + .byte 0x6c, 0x76, 0x6d, 0x2d + .byte 0x6d, 0x6f, 0x6e, 0x6f + .byte 0x5c, 0x6c, 0x6c, 0x64 + .byte 0x62, 0x5c, 0x6c, 0x69 + .byte 0x74, 0x5c, 0x53, 0x79 + .byte 0x6d, 0x62, 0x6f, 0x6c + .byte 0x46, 0x69, 0x6c, 0x65 + .byte 0x5c, 0x4e, 0x61, 0x74 + .byte 0x69, 0x76, 0x65, 0x50 + .byte 0x44, 0x42, 0x5c, 0x73 + .byte 0x5f, 0x63, 0x6f, 0x6e + .byte 0x73, 0x74, 0x61, 0x6e + .byte 0x74, 0x2e, 0x63, 0x70 + .byte 0x70, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x1007) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::LargeUnsignedEnum (0x1005) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 14 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x05, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x0e, 0x00, 0x00, 0x00 + # Modifier (0x1008) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::LargeUnsignedEnum (0x1005) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x05, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1009) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: LSE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 9223372036854775000 + # Name: LSE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 9223372036854776616 + # Name: LSE_C + # } + # } + .byte 0x36, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0xd8, 0xfc + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0x7f, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x28, 0x03 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x100A) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: __int64 (0x13) + # FieldListType: <field list> (0x1009) + # Name: A::B::C::LargeSignedEnum + # LinkageName: .?AW4LargeSignedEnum@C@B@A@@ + # } + .byte 0x46, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x13, 0x00, 0x00, 0x00 + .byte 0x09, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x4c, 0x61, 0x72 + .byte 0x67, 0x65, 0x53, 0x69 + .byte 0x67, 0x6e, 0x65, 0x64 + .byte 0x45, 0x6e, 0x75, 0x6d + .byte 0x00, 0x2e, 0x3f, 0x41 + .byte 0x57, 0x34, 0x4c, 0x61 + .byte 0x72, 0x67, 0x65, 0x53 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x100B) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::LargeSignedEnum (0x100A) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 20 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x0a, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x14, 0x00, 0x00, 0x00 + # Modifier (0x100C) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::LargeSignedEnum (0x100A) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x0a, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x100D) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: UE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 1000 + # Name: UE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 4294000000 + # Name: UE_C + # } + # } + .byte 0x2a, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x55, 0x45 + .byte 0x5f, 0x41, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xe8, 0x03, 0x55, 0x45 + .byte 0x5f, 0x42, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x04, 0x80, 0x80, 0x3d + .byte 0xf1, 0xff, 0x55, 0x45 + .byte 0x5f, 0x43, 0x00, 0xf1 + # Enum (0x100E) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned (0x75) + # FieldListType: <field list> (0x100D) + # Name: A::B::C::UnsignedEnum + # LinkageName: .?AW4UnsignedEnum@C@B@A@@ + # } + .byte 0x3e, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x75, 0x00, 0x00, 0x00 + .byte 0x0d, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x00, 0x2e, 0x3f + .byte 0x41, 0x57, 0x34, 0x55 + .byte 0x6e, 0x73, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x40 + .byte 0x43, 0x40, 0x42, 0x40 + .byte 0x41, 0x40, 0x40, 0x00 + # UdtSourceLine (0x100F) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::UnsignedEnum (0x100E) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 26 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x0e, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x1a, 0x00, 0x00, 0x00 + # Modifier (0x1010) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::UnsignedEnum (0x100E) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x0e, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1011) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 2147000000 + # Name: SE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744071562551616 + # Name: SE_C + # } + # } + .byte 0x32, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x45 + .byte 0x5f, 0x41, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x04, 0x80, 0xc0, 0x9e + .byte 0xf8, 0x7f, 0x53, 0x45 + .byte 0x5f, 0x42, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x40, 0x61 + .byte 0x07, 0x80, 0xff, 0xff + .byte 0xff, 0xff, 0x53, 0x45 + .byte 0x5f, 0x43, 0x00, 0xf1 + # Enum (0x1012) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: int (0x74) + # FieldListType: <field list> (0x1011) + # Name: A::B::C::SignedEnum + # LinkageName: .?AW4SignedEnum@C@B@A@@ + # } + .byte 0x3a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x11, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x00 + .byte 0x2e, 0x3f, 0x41, 0x57 + .byte 0x34, 0x53, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x40 + .byte 0x43, 0x40, 0x42, 0x40 + .byte 0x41, 0x40, 0x40, 0x00 + # UdtSourceLine (0x1013) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SignedEnum (0x1012) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 32 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x12, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x20, 0x00, 0x00, 0x00 + # Modifier (0x1014) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SignedEnum (0x1012) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x12, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1015) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SUE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 100 + # Name: SUE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 200 + # Name: SUE_C + # } + # } + .byte 0x26, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x64, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xc8, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x1016) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned char (0x20) + # FieldListType: <field list> (0x1015) + # Name: A::B::C::SmallUnsignedEnum + # LinkageName: .?AW4SmallUnsignedEnum@C@B@A@@ + # } + .byte 0x4a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x20, 0x00, 0x00, 0x00 + .byte 0x15, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x6d, 0x61 + .byte 0x6c, 0x6c, 0x55, 0x6e + .byte 0x73, 0x69, 0x67, 0x6e + .byte 0x65, 0x64, 0x45, 0x6e + .byte 0x75, 0x6d, 0x00, 0x2e + .byte 0x3f, 0x41, 0x57, 0x34 + .byte 0x53, 0x6d, 0x61, 0x6c + .byte 0x6c, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x1017) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SmallUnsignedEnum (0x1016) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 38 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x16, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x26, 0x00, 0x00, 0x00 + # Modifier (0x1018) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SmallUnsignedEnum (0x1016) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x16, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1019) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SSE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 100 + # Name: SSE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744073709551516 + # Name: SSE_C + # } + # } + .byte 0x2e, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x53 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x64, 0x00, 0x53, 0x53 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x9c, 0xff + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0xff, 0x53, 0x53 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x101A) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: char (0x70) + # FieldListType: <field list> (0x1019) + # Name: A::B::C::SmallSignedEnum + # LinkageName: .?AW4SmallSignedEnum@C@B@A@@ + # } + .byte 0x46, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x70, 0x00, 0x00, 0x00 + .byte 0x19, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x6d, 0x61 + .byte 0x6c, 0x6c, 0x53, 0x69 + .byte 0x67, 0x6e, 0x65, 0x64 + .byte 0x45, 0x6e, 0x75, 0x6d + .byte 0x00, 0x2e, 0x3f, 0x41 + .byte 0x57, 0x34, 0x53, 0x6d + .byte 0x61, 0x6c, 0x6c, 0x53 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x101B) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SmallSignedEnum (0x101A) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 44 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x1a, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x2c, 0x00, 0x00, 0x00 + # Modifier (0x101C) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SmallSignedEnum (0x101A) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x1a, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # StringId (0x101D) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\\src\\llvmbuild\\ninja-x64 + # } + .byte 0x26, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x5c + .byte 0x73, 0x72, 0x63, 0x5c + .byte 0x5c, 0x6c, 0x6c, 0x76 + .byte 0x6d, 0x62, 0x75, 0x69 + .byte 0x6c, 0x64, 0x5c, 0x5c + .byte 0x6e, 0x69, 0x6e, 0x6a + .byte 0x61, 0x2d, 0x78, 0x36 + .byte 0x34, 0x00, 0xf2, 0xf1 + # StringId (0x101E) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\variable.cpp + # } + .byte 0x42, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x73 + .byte 0x72, 0x63, 0x5c, 0x6c + .byte 0x6c, 0x76, 0x6d, 0x2d + .byte 0x6d, 0x6f, 0x6e, 0x6f + .byte 0x5c, 0x6c, 0x6c, 0x64 + .byte 0x62, 0x5c, 0x6c, 0x69 + .byte 0x74, 0x5c, 0x53, 0x79 + .byte 0x6d, 0x62, 0x6f, 0x6c + .byte 0x46, 0x69, 0x6c, 0x65 + .byte 0x5c, 0x4e, 0x61, 0x74 + .byte 0x69, 0x76, 0x65, 0x50 + .byte 0x44, 0x42, 0x5c, 0x76 + .byte 0x61, 0x72, 0x69, 0x61 + .byte 0x62, 0x6c, 0x65, 0x2e + .byte 0x63, 0x70, 0x70, 0x00 + # BuildInfo (0x101F) { + # TypeLeafKind: LF_BUILDINFO (0x1603) + # NumArgs: 5 + # Arguments [ + # ArgType: D:\\src\\llvmbuild\\ninja-x64 (0x101D) + # ArgType: 0x0 + # ArgType: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\variable.cpp (0x101E) + # ArgType: 0x0 + # ArgType: 0x0 + # ] + # } + .byte 0x1a, 0x00, 0x03, 0x16 + .byte 0x05, 0x00, 0x1d, 0x10 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x1e, 0x10 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0xf2, 0xf1 + + .addrsig + .addrsig_sym GlobalLUEA + .addrsig_sym GlobalLUEB + .addrsig_sym GlobalLUEC + .addrsig_sym GlobalLSEA + .addrsig_sym GlobalLSEB + .addrsig_sym GlobalLSEC + .addrsig_sym GlobalUEA + .addrsig_sym GlobalUEB + .addrsig_sym GlobalUEC + .addrsig_sym GlobalSEA + .addrsig_sym GlobalSEB + .addrsig_sym GlobalSEC + .addrsig_sym GlobalSUEA + .addrsig_sym GlobalSUEB + .addrsig_sym GlobalSUEC + .addrsig_sym GlobalSSEA + .addrsig_sym GlobalSSEB + .addrsig_sym GlobalSSEC diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/source-list.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/source-list.lldbinit new file mode 100644 index 00000000000..624ce5ba156 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/source-list.lldbinit @@ -0,0 +1,3 @@ +source list -n main +source list -n OvlGlobalFn +quit diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/stack_unwinding01.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/stack_unwinding01.lldbinit new file mode 100644 index 00000000000..d035d3bb881 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/stack_unwinding01.lldbinit @@ -0,0 +1,8 @@ +b stack_unwinding01.cpp:12 +run +thread backtrace +c +thread backtrace +c +thread backtrace +quit
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/tag-types.lldbinit b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/tag-types.lldbinit new file mode 100644 index 00000000000..a7ec496447e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/tag-types.lldbinit @@ -0,0 +1,10 @@ +type lookup -- Struct +type lookup -- Class +type lookup -- Union +type lookup -- Derived +type lookup -- Derived2 +type lookup -- DerivedVirtual1 +type lookup -- DerivedVirtual2 +type lookup -- EnumInt +type lookup -- EnumShort +type lookup -- InvalidType diff --git a/lldb/test/Shell/SymbolFile/NativePDB/ast-functions-msvc.cpp b/lldb/test/Shell/SymbolFile/NativePDB/ast-functions-msvc.cpp new file mode 100644 index 00000000000..b8154168aff --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/ast-functions-msvc.cpp @@ -0,0 +1,7 @@ +// clang-format off +// REQUIRES: msvc + +// RUN: %build --compiler=msvc --nodefaultlib -o %t.exe -- %S/ast-functions.cpp + +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck %S/ast-functions.cpp diff --git a/lldb/test/Shell/SymbolFile/NativePDB/ast-functions.cpp b/lldb/test/Shell/SymbolFile/NativePDB/ast-functions.cpp new file mode 100644 index 00000000000..1cfd01f13c1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/ast-functions.cpp @@ -0,0 +1,28 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s + +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck %s + +static int static_fn() { + return 42; +} + +int varargs_fn(int x, int y, ...) { + return x + y; +} + +int main(int argc, char **argv) { + return static_fn() + varargs_fn(argc, argc); +} + +// CHECK: TranslationUnitDecl +// CHECK-NEXT: |-FunctionDecl {{.*}} main 'int (int, char **)' +// CHECK-NEXT: | |-ParmVarDecl {{.*}} argc 'int' +// CHECK-NEXT: | `-ParmVarDecl {{.*}} argv 'char **' +// CHECK-NEXT: |-FunctionDecl {{.*}} static_fn 'int ()' static +// CHECK-NEXT: `-FunctionDecl {{.*}} varargs_fn 'int (int, int, ...)' +// CHECK-NEXT: |-ParmVarDecl {{.*}} x 'int' +// CHECK-NEXT: `-ParmVarDecl {{.*}} y 'int' diff --git a/lldb/test/Shell/SymbolFile/NativePDB/ast-methods.cpp b/lldb/test/Shell/SymbolFile/NativePDB/ast-methods.cpp new file mode 100644 index 00000000000..6006c722cfb --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/ast-methods.cpp @@ -0,0 +1,36 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-methods.lldbinit 2>&1 | FileCheck %s + +struct Struct { + void simple_method() {} + + virtual void virtual_method() {} + + static void static_method() {} + + int overloaded_method() {} + int overloaded_method(char c) {} + int overloaded_method(char c, int i, ...) {} +}; + +Struct s; + +int main(int argc, char **argv) { + return 0; +} + +// CHECK: TranslationUnitDecl +// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition +// CHECK: | |-CXXMethodDecl {{.*}} simple_method 'void (){{.*}}' +// CHECK: | |-CXXMethodDecl {{.*}} virtual_method 'void (){{.*}}' virtual +// CHECK: | |-CXXMethodDecl {{.*}} static_method 'void ()' static +// CHECK: | |-CXXMethodDecl {{.*}} overloaded_method 'int (){{.*}}' +// CHECK: | |-CXXMethodDecl {{.*}} overloaded_method 'int (char){{.*}}' +// CHECK: | | `-ParmVarDecl {{.*}} 'char' +// CHECK: | `-CXXMethodDecl {{.*}} overloaded_method 'int (char, int, ...)' +// CHECK: | |-ParmVarDecl {{.*}} 'char' +// CHECK: | `-ParmVarDecl {{.*}} 'int' diff --git a/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp b/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp new file mode 100644 index 00000000000..9d4ac139f59 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp @@ -0,0 +1,153 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-types.lldbinit 2>&1 | FileCheck %s + +// Test trivial versions of each tag type. +class TrivialC {}; +struct TrivialS {}; +union TrivialU {}; +enum TrivialE {TE_A}; + +// Test reconstruction of DeclContext hierarchies. +namespace A { + namespace B { + template<typename T> + struct C { + T ABCMember; + }; + + // Let's try a template specialization with a different implementation + template<> + struct C<void> { + void *ABCSpecializationMember; + }; + } + + // Let's make sure we can distinguish classes and namespaces. Also let's try + // a non-type template parameter. + template<int N> + struct C { + class D { + int ACDMember = 0; + C<N - 1> *CPtr = nullptr; + }; + }; + + struct D { + // Let's make a nested class with the same name as another nested class + // elsewhere, and confirm that they appear in the right DeclContexts in + // the AST. + struct E { + int ADDMember; + }; + }; +} + + +// Let's try an anonymous namespace. +namespace { + template<typename T> + struct Anonymous { + int AnonymousMember; + // And a nested class within an anonymous namespace + struct D { + int AnonymousDMember; + }; + }; +} + +TrivialC TC; +TrivialS TS; +TrivialU TU; +TrivialE TE; + +A::B::C<int> ABCInt; +A::B::C<float> ABCFloat; +A::B::C<void> ABCVoid; + +A::C<0> AC0; +A::C<-1> ACNeg1; + +// FIXME: The type `D` is located now at the level of the translation unit. +// FIXME: Should be located in the namespace `A`, in the struct `C<1>`. +A::C<1>::D AC1D; + +A::C<0>::D AC0D; +A::C<-1>::D ACNeg1D; +A::D AD; +A::D::E ADE; + +Anonymous<int> AnonInt; +Anonymous<A::B::C<void>> AnonABCVoid; +Anonymous<A::B::C<void>>::D AnonABCVoidD; + +// FIXME: Enum size isn't being correctly determined. +// FIXME: Can't read memory for variable values. + +// CHECK: (TrivialC) TC = {} +// CHECK: (TrivialS) TS = {} +// CHECK: (TrivialU) TU = {} +// CHECK: (TrivialE) TE = TE_A +// CHECK: (A::B::C<int>) ABCInt = (ABCMember = 0) +// CHECK: (A::B::C<float>) ABCFloat = (ABCMember = 0) +// CHECK: (A::B::C<void>) ABCVoid = (ABCSpecializationMember = 0x{{0+}}) +// CHECK: (A::C<0>) AC0 = {} +// CHECK: (A::C<-1>) ACNeg1 = {} +// CHECK: (A::C<1>::D) AC1D = (ACDMember = 0, CPtr = 0x{{0+}}) +// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x{{0+}}) +// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x{{0+}}) +// CHECK: (A::D) AD = {} +// CHECK: (A::D::E) ADE = (ADDMember = 0) +// CHECK: ((anonymous namespace)::Anonymous<int>) AnonInt = (AnonymousMember = 0) +// CHECK: ((anonymous namespace)::Anonymous<A::B::C<void>>) AnonABCVoid = (AnonymousMember = 0) +// CHECK: ((anonymous namespace)::Anonymous<A::B::C<void>>::D) AnonABCVoidD = (AnonymousDMember = 0) +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition +// CHECK: |-CXXRecordDecl {{.*}} struct TrivialS definition +// CHECK: |-CXXRecordDecl {{.*}} union TrivialU definition +// CHECK: |-EnumDecl {{.*}} TrivialE +// CHECK: | `-EnumConstantDecl {{.*}} TE_A 'TrivialE' +// CHECK: |-NamespaceDecl {{.*}} A +// CHECK: | |-NamespaceDecl {{.*}} B +// CHECK: | | |-CXXRecordDecl {{.*}} struct C<int> definition +// CHECK: | | | `-FieldDecl {{.*}} ABCMember 'int' +// CHECK: | | |-CXXRecordDecl {{.*}} struct C<float> definition +// CHECK: | | | `-FieldDecl {{.*}} ABCMember 'float' +// CHECK: | | `-CXXRecordDecl {{.*}} struct C<void> definition +// CHECK: | | `-FieldDecl {{.*}} ABCSpecializationMember 'void *' +// FIXME: | |-CXXRecordDecl {{.*}} struct C<1> definition +// FIXME: | | `-CXXRecordDecl {{.*}} class D definition +// FIXME: | | |-FieldDecl {{.*}} ACDMember 'int' +// FIXME: | | `-FieldDecl {{.*}} CPtr 'A::C<1> *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<0> definition +// CHECK: | | `-CXXRecordDecl {{.*}} class D definition +// CHECK: | | |-FieldDecl {{.*}} ACDMember 'int' +// CHECK: | | `-FieldDecl {{.*}} CPtr 'A::C<-1> *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<-1> definition +// CHECK: | | `-CXXRecordDecl {{.*}} class D definition +// CHECK: | | |-FieldDecl {{.*}} ACDMember 'int' +// CHECK: | | `-FieldDecl {{.*}} CPtr 'A::C<-2> *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<-2> +// CHECK: | `-CXXRecordDecl {{.*}} struct D definition +// CHECK: | `-CXXRecordDecl {{.*}} struct E definition +// CHECK: | `-FieldDecl {{.*}} ADDMember 'int' +// CHECK: |-NamespaceDecl +// CHECK: | |-CXXRecordDecl {{.*}} struct Anonymous<int> definition +// CHECK: | | `-FieldDecl {{.*}} AnonymousMember 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct Anonymous<A::B::C<void>> definition +// CHECK: | |-FieldDecl {{.*}} AnonymousMember 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct D definition +// CHECK: | `-FieldDecl {{.*}} AnonymousDMember 'int' + +int main(int argc, char **argv) { + AnonInt.AnonymousMember = 1; + AnonABCVoid.AnonymousMember = 2; + AnonABCVoidD.AnonymousDMember = 3; + + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp b/lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp new file mode 100644 index 00000000000..301ae3067d1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp @@ -0,0 +1,60 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s + +// Test trivial versions of each tag type. +struct Struct { + int A : 5 = 6; + int B : 7 = 8; + unsigned C : 3 = 2; + unsigned D : 15 = 12345; + char E : 1 = 0; + char F : 2 = 1; + char G : 3 = 2; + // H should be at offset 0 of a new byte. + char H : 3 = 3; +}; + +constexpr Struct TheStruct; + + +int main(int argc, char **argv) { + return TheStruct.A; +} + +// CHECK: (lldb) target variable -T TheStruct +// CHECK: (const Struct) TheStruct = { +// CHECK: (int:5) A = 6 +// CHECK: (int:7) B = 8 +// CHECK: (unsigned int:3) C = 2 +// CHECK: (unsigned int:15) D = 12345 +// CHECK: (char:1) E = '\0' +// CHECK: (char:2) F = '\x01' +// CHECK: (char:3) G = '\x02' +// CHECK: (char:3) H = '\x03' +// CHECK: } +// +// CHECK: target modules dump ast +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition +// CHECK: | |-FieldDecl {{.*}} A 'int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5 +// CHECK: | |-FieldDecl {{.*}} B 'int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7 +// CHECK: | |-FieldDecl {{.*}} C 'unsigned int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3 +// CHECK: | |-FieldDecl {{.*}} D 'unsigned int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15 +// CHECK: | |-FieldDecl {{.*}} E 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1 +// CHECK: | |-FieldDecl {{.*}} F 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2 +// CHECK: | |-FieldDecl {{.*}} G 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3 +// CHECK: | `-FieldDecl {{.*}} H 'char' +// CHECK: | `-IntegerLiteral {{.*}} 'int' 3 diff --git a/lldb/test/Shell/SymbolFile/NativePDB/break-by-function.cpp b/lldb/test/Shell/SymbolFile/NativePDB/break-by-function.cpp new file mode 100644 index 00000000000..c0c26f7617c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/break-by-function.cpp @@ -0,0 +1,57 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set simple breakpoints using PDB on any platform. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/break-by-function.lldbinit | FileCheck %s + +// Use different indentation style for each overload so that the starting +// line is in a different place. + +int OvlGlobalFn(int X) { + return X + 42; +} + +int OvlGlobalFn(int X, int Y) { return X + Y + 42; } + +int OvlGlobalFn(int X, int Y, int Z) +{ + return X + Y + Z + 42; +} + +static int StaticFn(int X) { + return X + 42; +} + +int main(int argc, char **argv) { + // Make sure they don't get optimized out. + // Note the comments here, we want to make sure the line number reported + // for the breakpoint is the first actual line of code. + int Result = OvlGlobalFn(argc) + OvlGlobalFn(argc, argc) + + OvlGlobalFn(argc, argc, argc) + StaticFn(argc); + return Result; +} + + +// CHECK: (lldb) target create "{{.*}}break-by-function.cpp.tmp.exe" +// CHECK: Current executable set to '{{.*}}break-by-function.cpp.tmp.exe' +// CHECK: (lldb) break set -n main +// CHECK: Breakpoint 1: where = break-by-function.cpp.tmp.exe`main + {{[0-9]+}} +// CHECK: (lldb) break set -n OvlGlobalFn +// CHECK: Breakpoint 2: 3 locations. +// CHECK: (lldb) break set -n StaticFn +// CHECK: Breakpoint 3: where = break-by-function.cpp.tmp.exe`StaticFn + {{[0-9]+}} +// CHECK: (lldb) break set -n DoesntExist +// CHECK: Breakpoint 4: no locations (pending). +// CHECK: (lldb) break list +// CHECK: Current breakpoints: +// CHECK: 1: name = 'main', locations = 1 +// CHECK: 1.1: where = break-by-function.cpp.tmp.exe`main + {{[0-9]+}} +// CHECK: 2: name = 'OvlGlobalFn', locations = 3 +// CHECK: 2.1: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}} +// CHECK: 2.2: where = break-by-function.cpp.tmp.exe`OvlGlobalFn +// CHECK: 2.3: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}} +// CHECK: 3: name = 'StaticFn', locations = 1 +// CHECK: 3.1: where = break-by-function.cpp.tmp.exe`StaticFn + {{[0-9]+}} +// CHECK: 4: name = 'DoesntExist', locations = 0 (pending) diff --git a/lldb/test/Shell/SymbolFile/NativePDB/break-by-line.cpp b/lldb/test/Shell/SymbolFile/NativePDB/break-by-line.cpp new file mode 100644 index 00000000000..ae3269f3719 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/break-by-line.cpp @@ -0,0 +1,26 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set simple breakpoints using PDB on any platform. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/break-by-line.lldbinit | FileCheck %s + +// This is a separate test from break-by-function.cpp because this test is +// sensitive to edits in the source file. + +namespace NS { + int NamespaceFn(int X) { + return X + 42; + } +} + +int main(int argc, char **argv) { + return NS::NamespaceFn(argc); +} + + +// CHECK: (lldb) target create "{{.*}}break-by-line.cpp.tmp.exe" +// CHECK: Current executable set to '{{.*}}break-by-line.cpp.tmp.exe' +// CHECK: (lldb) break set -f break-by-line.cpp -l 14 +// CHECK: Breakpoint 1: where = break-by-line.cpp.tmp.exe`NS::NamespaceFn + {{[0-9]+}} at break-by-line.cpp:14 diff --git a/lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp b/lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp new file mode 100644 index 00000000000..3553f29ce55 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp @@ -0,0 +1,38 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can show disassembly and source. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s + +// Some context lines before +// the function. + +int foo() { return 42; } + +int main(int argc, char **argv) { + foo(); + return 0; +} + + +// CHECK: (lldb) disassemble --flavor=intel -m -n main +// CHECK: 12 int foo() { return 42; } +// CHECK-NEXT: 13 +// CHECK-NEXT: ** 14 int main(int argc, char **argv) { +// CHECK: disassembly.cpp.tmp.exe`main: +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+0>: sub rsp, 0x38 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+4>: mov dword ptr [rsp + 0x34], 0x0 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+12>: mov qword ptr [rsp + 0x28], rdx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+17>: mov dword ptr [rsp + 0x24], ecx +// CHECK: ** 15 foo(); +// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+21>: call {{.*}} ; foo at disassembly.cpp:12 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+26>: xor ecx, ecx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+28>: mov dword ptr [rsp + 0x20], eax +// CHECK: ** 16 return 0; +// CHECK-NEXT: 17 } +// CHECK-NEXT: 18 +// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+32>: mov eax, ecx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+34>: add rsp, 0x38 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+38>: ret diff --git a/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp b/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp new file mode 100644 index 00000000000..05ad6841993 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/function-types-builtins.cpp @@ -0,0 +1,218 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/function-types-builtins.lldbinit | FileCheck %s + +// Test that we can display function signatures with simple builtin +// and pointer types. We do this by using `target variable` in lldb +// with global variables of type ptr-to-function or reference-to-function. +// This technique in general allows us to exercise most of LLDB's type +// system without a running process. + +// Define _fltused, since we're not linking against the MS C runtime, but use +// floats. +extern "C" int _fltused = 0; + +template<typename T> +struct MakeResult { + static T result() { + return T{}; + } +}; + +template<typename T> +struct MakeResult<T&> { + static T& result() { + static T t; + return t; + } +}; + +template<typename T> +struct MakeResult<T&&> { + static T&& result() { + static T t; + return static_cast<T&&>(t); + } +}; + + +void nullary() {} + +template<typename Arg> +void unary(Arg) { } + +template<typename Ret, int N> +Ret unaryret() { return MakeResult<Ret>::result(); } + +template<typename A1, typename A2> +void binary(A1, A2) { } + +int varargs(int, int, ...) { return 0; } + +// Make sure to test every builtin type at least once for completeness. We +// test these in the globals-fundamentals.cpp when they are the types of +// variables but it's possible to imagine a situation where things behave +// differently as function arguments or return values than they do with +// global variables. + +// some interesting cases with argument types. +auto aa = &unary<bool>; +// CHECK: (void (*)(bool)) aa = {{.*}} +auto ab = &unary<char>; +// CHECK: (void (*)(char)) ab = {{.*}} +auto ac = &unary<signed char>; +// CHECK: (void (*)(signed char)) ac = {{.*}} +auto ad = &unary<unsigned char>; +// CHECK: (void (*)(unsigned char)) ad = {{.*}} +auto ae = &unary<char16_t>; +// CHECK: (void (*)(char16_t)) ae = {{.*}} +auto af = &unary<char32_t>; +// CHECK: (void (*)(char32_t)) af = {{.*}} +auto ag = &unary<wchar_t>; +// CHECK: (void (*)(wchar_t)) ag = {{.*}} +auto ah = &unary<short>; +// CHECK: (void (*)(short)) ah = {{.*}} +auto ai = &unary<unsigned short>; +// CHECK: (void (*)(unsigned short)) ai = {{.*}} +auto aj = &unary<int>; +// CHECK: (void (*)(int)) aj = {{.*}} +auto ak = &unary<unsigned int>; +// CHECK: (void (*)(unsigned int)) ak = {{.*}} +auto al = &unary<long>; +// CHECK: (void (*)(long)) al = {{.*}} +auto am = &unary<unsigned long>; +// CHECK: (void (*)(unsigned long)) am = {{.*}} +auto an = &unary<long long>; +// CHECK: (void (*)(long long)) an = {{.*}} +auto ao = &unary<unsigned long long>; +// CHECK: (void (*)(unsigned long long)) ao = {{.*}} +auto aq = &unary<float>; +// CHECK: (void (*)(float)) aq = {{.*}} +auto ar = &unary<double>; +// CHECK: (void (*)(double)) ar = {{.*}} + +auto as = &unary<int*>; +// CHECK: (void (*)(int *)) as = {{.*}} +auto at = &unary<int**>; +// CHECK: (void (*)(int **)) at = {{.*}} +auto au = &unary<int&>; +// CHECK: (void (*)(int &)) au = {{.*}} +auto av = &unary<int&&>; +// CHECK: (void (*)(int &&)) av = {{.*}} +auto aw = &unary<const int*>; +// CHECK: (void (*)(const int *)) aw = {{.*}} +auto ax = &unary<volatile int*>; +// CHECK: (void (*)(volatile int *)) ax = {{.*}} +auto ay = &unary<const volatile int*>; +// CHECK: (void (*)(const volatile int *)) ay = {{.*}} +auto az = &unary<void*&>; +// CHECK: (void (*)(void *&)) az = {{.*}} +auto aaa = &unary<int(&)[5]>; +// CHECK: (void (*)(int (&)[5])) aaa = {{.*}} +auto aab = &unary<int(*)[5]>; +// CHECK: (void (*)(int (*)[5])) aab = {{.*}} +auto aac = &unary<int(&&)[5]>; +// CHECK: (void (*)(int (&&)[5])) aac = {{.*}} +auto aad = &unary<int(*const)[5]>; +// CHECK: (void (*)(int (*)[5])) aad = {{.*}} + + +// same test cases with return values, note we can't overload on return type +// so we need to use a different instantiation each time. +auto ra = &unaryret<bool, 0>; +// CHECK: (bool (*)()) ra = {{.*}} +auto rb = &unaryret<char, 1>; +// CHECK: (char (*)()) rb = {{.*}} +auto rc = &unaryret<signed char, 2>; +// CHECK: (signed char (*)()) rc = {{.*}} +auto rd = &unaryret<unsigned char, 3>; +// CHECK: (unsigned char (*)()) rd = {{.*}} +auto re = &unaryret<char16_t, 4>; +// CHECK: (char16_t (*)()) re = {{.*}} +auto rf = &unaryret<char32_t, 5>; +// CHECK: (char32_t (*)()) rf = {{.*}} +auto rg = &unaryret<wchar_t, 6>; +// CHECK: (wchar_t (*)()) rg = {{.*}} +auto rh = &unaryret<short, 7>; +// CHECK: (short (*)()) rh = {{.*}} +auto ri = &unaryret<unsigned short, 8>; +// CHECK: (unsigned short (*)()) ri = {{.*}} +auto rj = &unaryret<int, 9>; +// CHECK: (int (*)()) rj = {{.*}} +auto rk = &unaryret<unsigned int, 10>; +// CHECK: (unsigned int (*)()) rk = {{.*}} +auto rl = &unaryret<long, 11>; +// CHECK: (long (*)()) rl = {{.*}} +auto rm = &unaryret<unsigned long, 12>; +// CHECK: (unsigned long (*)()) rm = {{.*}} +auto rn = &unaryret<long long, 13>; +// CHECK: (long long (*)()) rn = {{.*}} +auto ro = &unaryret<unsigned long long, 14>; +// CHECK: (unsigned long long (*)()) ro = {{.*}} +auto rq = &unaryret<float, 15>; +// CHECK: (float (*)()) rq = {{.*}} +auto rr = &unaryret<double, 16>; +// CHECK: (double (*)()) rr = {{.*}} + +auto rs = &unaryret<int*, 17>; +// CHECK: (int *(*)()) rs = {{.*}} +auto rt = &unaryret<int**, 18>; +// CHECK: (int **(*)()) rt = {{.*}} +auto ru = &unaryret<int&, 19>; +// CHECK: (int &(*)()) ru = {{.*}} +auto rv = &unaryret<int&&, 20>; +// CHECK: (int &&(*)()) rv = {{.*}} +auto rw = &unaryret<const int*, 21>; +// CHECK: (const int *(*)()) rw = {{.*}} +auto rx = &unaryret<volatile int*, 22>; +// CHECK: (volatile int *(*)()) rx = {{.*}} +auto ry = &unaryret<const volatile int*, 23>; +// CHECK: (const volatile int *(*)()) ry = {{.*}} +auto rz = &unaryret<void*&, 24>; +// CHECK: (void *&(*)()) rz = {{.*}} + +// FIXME: This output doesn't really look correct. It should probably be +// formatting this as `int(&)[5] (*)()`. +auto raa = &unaryret<int(&)[5], 25>; +// CHECK: (int (&(*)())[5]) raa = {{.*}} +auto rab = &unaryret<int(*)[5], 26>; +// CHECK: (int (*(*)())[5]) rab = {{.*}} +auto rac = &unaryret<int(&&)[5], 27>; +// CHECK: (int (&&(*)())[5]) rac = {{.*}} +auto rad = &unaryret<int(*const)[5], 28>; +// CHECK: (int (*const (*)())[5]) rad = {{.*}} + + + +// Function references, we only need a couple of these since most of the +// interesting cases are already tested. +auto &ref = unary<bool>; +// CHECK: (void (&)(bool)) ref = {{.*}} (&::ref = <no summary available>) +auto &ref2 = unary<volatile int*>; +// CHECK: (void (&)(volatile int *)) ref2 = {{.*}} (&::ref2 = <no summary available>) +auto &ref3 = varargs; +// CHECK: (int (&)(int, int, ...)) ref3 = {{.*}} (&::ref3 = <no summary available>) + +// Multiple arguments, as before, just something to make sure it works. +auto binp = &binary<int*, const int*>; +// CHECK: (void (*)(int *, const int *)) binp = {{.*}} +auto &binr = binary<int*, const int*>; +// CHECK: (void (&)(int *, const int *)) binr = {{.*}} (&::binr = <no summary available>) + +// And finally, a function with no arguments. +auto null = &nullary; +// CHECK: (void (*)()) null = {{.*}} + +// FIXME: These currently don't work because clang-cl emits incorrect debug info +// for std::nullptr_t. We should fix these in clang-cl. +auto rae = &unaryret<decltype(nullptr), 29>; +// CHECK: (nullptr_t (*)()) rae = {{.*}} +auto aae = &unary<decltype(nullptr)>; +// CHECK: (void (*)(nullptr_t)) aae = {{.*}} + +int main(int argc, char **argv) { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp b/lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp new file mode 100644 index 00000000000..cd13159d508 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp @@ -0,0 +1,32 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s + + +void __stdcall StdcallFn() {} +void __fastcall FastcallFn() {} +void __thiscall ThiscallFn() {} +void __cdecl CdeclFn() {} +void __vectorcall VectorcallFn() {} + +auto sfn = &StdcallFn; +// CHECK: (void (*)() __attribute__((stdcall))) sfn = {{.*}} + +auto ffn = &FastcallFn; +// CHECK: (void (*)() __attribute__((fastcall))) ffn = {{.*}} + +auto tfn = &ThiscallFn; +// CHECK: (void (*)() __attribute__((thiscall))) tfn = {{.*}} + +auto cfn = &CdeclFn; +// CHECK: (void (*)()) cfn = {{.*}} + +auto vfn = &VectorcallFn; +// CHECK: (void (*)() __attribute__((vectorcall))) vfn = {{.*}} + +int main(int argc, char **argv) { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp b/lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp new file mode 100644 index 00000000000..4a8caa7f837 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp @@ -0,0 +1,141 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display function signatures with class types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/function-types-classes.lldbinit | FileCheck %s + +// This is just some unimportant helpers needed so that we can get reference and +// rvalue-reference types into return values. +template<typename T> +struct MakeResult { + static T result() { + return T{}; + } +}; + +template<typename T> +struct MakeResult<T&> { + static T& result() { + static T t; + return t; + } +}; + +template<typename T> +struct MakeResult<T&&> { + static T&& result() { + static T t; + return static_cast<T&&>(t); + } +}; + + +template<typename R> +R nullary() { return MakeResult<R>::result(); } + +template<typename R, typename A, typename B> +R three(A a, B b) { return MakeResult<R>::result(); } + +template<typename R, typename A, typename B, typename C> +R four(A a, B b, C c) { return MakeResult<R>::result(); } + +struct S {}; +class C {}; +union U {}; +enum E {}; + +namespace A { + namespace B { + // NS::NS + struct S { }; + } + + struct C { + // NS::Struct + struct S {}; + }; +} + +struct B { + struct A { + // Struct::Struct + struct S {}; + }; +}; + +// clang (incorrectly) doesn't emit debug information for outer classes +// unless they are instantiated. They should also be emitted if there +// is an inner class which is instantiated. +A::C ForceInstantiateAC; +B ForceInstantiateB; +B::A ForceInstantiateBA; + +template<typename T> +struct TC {}; + +// const and volatile modifiers +auto a = &four<S, C*, U&, E&&>; +// CHECK: (S (*)(C *, U &, E &&)) a = {{.*}} +auto b = &four<E, const S*, const C&, const U&&>; +// CHECK: (E (*)(const S *, const C &, const U &&)) b = {{.*}} +auto c = &four<U, volatile E*, volatile S&, volatile C&&>; +// CHECK: (U (*)(volatile E *, volatile S &, volatile C &&)) c = {{.*}} +auto d = &four<C, const volatile U*, const volatile E&, const volatile S&&>; +// CHECK: (C (*)(const volatile U *, const volatile E &, const volatile S &&)) d = {{.*}} + +// classes nested in namespaces and inner classes + +auto e = &three<A::B::S*, B::A::S*, A::C::S&>; +// CHECK: (A::B::S *(*)(B::A::S *, A::C::S &)) e = {{.*}} +auto f = &three<A::C::S&, A::B::S*, B::A::S*>; +// CHECK: (A::C::S &(*)(A::B::S *, B::A::S *)) f = {{.*}} +auto g = &three<B::A::S*, A::C::S&, A::B::S*>; +// CHECK: (B::A::S *(*)(A::C::S &, A::B::S *)) g = {{.*}} + +// parameter types that are themselves template instantiations. +auto h = &four<TC<void>, TC<int>, TC<TC<int>>, TC<A::B::S>>; +// CHECK: (TC<void> (*)(TC<int>, TC<TC<int>>, TC<A::B::S>)) h = {{.*}} + +auto i = &nullary<A::B::S>; +// CHECK: (A::B::S (*)()) i = {{.*}} + + +// Make sure we can handle types that don't have complete debug info. +struct Incomplete; +auto incomplete = &three<Incomplete*, Incomplete**, const Incomplete*>; +// CHECK: (Incomplete *(*)(Incomplete **, const Incomplete *)) incomplete = {{.*}} + +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class C +// CHECK: |-CXXRecordDecl {{.*}} union U +// CHECK: |-EnumDecl {{.*}} E +// CHECK: |-CXXRecordDecl {{.*}} struct S +// CHECK: |-VarDecl {{.*}} a 'S (*)(C *, U &, E &&)'
+// CHECK: |-VarDecl {{.*}} b 'E (*)(const S *, const C &, const U &&)'
+// CHECK: |-VarDecl {{.*}} c 'U (*)(volatile E *, volatile S &, volatile C &&)'
+// CHECK: |-VarDecl {{.*}} d 'C (*)(const volatile U *, const volatile E &, const volatile S &&)' +// CHECK: |-CXXRecordDecl {{.*}} struct B +// CHECK: | `-CXXRecordDecl {{.*}} struct A +// CHECK: | `-CXXRecordDecl {{.*}} struct S +// CHECK: |-NamespaceDecl {{.*}} A +// CHECK: | |-CXXRecordDecl {{.*}} struct C +// CHECK: | | `-CXXRecordDecl {{.*}} struct S +// CHECK: | `-NamespaceDecl {{.*}} B +// CHECK: | `-CXXRecordDecl {{.*}} struct S +// CHECK: |-VarDecl {{.*}} e 'A::B::S *(*)(B::A::S *, A::C::S &)'
+// CHECK: |-VarDecl {{.*}} f 'A::C::S &(*)(A::B::S *, B::A::S *)'
+// CHECK: |-VarDecl {{.*}} g 'B::A::S *(*)(A::C::S &, A::B::S *)' +// CHECK: |-CXXRecordDecl {{.*}} struct TC<int> +// CHECK: |-CXXRecordDecl {{.*}} struct TC<TC<int>> +// CHECK: |-CXXRecordDecl {{.*}} struct TC<A::B::S> +// CHECK: |-CXXRecordDecl {{.*}} struct TC<void> +// CHECK: |-VarDecl {{.*}} h 'TC<void> (*)(TC<int>, TC<TC<int>>, TC<A::B::S>)'
+// CHECK: |-VarDecl {{.*}} i 'A::B::S (*)()' +// CHECK: |-CXXRecordDecl {{.*}} struct Incomplete +// CHECK: `-VarDecl {{.*}} incomplete 'Incomplete *(*)(Incomplete **, const Incomplete *)' + +int main(int argc, char **argv) { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/global-classes.cpp b/lldb/test/Shell/SymbolFile/NativePDB/global-classes.cpp new file mode 100644 index 00000000000..e45fbfa4eef --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/global-classes.cpp @@ -0,0 +1,385 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-classes.lldbinit | FileCheck %s + +enum class EnumType : unsigned { + A = 1, + B = 2 +}; + +class ClassNoPadding { + /* [ 0] */ unsigned char a = 86; + /* [ 1] */ char b = 'a'; + /* [ 2] */ bool c = false; + /* [ 3] */ bool d = true; + /* [ 4] */ short e = -1234; + /* [ 6] */ unsigned short f = 8123; + /* [ 8] */ unsigned int g = 123908; + /* [12] */ int h = -890234; + /* [16] */ unsigned long i = 2908234; + /* [20] */ long j = 7234890; + /* [24] */ float k = 908234.12392; + /* [28] */ EnumType l = EnumType::A; + /* [32] */ double m = 23890.897423; + /* [40] */ unsigned long long n = 23490782; + /* [48] */ long long o = -923409823; + /* [56] */ int p[5] = { 2, 3, 5, 8, 13 }; +}; + +class ClassWithPadding { + /* [ 0] */ char a = '0'; + // char padding[1]; + /* [ 2] */ short b = 50; + /* [ 4] */ char c[2] = { '0', '1' }; + // char padding[2]; + /* [ 8] */ int d = 100; + /* [12] */ char e = '0'; + // char padding[3]; + /* [16] */ int f = 200; + // char padding[4]; + /* [24] */ long long g = 300; + /* [32] */ char h[3] = { '0', '1', '2' }; + // char padding[5]; + /* [40] */ long long i = 400; + /* [48] */ char j[2] = { '0', '1' }; + // char padding[6]; + /* [56] */ long long k = 500; + /* [64] */ char l = '0'; + // char padding[7]; + /* [72] */ long long m = 600; +} ; + +struct EmptyBase {}; + +template<typename T> +struct BaseClass { + constexpr BaseClass(int N) + : BaseMember(N) {} + + int BaseMember; +}; + +struct DerivedClass : public BaseClass<int> { + constexpr DerivedClass(int Base, int Derived) + : BaseClass(Base), DerivedMember(Derived) {} + + int DerivedMember; +}; + +struct EBO : public EmptyBase { + constexpr EBO(int N) : Member(N) {} + int Member; +}; + +struct PaddedBases : public BaseClass<char>, public BaseClass<short>, BaseClass<int> { + constexpr PaddedBases(char CH, short S, int N, long long D) + : BaseClass<char>(CH), BaseClass<short>(S), BaseClass<int>(N), DerivedMember(D) {} + long long DerivedMember; +}; + +struct Statics { + static char a; + static bool b; + static short c; + static unsigned short d; + static unsigned int e; + static int f; + static unsigned long g; + static long h; + static float i; + static EnumType j; + static double k; + static unsigned long long l; + static long long m; +}; + +char Statics::a = 'a'; +bool Statics::b = true; +short Statics::c = 1234; +unsigned short Statics::d = 2345; +unsigned int Statics::e = 3456; +int Statics::f = 4567; +unsigned long Statics::g = 5678; +long Statics::h = 6789; +float Statics::i = 7890.1234; +EnumType Statics::j = EnumType::A; +double Statics::k = 8901.2345; +unsigned long long Statics::l = 9012345; +long long Statics::m = 1234567; + + +struct Pointers { + void *a = nullptr; + char *b = &Statics::a; + bool *c = &Statics::b; + short *e = &Statics::c; + unsigned short *f = &Statics::d; + unsigned int *g = &Statics::e; + int *h = &Statics::f; + unsigned long *i = &Statics::g; + long *j = &Statics::h; + float *k = &Statics::i; + EnumType *l = &Statics::j; + double *m = &Statics::k; + unsigned long long *n = &Statics::l; + long long *o = &Statics::m; +}; + +struct References { + char &a = Statics::a; + bool &b = Statics::b; + short &c = Statics::c; + unsigned short &d = Statics::d; + unsigned int &e = Statics::e; + int &f = Statics::f; + unsigned long &g = Statics::g; + long &h = Statics::h; + float &i = Statics::i; + EnumType &j = Statics::j; + double &k = Statics::k; + unsigned long long &l = Statics::l; + long long &m = Statics::m; +}; + + +constexpr ClassWithPadding ClassWithPaddingInstance; +// CHECK: (lldb) target variable -T ClassWithPaddingInstance +// CHECK-NEXT: (const ClassWithPadding) ClassWithPaddingInstance = { +// CHECK-NEXT: (char) a = '0' +// CHECK-NEXT: (short) b = 50 +// CHECK-NEXT: (char [2]) c = "01" +// CHECK-NEXT: (int) d = 100 +// CHECK-NEXT: (char) e = '0' +// CHECK-NEXT: (int) f = 200 +// CHECK-NEXT: (long long) g = 300 +// CHECK-NEXT: (char [3]) h = "012" +// CHECK-NEXT: (long long) i = 400 +// CHECK-NEXT: (char [2]) j = "01" +// CHECK-NEXT: (long long) k = 500 +// CHECK-NEXT: (char) l = '0' +// CHECK-NEXT: (long long) m = 600 +// CHECK-NEXT: } + +constexpr ClassNoPadding ClassNoPaddingInstance; +// CHECK: (lldb) target variable -T ClassNoPaddingInstance +// CHECK-NEXT: (const ClassNoPadding) ClassNoPaddingInstance = { +// CHECK-NEXT: (unsigned char) a = 'V' +// CHECK-NEXT: (char) b = 'a' +// CHECK-NEXT: (bool) c = false +// CHECK-NEXT: (bool) d = true +// CHECK-NEXT: (short) e = -1234 +// CHECK-NEXT: (unsigned short) f = 8123 +// CHECK-NEXT: (unsigned int) g = 123908 +// CHECK-NEXT: (int) h = -890234 +// CHECK-NEXT: (unsigned long) i = 2908234 +// CHECK-NEXT: (long) j = 7234890 +// CHECK-NEXT: (float) k = 908234.125 +// CHECK-NEXT: (EnumType) l = A +// CHECK-NEXT: (double) m = 23890.897422999999 +// CHECK-NEXT: (unsigned long long) n = 23490782 +// CHECK-NEXT: (long long) o = -923409823 +// CHECK-NEXT: (int [5]) p = { +// CHECK-NEXT: (int) [0] = 2 +// CHECK-NEXT: (int) [1] = 3 +// CHECK-NEXT: (int) [2] = 5 +// CHECK-NEXT: (int) [3] = 8 +// CHECK-NEXT: (int) [4] = 13 +// CHECK-NEXT: } +// CHECK-NEXT: } + +constexpr DerivedClass DC(10, 20); +// CHECK: (lldb) target variable -T DC +// CHECK-NEXT: (const DerivedClass) DC = { +// CHECK-NEXT: (BaseClass<int>) BaseClass<int> = { +// CHECK-NEXT: (int) BaseMember = 10 +// CHECK-NEXT: } +// CHECK-NEXT: (int) DerivedMember = 20 +// CHECK-NEXT: } + +constexpr EBO EBOC(20); +// CHECK: (lldb) target variable -T EBOC +// CHECK-NEXT: (const EBO) EBOC = { +// CHECK-NEXT: (int) Member = 20 +// CHECK-NEXT: } + +constexpr PaddedBases PBC('a', 12, 120, 1200); +// CHECK: (lldb) target variable -T PBC +// CHECK-NEXT: (const PaddedBases) PBC = { +// CHECK-NEXT: (BaseClass<char>) BaseClass<char> = { +// CHECK-NEXT: (int) BaseMember = 97 +// CHECK-NEXT: } +// CHECK-NEXT: (BaseClass<short>) BaseClass<short> = { +// CHECK-NEXT: (int) BaseMember = 12 +// CHECK-NEXT: } +// CHECK-NEXT: (BaseClass<int>) BaseClass<int> = { +// CHECK-NEXT: (int) BaseMember = 120 +// CHECK-NEXT: } +// CHECK-NEXT: (long long) DerivedMember = 1200 +// CHECK-NEXT: } + +constexpr struct { + int x = 12; + EBO EBOC{ 42 }; +} UnnamedClassInstance; +// CHECK: (lldb) target variable -T UnnamedClassInstance +// CHECK-NEXT: (const <unnamed-type-UnnamedClassInstance>) UnnamedClassInstance = { +// CHECK-NEXT: (int) x = 12 +// CHECK-NEXT: (EBO) EBOC = { +// CHECK-NEXT: (int) Member = 42 +// CHECK-NEXT: } +// CHECK-NEXT: } + +constexpr Pointers PointersInstance; +// CHECK: (lldb) target variable -T PointersInstance +// CHECK-NEXT: (const Pointers) PointersInstance = { +// CHECK-NEXT: (void *) a = {{.*}} +// CHECK-NEXT: (char *) b = {{.*}} +// CHECK-NEXT: (bool *) c = {{.*}} +// CHECK-NEXT: (short *) e = {{.*}} +// CHECK-NEXT: (unsigned short *) f = {{.*}} +// CHECK-NEXT: (unsigned int *) g = {{.*}} +// CHECK-NEXT: (int *) h = {{.*}} +// CHECK-NEXT: (unsigned long *) i = {{.*}} +// CHECK-NEXT: (long *) j = {{.*}} +// CHECK-NEXT: (float *) k = {{.*}} +// CHECK-NEXT: (EnumType *) l = {{.*}} +// CHECK-NEXT: (double *) m = {{.*}} +// CHECK-NEXT: (unsigned long long *) n = {{.*}} +// CHECK-NEXT: (long long *) o = {{.*}} +// CHECK-NEXT: } +constexpr References ReferencesInstance; +// CHECK: (lldb) target variable -T ReferencesInstance +// CHECK-NEXT: (const References) ReferencesInstance = { +// CHECK-NEXT: (char &) a = {{.*}} +// CHECK-NEXT: (bool &) b = {{.*}} +// CHECK-NEXT: (short &) c = {{.*}} +// CHECK-NEXT: (unsigned short &) d = {{.*}} +// CHECK-NEXT: (unsigned int &) e = {{.*}} +// CHECK-NEXT: (int &) f = {{.*}} +// CHECK-NEXT: (unsigned long &) g = {{.*}} +// CHECK-NEXT: (long &) h = {{.*}} +// CHECK-NEXT: (float &) i = {{.*}} +// CHECK-NEXT: (EnumType &) j = {{.*}} +// CHECK-NEXT: (double &) k = {{.*}} +// CHECK-NEXT: (unsigned long long &) l = {{.*}} +// CHECK-NEXT: (long long &) m = {{.*}} +// CHECK-NEXT: } + +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class ClassWithPadding definition +// CHECK: | |-FieldDecl {{.*}} a 'char' +// CHECK: | |-FieldDecl {{.*}} b 'short' +// CHECK: | |-FieldDecl {{.*}} c 'char [2]' +// CHECK: | |-FieldDecl {{.*}} d 'int' +// CHECK: | |-FieldDecl {{.*}} e 'char' +// CHECK: | |-FieldDecl {{.*}} f 'int' +// CHECK: | |-FieldDecl {{.*}} g 'long long' +// CHECK: | |-FieldDecl {{.*}} h 'char [3]' +// CHECK: | |-FieldDecl {{.*}} i 'long long' +// CHECK: | |-FieldDecl {{.*}} j 'char [2]' +// CHECK: | |-FieldDecl {{.*}} k 'long long' +// CHECK: | |-FieldDecl {{.*}} l 'char' +// CHECK: | `-FieldDecl {{.*}} m 'long long' +// CHECK: |-VarDecl {{.*}} ClassWithPaddingInstance 'const ClassWithPadding' +// CHECK: |-CXXRecordDecl {{.*}} class ClassNoPadding definition +// CHECK: | |-FieldDecl {{.*}} a 'unsigned char' +// CHECK: | |-FieldDecl {{.*}} b 'char' +// CHECK: | |-FieldDecl {{.*}} c 'bool' +// CHECK: | |-FieldDecl {{.*}} d 'bool' +// CHECK: | |-FieldDecl {{.*}} e 'short' +// CHECK: | |-FieldDecl {{.*}} f 'unsigned short' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned int' +// CHECK: | |-FieldDecl {{.*}} h 'int' +// CHECK: | |-FieldDecl {{.*}} i 'unsigned long' +// CHECK: | |-FieldDecl {{.*}} j 'long' +// CHECK: | |-FieldDecl {{.*}} k 'float' +// CHECK: | |-FieldDecl {{.*}} l 'EnumType' +// CHECK: | |-FieldDecl {{.*}} m 'double' +// CHECK: | |-FieldDecl {{.*}} n 'unsigned long long' +// CHECK: | |-FieldDecl {{.*}} o 'long long' +// CHECK: | `-FieldDecl {{.*}} p 'int [5]' +// CHECK: |-VarDecl {{.*}} ClassNoPaddingInstance 'const ClassNoPadding' +// CHECK: |-EnumDecl {{.*}} EnumType +// CHECK: | |-EnumConstantDecl {{.*}} A 'EnumType' +// CHECK: | `-EnumConstantDecl {{.*}} B 'EnumType' +// CHECK: |-CXXRecordDecl {{.*}} struct DerivedClass definition +// CHECK: | |-public 'BaseClass<int>' +// CHECK: | |-FieldDecl {{.*}} DerivedMember 'int' +// CHECK: | `-CXXConstructorDecl {{.*}} DerivedClass 'void (int, int)' +// CHECK: | |-ParmVarDecl {{.*}} 'int' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-VarDecl {{.*}} DC 'const DerivedClass' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass<int> definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct EBO definition +// CHECK: | |-public 'EmptyBase' +// CHECK: | |-FieldDecl {{.*}} Member 'int' +// CHECK: | `-CXXConstructorDecl {{.*}} EBO 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-VarDecl {{.*}} EBOC 'const EBO' +// CHECK: |-CXXRecordDecl {{.*}} struct EmptyBase definition +// CHECK: |-CXXRecordDecl {{.*}} struct PaddedBases definition +// CHECK: | |-public 'BaseClass<char>' +// CHECK: | |-public 'BaseClass<short>' +// CHECK: | |-public 'BaseClass<int>' +// CHECK: | |-FieldDecl {{.*}} DerivedMember 'long long' +// CHECK: | `-CXXConstructorDecl {{.*}} PaddedBases 'void (char, short, int, long long)' +// CHECK: | |-ParmVarDecl {{.*}} 'char' +// CHECK: | |-ParmVarDecl {{.*}} 'short' +// CHECK: | |-ParmVarDecl {{.*}} 'int' +// CHECK: | `-ParmVarDecl {{.*}} 'long long' +// CHECK: |-VarDecl {{.*}} PBC 'const PaddedBases' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass<char> definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass<short> definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct <unnamed-type-UnnamedClassInstance> definition +// CHECK: | |-FieldDecl {{.*}} x 'int' +// CHECK: | `-FieldDecl {{.*}} EBOC 'EBO' +// CHECK: |-VarDecl {{.*}} UnnamedClassInstance 'const <unnamed-type-UnnamedClassInstance>' +// CHECK: |-CXXRecordDecl {{.*}} struct Pointers definition +// CHECK: | |-FieldDecl {{.*}} a 'void *' +// CHECK: | |-FieldDecl {{.*}} b 'char *' +// CHECK: | |-FieldDecl {{.*}} c 'bool *' +// CHECK: | |-FieldDecl {{.*}} e 'short *' +// CHECK: | |-FieldDecl {{.*}} f 'unsigned short *' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned int *' +// CHECK: | |-FieldDecl {{.*}} h 'int *' +// CHECK: | |-FieldDecl {{.*}} i 'unsigned long *' +// CHECK: | |-FieldDecl {{.*}} j 'long *' +// CHECK: | |-FieldDecl {{.*}} k 'float *' +// CHECK: | |-FieldDecl {{.*}} l 'EnumType *' +// CHECK: | |-FieldDecl {{.*}} m 'double *' +// CHECK: | |-FieldDecl {{.*}} n 'unsigned long long *' +// CHECK: | `-FieldDecl {{.*}} o 'long long *' +// CHECK: |-VarDecl {{.*}} PointersInstance 'const Pointers' +// CHECK: |-CXXRecordDecl {{.*}} struct References definition +// CHECK: | |-FieldDecl {{.*}} a 'char &' +// CHECK: | |-FieldDecl {{.*}} b 'bool &' +// CHECK: | |-FieldDecl {{.*}} c 'short &' +// CHECK: | |-FieldDecl {{.*}} d 'unsigned short &' +// CHECK: | |-FieldDecl {{.*}} e 'unsigned int &' +// CHECK: | |-FieldDecl {{.*}} f 'int &' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned long &' +// CHECK: | |-FieldDecl {{.*}} h 'long &' +// CHECK: | |-FieldDecl {{.*}} i 'float &' +// CHECK: | |-FieldDecl {{.*}} j 'EnumType &' +// CHECK: | |-FieldDecl {{.*}} k 'double &' +// CHECK: | |-FieldDecl {{.*}} l 'unsigned long long &' +// CHECK: | `-FieldDecl {{.*}} m 'long long &' +// CHECK: `-VarDecl {{.*}} ReferencesInstance 'const References' + +int main(int argc, char **argv) { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/globals-bss.cpp b/lldb/test/Shell/SymbolFile/NativePDB/globals-bss.cpp new file mode 100644 index 00000000000..c10c3c19628 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/globals-bss.cpp @@ -0,0 +1,34 @@ +// clang-format off +// REQUIRES: lld + +// Make sure we can read variables from BSS +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: llvm-readobj -s %t.exe | FileCheck --check-prefix=BSS %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-bss.lldbinit 2>&1 | FileCheck %s + +int GlobalVariable = 0; + +int main(int argc, char **argv) { + return 0; +} + +// BSS: Section { +// BSS: Number: 3 +// BSS: Name: .data +// BSS-NEXT: VirtualSize: 0x4 +// BSS-NEXT: VirtualAddress: +// BSS-NEXT: RawDataSize: 0 +// BSS-NEXT: PointerToRawData: 0x0 +// BSS-NEXT: PointerToRelocations: 0x0 +// BSS-NEXT: PointerToLineNumbers: 0x0 +// BSS-NEXT: RelocationCount: 0 +// BSS-NEXT: LineNumberCount: 0 +// BSS-NEXT: Characteristics [ (0xC0000040) +// BSS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40) +// BSS-NEXT: IMAGE_SCN_MEM_READ (0x40000000) +// BSS-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000) +// BSS-NEXT: ] +// BSS-NEXT: } + +// CHECK: (int) GlobalVariable = 0 diff --git a/lldb/test/Shell/SymbolFile/NativePDB/globals-fundamental.cpp b/lldb/test/Shell/SymbolFile/NativePDB/globals-fundamental.cpp new file mode 100644 index 00000000000..48dea6d51e4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/globals-fundamental.cpp @@ -0,0 +1,879 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-fundamental.lldbinit | FileCheck %s + + +// Fundamental data types +bool BFalse = false; +// CHECK: (lldb) target variable BFalse +// CHECK-NEXT: (bool) BFalse = false +bool BTrue = true; +// CHECK-NEXT: (lldb) target variable BTrue +// CHECK-NEXT: (bool) BTrue = true +char CA = 'A'; +// CHECK-NEXT: (lldb) target variable CA +// CHECK-NEXT: (char) CA = 'A' +char CZ = 'Z'; +// CHECK-NEXT: (lldb) target variable CZ +// CHECK-NEXT: (char) CZ = 'Z' +signed char SCa = 'a'; +// CHECK-NEXT: (lldb) target variable SCa +// CHECK-NEXT: (signed char) SCa = 'a' +signed char SCz = 'z'; +// CHECK-NEXT: (lldb) target variable SCz +// CHECK-NEXT: (signed char) SCz = 'z' +unsigned char UC24 = 24; +// CHECK-NEXT: (lldb) target variable UC24 +// CHECK-NEXT: (unsigned char) UC24 = '\x18' +unsigned char UC42 = 42; +// CHECK-NEXT: (lldb) target variable UC42 +// CHECK-NEXT: (unsigned char) UC42 = '*' +char16_t C16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable C16_24 +// CHECK-NEXT: (char16_t) C16_24 = U+0014 +char32_t C32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable C32_42 +// CHECK-NEXT: (char32_t) C32_42 = U+0x00000022 +wchar_t WC1 = L'1'; +// CHECK-NEXT: (lldb) target variable WC1 +// CHECK-NEXT: (wchar_t) WC1 = L'1' +wchar_t WCP = L'P'; +// CHECK-NEXT: (lldb) target variable WCP +// CHECK-NEXT: (wchar_t) WCP = L'P' +short SMax = 32767; +// CHECK-NEXT: (lldb) target variable SMax +// CHECK-NEXT: (short) SMax = 32767 +short SMin = -32768; +// CHECK-NEXT: (lldb) target variable SMin +// CHECK-NEXT: (short) SMin = -32768 +unsigned short USMax = 65535; +// CHECK-NEXT: (lldb) target variable USMax +// CHECK-NEXT: (unsigned short) USMax = 65535 +unsigned short USMin = 0; +// CHECK-NEXT: (lldb) target variable USMin +// CHECK-NEXT: (unsigned short) USMin = 0 +int IMax = 2147483647; +// CHECK-NEXT: (lldb) target variable IMax +// CHECK-NEXT: (int) IMax = 2147483647 +int IMin = -2147483648; +// CHECK-NEXT: (lldb) target variable IMin +// CHECK-NEXT: (int) IMin = -2147483648 +unsigned int UIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable UIMax +// CHECK-NEXT: (unsigned int) UIMax = 4294967295 +unsigned int UIMin = 0; +// CHECK-NEXT: (lldb) target variable UIMin +// CHECK-NEXT: (unsigned int) UIMin = 0 +long LMax = 2147483647; +// CHECK-NEXT: (lldb) target variable LMax +// CHECK-NEXT: (long) LMax = 2147483647 +long LMin = -2147483648; +// CHECK-NEXT: (lldb) target variable LMin +// CHECK-NEXT: (long) LMin = -2147483648 +unsigned long ULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ULMax +// CHECK-NEXT: (unsigned long) ULMax = 4294967295 +unsigned long ULMin = 0; +// CHECK-NEXT: (lldb) target variable ULMin +// CHECK-NEXT: (unsigned long) ULMin = 0 +long long LLMax = 9223372036854775807LL; +// CHECK-NEXT: (lldb) target variable LLMax +// CHECK-NEXT: (long long) LLMax = 9223372036854775807 +long long LLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable LLMin +// CHECK-NEXT: (long long) LLMin = -9223372036854775808 +unsigned long long ULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable ULLMax +// CHECK-NEXT: (unsigned long long) ULLMax = 18446744073709551615 +unsigned long long ULLMin = 0; +// CHECK-NEXT: (lldb) target variable ULLMin +// CHECK-NEXT: (unsigned long long) ULLMin = 0 +float F = 3.1415f; +// CHECK-NEXT: (lldb) target variable F +// CHECK-NEXT: (float) F = 3.1415 +double D = 3.1415; +// CHECK-NEXT: (lldb) target variable D +// CHECK-NEXT: (double) D = 3.1415 + +const bool CBFalse = false; +// CHECK-NEXT: (lldb) target variable CBFalse +// CHECK-NEXT: (const bool) CBFalse = false +const bool CBTrue = true; +// CHECK-NEXT: (lldb) target variable CBTrue +// CHECK-NEXT: (const bool) CBTrue = true +const char CCA = 'A'; +// CHECK-NEXT: (lldb) target variable CCA +// CHECK-NEXT: (const char) CCA = 'A' +const char CCZ = 'Z'; +// CHECK-NEXT: (lldb) target variable CCZ +// CHECK-NEXT: (const char) CCZ = 'Z' +const signed char CSCa = 'a'; +// CHECK-NEXT: (lldb) target variable CSCa +// CHECK-NEXT: (const signed char) CSCa = 'a' +const signed char CSCz = 'z'; +// CHECK-NEXT: (lldb) target variable CSCz +// CHECK-NEXT: (const signed char) CSCz = 'z' +const unsigned char CUC24 = 24; +// CHECK-NEXT: (lldb) target variable CUC24 +// CHECK-NEXT: (const unsigned char) CUC24 = '\x18' +const unsigned char CUC42 = 42; +// CHECK-NEXT: (lldb) target variable CUC42 +// CHECK-NEXT: (const unsigned char) CUC42 = '*' +const char16_t CC16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable CC16_24 +// CHECK-NEXT: (const char16_t) CC16_24 = U+0014 +const char32_t CC32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable CC32_42 +// CHECK-NEXT: (const char32_t) CC32_42 = U+0x00000022 +const wchar_t CWC1 = L'1'; +// CHECK-NEXT: (lldb) target variable CWC1 +// CHECK-NEXT: (const wchar_t) CWC1 = L'1' +const wchar_t CWCP = L'P'; +// CHECK-NEXT: (lldb) target variable CWCP +// CHECK-NEXT: (const wchar_t) CWCP = L'P' +const short CSMax = 32767; +// CHECK-NEXT: (lldb) target variable CSMax +// CHECK-NEXT: (const short) CSMax = 32767 +const short CSMin = -32768; +// CHECK-NEXT: (lldb) target variable CSMin +// CHECK-NEXT: (const short) CSMin = -32768 +const unsigned short CUSMax = 65535; +// CHECK-NEXT: (lldb) target variable CUSMax +// CHECK-NEXT: (const unsigned short) CUSMax = 65535 +const unsigned short CUSMin = 0; +// CHECK-NEXT: (lldb) target variable CUSMin +// CHECK-NEXT: (const unsigned short) CUSMin = 0 +const int CIMax = 2147483647; +// CHECK-NEXT: (lldb) target variable CIMax +// CHECK-NEXT: (const int) CIMax = 2147483647 +const int CIMin = -2147483648; +// CHECK-NEXT: (lldb) target variable CIMin +// CHECK-NEXT: (const int) CIMin = -2147483648 +const unsigned int CUIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable CUIMax +// CHECK-NEXT: (const unsigned int) CUIMax = 4294967295 +const unsigned int CUIMin = 0; +// CHECK-NEXT: (lldb) target variable CUIMin +// CHECK-NEXT: (const unsigned int) CUIMin = 0 +const long CLMax = 2147483647; +// CHECK-NEXT: (lldb) target variable CLMax +// CHECK-NEXT: (const long) CLMax = 2147483647 +const long CLMin = -2147483648; +// CHECK-NEXT: (lldb) target variable CLMin +// CHECK-NEXT: (const long) CLMin = -2147483648 +const unsigned long CULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable CULMax +// CHECK-NEXT: (const unsigned long) CULMax = 4294967295 +const unsigned long CULMin = 0; +// CHECK-NEXT: (lldb) target variable CULMin +// CHECK-NEXT: (const unsigned long) CULMin = 0 +const long long CLLMax = 9223372036854775807i64; +// CHECK-NEXT: (lldb) target variable CLLMax +// CHECK-NEXT: (const long long) CLLMax = 9223372036854775807 +const long long CLLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable CLLMin +// CHECK-NEXT: (const long long) CLLMin = -9223372036854775808 +const unsigned long long CULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable CULLMax +// CHECK-NEXT: (const unsigned long long) CULLMax = 18446744073709551615 +const unsigned long long CULLMin = 0; +// CHECK-NEXT: (lldb) target variable CULLMin +// CHECK-NEXT: (const unsigned long long) CULLMin = 0 +const float CF = 3.1415f; +// CHECK-NEXT: (lldb) target variable CF +// CHECK-NEXT: (const float) CF = 3.1415 +const double CD = 3.1415; +// CHECK-NEXT: (lldb) target variable CD +// CHECK-NEXT: (const double) CD = 3.1415 + +// constexpr fundamental data types. +constexpr bool ConstexprBFalse = false; +// CHECK-NEXT: (lldb) target variable ConstexprBFalse +// CHECK-NEXT: (const bool) ConstexprBFalse = false +constexpr bool ConstexprBTrue = true; +// CHECK-NEXT: (lldb) target variable ConstexprBTrue +// CHECK-NEXT: (const bool) ConstexprBTrue = true +constexpr char ConstexprCA = 'A'; +// CHECK-NEXT: (lldb) target variable ConstexprCA +// CHECK-NEXT: (const char) ConstexprCA = 'A' +constexpr char ConstexprCZ = 'Z'; +// CHECK-NEXT: (lldb) target variable ConstexprCZ +// CHECK-NEXT: (const char) ConstexprCZ = 'Z' +constexpr signed char ConstexprSCa = 'a'; +// CHECK-NEXT: (lldb) target variable ConstexprSCa +// CHECK-NEXT: (const signed char) ConstexprSCa = 'a' +constexpr signed char ConstexprSCz = 'z'; +// CHECK-NEXT: (lldb) target variable ConstexprSCz +// CHECK-NEXT: (const signed char) ConstexprSCz = 'z' +constexpr unsigned char ConstexprUC24 = 24; +// CHECK-NEXT: (lldb) target variable ConstexprUC24 +// CHECK-NEXT: (const unsigned char) ConstexprUC24 = '\x18' +constexpr unsigned char ConstexprUC42 = 42; +// CHECK-NEXT: (lldb) target variable ConstexprUC42 +// CHECK-NEXT: (const unsigned char) ConstexprUC42 = '*' +constexpr char16_t ConstexprC16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable ConstexprC16_24 +// CHECK-NEXT: (const char16_t) ConstexprC16_24 = U+0014 +constexpr char32_t ConstexprC32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable ConstexprC32_42 +// CHECK-NEXT: (const char32_t) ConstexprC32_42 = U+0x00000022 +constexpr wchar_t ConstexprWC1 = L'1'; +// CHECK-NEXT: (lldb) target variable ConstexprWC1 +// CHECK-NEXT: (const wchar_t) ConstexprWC1 = L'1' +constexpr wchar_t ConstexprWCP = L'P'; +// CHECK-NEXT: (lldb) target variable ConstexprWCP +// CHECK-NEXT: (const wchar_t) ConstexprWCP = L'P' +constexpr short ConstexprSMax = 32767; +// CHECK-NEXT: (lldb) target variable ConstexprSMax +// CHECK-NEXT: (const short) ConstexprSMax = 32767 +constexpr short ConstexprSMin = -32768; +// CHECK-NEXT: (lldb) target variable ConstexprSMin +// CHECK-NEXT: (const short) ConstexprSMin = -32768 +constexpr unsigned short ConstexprUSMax = 65535; +// CHECK-NEXT: (lldb) target variable ConstexprUSMax +// CHECK-NEXT: (const unsigned short) ConstexprUSMax = 65535 +constexpr unsigned short ConstexprUSMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprUSMin +// CHECK-NEXT: (const unsigned short) ConstexprUSMin = 0 +constexpr int ConstexprIMax = 2147483647; +// CHECK-NEXT: (lldb) target variable ConstexprIMax +// CHECK-NEXT: (const int) ConstexprIMax = 2147483647 +constexpr int ConstexprIMin = -2147483648; +// CHECK-NEXT: (lldb) target variable ConstexprIMin +// CHECK-NEXT: (const int) ConstexprIMin = -2147483648 +constexpr unsigned int ConstexprUIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ConstexprUIMax +// CHECK-NEXT: (const unsigned int) ConstexprUIMax = 4294967295 +constexpr unsigned int ConstexprUIMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprUIMin +// CHECK-NEXT: (const unsigned int) ConstexprUIMin = 0 +constexpr long ConstexprLMax = 2147483647; +// CHECK-NEXT: (lldb) target variable ConstexprLMax +// CHECK-NEXT: (const long) ConstexprLMax = 2147483647 +constexpr long ConstexprLMin = -2147483648; +// CHECK-NEXT: (lldb) target variable ConstexprLMin +// CHECK-NEXT: (const long) ConstexprLMin = -2147483648 +constexpr unsigned long ConstexprULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ConstexprULMax +// CHECK-NEXT: (const unsigned long) ConstexprULMax = 4294967295 +constexpr unsigned long ConstexprULMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprULMin +// CHECK-NEXT: (const unsigned long) ConstexprULMin = 0 +constexpr long long ConstexprLLMax = 9223372036854775807i64; +// CHECK-NEXT: (lldb) target variable ConstexprLLMax +// CHECK-NEXT: (const long long) ConstexprLLMax = 9223372036854775807 +constexpr long long ConstexprLLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable ConstexprLLMin +// CHECK-NEXT: (const long long) ConstexprLLMin = -9223372036854775808 +constexpr unsigned long long ConstexprULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable ConstexprULLMax +// CHECK-NEXT: (const unsigned long long) ConstexprULLMax = 18446744073709551615 +constexpr unsigned long long ConstexprULLMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprULLMin +// CHECK-NEXT: (const unsigned long long) ConstexprULLMin = 0 +constexpr float ConstexprF = 3.1415f; +// CHECK-NEXT: (lldb) target variable ConstexprF +// CHECK-NEXT: (const float) ConstexprF = 3.1415 +constexpr double ConstexprD = 3.1415; +// CHECK-NEXT: (lldb) target variable ConstexprD +// CHECK-NEXT: (const double) ConstexprD = 3.1415 + + +// FIXME: LLDB currently doesn't resolve pointers within the target without a +// running process (I haven't checked whether or not it can with a running +// process). So currently it will just print an address, which is unstable and +// should not be relied upon for testing. So for now we're just checking that +// the variable name and type is correct. We should fix this in LLDB and then +// update the tests. +bool *PBFalse = &BFalse; +// CHECK-NEXT: (lldb) target variable PBFalse +// CHECK-NEXT: (bool *) PBFalse = {{.*}} +bool *PBTrue = &BTrue; +// CHECK-NEXT: (lldb) target variable PBTrue +// CHECK-NEXT: (bool *) PBTrue = {{.*}} +char *PCA = &CA; +// CHECK-NEXT: (lldb) target variable PCA +// CHECK-NEXT: (char *) PCA = {{.*}} +char *PCZ = &CZ; +// CHECK-NEXT: (lldb) target variable PCZ +// CHECK-NEXT: (char *) PCZ = {{.*}} +signed char *PSCa = &SCa; +// CHECK-NEXT: (lldb) target variable PSCa +// CHECK-NEXT: (signed char *) PSCa = {{.*}} +signed char *PSCz = &SCz; +// CHECK-NEXT: (lldb) target variable PSCz +// CHECK-NEXT: (signed char *) PSCz = {{.*}} +unsigned char *PUC24 = &UC24; +// CHECK-NEXT: (lldb) target variable PUC24 +// CHECK-NEXT: (unsigned char *) PUC24 = {{.*}} +unsigned char *PUC42 = &UC42; +// CHECK-NEXT: (lldb) target variable PUC42 +// CHECK-NEXT: (unsigned char *) PUC42 = {{.*}} +char16_t *PC16_24 = &C16_24; +// CHECK-NEXT: (lldb) target variable PC16_24 +// CHECK-NEXT: (char16_t *) PC16_24 = {{.*}} +char32_t *PC32_42 = &C32_42; +// CHECK-NEXT: (lldb) target variable PC32_42 +// CHECK-NEXT: (char32_t *) PC32_42 = {{.*}} +wchar_t *PWC1 = &WC1; +// CHECK-NEXT: (lldb) target variable PWC1 +// CHECK-NEXT: (wchar_t *) PWC1 = {{.*}} +wchar_t *PWCP = &WCP; +// CHECK-NEXT: (lldb) target variable PWCP +// CHECK-NEXT: (wchar_t *) PWCP = {{.*}} +short *PSMax = &SMax; +// CHECK-NEXT: (lldb) target variable PSMax +// CHECK-NEXT: (short *) PSMax = {{.*}} +short *PSMin = &SMin; +// CHECK-NEXT: (lldb) target variable PSMin +// CHECK-NEXT: (short *) PSMin = {{.*}} +unsigned short *PUSMax = &USMax; +// CHECK-NEXT: (lldb) target variable PUSMax +// CHECK-NEXT: (unsigned short *) PUSMax = {{.*}} +unsigned short *PUSMin = &USMin; +// CHECK-NEXT: (lldb) target variable PUSMin +// CHECK-NEXT: (unsigned short *) PUSMin = {{.*}} +int *PIMax = &IMax; +// CHECK-NEXT: (lldb) target variable PIMax +// CHECK-NEXT: (int *) PIMax = {{.*}} +int *PIMin = &IMin; +// CHECK-NEXT: (lldb) target variable PIMin +// CHECK-NEXT: (int *) PIMin = {{.*}} +unsigned int *PUIMax = &UIMax; +// CHECK-NEXT: (lldb) target variable PUIMax +// CHECK-NEXT: (unsigned int *) PUIMax = {{.*}} +unsigned int *PUIMin = &UIMin; +// CHECK-NEXT: (lldb) target variable PUIMin +// CHECK-NEXT: (unsigned int *) PUIMin = {{.*}} +long *PLMax = &LMax; +// CHECK-NEXT: (lldb) target variable PLMax +// CHECK-NEXT: (long *) PLMax = {{.*}} +long *PLMin = &LMin; +// CHECK-NEXT: (lldb) target variable PLMin +// CHECK-NEXT: (long *) PLMin = {{.*}} +unsigned long *PULMax = &ULMax; +// CHECK-NEXT: (lldb) target variable PULMax +// CHECK-NEXT: (unsigned long *) PULMax = {{.*}} +unsigned long *PULMin = &ULMin; +// CHECK-NEXT: (lldb) target variable PULMin +// CHECK-NEXT: (unsigned long *) PULMin = {{.*}} +long long *PLLMax = &LLMax; +// CHECK-NEXT: (lldb) target variable PLLMax +// CHECK-NEXT: (long long *) PLLMax = {{.*}} +long long *PLLMin = &LLMin; +// CHECK-NEXT: (lldb) target variable PLLMin +// CHECK-NEXT: (long long *) PLLMin = {{.*}} +unsigned long long *PULLMax = &ULLMax; +// CHECK-NEXT: (lldb) target variable PULLMax +// CHECK-NEXT: (unsigned long long *) PULLMax = {{.*}} +unsigned long long *PULLMin = &ULLMin; +// CHECK-NEXT: (lldb) target variable PULLMin +// CHECK-NEXT: (unsigned long long *) PULLMin = {{.*}} +float *PF = &F; +// CHECK-NEXT: (lldb) target variable PF +// CHECK-NEXT: (float *) PF = {{.*}} +double *PD = &D; +// CHECK-NEXT: (lldb) target variable PD +// CHECK-NEXT: (double *) PD = {{.*}} + +// Const pointers to fundamental data types +const bool *CPBFalse = &BFalse; +// CHECK-NEXT: (lldb) target variable CPBFalse +// CHECK-NEXT: (const bool *) CPBFalse = {{.*}} +const bool *CPBTrue = &BTrue; +// CHECK-NEXT: (lldb) target variable CPBTrue +// CHECK-NEXT: (const bool *) CPBTrue = {{.*}} +const char *CPCA = &CA; +// CHECK-NEXT: (lldb) target variable CPCA +// CHECK-NEXT: (const char *) CPCA = {{.*}} +const char *CPCZ = &CZ; +// CHECK-NEXT: (lldb) target variable CPCZ +// CHECK-NEXT: (const char *) CPCZ = {{.*}} +const signed char *CPSCa = &SCa; +// CHECK-NEXT: (lldb) target variable CPSCa +// CHECK-NEXT: (const signed char *) CPSCa = {{.*}} +const signed char *CPSCz = &SCz; +// CHECK-NEXT: (lldb) target variable CPSCz +// CHECK-NEXT: (const signed char *) CPSCz = {{.*}} +const unsigned char *CPUC24 = &UC24; +// CHECK-NEXT: (lldb) target variable CPUC24 +// CHECK-NEXT: (const unsigned char *) CPUC24 = {{.*}} +const unsigned char *CPUC42 = &UC42; +// CHECK-NEXT: (lldb) target variable CPUC42 +// CHECK-NEXT: (const unsigned char *) CPUC42 = {{.*}} +const char16_t *CPC16_24 = &C16_24; +// CHECK-NEXT: (lldb) target variable CPC16_24 +// CHECK-NEXT: (const char16_t *) CPC16_24 = {{.*}} +const char32_t *CPC32_42 = &C32_42; +// CHECK-NEXT: (lldb) target variable CPC32_42 +// CHECK-NEXT: (const char32_t *) CPC32_42 = {{.*}} +const wchar_t *CPWC1 = &WC1; +// CHECK-NEXT: (lldb) target variable CPWC1 +// CHECK-NEXT: (const wchar_t *) CPWC1 = {{.*}} +const wchar_t *CPWCP = &WCP; +// CHECK-NEXT: (lldb) target variable CPWCP +// CHECK-NEXT: (const wchar_t *) CPWCP = {{.*}} +const short *CPSMax = &SMax; +// CHECK-NEXT: (lldb) target variable CPSMax +// CHECK-NEXT: (const short *) CPSMax = {{.*}} +const short *CPSMin = &SMin; +// CHECK-NEXT: (lldb) target variable CPSMin +// CHECK-NEXT: (const short *) CPSMin = {{.*}} +const unsigned short *CPUSMax = &USMax; +// CHECK-NEXT: (lldb) target variable CPUSMax +// CHECK-NEXT: (const unsigned short *) CPUSMax = {{.*}} +const unsigned short *CPUSMin = &USMin; +// CHECK-NEXT: (lldb) target variable CPUSMin +// CHECK-NEXT: (const unsigned short *) CPUSMin = {{.*}} +const int *CPIMax = &IMax; +// CHECK-NEXT: (lldb) target variable CPIMax +// CHECK-NEXT: (const int *) CPIMax = {{.*}} +const int *CPIMin = &IMin; +// CHECK-NEXT: (lldb) target variable CPIMin +// CHECK-NEXT: (const int *) CPIMin = {{.*}} +const unsigned int *CPUIMax = &UIMax; +// CHECK-NEXT: (lldb) target variable CPUIMax +// CHECK-NEXT: (const unsigned int *) CPUIMax = {{.*}} +const unsigned int *CPUIMin = &UIMin; +// CHECK-NEXT: (lldb) target variable CPUIMin +// CHECK-NEXT: (const unsigned int *) CPUIMin = {{.*}} +const long *CPLMax = &LMax; +// CHECK-NEXT: (lldb) target variable CPLMax +// CHECK-NEXT: (const long *) CPLMax = {{.*}} +const long *CPLMin = &LMin; +// CHECK-NEXT: (lldb) target variable CPLMin +// CHECK-NEXT: (const long *) CPLMin = {{.*}} +const unsigned long *CPULMax = &ULMax; +// CHECK-NEXT: (lldb) target variable CPULMax +// CHECK-NEXT: (const unsigned long *) CPULMax = {{.*}} +const unsigned long *CPULMin = &ULMin; +// CHECK-NEXT: (lldb) target variable CPULMin +// CHECK-NEXT: (const unsigned long *) CPULMin = {{.*}} +const long long *CPLLMax = &LLMax; +// CHECK-NEXT: (lldb) target variable CPLLMax +// CHECK-NEXT: (const long long *) CPLLMax = {{.*}} +const long long *CPLLMin = &LLMin; +// CHECK-NEXT: (lldb) target variable CPLLMin +// CHECK-NEXT: (const long long *) CPLLMin = {{.*}} +const unsigned long long *CPULLMax = &ULLMax; +// CHECK-NEXT: (lldb) target variable CPULLMax +// CHECK-NEXT: (const unsigned long long *) CPULLMax = {{.*}} +const unsigned long long *CPULLMin = &ULLMin; +// CHECK-NEXT: (lldb) target variable CPULLMin +// CHECK-NEXT: (const unsigned long long *) CPULLMin = {{.*}} +const float *CPF = &F; +// CHECK-NEXT: (lldb) target variable CPF +// CHECK-NEXT: (const float *) CPF = {{.*}} +const double *CPD = &D; +// CHECK-NEXT: (lldb) target variable CPD +// CHECK-NEXT: (const double *) CPD = {{.*}} + + +// References to fundamental data types + +bool &RBFalse = BFalse; +// CHECK-NEXT: (lldb) target variable RBFalse +// CHECK-NEXT: (bool &) RBFalse = {{.*}} (&::RBFalse = false) +bool &RBTrue = BTrue; +// CHECK-NEXT: (lldb) target variable RBTrue +// CHECK-NEXT: (bool &) RBTrue = {{.*}} (&::RBTrue = true) +char &RCA = CA; +// CHECK-NEXT: (lldb) target variable RCA +// CHECK-NEXT: (char &) RCA = {{.*}} (&::RCA = 'A') +char &RCZ = CZ; +// CHECK-NEXT: (lldb) target variable RCZ +// CHECK-NEXT: (char &) RCZ = {{.*}} (&::RCZ = 'Z') +signed char &RSCa = SCa; +// CHECK-NEXT: (lldb) target variable RSCa +// CHECK-NEXT: (signed char &) RSCa = {{.*}} (&::RSCa = 'a') +signed char &RSCz = SCz; +// CHECK-NEXT: (lldb) target variable RSCz +// CHECK-NEXT: (signed char &) RSCz = {{.*}} (&::RSCz = 'z') +unsigned char &RUC24 = UC24; +// CHECK-NEXT: (lldb) target variable RUC24 +// CHECK-NEXT: (unsigned char &) RUC24 = {{.*}} (&::RUC24 = '\x18') +unsigned char &RUC42 = UC42; +// CHECK-NEXT: (lldb) target variable RUC42 +// CHECK-NEXT: (unsigned char &) RUC42 = {{.*}} (&::RUC42 = '*') +short &RSMax = SMax; +// CHECK-NEXT: (lldb) target variable RSMax +// CHECK-NEXT: (short &) RSMax = {{.*}} (&::RSMax = 32767) +short &RSMin = SMin; +// CHECK-NEXT: (lldb) target variable RSMin +// CHECK-NEXT: (short &) RSMin = {{.*}} (&::RSMin = -32768) +unsigned short &RUSMax = USMax; +// CHECK-NEXT: (lldb) target variable RUSMax +// CHECK-NEXT: (unsigned short &) RUSMax = {{.*}} (&::RUSMax = 65535) +unsigned short &RUSMin = USMin; +// CHECK-NEXT: (lldb) target variable RUSMin +// CHECK-NEXT: (unsigned short &) RUSMin = {{.*}} (&::RUSMin = 0) +int &RIMax = IMax; +// CHECK-NEXT: (lldb) target variable RIMax +// CHECK-NEXT: (int &) RIMax = {{.*}} (&::RIMax = 2147483647) +int &RIMin = IMin; +// CHECK-NEXT: (lldb) target variable RIMin +// CHECK-NEXT: (int &) RIMin = {{.*}} (&::RIMin = -2147483648) +unsigned int &RUIMax = UIMax; +// CHECK-NEXT: (lldb) target variable RUIMax +// CHECK-NEXT: (unsigned int &) RUIMax = {{.*}} (&::RUIMax = 4294967295) +unsigned int &RUIMin = UIMin; +// CHECK-NEXT: (lldb) target variable RUIMin +// CHECK-NEXT: (unsigned int &) RUIMin = {{.*}} (&::RUIMin = 0) +long &RLMax = LMax; +// CHECK-NEXT: (lldb) target variable RLMax +// CHECK-NEXT: (long &) RLMax = {{.*}} (&::RLMax = 2147483647) +long &RLMin = LMin; +// CHECK-NEXT: (lldb) target variable RLMin +// CHECK-NEXT: (long &) RLMin = {{.*}} (&::RLMin = -2147483648) +unsigned long &RULMax = ULMax; +// CHECK-NEXT: (lldb) target variable RULMax +// CHECK-NEXT: (unsigned long &) RULMax = {{.*}} (&::RULMax = 4294967295) +unsigned long &RULMin = ULMin; +// CHECK-NEXT: (lldb) target variable RULMin +// CHECK-NEXT: (unsigned long &) RULMin = {{.*}} (&::RULMin = 0) +long long &RLLMax = LLMax; +// CHECK-NEXT: (lldb) target variable RLLMax +// CHECK-NEXT: (long long &) RLLMax = {{.*}} (&::RLLMax = 9223372036854775807) +long long &RLLMin = LLMin; +// CHECK-NEXT: (lldb) target variable RLLMin +// CHECK-NEXT: (long long &) RLLMin = {{.*}} (&::RLLMin = -9223372036854775808) +unsigned long long &RULLMax = ULLMax; +// CHECK-NEXT: (lldb) target variable RULLMax +// CHECK-NEXT: (unsigned long long &) RULLMax = {{.*}} (&::RULLMax = 18446744073709551615) +unsigned long long &RULLMin = ULLMin; +// CHECK-NEXT: (lldb) target variable RULLMin +// CHECK-NEXT: (unsigned long long &) RULLMin = {{.*}} (&::RULLMin = 0) +float &RF = F; +// CHECK-NEXT: (lldb) target variable RF +// CHECK-NEXT: (float &) RF = {{.*}} (&::RF = 3.1415) +double &RD = D; +// CHECK-NEXT: (lldb) target variable RD +// CHECK-NEXT: (double &) RD = {{.*}} (&::RD = 3.1415000000000002) + +// const references to fundamental data types +const bool &CRBFalse = BFalse; +// CHECK-NEXT: (lldb) target variable CRBFalse +// CHECK-NEXT: (const bool &) CRBFalse = {{.*}} (&::CRBFalse = false) +const bool &CRBTrue = BTrue; +// CHECK-NEXT: (lldb) target variable CRBTrue +// CHECK-NEXT: (const bool &) CRBTrue = {{.*}} (&::CRBTrue = true) +const char &CRCA = CA; +// CHECK-NEXT: (lldb) target variable CRCA +// CHECK-NEXT: (const char &) CRCA = {{.*}} (&::CRCA = 'A') +const char &CRCZ = CZ; +// CHECK-NEXT: (lldb) target variable CRCZ +// CHECK-NEXT: (const char &) CRCZ = {{.*}} (&::CRCZ = 'Z') +const signed char &CRSCa = SCa; +// CHECK-NEXT: (lldb) target variable CRSCa +// CHECK-NEXT: (const signed char &) CRSCa = {{.*}} (&::CRSCa = 'a') +const signed char &CRSCz = SCz; +// CHECK-NEXT: (lldb) target variable CRSCz +// CHECK-NEXT: (const signed char &) CRSCz = {{.*}} (&::CRSCz = 'z') +const unsigned char &CRUC24 = UC24; +// CHECK-NEXT: (lldb) target variable CRUC24 +// CHECK-NEXT: (const unsigned char &) CRUC24 = {{.*}} (&::CRUC24 = '\x18') +const unsigned char &CRUC42 = UC42; +// CHECK-NEXT: (lldb) target variable CRUC42 +// CHECK-NEXT: (const unsigned char &) CRUC42 = {{.*}} (&::CRUC42 = '*') +const short &CRSMax = SMax; +// CHECK-NEXT: (lldb) target variable CRSMax +// CHECK-NEXT: (const short &) CRSMax = {{.*}} (&::CRSMax = 32767) +const short &CRSMin = SMin; +// CHECK-NEXT: (lldb) target variable CRSMin +// CHECK-NEXT: (const short &) CRSMin = {{.*}} (&::CRSMin = -32768) +const unsigned short &CRUSMax = USMax; +// CHECK-NEXT: (lldb) target variable CRUSMax +// CHECK-NEXT: (const unsigned short &) CRUSMax = {{.*}} (&::CRUSMax = 65535) +const unsigned short &CRUSMin = USMin; +// CHECK-NEXT: (lldb) target variable CRUSMin +// CHECK-NEXT: (const unsigned short &) CRUSMin = {{.*}} (&::CRUSMin = 0) +const int &CRIMax = IMax; +// CHECK-NEXT: (lldb) target variable CRIMax +// CHECK-NEXT: (const int &) CRIMax = {{.*}} (&::CRIMax = 2147483647) +const int &CRIMin = IMin; +// CHECK-NEXT: (lldb) target variable CRIMin +// CHECK-NEXT: (const int &) CRIMin = {{.*}} (&::CRIMin = -2147483648) +const unsigned int &CRUIMax = UIMax; +// CHECK-NEXT: (lldb) target variable CRUIMax +// CHECK-NEXT: (const unsigned int &) CRUIMax = {{.*}} (&::CRUIMax = 4294967295) +const unsigned int &CRUIMin = UIMin; +// CHECK-NEXT: (lldb) target variable CRUIMin +// CHECK-NEXT: (const unsigned int &) CRUIMin = {{.*}} (&::CRUIMin = 0) +const long &CRLMax = LMax; +// CHECK-NEXT: (lldb) target variable CRLMax +// CHECK-NEXT: (const long &) CRLMax = {{.*}} (&::CRLMax = 2147483647) +const long &CRLMin = LMin; +// CHECK-NEXT: (lldb) target variable CRLMin +// CHECK-NEXT: (const long &) CRLMin = {{.*}} (&::CRLMin = -2147483648) +const unsigned long &CRULMax = ULMax; +// CHECK-NEXT: (lldb) target variable CRULMax +// CHECK-NEXT: (const unsigned long &) CRULMax = {{.*}} (&::CRULMax = 4294967295) +const unsigned long &CRULMin = ULMin; +// CHECK-NEXT: (lldb) target variable CRULMin +// CHECK-NEXT: (const unsigned long &) CRULMin = {{.*}} (&::CRULMin = 0) +const long long &CRLLMax = LLMax; +// CHECK-NEXT: (lldb) target variable CRLLMax +// CHECK-NEXT: (const long long &) CRLLMax = {{.*}} (&::CRLLMax = 9223372036854775807) +const long long &CRLLMin = LLMin; +// CHECK-NEXT: (lldb) target variable CRLLMin +// CHECK-NEXT: (const long long &) CRLLMin = {{.*}} (&::CRLLMin = -9223372036854775808) +const unsigned long long &CRULLMax = ULLMax; +// CHECK-NEXT: (lldb) target variable CRULLMax +// CHECK-NEXT: (const unsigned long long &) CRULLMax = {{.*}} (&::CRULLMax = 18446744073709551615) +const unsigned long long &CRULLMin = ULLMin; +// CHECK-NEXT: (lldb) target variable CRULLMin +// CHECK-NEXT: (const unsigned long long &) CRULLMin = {{.*}} (&::CRULLMin = 0) +const float &CRF = F; +// CHECK-NEXT: (lldb) target variable CRF +// CHECK-NEXT: (const float &) CRF = {{.*}} (&::CRF = 3.1415) +const double &CRD = D; +// CHECK-NEXT: (lldb) target variable CRD +// CHECK-NEXT: (const double &) CRD = {{.*}} (&::CRD = 3.1415000000000002) + +char16_t &RC16_24 = C16_24; +// CHECK: (lldb) target variable RC16_24 +// FIXME: (char16_t &) RC16_24 = {{.*}} (&::RC16_24 = U+0014) +char32_t &RC32_42 = C32_42; +// CHECK: (lldb) target variable RC32_42 +// FIXME: (char32_t &) RC32_42 = {{.*}} (&::RC32_42 = U+0x00000022) +wchar_t &RWC1 = WC1; +// CHECK: (lldb) target variable RWC1 +// FIXME: (wchar_t &) RWC1 = {{.*}} (&::RWC1 = L'1') +wchar_t &RWCP = WCP; +// CHECK: (lldb) target variable RWCP +// FIXME: (wchar_t &) RWCP = {{.*}} (&::RWCP = L'P') +const char16_t &CRC16_24 = C16_24; +// CHECK: (lldb) target variable CRC16_24 +// FIXME: (const char16_t &) CRC16_24 = {{.*}} (&::CRC16_24 = U+0014) +const char32_t &CRC32_42 = C32_42; +// CHECK: (lldb) target variable CRC32_42 +// FIXME: (const char32_t &) CRC32_42 = {{.*}} (&::CRC32_42 = U+0x00000022) +const wchar_t &CRWC1 = WC1; +// CHECK: (lldb) target variable CRWC1 +// FIXME: (const wchar_t &) CRWC1 = {{.*}} (&::CRWC1 = L'1') +const wchar_t &CRWCP = WCP; +// CHECK: (lldb) target variable CRWCP +// FIXME: (const wchar_t &) CRWCP = {{.*}} (&::CRWCP = L'P') + + +// CHECK: TranslationUnitDecl {{.*}} +// CHECK-NEXT: |-VarDecl {{.*}} BFalse 'bool' +// CHECK-NEXT: |-VarDecl {{.*}} BTrue 'bool' +// CHECK-NEXT: |-VarDecl {{.*}} CA 'char' +// CHECK-NEXT: |-VarDecl {{.*}} CZ 'char' +// CHECK-NEXT: |-VarDecl {{.*}} SCa 'signed char' +// CHECK-NEXT: |-VarDecl {{.*}} SCz 'signed char' +// CHECK-NEXT: |-VarDecl {{.*}} UC24 'unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} UC42 'unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} C16_24 'char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} C32_42 'char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} WC1 'wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} WCP 'wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} SMax 'short' +// CHECK-NEXT: |-VarDecl {{.*}} SMin 'short' +// CHECK-NEXT: |-VarDecl {{.*}} USMax 'unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} USMin 'unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} IMax 'int' +// CHECK-NEXT: |-VarDecl {{.*}} IMin 'int' +// CHECK-NEXT: |-VarDecl {{.*}} UIMax 'unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} UIMin 'unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} LMax 'long' +// CHECK-NEXT: |-VarDecl {{.*}} LMin 'long' +// CHECK-NEXT: |-VarDecl {{.*}} ULMax 'unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ULMin 'unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} LLMax 'long long' +// CHECK-NEXT: |-VarDecl {{.*}} LLMin 'long long' +// CHECK-NEXT: |-VarDecl {{.*}} ULLMax 'unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ULLMin 'unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} F 'float' +// CHECK-NEXT: |-VarDecl {{.*}} D 'double' +// CHECK-NEXT: |-VarDecl {{.*}} CBFalse 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} CBTrue 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} CCA 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} CCZ 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} CSCa 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} CSCz 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} CUC24 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} CUC42 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} CC16_24 'const char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} CC32_42 'const char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} CWC1 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} CWCP 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} CSMax 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} CSMin 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} CUSMax 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} CUSMin 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} CIMax 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} CIMin 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} CUIMax 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} CUIMin 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} CLMax 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} CLMin 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} CULMax 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} CULMin 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} CLLMax 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} CLLMin 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} CULLMax 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} CULLMin 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} CF 'const float' +// CHECK-NEXT: |-VarDecl {{.*}} CD 'const double' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprBFalse 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprBTrue 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprCA 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprCZ 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSCa 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSCz 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUC24 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUC42 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprC16_24 'const char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprC32_42 'const char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprWC1 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprWCP 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSMax 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSMin 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUSMax 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUSMin 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprIMax 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprIMin 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUIMax 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUIMin 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLMax 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLMin 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULMax 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULMin 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLLMax 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLLMin 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULLMax 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULLMin 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprF 'const float' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprD 'const double' +// CHECK-NEXT: |-VarDecl {{.*}} PBFalse 'bool *' +// CHECK-NEXT: |-VarDecl {{.*}} PBTrue 'bool *' +// CHECK-NEXT: |-VarDecl {{.*}} PCA 'char *' +// CHECK-NEXT: |-VarDecl {{.*}} PCZ 'char *' +// CHECK-NEXT: |-VarDecl {{.*}} PSCa 'signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} PSCz 'signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} PUC24 'unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} PUC42 'unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} PC16_24 'char16_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PC32_42 'char32_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PWC1 'wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PWCP 'wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PSMax 'short *' +// CHECK-NEXT: |-VarDecl {{.*}} PSMin 'short *' +// CHECK-NEXT: |-VarDecl {{.*}} PUSMax 'unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} PUSMin 'unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} PIMax 'int *' +// CHECK-NEXT: |-VarDecl {{.*}} PIMin 'int *' +// CHECK-NEXT: |-VarDecl {{.*}} PUIMax 'unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} PUIMin 'unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} PLMax 'long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLMin 'long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULMax 'unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULMin 'unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLLMax 'long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLLMin 'long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULLMax 'unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULLMin 'unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PF 'float *' +// CHECK-NEXT: |-VarDecl {{.*}} PD 'double *' +// CHECK-NEXT: |-VarDecl {{.*}} CPBFalse 'const bool *' +// CHECK-NEXT: |-VarDecl {{.*}} CPBTrue 'const bool *' +// CHECK-NEXT: |-VarDecl {{.*}} CPCA 'const char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPCZ 'const char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSCa 'const signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSCz 'const signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUC24 'const unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUC42 'const unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPC16_24 'const char16_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPC32_42 'const char32_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPWC1 'const wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPWCP 'const wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSMax 'const short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSMin 'const short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUSMax 'const unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUSMin 'const unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPIMax 'const int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPIMin 'const int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUIMax 'const unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUIMin 'const unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLMax 'const long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLMin 'const long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULMax 'const unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULMin 'const unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLLMax 'const long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLLMin 'const long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULLMax 'const unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULLMin 'const unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPF 'const float *' +// CHECK-NEXT: |-VarDecl {{.*}} CPD 'const double *' +// CHECK-NEXT: |-VarDecl {{.*}} RBFalse 'bool &' +// CHECK-NEXT: |-VarDecl {{.*}} RBTrue 'bool &' +// CHECK-NEXT: |-VarDecl {{.*}} RCA 'char &' +// CHECK-NEXT: |-VarDecl {{.*}} RCZ 'char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSCa 'signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSCz 'signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} RUC24 'unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} RUC42 'unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSMax 'short &' +// CHECK-NEXT: |-VarDecl {{.*}} RSMin 'short &' +// CHECK-NEXT: |-VarDecl {{.*}} RUSMax 'unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} RUSMin 'unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} RIMax 'int &' +// CHECK-NEXT: |-VarDecl {{.*}} RIMin 'int &' +// CHECK-NEXT: |-VarDecl {{.*}} RUIMax 'unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} RUIMin 'unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} RLMax 'long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLMin 'long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULMax 'unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULMin 'unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLLMax 'long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLLMin 'long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULLMax 'unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULLMin 'unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RF 'float &' +// CHECK-NEXT: |-VarDecl {{.*}} RD 'double &' +// CHECK-NEXT: |-VarDecl {{.*}} CRBFalse 'const bool &' +// CHECK-NEXT: |-VarDecl {{.*}} CRBTrue 'const bool &' +// CHECK-NEXT: |-VarDecl {{.*}} CRCA 'const char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRCZ 'const char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSCa 'const signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSCz 'const signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUC24 'const unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUC42 'const unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSMax 'const short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSMin 'const short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUSMax 'const unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUSMin 'const unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRIMax 'const int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRIMin 'const int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUIMax 'const unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUIMin 'const unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLMax 'const long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLMin 'const long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULMax 'const unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULMin 'const unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLLMax 'const long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLLMin 'const long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULLMax 'const unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULLMin 'const unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRF 'const float &' +// CHECK-NEXT: |-VarDecl {{.*}} CRD 'const double &' +// CHECK-NEXT: |-VarDecl {{.*}} RC16_24 'char16_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RC32_42 'char32_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RWC1 'wchar_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RWCP 'wchar_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRC16_24 'const char16_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRC32_42 'const char32_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRWC1 'const wchar_t &' +// CHECK-NEXT: `-VarDecl {{.*}} CRWCP 'const wchar_t &' + +// CHECK: (lldb) quit + +int main(int argc, char **argv) { + return CIMax; +} diff --git a/lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp b/lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp new file mode 100644 index 00000000000..a7e786dc4e5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp @@ -0,0 +1,161 @@ +// clang-format off + +// REQUIRES: system-windows +// RUN: %build -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/local-variables.lldbinit 2>&1 | FileCheck %s + +int Function(int Param1, char Param2) { + unsigned Local1 = Param1 + 1; + char Local2 = Param2 + 1; + ++Local1; + ++Local2; + return Local1; +} + +int main(int argc, char **argv) { + int SomeLocal = argc * 2; + return Function(SomeLocal, 'a'); +} + +// CHECK: (lldb) target create "{{.*}}local-variables.cpp.tmp.exe" +// CHECK-NEXT: Current executable set to '{{.*}}local-variables.cpp.tmp.exe' +// CHECK-NEXT: (lldb) command source -s 0 '{{.*}}local-variables.lldbinit' +// CHECK-NEXT: Executing commands in '{{.*}}local-variables.lldbinit'. +// CHECK-NEXT: (lldb) break set -n main +// CHECK-NEXT: Breakpoint 1: where = local-variables.cpp.tmp.exe`main + {{.*}} at local-variables.cpp:{{.*}}, address = {{.*}} +// CHECK-NEXT: (lldb) run a b c d e f g +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1 +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`main(argc=8, argv={{.*}}) at local-variables.cpp:{{.*}} +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { +// CHECK-NEXT: -> 17 int SomeLocal = argc * 2; +// CHECK-NEXT: 18 return Function(SomeLocal, 'a'); +// CHECK-NEXT: 19 } +// CHECK-NEXT: 20 + +// CHECK: Process {{.*}} launched: '{{.*}}local-variables.cpp.tmp.exe' +// CHECK-NEXT: (lldb) p argc +// CHECK-NEXT: (int) $0 = 8 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`main(argc=8, argv={{.*}}) at local-variables.cpp:{{.*}} +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { +// CHECK-NEXT: 17 int SomeLocal = argc * 2; +// CHECK-NEXT: -> 18 return Function(SomeLocal, 'a'); +// CHECK-NEXT: 19 } +// CHECK-NEXT: 20 + +// CHECK: (lldb) p SomeLocal +// CHECK-NEXT: (int) $1 = 16 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 6 +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: -> 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $2 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $3 = 'a' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: -> 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: 13 return Local1; + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $4 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $5 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $6 = 17 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: -> 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: 13 return Local1; +// CHECK-NEXT: 14 } + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $7 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $8 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $9 = 17 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $10 = 'b' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: -> 12 ++Local2; +// CHECK-NEXT: 13 return Local1; +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $11 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $12 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $13 = 18 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $14 = 'b' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: -> 13 return Local1; +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $15 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $16 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $17 = 18 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $18 = 'c' +// CHECK-NEXT: (lldb) continue +// CHECK-NEXT: Process {{.*}} resuming +// CHECK-NEXT: Process {{.*}} exited with status = 18 (0x00000012) + +// CHECK: (lldb) target modules dump ast +// CHECK-NEXT: Dumping clang ast for {{.*}} modules. +// CHECK-NEXT: TranslationUnitDecl +// CHECK-NEXT: |-FunctionDecl {{.*}} main 'int (int, char **)' +// CHECK-NEXT: | |-ParmVarDecl {{.*}} argc 'int' +// CHECK-NEXT: | `-ParmVarDecl {{.*}} argv 'char **' +// CHECK-NEXT: `-FunctionDecl {{.*}} Function 'int (int, char)' +// CHECK-NEXT: |-ParmVarDecl {{.*}} Param1 'int' +// CHECK-NEXT: `-ParmVarDecl {{.*}} Param2 'char' diff --git a/lldb/test/Shell/SymbolFile/NativePDB/nested-types.cpp b/lldb/test/Shell/SymbolFile/NativePDB/nested-types.cpp new file mode 100644 index 00000000000..e9bee690d30 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/nested-types.cpp @@ -0,0 +1,153 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/nested-types.lldbinit 2>&1 | FileCheck %s + +struct S { + struct NestedStruct { + int A = 0; + int B = 1; + }; + + enum class NestedEnum { + EnumValue1 = 0, + EnumValue2 = 1, + }; + int C = 2; + int D = 3; + using VoidPtrT = void *; + VoidPtrT DD = nullptr; +}; +struct T { + using NestedTypedef = int; + using NestedTypedef2 = S; + + struct NestedStruct { + int E = 4; + int F = 5; + }; + + using NestedStructAlias = NestedStruct; + using NST = S::NestedStruct; + + NestedTypedef NT = 4; + + using U = struct { + int G = 6; + int H = 7; + }; +}; + +template<typename Param> +class U { +public: + // See llvm.org/pr39607. clang-cl currently doesn't emit an important debug + // info record for nested template instantiations, so we can't reconstruct + // a proper DeclContext hierarchy for these. As such, U<X>::V<Y> will show up + // in the global namespace. + template<typename Param> + struct V { + Param I = 8; + Param J = 9; + + using W = T::NestedTypedef; + using X = U<int>; + }; + + struct W { + Param M = 12; + Param N = 13; + }; + Param K = 10; + Param L = 11; + using Y = V<int>; + using Z = V<T>; +}; + +constexpr S GlobalA; +constexpr S::NestedStruct GlobalB; +constexpr T GlobalC; +constexpr T::NestedStruct GlobalD; +constexpr T::U GlobalE; +constexpr U<int> GlobalF; +constexpr U<int>::V<int> GlobalG; +constexpr U<int>::W GlobalH; +constexpr S::NestedEnum GlobalEnum = S::NestedEnum::EnumValue1; + + +int main(int argc, char **argv) { + return 0; +} + + + +// CHECK: (lldb) target variable -T GlobalA +// CHECK: (const S) GlobalA = { +// CHECK: (int) C = 2 +// CHECK: (int) D = 3 +// CHECK: (void *) DD = 0x00000000 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalB +// CHECK: (const S::NestedStruct) GlobalB = { +// CHECK: (int) A = 0 +// CHECK: (int) B = 1 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalC +// CHECK: (const T) GlobalC = { +// CHECK: (int) NT = 4 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalD +// CHECK: (const T::NestedStruct) GlobalD = { +// CHECK: (int) E = 4 +// CHECK: (int) F = 5 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalE +// CHECK: (const T::U) GlobalE = { +// CHECK: (int) G = 6 +// CHECK: (int) H = 7 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalF +// CHECK: (const U<int>) GlobalF = { +// CHECK: (int) K = 10 +// CHECK: (int) L = 11 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalG +// CHECK: (const U<int>::V<int>) GlobalG = { +// CHECK: (int) I = 8 +// CHECK: (int) J = 9 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalEnum +// CHECK: (const S::NestedEnum) GlobalEnum = EnumValue1 +// CHECK: (lldb) target modules dump ast +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} struct S definition +// CHECK: | |-FieldDecl {{.*}} C 'int' +// CHECK: | |-FieldDecl {{.*}} D 'int' +// CHECK: | |-FieldDecl {{.*}} DD 'void *' +// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition +// CHECK: | | |-FieldDecl {{.*}} A 'int' +// CHECK: | | `-FieldDecl {{.*}} B 'int' +// CHECK: | `-EnumDecl {{.*}} NestedEnum +// CHECK: | |-EnumConstantDecl {{.*}} EnumValue1 'S::NestedEnum' +// CHECK: | `-EnumConstantDecl {{.*}} EnumValue2 'S::NestedEnum' +// CHECK: |-CXXRecordDecl {{.*}} struct T definition +// CHECK: | |-FieldDecl {{.*}} NT 'int' +// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition +// CHECK: | | |-FieldDecl {{.*}} E 'int' +// CHECK: | | `-FieldDecl {{.*}} F 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct U definition +// CHECK: | |-FieldDecl {{.*}} G 'int' +// CHECK: | `-FieldDecl {{.*}} H 'int' +// CHECK: |-CXXRecordDecl {{.*}} class U<int> definition +// CHECK: | |-FieldDecl {{.*}} K 'int' +// CHECK: | |-FieldDecl {{.*}} L 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct W definition +// CHECK: | |-FieldDecl {{.*}} M 'int' +// CHECK: | `-FieldDecl {{.*}} N 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct U<int>::V<int> definition +// CHECK: | |-FieldDecl {{.*}} I 'int' +// CHECK: | `-FieldDecl {{.*}} J 'int' diff --git a/lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp b/lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp new file mode 100644 index 00000000000..7603a4daba4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp @@ -0,0 +1,115 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display S_CONSTANT records. + +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %p/Inputs/s_constant.s > %t.obj +// RUN: %build --compiler=clang-cl --nodefaultlib --mode=link -o %t.exe -- %t.obj +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/s_constant.lldbinit | FileCheck %s + +// clang-cl cannot generate S_CONSTANT records, but we need to test that we can +// handle them for compatibility with MSVC, which does emit them. This test +// case was generated by compiling this file with MSVC and copying the bytes +// that they emit for S_CONSTANT records. Then we compile the same code with +// clang to get a .s file, and replace all S_LDATA32 records with the bytes from +// the S_CONSTANT records. This way we end up with a .s file that contains +// symbol records that clang-cl won't generate. + +namespace A { +namespace B { +namespace C { + enum LargeUnsignedEnum : unsigned long long { + LUE_A = 0ULL, + LUE_B = 1000ULL, + LUE_C = 18446744073709551600ULL, + }; + + enum LargeSignedEnum : long long { + LSE_A = 0LL, + LSE_B = 9223372036854775000LL, + LSE_C = -9223372036854775000LL, + }; + + enum UnsignedEnum : unsigned int { + UE_A = 0, + UE_B = 1000, + UE_C = 4294000000, + }; + + enum SignedEnum : int { + SE_A = 0, + SE_B = 2147000000, + SE_C = -2147000000, + }; + + enum SmallUnsignedEnum : unsigned char { + SUE_A = 0, + SUE_B = 100, + SUE_C = 200, + }; + + enum SmallSignedEnum : char { + SSE_A = 0, + SSE_B = 100, + SSE_C = -100, + }; +} +} +} + +using namespace A::B::C; + +constexpr LargeUnsignedEnum GlobalLUEA = LUE_A; +constexpr LargeUnsignedEnum GlobalLUEB = LUE_B; +constexpr LargeUnsignedEnum GlobalLUEC = LUE_C; + +constexpr LargeSignedEnum GlobalLSEA = LSE_A; +constexpr LargeSignedEnum GlobalLSEB = LSE_B; +constexpr LargeSignedEnum GlobalLSEC = LSE_C; + +constexpr UnsignedEnum GlobalUEA = UE_A; +constexpr UnsignedEnum GlobalUEB = UE_B; +constexpr UnsignedEnum GlobalUEC = UE_C; + +constexpr SignedEnum GlobalSEA = SE_A; +constexpr SignedEnum GlobalSEB = SE_B; +constexpr SignedEnum GlobalSEC = SE_C; + +constexpr SmallUnsignedEnum GlobalSUEA = SUE_A; +constexpr SmallUnsignedEnum GlobalSUEB = SUE_B; +constexpr SmallUnsignedEnum GlobalSUEC = SUE_C; + +constexpr SmallSignedEnum GlobalSSEA = SSE_A; +constexpr SmallSignedEnum GlobalSSEB = SSE_B; +constexpr SmallSignedEnum GlobalSSEC = SSE_C; + +int main(int argc, char **argv) { + return 0; +} + +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEA = LUE_A +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEB = LUE_B + +// X-FAIL: Something is outputting bad debug info here, maybe cl. +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEC = {{.*}} + +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEA = LSE_A +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEB = LSE_B +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEC = LSE_C + +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEA = UE_A +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEB = UE_B +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEC = UE_C + +// CHECK: (const A::B::C::SignedEnum) GlobalSEA = SE_A +// CHECK: (const A::B::C::SignedEnum) GlobalSEB = SE_B +// CHECK: (const A::B::C::SignedEnum) GlobalSEC = SE_C + +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEA = SUE_A +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEB = SUE_B +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEC = SUE_C + +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEA = SSE_A +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEB = SSE_B +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEC = SSE_C diff --git a/lldb/test/Shell/SymbolFile/NativePDB/source-list.cpp b/lldb/test/Shell/SymbolFile/NativePDB/source-list.cpp new file mode 100644 index 00000000000..6b749b082e3 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/source-list.cpp @@ -0,0 +1,42 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set display source of functions. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/source-list.lldbinit | FileCheck %s + + + +// Some context lines before +// the function. + + +int main(int argc, char **argv) { + // Here are some comments. + // That we should print when listing source. + return 0; +} + +// Some context lines after +// the function. + +// check lines go at the end so that line numbers stay stable when +// changing this file. + +// CHECK: (lldb) source list -n main +// CHECK: File: {{.*}}source-list.cpp +// CHECK: 10 +// CHECK: 11 // Some context lines before +// CHECK: 12 // the function. +// CHECK: 13 +// CHECK: 14 +// CHECK: 15 int main(int argc, char **argv) { +// CHECK: 16 // Here are some comments. +// CHECK: 17 // That we should print when listing source. +// CHECK: 18 return 0; +// CHECK: 19 } +// CHECK: 20 +// CHECK: 21 // Some context lines after +// CHECK: 22 // the function. +// CHECK: 23 diff --git a/lldb/test/Shell/SymbolFile/NativePDB/stack_unwinding01.cpp b/lldb/test/Shell/SymbolFile/NativePDB/stack_unwinding01.cpp new file mode 100644 index 00000000000..701b843fa12 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/stack_unwinding01.cpp @@ -0,0 +1,42 @@ +// clang-format off +// REQUIRES: lld, system-windows + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/stack_unwinding01.lldbinit 2>&1 | FileCheck %s + + +struct Struct { + void simple_method(int a, int b) { + a += 1; + simple_method(a, b); + } +}; + + + +int main(int argc, char **argv) { + Struct s; + s.simple_method(1,2); + return 0; +} + + +// CHECK: (lldb) thread backtrace +// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1 +// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20 + + +// CHECK: (lldb) thread backtrace +// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1 +// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #2: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20 + +// CHECK: (lldb) thread backtrace +// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1 +// CHECK-NEXT: * frame #0: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #1: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #2: {{.*}} stack_unwinding01.cpp.tmp.exe`Struct::simple_method at stack_unwinding01.cpp:12 +// CHECK-NEXT: frame #3: {{.*}} stack_unwinding01.cpp.tmp.exe`main(argc={{.*}}, argv={{.*}}) at stack_unwinding01.cpp:20 diff --git a/lldb/test/Shell/SymbolFile/NativePDB/tag-types.cpp b/lldb/test/Shell/SymbolFile/NativePDB/tag-types.cpp new file mode 100644 index 00000000000..db981eafa6e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/tag-types.cpp @@ -0,0 +1,249 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/tag-types.lldbinit | FileCheck %s + +// Test struct +struct Struct { + // Test builtin types, which are represented by special CodeView type indices. + bool B; + char C; + signed char SC; + unsigned char UC; + char16_t C16; + char32_t C32; + wchar_t WC; + short S; + unsigned short US; + int I; + unsigned int UI; + long L; + unsigned long UL; + long long LL; + unsigned long long ULL; + float F; + double D; + long double LD; +}; + +// Test class +class Class { +public: + // Test pointers to builtin types, which are represented by different special + // CodeView type indices. + bool *PB; + char *PC; + signed char *PSC; + unsigned char *PUC; + char16_t *PC16; + char32_t *PC32; + wchar_t *PWC; + short *PS; + unsigned short *PUS; + int *PI; + unsigned int *PUI; + long *PL; + unsigned long *PUL; + long long *PLL; + unsigned long long *PULL; + float *PF; + double *PD; + long double *PLD; +}; + +// Test union +union Union { + // Test modified types. + const bool *PB; + const char *PC; + const signed char *PSC; + const unsigned char *PUC; + const char16_t *PC16; + const char32_t *PC32; + const wchar_t *PWC; + const short *PS; + const unsigned short *PUS; + const int *PI; + const unsigned int *PUI; + const long *PL; + const unsigned long *PUL; + const long long *PLL; + const unsigned long long *PULL; + const float *PF; + const double *PD; + const long double *PLD; +}; + +struct OneMember { + int N = 0; +}; + + +// Test single inheritance. +class Derived : public Class { +public: + explicit Derived() + : Reference(*this), RefMember(Member), RValueRefMember((OneMember&&)Member) {} + + // Test reference to self, to make sure we don't end up in an + // infinite cycle. + Derived &Reference; + + // Test aggregate class member. + OneMember Member; + + // And modified aggregate class member. + const OneMember ConstMember; + volatile OneMember VolatileMember; + const volatile OneMember CVMember; + + // And all types of pointers to class members + OneMember *PtrMember; + OneMember &RefMember; + OneMember &&RValueRefMember; +}; + +// Test multiple inheritance, as well as protected and private inheritance. +class Derived2 : protected Class, private Struct { +public: + // Test static data members + static unsigned StaticDataMember; +}; + +unsigned Derived2::StaticDataMember = 0; + +// Test virtual inheritance. +class DerivedVirtual1 : public virtual Class {}; + +// Test the correctness of the virtual bases order. +class DerivedVirtual2 : public DerivedVirtual1, public virtual OneMember {}; + +// Test scoped enums and unscoped enums. +enum class EnumInt { + A = 1, + B = 2 +}; + +// Test explicit underlying types +enum EnumShort : short { + ES_A = 2, + ES_B = 3 +}; + +int main(int argc, char **argv) { + Struct S; + Class C; + Union U; + Derived D; + Derived2 D2; + DerivedVirtual1 DV1; + DerivedVirtual2 DV2; + EnumInt EI; + EnumShort ES; + + return 0; +} + +// CHECK: (lldb) target create "{{.*}}tag-types.cpp.tmp.exe" +// CHECK-NEXT: Current executable set to '{{.*}}tag-types.cpp.tmp.exe' +// CHECK-NEXT: (lldb) command source -s 0 '{{.*}}tag-types.lldbinit' +// CHECK-NEXT: Executing commands in '{{.*}}tag-types.lldbinit'. +// CHECK-NEXT: (lldb) type lookup -- Struct +// CHECK-NEXT: struct Struct { +// CHECK-NEXT: bool B; +// CHECK-NEXT: char C; +// CHECK-NEXT: signed char SC; +// CHECK-NEXT: unsigned char UC; +// CHECK-NEXT: char16_t C16; +// CHECK-NEXT: char32_t C32; +// CHECK-NEXT: wchar_t WC; +// CHECK-NEXT: short S; +// CHECK-NEXT: unsigned short US; +// CHECK-NEXT: int I; +// CHECK-NEXT: unsigned int UI; +// CHECK-NEXT: long L; +// CHECK-NEXT: unsigned long UL; +// CHECK-NEXT: long long LL; +// CHECK-NEXT: unsigned long long ULL; +// CHECK-NEXT: float F; +// CHECK-NEXT: double D; +// CHECK-NEXT: double LD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Class +// CHECK-NEXT: class Class { +// CHECK-NEXT: bool *PB; +// CHECK-NEXT: char *PC; +// CHECK-NEXT: signed char *PSC; +// CHECK-NEXT: unsigned char *PUC; +// CHECK-NEXT: char16_t *PC16; +// CHECK-NEXT: char32_t *PC32; +// CHECK-NEXT: wchar_t *PWC; +// CHECK-NEXT: short *PS; +// CHECK-NEXT: unsigned short *PUS; +// CHECK-NEXT: int *PI; +// CHECK-NEXT: unsigned int *PUI; +// CHECK-NEXT: long *PL; +// CHECK-NEXT: unsigned long *PUL; +// CHECK-NEXT: long long *PLL; +// CHECK-NEXT: unsigned long long *PULL; +// CHECK-NEXT: float *PF; +// CHECK-NEXT: double *PD; +// CHECK-NEXT: double *PLD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Union +// CHECK-NEXT: union Union { +// CHECK-NEXT: const bool *PB; +// CHECK-NEXT: const char *PC; +// CHECK-NEXT: const signed char *PSC; +// CHECK-NEXT: const unsigned char *PUC; +// CHECK-NEXT: const char16_t *PC16; +// CHECK-NEXT: const char32_t *PC32; +// CHECK-NEXT: const wchar_t *PWC; +// CHECK-NEXT: const short *PS; +// CHECK-NEXT: const unsigned short *PUS; +// CHECK-NEXT: const int *PI; +// CHECK-NEXT: const unsigned int *PUI; +// CHECK-NEXT: const long *PL; +// CHECK-NEXT: const unsigned long *PUL; +// CHECK-NEXT: const long long *PLL; +// CHECK-NEXT: const unsigned long long *PULL; +// CHECK-NEXT: const float *PF; +// CHECK-NEXT: const double *PD; +// CHECK-NEXT: const double *PLD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Derived +// CHECK-NEXT: class Derived : public Class { +// CHECK: Derived &Reference; +// CHECK-NEXT: OneMember Member; +// CHECK-NEXT: const OneMember ConstMember; +// CHECK-NEXT: volatile OneMember VolatileMember; +// CHECK-NEXT: const volatile OneMember CVMember; +// CHECK-NEXT: OneMember *PtrMember; +// CHECK-NEXT: OneMember &RefMember; +// CHECK-NEXT: OneMember &&RValueRefMember; +// CHECK: } +// CHECK-NEXT: (lldb) type lookup -- Derived2 +// CHECK-NEXT: class Derived2 : protected Class, private Struct { +// CHECK-NEXT: static unsigned int StaticDataMember; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- DerivedVirtual1 +// CHECK-NEXT: class DerivedVirtual1 : virtual public Class { +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- DerivedVirtual2 +// CHECK-NEXT: class DerivedVirtual2 : public DerivedVirtual1, virtual public Class, virtual public OneMember { +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- EnumInt +// CHECK-NEXT: enum EnumInt { +// CHECK-NEXT: A, +// CHECK-NEXT: B +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- EnumShort +// CHECK-NEXT: enum EnumShort { +// CHECK-NEXT: ES_A, +// CHECK-NEXT: ES_B +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- InvalidType +// CHECK-NEXT: no type was found matching 'InvalidType' diff --git a/lldb/test/Shell/SymbolFile/NativePDB/typedefs.cpp b/lldb/test/Shell/SymbolFile/NativePDB/typedefs.cpp new file mode 100644 index 00000000000..e303a4f4363 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/typedefs.cpp @@ -0,0 +1,71 @@ +// clang-format off + +// REQUIRES: system-windows +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck %s + +namespace A { + namespace B { + using NamespaceTypedef = double; + } + template<typename T> + class C { + public: + using ClassTypedef = T; + }; + using ClassTypedef = C<char>::ClassTypedef; + using ClassTypedef2 = C<wchar_t>::ClassTypedef; + + template<typename T> + using AliasTemplate = typename C<T>::ClassTypedef; +} + +namespace { + using AnonNamespaceTypedef = bool; +} + +using IntTypedef = int; + +using ULongArrayTypedef = unsigned long[10]; + +using RefTypedef = long double*&; + +using FuncPtrTypedef = long long(*)(int&, unsigned char**, short[], const double, volatile bool); + +using VarArgsFuncTypedef = char(*)(void*, long, unsigned short, unsigned int, ...); + +using VarArgsFuncTypedefA = float(*)(...); + +int main(int argc, char **argv) { + long double *Ptr; + + A::B::NamespaceTypedef *X0; + A::C<char>::ClassTypedef *X1; + A::C<wchar_t>::ClassTypedef *X2; + AnonNamespaceTypedef *X3; + IntTypedef *X4; + ULongArrayTypedef *X5; + RefTypedef X6 = Ptr; + FuncPtrTypedef X7; + VarArgsFuncTypedef X8; + VarArgsFuncTypedefA X9; + A::AliasTemplate<float> X10; + return 0; +} + + +// CHECK: namespace { +// CHECK-NEXT: typedef bool AnonNamespaceTypedef; +// CHECK-NEXT: } +// CHECK-NEXT: typedef unsigned long ULongArrayTypedef[10]; +// CHECK-NEXT: typedef double *&RefTypedef; +// CHECK-NEXT: namespace A { +// CHECK-NEXT: namespace B { +// CHECK-NEXT: typedef double NamespaceTypedef; +// CHECK-NEXT: } +// CHECK-NEXT: typedef float AliasTemplate<float>; +// CHECK-NEXT: } +// CHECK-NEXT: typedef long long (*FuncPtrTypedef)(int &, unsigned char **, short *, const double, volatile bool); +// CHECK-NEXT: typedef char (*VarArgsFuncTypedef)(void *, long, unsigned short, unsigned int, ...); +// CHECK-NEXT: typedef float (*VarArgsFuncTypedefA)(...); +// CHECK-NEXT: typedef int IntTypedef; diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp new file mode 100644 index 00000000000..8c9e26744d5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp @@ -0,0 +1,55 @@ +namespace N0 { +namespace N1 { + +namespace { +enum Enum { Enum_0 = 1, Enum_1 = 2, Enum_2 = 4, Enum_3 = 8 }; +} + +Enum Global = Enum_3; + +struct Base { + Enum m_e = Enum_1; +}; + +class Class : public Base { +public: + Class(Enum e) : m_ce(e) {} + + static int StaticFunc(const Class &c) { + return c.PrivateFunc(c.m_inner) + Global + ClassStatic; + } + + const Enum m_ce; + + static int ClassStatic; + +private: + struct Inner { + char x; + short y; + int z; + }; + + int PrivateFunc(const Inner &i) const { return i.z; } + + Inner m_inner{}; +}; +int Class::ClassStatic = 7; + +template<typename T> +struct Template { + template<Enum E> + void TemplateFunc() { + T::StaticFunc(T(E)); + } +}; + +void foo() { Template<Class>().TemplateFunc<Enum_0>(); } + +} // namespace N1 +} // namespace N0 + +int main() { + N0::N1::foo(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp new file mode 100644 index 00000000000..60854c04c60 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp @@ -0,0 +1,20 @@ +int FuncCCall() { return 0; } +auto FuncCCallPtr = &FuncCCall; + +int __stdcall FuncStdCall() { return 0; } +auto FuncStdCallPtr = &FuncStdCall; + +int __fastcall FuncFastCall() { return 0; } +auto FuncFastCallPtr = &FuncFastCall; + +int __vectorcall FuncVectorCall() { return 0; } +auto FuncVectorCallPtr = &FuncVectorCall; + +struct S { + int FuncThisCall() { return 0; } +}; +auto FuncThisCallPtr = &S::FuncThisCall; + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp new file mode 100644 index 00000000000..3c4b005cdf1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp @@ -0,0 +1,111 @@ +// To avoid linking MSVC specific libs, we don't test virtual/override methods +// that needs vftable support in this file. + +// Enum. +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +// Union. +union Union { + short Row; + unsigned short Col; + int Line : 16; // Test named bitfield. + short : 8; // Unnamed bitfield symbol won't be generated in PDB. + long Table; +}; +Union UnionVar; + +// Struct. +struct Struct; +typedef Struct StructTypedef; + +struct Struct { + bool A; + unsigned char UCharVar; + unsigned int UIntVar; + long long LongLongVar; + Enum EnumVar; // Test struct has UDT member. + int array[10]; +}; +struct Struct StructVar; + +struct _List; // Forward declaration. +struct Complex { + struct _List *array[90]; + struct { // Test unnamed struct. MSVC treats it as `int x` + int x; + }; + union { // Test unnamed union. MSVC treats it as `int a; float b;` + int a; + float b; + }; +}; +struct Complex c; + +struct _List { // Test doubly linked list. + struct _List *current; + struct _List *previous; + struct _List *next; +}; +struct _List ListVar; + +typedef struct { + int a; +} UnnamedStruct; // Test unnamed typedef-ed struct. +UnnamedStruct UnnanmedVar; + +// Class. +namespace MemberTest { +class Base { +public: + Base() {} + ~Base() {} + +public: + int Get() { return 0; } + +protected: + int a; +}; +class Friend { +public: + int f() { return 3; } +}; +class Class : public Base { // Test base class. + friend Friend; + static int m_static; // Test static member variable. +public: + Class() : m_public(), m_private(), m_protected() {} + explicit Class(int a) { m_public = a; } // Test first reference of m_public. + ~Class() {} + + static int StaticMemberFunc(int a, ...) { + return 1; + } // Test static member function. + int Get() { return 1; } + int f(Friend c) { return c.f(); } + inline bool operator==(const Class &rhs) const // Test operator. + { + return (m_public == rhs.m_public); + } + +public: + int m_public; + struct Struct m_struct; + +private: + Union m_union; + int m_private; + +protected: + friend class Friend; + int m_protected; +}; +} // namespace MemberTest + +int main() { + MemberTest::Base B1; + B1.Get(); + MemberTest::Class::StaticMemberFunc(1, 10, 2); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp new file mode 100644 index 00000000000..4cce7f667ff --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp new file mode 100644 index 00000000000..3785cd3c64c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp @@ -0,0 +1,20 @@ +namespace N0 { +namespace N1 { + +char *buf0 = nullptr; +char buf1[] = {0, 1, 2, 3, 4, 5, 6, 7}; + +char sum(char *buf, int size) { + char result = 0; + for (int i = 0; i < size; i++) + result += buf[i]; + return result; +} + +} // namespace N1 +} // namespace N0 + +int main() { + char result = N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script new file mode 100644 index 00000000000..d31a2abb68a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script @@ -0,0 +1,7 @@ +breakpoint set --file ExpressionsTest.cpp --line 19 +run +print result +print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +print N1::sum(N1::buf1, sizeof(N1::buf1)) +print sum(buf1, sizeof(buf1)) +print sum(buf1, 1000000000) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script new file mode 100644 index 00000000000..dac887faa5b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script @@ -0,0 +1 @@ +print sum(buf0, 1) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script new file mode 100644 index 00000000000..b19240baf99 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script @@ -0,0 +1,2 @@ +print sum(buf0, result - 28) +print sum(buf1 + 3, 3) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp new file mode 100644 index 00000000000..ccccf6ffd10 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp @@ -0,0 +1,16 @@ +// Static function +namespace { +static long StaticFunction(int a) +{ + return 2; +} +} + +// Inlined function +static inline int InlinedFunction(long a) { return 10; } + +void FunctionCall() +{ + StaticFunction(1); + InlinedFunction(1); +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp new file mode 100644 index 00000000000..17eeab7117b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp @@ -0,0 +1,59 @@ + +// Global functions +int Func_arg_array(int array[]) { return 1; } +void Func_arg_void(void) { return; } +void Func_arg_none(void) { return; } +void Func_varargs(...) { return; } + +// Class +namespace MemberTest { + class A { + public: + int Func(int a, ...) { return 1; } + }; +} + +// Template +template <int N=1, class ...T> +void TemplateFunc(T ...Arg) { + return; +} + +// namespace +namespace { + void Func(int a, const long b, volatile bool c, ...) { return; } +} + +namespace NS { + void Func(char a, int b) { + return; + } +} + +// Static function +static long StaticFunction(int a) +{ + return 2; +} + +// Inlined function +inline void InlinedFunction(long a) { return; } + +extern void FunctionCall(); + +int main() { + MemberTest::A v1; + v1.Func('a',10); + + Func(1, 5, true, 10, 8); + NS::Func('c', 2); + + TemplateFunc(10); + TemplateFunc(10,11,88); + + StaticFunction(2); + InlinedFunction(1); + + FunctionCall(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp new file mode 100644 index 00000000000..fa0030bacbf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp @@ -0,0 +1,9 @@ +#include "FunctionLevelLinkingTest.h" + +int foo() { + return 0; +} + +int main() { + return foo() + bar() + baz(); +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h new file mode 100644 index 00000000000..0cc9d80d85d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h @@ -0,0 +1,12 @@ +#ifndef FUNCTION_LEVEL_LINKING_TEST_H +#define FUNCTION_LEVEL_LINKING_TEST_H + +int bar() { + return 0; +} + +int baz() { + return 0; +} + +#endif diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord new file mode 100644 index 00000000000..48abd0b872f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord @@ -0,0 +1,4 @@ +?foo@@YAHXZ +?bar@@YAHXZ +main +?baz@@YAHXZ diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp new file mode 100644 index 00000000000..62e201df5fe --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp @@ -0,0 +1,8 @@ +int main() { + auto r = 0; + for (auto i = 1; i <= 10; i++) { + r += i & 1 + (i - 1) & 1 - 1; + } + + return r; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp new file mode 100644 index 00000000000..6612c30f00d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp @@ -0,0 +1,23 @@ +int main() { + // Test pointer to array. + int array[2][4]; + int(*array_pointer)[2][4] = &array; + + struct ST { + int a; + int f(int x) { return 1; } + }; + + ST s = {10}; + + // Test pointer to a local. + int *p_int = &s.a; + + // Test pointer to data member. + int ST::*p_member_field = &ST::a; + + // Test pointer to member function. + int (ST::*p_member_method)(int) = &ST::f; + + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp new file mode 100644 index 00000000000..de13a5b430c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp @@ -0,0 +1,52 @@ +// typedef +typedef unsigned long ULongArrayTypedef[10]; +ULongArrayTypedef ULongArrayVar; + +typedef long double*& RefTypedef; +long double* LongDoublePtrVar = 0; +RefTypedef RefVar = LongDoublePtrVar; + +typedef long long (*FuncPtrTypedef)(int&, unsigned char**, short[], const double, volatile bool); +FuncPtrTypedef FuncVar; + +typedef char (*VarArgsFuncTypedef)(void*, long, unsigned short, unsigned int, ...); +VarArgsFuncTypedef VarArgsFuncVar; + +typedef float (*VarArgsFuncTypedefA)(...); +VarArgsFuncTypedefA VarArgsFuncVarA; + +// unscoped enum +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +enum EnumConst { LOW, NORMAL = 10, HIGH }; +EnumConst EnumConstVar; + +enum EnumEmpty {}; +EnumEmpty EnumEmptyVar; + +enum EnumUChar : unsigned char { ON, OFF, AUTO }; +EnumUChar EnumCharVar; + +// scoped enum +enum class EnumClass { YES, NO, DEFAULT }; +EnumClass EnumClassVar; + +enum struct EnumStruct { red, blue, black }; +EnumStruct EnumStructVar; + +typedef signed char SCharTypedef; +SCharTypedef SCVar; + +typedef char16_t WChar16Typedef; +WChar16Typedef WC16Var; + +typedef char32_t WChar32Typedef; +WChar32Typedef WC32Var; + +typedef wchar_t WCharTypedef; +WCharTypedef WCVar; + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp new file mode 100644 index 00000000000..bedafcdacfc --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp @@ -0,0 +1,46 @@ +// Rank > 0 array +typedef volatile int* RankNArray[10][100]; +RankNArray ArrayVar; + +typedef int __unaligned *UnalignedTypedef; +UnalignedTypedef UnVar; + +typedef long* __restrict RestrictTypedef; +RestrictTypedef RestrictVar; + +void Func1(const int* a, int const* b, const int ** const c, const int* const* d) { + return; +} + +void Func2(volatile int* a, int volatile* b) { + return; +} + +void Func3(int*& a, int& b, const int&c, int&& d) { + return; +} + +void Func4(int* __unaligned a, __unaligned int* b) { + return; +} + +void Func5(int a, int* __restrict b, int& __restrict c) { + return; +} + +void Func6(const volatile int* __restrict b) { + return; +} + +// LValue +typedef int& IntRef; +int x = 0; +IntRef IVar = x; + +// RValue +typedef int&& IIRef; +IIRef IIVar = int(1); + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp new file mode 100644 index 00000000000..59a4fc585d7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp @@ -0,0 +1,61 @@ +struct A { + explicit A(int u) { _u._u3 = u; } + A(const A &) = default; + virtual ~A() = default; + +private: + union U { + char _u1; + short _u2; + int _u3; + }; + + A::U _u; +}; + +#pragma pack(push, 1) +template <int I> struct B : public virtual A { + B(char a, unsigned short b, int c) : A(a + b + c), _a(a), _b(b), _c(c) {} + +private: + char _a; + unsigned short : 3; + unsigned short _b : 6; + unsigned short : 4; + int _c; +}; +#pragma pack(pop) + +#pragma pack(push, 16) +class C : private virtual B<0>, public virtual B<1>, private B<2>, public B<3> { +public: + C(char x, char y, char z) + : A(x - y + z), B<0>(x, y, z), B<1>(x * 2, y * 2, z * 2), + B<2>(x * 3, y * 3, z * 3), B<3>(x * 4, y * 4, z * 4), _x(x * 5), + _y(y * 5), _z(z * 5) {} + + static int abc; + +private: + int _x; + short _y; + char _z; +}; +int C::abc = 123; +#pragma pack(pop) + +class List { +public: + List() = default; + List(List *p, List *n, C v) : Prev(p), Next(n), Value(v) {} + +private: + List *Prev = nullptr; + List *Next = nullptr; + C Value{1, 2, 3}; +}; + +int main() { + List ls[16]; + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script new file mode 100644 index 00000000000..91de55f4ade --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script @@ -0,0 +1,4 @@ +breakpoint set --file UdtLayoutTest.cpp --line 60 +run +target variable +frame variable diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp new file mode 100644 index 00000000000..a5e84bd3657 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp @@ -0,0 +1,16 @@ +struct A { + char a = 1; +}; + +struct B { + int b = 2; +}; + +struct C : virtual A, virtual B { + short c = 3; +}; + +int main() { + C c{}; + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script new file mode 100644 index 00000000000..8675890b76e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script @@ -0,0 +1,7 @@ +breakpoint set --file VBases.cpp --line 15 + +run + +print c + +frame variable c
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp new file mode 100644 index 00000000000..7b7180a3ec4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp @@ -0,0 +1,26 @@ +int g_var = 2222; + +void __fastcall foo(short arg_0, float arg_1) { + char loc_0 = 'x'; + double loc_1 = 0.5678; +} + +__declspec(align(128)) struct S { + int a = 1234; +}; + +void bar(int arg_0) { + S loc_0; + int loc_1 = 5678; +} + + +int main(int argc, char *argv[]) { + bool loc_0 = true; + int loc_1 = 3333; + + foo(1111, 0.1234); + bar(22); + + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script new file mode 100644 index 00000000000..7dd90352cce --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script @@ -0,0 +1,25 @@ +breakpoint set --file VariablesLocationsTest.cpp --line 6 +breakpoint set --file VariablesLocationsTest.cpp --line 15 + +run + +target variable g_var + +frame variable arg_0 +frame variable arg_1 + +frame variable loc_0 +frame variable loc_1 + +frame select 1 + +frame variable loc_0 +frame variable loc_1 + +continue + +frame variable arg_0 + +frame variable loc_0 +frame variable loc_1 + diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp new file mode 100644 index 00000000000..304d9056609 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp @@ -0,0 +1,50 @@ +typedef int IntTypedef; +IntTypedef g_IntVar; // Testing globals. + +typedef enum Enum { // Testing constants. + RED, + GREEN, + BLUE +} EnumTypedef; +EnumTypedef g_EnumVar; // Testing members. + +// FIXME: `sg_IntVar` appears both in global scope's children and compiland's +// children but with different symbol's id. +static int sg_IntVar = -1; // Testing file statics. + +// FIXME: `g_Const` appears both in global scope's children and compiland's +// children but with different symbol's id. +const int g_Const = 0x88; // Testing constant data. +const int *g_pConst = &g_Const; // Avoid optimizing the const away + +thread_local int g_tls = 0; // Testing thread-local storage. + +class Class { + static int m_StaticClassMember; +public: + explicit Class(int a) {} + void Func() {} +}; +int Class::m_StaticClassMember = 10; // Testing static class members. +Class ClassVar(1); + +int f(int var_arg1, int var_arg2) { // Testing parameters. + long same_name_var = -1; + return 1; +} + +int same_name_var = 100; +int main() { + int same_name_var = 0; // Testing locals. + const char local_const = 0x1; + + // FIXME: 'local_CString` is not found through compiland's children. + const char local_CString[] = "abc"; // Testing constant string. + const char *local_pCString = local_CString; // Avoid optimizing the const away + + int a = 10; + a++; + + ClassVar.Func(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/ast-restore.test b/lldb/test/Shell/SymbolFile/PDB/ast-restore.test new file mode 100644 index 00000000000..14ec0d52f2e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/ast-restore.test @@ -0,0 +1,83 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/AstRestoreTest.cpp +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=GLOBAL %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CLASS %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=INNER %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=TEMPLATE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=FOO %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=MAIN %s + +ENUM: Module: {{.*}} +ENUM: namespace N0 { +ENUM: namespace N1 { +ENUM: namespace { +ENUM: enum Enum { +ENUM: Enum_0, +ENUM: Enum_1, +ENUM: Enum_2, +ENUM: Enum_3 +ENUM: }; +ENUM: } +ENUM: } +ENUM: } + +GLOBAL: Module: {{.*}} +GLOBAL: namespace N0 { +GLOBAL: namespace N1 { +GLOBAL: N0::N1::(anonymous namespace)::Enum Global; +GLOBAL: } +GLOBAL: } + +BASE: Module: {{.*}} +BASE: namespace N0 { +BASE: namespace N1 { +BASE: struct Base { +BASE: N0::N1::(anonymous namespace)::Enum m_e; +BASE: }; +BASE: } +BASE: } + +CLASS: Module: {{.*}} +CLASS: namespace N0 { +CLASS: namespace N1 { +CLASS: class Class : public N0::N1::Base { +CLASS-DAG: const N0::N1::(anonymous namespace)::Enum m_ce; +CLASS-DAG: static int ClassStatic; +CLASS-DAG: N0::N1::Class::Inner m_inner; +CLASS-DAG: {{(inline )?}}Class(N0::N1::(anonymous namespace)::Enum); +CLASS-DAG: static {{(inline )?}}int StaticFunc(const N0::N1::Class &); +CLASS-DAG: {{(inline )?}}int PrivateFunc(const N0::N1::Class::Inner &); +CLASS: }; +CLASS: } +CLASS: } + +INNER: Module: {{.*}} +INNER: namespace N0 { +INNER: namespace N1 { +INNER: class Class : public N0::N1::Base { +INNER: struct Inner { +INNER: char x; +INNER: short y; +INNER: int z; +INNER: }; +INNER: }; +INNER: } +INNER: } + +TEMPLATE: Module: {{.*}} +TEMPLATE: struct Template<N0::N1::Class> { +TEMPLATE: inline void TemplateFunc<1>(); +TEMPLATE: }; + +FOO: Module: {{.*}} +FOO: namespace N0 { +FOO: namespace N1 { +FOO: void foo(); +FOO: } +FOO: } + +MAIN: Module: {{.*}} +MAIN: int main(); diff --git a/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test b/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test new file mode 100644 index 00000000000..a85dc65ff04 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test @@ -0,0 +1,10 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe %S/Inputs/CallingConventionsTest.cpp +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s + +CHECK: Module: {{.*}} +CHECK-DAG: int (*FuncCCallPtr)(); +CHECK-DAG: int (*FuncStdCallPtr)() __attribute__((stdcall)); +CHECK-DAG: int (*FuncFastCallPtr)() __attribute__((fastcall)); +CHECK-DAG: int (*FuncVectorCallPtr)() __attribute__((vectorcall)); +CHECK-DAG: int (S::*FuncThisCallPtr)() __attribute__((thiscall)); diff --git a/lldb/test/Shell/SymbolFile/PDB/class-layout.test b/lldb/test/Shell/SymbolFile/PDB/class-layout.test new file mode 100644 index 00000000000..fcd6b610826 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/class-layout.test @@ -0,0 +1,92 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.obj %S/Inputs/ClassLayoutTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.exe %T/ClassLayoutTest.cpp.obj +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNION %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=COMPLEX %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=LIST %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNNAMED-STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=FRIEND %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=CLASS %s + +CHECK: Module [[MOD:.*]] +CHECK: SymbolFile pdb ([[MOD]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\ClassLayoutTest.cpp' + +ENUM: name = "Enum", size = 4, decl = ClassLayoutTest.cpp:5 +ENUM-SAME: enum Enum { +ENUM: RED, +ENUM: GREEN, +ENUM: BLUE +ENUM:} + +UNION: name = "Union", size = 4, decl = ClassLayoutTest.cpp:9 +UNION-SAME: union Union { +UNION: short Row; +UNION: unsigned short Col; +UNION: int Line : 16; +UNION: long Table; +UNION:} + +STRUCT: name = "Struct", size = 64, decl = ClassLayoutTest.cpp:22 +STRUCT-SAME: struct Struct { +STRUCT: bool A; +STRUCT: unsigned char UCharVar; +STRUCT: unsigned int UIntVar; +STRUCT: long long LongLongVar; +STRUCT: Enum EnumVar; +STRUCT: int array[10]; +STRUCT:} + +COMPLEX: name = "Complex", size = 368, decl = ClassLayoutTest.cpp:33 +COMPLEX-SAME: struct Complex { +COMPLEX: _List *array[90]; +COMPLEX: int x; +COMPLEX: int a; +COMPLEX: float b; +COMPLEX:} + +LIST: name = "_List", size = 12, decl = ClassLayoutTest.cpp:45 +LIST-SAME: struct _List { +LIST: _List *current; +LIST: _List *previous; +LIST: _List *next; +LIST:} + +UNNAMED-STRUCT: name = "UnnamedStruct", size = 4, decl = ClassLayoutTest.cpp:52 +UNNAMED-STRUCT-SAME: struct UnnamedStruct { +UNNAMED-STRUCT: int a; +UNNAMED-STRUCT:} + +BASE: name = "Base", size = 4, decl = ClassLayoutTest.cpp:59 +BASE-SAME: class Base { +BASE: int a; +BASE: Base(); +BASE: ~Base(); +BASE: int Get(); +BASE:} + +FRIEND: name = "Friend", size = 1, decl = ClassLayoutTest.cpp:70 +FRIEND-SAME: class Friend { +FRIEND: int f(); +FRIEND: } + +CLASS: name = "Class", size = 88, decl = ClassLayoutTest.cpp:74 +CLASS-SAME: class Class : public MemberTest::Base { +CLASS: static int m_static; +CLASS: int m_public; +CLASS: Struct m_struct; +CLASS: Union m_union; +CLASS: int m_private; +CLASS: int m_protected; +CLASS: Class(); +CLASS: Class(int); +CLASS: ~Class(); +CLASS: static int {{.*}}StaticMemberFunc(int, ...); +CLASS: int Get(); +CLASS: int f(MemberTest::Friend); +CLASS: bool operator==(const MemberTest::Class &) +CLASS:} diff --git a/lldb/test/Shell/SymbolFile/PDB/compilands.test b/lldb/test/Shell/SymbolFile/PDB/compilands.test new file mode 100644 index 00000000000..0bda82ee236 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/compilands.test @@ -0,0 +1,11 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.obj %S/Inputs/CompilandsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.exe %T/CompilandsTest.cpp.obj +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s + +; Link default libraries + +CHECK: Module [[CU:.*]] +CHECK: SymbolFile pdb ([[CU]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\CompilandsTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/enums-layout.test b/lldb/test/Shell/SymbolFile/PDB/enums-layout.test new file mode 100644 index 00000000000..79efb259663 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/enums-layout.test @@ -0,0 +1,45 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.enums.exe %S/Inputs/SimpleTypesTest.cpp +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CONST %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_EMPTY %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_UCHAR %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CLASS %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_STRUCT %s + +; FIXME: PDB does not have information about scoped enumeration (Enum class) so the +; compiler type used is the same as the one for unscoped enumeration. + +ENUM: Type{{.*}} , name = "Enum", size = 4, decl = simpletypestest.cpp:19, compiler_type = {{.*}} enum Enum { +ENUM_NEXT: RED, +ENUM_NEXT: GREEN, +ENUM_NEXT: BLUE +ENUM_NEXT:} + +ENUM_CONST: Type{{.*}} , name = "EnumConst", size = 4, decl = simpletypestest.cpp:22, compiler_type = {{.*}} enum EnumConst { +ENUM_CONST-NEXT: LOW, +ENUM_CONST-NEXT: NORMAL, +ENUM_CONST-NEXT: HIGH +ENUM_CONST-NEXT:} + +ENUM_EMPTY: Type{{.*}} , name = "EnumEmpty", size = 4, decl = simpletypestest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { +ENUM_EMPTY-NEXT:} + +ENUM_UCHAR: Type{{.*}} , name = "EnumUChar", size = 1, decl = simpletypestest.cpp:28, compiler_type = {{.*}} enum EnumUChar { +ENUM_UCHAR-NEXT: ON, +ENUM_UCHAR-NEXT: OFF, +ENUM_UCHAR-NEXT: AUTO +ENUM_UCHAR-NEXT:} + +; Note that `enum EnumClass` is tested instead of `enum class EnumClass` +ENUM_CLASS: Type{{.*}} , name = "EnumClass", size = 4, decl = simpletypestest.cpp:32, compiler_type = {{.*}} enum EnumClass { +ENUM_CLASS-NEXT: YES, +ENUM_CLASS-NEXT: NO, +ENUM_CLASS-NEXT: DEFAULT +ENUM_CLASS-NEXT:} + +ENUM_STRUCT: Type{{.*}} , name = "EnumStruct", size = 4, decl = simpletypestest.cpp:35, compiler_type = {{.*}} enum EnumStruct { +ENUM_STRUCT-NEXT: red, +ENUM_STRUCT-NEXT: blue, +ENUM_STRUCT-NEXT: black +ENUM_STRUCT-NEXT:} diff --git a/lldb/test/Shell/SymbolFile/PDB/expressions.test b/lldb/test/Shell/SymbolFile/PDB/expressions.test new file mode 100644 index 00000000000..49016196117 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/expressions.test @@ -0,0 +1,35 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/ExpressionsTest.cpp +RUN: %lldb -b -s %S/Inputs/ExpressionsTest0.script -s %S/Inputs/ExpressionsTest1.script -s %S/Inputs/ExpressionsTest2.script -- %t.exe 2>&1 | FileCheck %s + +// Check the variable value through `print` +CHECK: (lldb) print result +CHECK: (char) $0 = '\x1c' + +// Call the function just like in the code +CHECK: (lldb) print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +CHECK: (char) $1 = '\x1c' + +// Try the relaxed namespaces search +CHECK: (lldb) print N1::sum(N1::buf1, sizeof(N1::buf1)) +CHECK: (char) $2 = '\x1c' + +// Try the relaxed variables and functions search +CHECK: (lldb) print sum(buf1, sizeof(buf1)) +CHECK: (char) $3 = '\x1c' + +// Make a crash during expression calculation +CHECK: (lldb) print sum(buf1, 1000000000) +CHECK: The process has been returned to the state before expression evaluation. + +// Make one more crash +CHECK: (lldb) print sum(buf0, 1) +CHECK: The process has been returned to the state before expression evaluation. + +// Check if the process state was restored succesfully +CHECK: (lldb) print sum(buf0, result - 28) +CHECK: (char) $4 = '\0' + +// Call the function with arbitrary parameters +CHECK: (lldb) print sum(buf1 + 3, 3) +CHECK: (char) $5 = '\f' diff --git a/lldb/test/Shell/SymbolFile/PDB/func-symbols.test b/lldb/test/Shell/SymbolFile/PDB/func-symbols.test new file mode 100644 index 00000000000..676be1c632b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/func-symbols.test @@ -0,0 +1,46 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%T/FuncSymbolsTest.exe %S/Inputs/FuncSymbolsTestMain.cpp %S/Inputs/FuncSymbols.cpp +RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-ONE %s +RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-TWO %s + +; Link multiple objects +; In this test, We don't check demangled name of a mangled function. + +CHECK-ONE: Module [[MD:.*]] +CHECK-ONE-DAG: SymbolFile pdb ([[MD]]) +CHECK-ONE-DAG: [[TY0:.*]]: Type{[[UID0:.*]]} , name = "Func_arg_array", decl = FuncSymbolsTestMain.cpp:3, compiler_type = {{.*}} int (int *) +CHECK-ONE-DAG: [[TY1:.*]]: Type{[[UID1:.*]]} , name = "Func_arg_void", decl = FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY2:.*]]: Type{[[UID2:.*]]} , name = "Func_arg_none", decl = FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY3:.*]]: Type{[[UID3:.*]]} , name = "Func_varargs", decl = FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...) +CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (char, int) +CHECK-ONE-DAG: [[TY5:.*]]: Type{[[UID5:.*]]} , name = "main", decl = FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void) +CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) +CHECK-ONE-DAG: [[TY7:.*]]: Type{[[UID7:.*]]} , name = "StaticFunction", decl = FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int) +CHECK-ONE-DAG: [[TY8:.*]]: Type{[[UID8:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:12, compiler_type = {{.*}} int (int, ...) +CHECK-ONE-DAG: [[TY9:.*]]: Type{[[UID9:.*]]} , name = "TemplateFunc<1,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int) +CHECK-ONE-DAG: [[TY10:.*]]: Type{[[UID10:.*]]} , name = "TemplateFunc<1,int,int,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int, int, int) +CHECK-ONE-DAG: [[TY11:.*]]: Type{[[UID11:.*]]} , name = "InlinedFunction", decl = FuncSymbolsTestMain.cpp:40, compiler_type = {{.*}} void (long) + +CHECK-ONE: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp' +CHECK-ONE-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]] +CHECK-ONE-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]] +CHECK-ONE-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]] +CHECK-ONE-DAG: Function{[[UID3]]}, mangled = ?Func_varargs@@YAXZZ, demangled = {{.*}}, type = [[TY3]] +CHECK-ONE-DAG: Function{[[UID4]]}, mangled = ?Func@NS@@YAXDH@Z, demangled = {{.*}}, type = [[TY4]] +CHECK-ONE-DAG: Function{[[UID5]]}, mangled = _main, demangled = {{.*}}, type = [[TY5]] +CHECK-ONE-DAG: Function{[[UID6]]}, demangled = {{.*}}`anonymous namespace'::Func{{.*}}, type = [[TY6]] +CHECK-ONE-DAG: Function{[[UID7]]}, demangled = {{.*}}StaticFunction{{.*}}, type = [[TY7]] +CHECK-ONE-DAG: Function{[[UID8]]}, mangled = ?Func@A@MemberTest@@QAAHHZZ, demangled = {{.*}}, type = [[TY8]] +CHECK-ONE-DAG: Function{[[UID9]]}, mangled = ??$TemplateFunc@$00H@@YAXH@Z, demangled = {{.*}}, type = [[TY9]] +CHECK-ONE-DAG: Function{[[UID10]]}, mangled = ??$TemplateFunc@$00HHH@@YAXHHH@Z, demangled = {{.*}}, type = [[TY10]] +CHECK-ONE-DAG: Function{[[UID11]]}, mangled = ?InlinedFunction@@YAXJ@Z, demangled = {{.*}}, type = [[TY11]] + +; We expect new types observed in another compile unit +CHECK-TWO-DAG: [[TY30:.*]]: Type{[[UID30:.*]]} , name = "FunctionCall", decl = FuncSymbols.cpp:13, compiler_type = {{.*}} void (void) +CHECK-TWO-DAG: [[TY31:.*]]: Type{[[UID31:.*]]} , name = "StaticFunction", decl = FuncSymbols.cpp:4, compiler_type = {{.*}} long (int) +CHECK-TWO-DAG: [[TY32:.*]]: Type{[[UID32:.*]]} , name = "InlinedFunction", decl = FuncSymbols.cpp:10, compiler_type = {{.*}} int (long) + +CHECK-TWO: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp' +CHECK-TWO-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]] +CHECK-TWO-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]] +CHECK-TWO-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]] diff --git a/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test b/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test new file mode 100644 index 00000000000..37b2cbc761b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test @@ -0,0 +1,5 @@ +REQUIRES: system-windows, lld +RUN: %clang_cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj +RUN: lld-link /debug:full /nodefaultlib /entry:main /order:@%S/Inputs/FunctionLevelLinkingTest.ord %t.obj /out:%t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -verify %t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -verify %t.exe diff --git a/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test new file mode 100644 index 00000000000..9057d01c258 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test @@ -0,0 +1,11 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --nodefaultlib --output=%t.exe %S/Inputs/FunctionNestedBlockTest.cpp +RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s +RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s + +CHECK-FUNCTION: Found 1 functions: +CHECK-FUNCTION: name = "{{.*}}", mangled = "{{_?}}main" + +CHECK-BLOCK: Found 1 blocks: +CHECK-BLOCK: Blocks: id = {{.*}}, range = {{.*}} +CHECK-BLOCK: id = {{.*}}, range = {{.*}} diff --git a/lldb/test/Shell/SymbolFile/PDB/pointers.test b/lldb/test/Shell/SymbolFile/PDB/pointers.test new file mode 100644 index 00000000000..a8f84f14783 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/pointers.test @@ -0,0 +1,38 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST-F %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=F %s + +CHECK: Module [[MOD:.*]] +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\PointerTypeTest.cpp' + +MAIN-ST-F: name = "f" +MAIN-ST-F-SAME: decl = PointerTypeTest.cpp:8 +MAIN-ST-F-SAME: compiler_type = {{.*}} int (int) + +MAIN-ST: name = "ST", size = 4, decl = PointerTypeTest.cpp:6, compiler_type = {{.*}} struct ST { +MAIN-ST-NEXT: int a; +MAIN-ST-NEXT: int {{.*}}f(int); +MAIN-ST-NEXT:} + +MAIN: Function{[[FID1:.*]]}, mangled = _main +MAIN-NEXT: Block{[[FID1]]} +MAIN: Variable{{.*}}, name = "array_pointer" +MAIN-SAME: (int (*)[2][4]), scope = local +MAIN: Variable{{.*}}, name = "p_int" +MAIN-SAME: (int *), scope = local +MAIN: Variable{{.*}}, name = "p_member_field" +MAIN-SAME: (int ST::*), scope = local +MAIN: Variable{{.*}}, name = "p_member_method" +MAIN-SAME: (int (ST::*)(int) __attribute__((thiscall))), scope = local + +F: Function{[[FID2:.*]]}, demangled = {{.*}}f(int) +F-NEXT: Block{[[FID2]]} +F: Variable{{.*}}, name = "this" +F-SAME: (ST *), scope = parameter, location = {{.*}}, artificial +F: Variable{{.*}}, name = "x" +F-SAME: (int), scope = parameter, decl = PointerTypeTest.cpp:8 diff --git a/lldb/test/Shell/SymbolFile/PDB/type-quals.test b/lldb/test/Shell/SymbolFile/PDB/type-quals.test new file mode 100644 index 00000000000..cf65c79223b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/type-quals.test @@ -0,0 +1,39 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.obj %S/Inputs/TypeQualsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.exe %T/TypeQualsTest.cpp.obj +RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s + +CHECK: Module [[MOD:.*]] +CHECK-DAG: SymbolFile pdb ([[MOD]]) +CHECK-DAG: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * +CHECK-DAG: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * +CHECK-DAG: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int && +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & +CHECK-DAG: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) + +// FIXME: __unaligned is not supported. +CHECK-DAG: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict +CHECK-DAG: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) + +CHECK-DAG: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) + +CHECK-DAG: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] +CHECK-DAG: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\TypeQualsTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/typedefs.test b/lldb/test/Shell/SymbolFile/PDB/typedefs.test new file mode 100644 index 00000000000..5f70d878230 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/typedefs.test @@ -0,0 +1,59 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.typedefs.exe %S/Inputs/SimpleTypesTest.cpp +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s + +; Generate 32-bit target + +; FIXME: PDB does not have line information for typedef statements so source +; and line information for them is not tested. + +; Note, types `long double` and `double` have same bit size in MSVC and there +; is no information in the PDB to distinguish them. So the compiler type for +; both of them is the same. + +CHECK: Module [[MOD:.*]] +CHECK: SymbolFile pdb ([[MOD]]) +CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t +CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t +CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = {{.*}} unsigned long +CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10] +CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} typedef ULongArrayTypedef + +; Note: compiler_type of `long double` is represented by the one for `double` +CHECK-DAG: Type{{.*}} , name = "double", size = 8, compiler_type = {{.*}} double +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *& +CHECK-DAG: Type{{.*}} , name = "RefTypedef", compiler_type = {{.*}} typedef RefTypedef + +CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = {{.*}} wchar_t + +CHECK-DAG: Type{{.*}} , name = "int", size = 4, compiler_type = {{.*}} int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = {{.*}} unsigned char +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char ** +CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = {{.*}} short +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} short * +CHECK-DAG: Type{{.*}} , name = "const double", size = 8, compiler_type = {{.*}} const double +CHECK-DAG: Type{{.*}} , name = "volatile bool", size = 1, compiler_type = {{.*}} volatile _Bool +CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = {{.*}} long long +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} long long (int &, unsigned char **, short *, const double, volatile _Bool) +CHECK-DAG: Type{{.*}} , name = "FuncPtrTypedef", compiler_type = {{.*}} typedef FuncPtrTypedef + +CHECK-DAG: Type{{.*}} , name = "void", compiler_type = {{.*}} void +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void * +CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long +CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = {{.*}} unsigned short +CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = {{.*}} unsigned int +CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char +CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} signed char +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} typedef VarArgsFuncTypedef + +CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} float (...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} float (*)(...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedefA", compiler_type = {{.*}} typedef VarArgsFuncTypedefA + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test new file mode 100644 index 00000000000..726f633efe5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test @@ -0,0 +1,51 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp +RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s + +CHECK:(int) int C::abc = 123 +CHECK:(List [16]) ls = { +CHECK: [15] = { +CHECK: Prev = 0x00000000 +CHECK: Next = 0x00000000 +CHECK: Value = { +CHECK: B<0> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x01' +CHECK: _b = 2 +CHECK: _c = 3 +CHECK: } +CHECK: B<1> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x02' +CHECK: _b = 4 +CHECK: _c = 6 +CHECK: } +CHECK: B<2> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x03' +CHECK: _b = 6 +CHECK: _c = 9 +CHECK: } +CHECK: B<3> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x04' +CHECK: _b = 8 +CHECK: _c = 12 +CHECK: } +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _x = 5 +CHECK: _y = 10 +CHECK: _z = '\x0f' +CHECK: } +CHECK: } +CHECK:} diff --git a/lldb/test/Shell/SymbolFile/PDB/variables-locations.test b/lldb/test/Shell/SymbolFile/PDB/variables-locations.test new file mode 100644 index 00000000000..b5bfc6fe81a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/variables-locations.test @@ -0,0 +1,20 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VariablesLocationsTest.cpp +RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s +RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s + +CHECK: g_var = 2222 + +CHECK: arg_0 = 1111 +CHECK: arg_1 = 0.123 + +CHECK: loc_0 = 'x' +CHECK: loc_1 = 0.567 + +CHECK: loc_0 = true +CHECK: loc_1 = 3333 + +CHECK: arg_0 = 22 + +CHECK: loc_0 = (a = 1234) +CHECK: loc_1 = 5678 diff --git a/lldb/test/Shell/SymbolFile/PDB/variables.test b/lldb/test/Shell/SymbolFile/PDB/variables.test new file mode 100644 index 00000000000..ae14f02754c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/variables.test @@ -0,0 +1,66 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.obj %S/Inputs/VariablesTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.exe %T/VariablesTest.cpp.obj +RUN: lldb-test symbols %T/VariablesTest.cpp.exe > %T/VariablesTest.out +RUN: FileCheck --check-prefix=GLOBALS --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-F --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MAIN --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-CONSTRUCTOR --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MEMBER --input-file=%T/VariablesTest.out %s + +GLOBALS: Module [[MOD:.*]] +GLOBALS: SymbolFile pdb ([[MOD]]) +GLOBALS: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\VariablesTest.cpp' +GLOBALS-DAG: Variable{{.*}}, name = "g_IntVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "m_StaticClassMember" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_pConst" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "same_name_var" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_EnumVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_tls" +GLOBALS-SAME: scope = thread local, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "ClassVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_Const" +GLOBALS-SAME: scope = ??? (2) +GLOBALS: Function + +FUNC-F: Function{{.*}}, mangled = ?f@@YAHHH@Z +FUNC-F-NEXT: Block +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg1" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg2" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-F-SAME: scope = local + +FUNC-MAIN: Function{{.*}}, mangled = main +FUNC-MAIN-NEXT: Block +FUNC-MAIN-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_const" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_CString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_pCString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "a" +FUNC-MAIN-SAME: scope = local + +FUNC-CONSTRUCTOR: Function{{.*}}, mangled = ??0Class@@QEAA@H@Z +FUNC-CONSTRUCTOR-NEXT: Block +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "this" +FUNC-CONSTRUCTOR-SAME: scope = parameter +FUNC-CONSTRUCTOR-SAME: artificial +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "a" +FUNC-CONSTRUCTOR-SAME: scope = parameter + +FUNC-MEMBER: Function{{.*}}, mangled = ?Func@Class@@QEAAXXZ +FUNC-MEMBER-NEXT: Block +FUNC-MEMBER-NEXT: Variable{{.*}}, name = "this" +FUNC-MEMBER-SAME: scope = parameter +FUNC-MEMBER-SAME: artificial diff --git a/lldb/test/Shell/SymbolFile/PDB/vbases.test b/lldb/test/Shell/SymbolFile/PDB/vbases.test new file mode 100644 index 00000000000..57239e07c87 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/vbases.test @@ -0,0 +1,15 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VBases.cpp +RUN: %lldb -b -s %S/Inputs/VBases.script -- %t.exe | FileCheck %s + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } diff --git a/lldb/test/Shell/SymbolFile/dissassemble-entry-point.s b/lldb/test/Shell/SymbolFile/dissassemble-entry-point.s new file mode 100644 index 00000000000..c8059990237 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/dissassemble-entry-point.s @@ -0,0 +1,13 @@ +# REQUIRES: lld, arm + +# RUN: llvm-mc -triple=thumbv7-eabi %s -filetype=obj -o %t.o +# RUN: ld.lld %t.o -o %t --section-start=.text=0x8074 -e 0x8075 -s +# RUN: %lldb -x -b -o 'dis -s 0x8074 -e 0x8080' -- %t | FileCheck %s +# CHECK: {{.*}}[0x8074] <+0>: movs r0, #0x2a +# CHECK-NEXT: {{.*}}[0x8076] <+2>: movs r7, #0x1 +# CHECK-NEXT: {{.*}}[0x8078] <+4>: svc #0x0 + +_start: + movs r0, #0x2a + movs r7, #0x1 + svc #0x0
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/sizeless-symbol.test b/lldb/test/Shell/SymbolFile/sizeless-symbol.test new file mode 100644 index 00000000000..1459d6ada8d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/sizeless-symbol.test @@ -0,0 +1,14 @@ +# Some targets do not have the .size directive. +# RUN: %clang -target x86_64-unknown-unknown-elf %S/Inputs/sizeless-symbol.s -c -o %t.o +# RUN: %lldb %t.o -s %s -o quit | FileCheck %s + +image lookup --address 1 +# CHECK: Summary: sizeless-symbol.test.tmp.o`sizeful +image lookup --address 2 +# CHECK: Summary: sizeless-symbol.test.tmp.o`sizeful + 1 +image dump symtab +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK-NEXT:------- ------ --- --------------- ------------------ ------------------ ------------------ ---------- ---------------------------------- +# CHECK-NEXT:[ 0] 1 Code 0x0000000000000003 0x0000000000000000 0x00000000 sizeend +# CHECK-NEXT:[ 1] 2 Code 0x0000000000000001 0x0000000000000002 0x00000000 sizeful +# CHECK-NEXT:[ 2] 3 Code 0x0000000000000001 0x0000000000000000 0x00000000 sizeless diff --git a/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test new file mode 100644 index 00000000000..c6542134fcf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test @@ -0,0 +1,26 @@ +# TODO: When it's possible to run "image show-unwind" without a running +# process, we can remove the unsupported line below, and hard-code an ELF +# triple in the test. +# UNSUPPORTED: system-windows, system-darwin + +# RUN: cd %T +# RUN: %clang %S/Inputs/target-symbols-add-unwind.c -g \ +# RUN: -fno-unwind-tables -o target-symbols-add-unwind.debug +# RUN: llvm-objcopy --strip-debug target-symbols-add-unwind.debug \ +# RUN: target-symbols-add-unwind.stripped +# RUN: %lldb target-symbols-add-unwind.stripped -s %s -o quit | FileCheck %s + +process launch --stop-at-entry +image show-unwind -n main +# CHECK-LABEL: image show-unwind -n main +# CHECK-NOT: debug_frame UnwindPlan: + +target symbols add -s target-symbols-add-unwind.stripped target-symbols-add-unwind.debug +# CHECK-LABEL: target symbols add +# CHECK: symbol file {{.*}} has been added to {{.*}} + +image show-unwind -n main +# CHECK-LABEL: image show-unwind -n main +# CHECK: debug_frame UnwindPlan: +# CHECK-NEXT: This UnwindPlan originally sourced from DWARF CFI +# CHECK-NEXT: This UnwindPlan is sourced from the compiler: yes. |