diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 16:38:47 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 16:38:47 +0000 |
| commit | 22314179f0660c172514b397060fd8f34b586e82 (patch) | |
| tree | afb3f04cd285733772ffceec4ccf3d8539dca91c /lldb/test/Shell/SymbolFile/DWARF | |
| parent | df14bd315db94d286c0c75b4b6ee5d760f311399 (diff) | |
| download | bcm5719-llvm-22314179f0660c172514b397060fd8f34b586e82.tar.gz bcm5719-llvm-22314179f0660c172514b397060fd8f34b586e82.zip | |
[test] Split LLDB tests into API, Shell & Unit
LLDB has three major testing strategies: unit tests, tests that exercise
the SB API though dotest.py and what we currently call lit tests. The
later is rather confusing as we're now using lit as the driver for all
three types of tests. As most of this grew organically, the directory
structure in the LLDB repository doesn't really make this clear.
The 'lit' tests are part of the root and among these tests there's a
Unit and Suite folder for the unit and dotest-tests. This layout makes
it impossible to run just the lit tests.
This patch changes the directory layout to match the 3 testing
strategies, each with their own directory and their own configuration
file. This means there are now 3 directories under lit with 3
corresponding targets:
- API (check-lldb-api): Test exercising the SB API.
- Shell (check-lldb-shell): Test exercising command line utilities.
- Unit (check-lldb-unit): Unit tests.
Finally, there's still the `check-lldb` target that runs all three test
suites.
Finally, this also renames the lit folder to `test` to match the LLVM
repository layout.
Differential revision: https://reviews.llvm.org/D68606
llvm-svn: 374184
Diffstat (limited to 'lldb/test/Shell/SymbolFile/DWARF')
53 files changed, 3120 insertions, 0 deletions
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} |

