[llvm] 6c1740f - Add dsymutil dwarf5 tests for darwin
Shubham Sandeep Rastogi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 09:53:29 PDT 2023
Author: Shubham Sandeep Rastogi
Date: 2023-06-15T09:52:18-07:00
New Revision: 6c1740f462809b44ae7a312fc44642d3cb8cea61
URL: https://github.com/llvm/llvm-project/commit/6c1740f462809b44ae7a312fc44642d3cb8cea61
DIFF: https://github.com/llvm/llvm-project/commit/6c1740f462809b44ae7a312fc44642d3cb8cea61.diff
LOG: Add dsymutil dwarf5 tests for darwin
The first test, dwarf5-macho.test checks to make sure that dsymutil
generates the correct headers and sections for a macho binary with
DWARF v5 in it.
The second test, dwarf5-dwarf4-combination-macho.test checks that
dsymutil generates the correct headers and sections for a macho binary
with which was linked with one object file with DWARF v4 and the other
with DWARF v5 in it.
Differential Revision: https://reviews.llvm.org/D151932
Added:
llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test
llvm/test/tools/dsymutil/ARM/dwarf5-macho.test
llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/1.o
llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/2.o
llvm/test/tools/dsymutil/Inputs/DWARF5/1.o
Modified:
llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
Removed:
################################################################################
diff --git a/llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map b/llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
index a23e0c34c3f81..4175649e6d7bf 100644
--- a/llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
+++ b/llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
@@ -11,5 +11,8 @@ objects:
- filename: 1.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }
+ - filename: 2.o
+ symbols:
+ - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x20000, size: 0x10 }
...
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test b/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test
new file mode 100644
index 0000000000000..c0b1af306461d
--- /dev/null
+++ b/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test
@@ -0,0 +1,161 @@
+; This test checks to ensure that if a DWARF v5 and DWARF v4 object file is used to
+; generate a dsym, dsymutil correctly outputs the debug information, by keeping
+; the DWARF v5 and DWARF v4 debug info distinct, and that all the section headers
+; have the correct format.
+
+; 1.o was produced with the source file:
+
+; a.cpp
+; __attribute__((section("1,__text_foo"))) void foo() {}
+;
+; int foo2(int a) {
+; return a+5;
+; }
+; int main () {
+; return 1;
+; }
+
+; clang -g -c -O1 a.cpp -Xclang -gdwarf-5 -o 1.o
+
+; 2.o was produced with the following source file:
+
+; b.cpp
+; __attribute__((section("1,__text_foo2"))) void foo2() {}
+;
+; int bar(int x) {
+; int y = x + 2;
+; return y;
+; }
+
+; clang -g -c -O1 b.cpp -gdwarf-4 -o 2.o
+
+
+RUN: rm -rf %t.dir && mkdir -p %t.dir
+RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM
+RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM -a --verbose | FileCheck %s
+
+
+CHECK:.debug_abbrev contents:
+CHECK-NEXT: Abbrev table for offset: 0x00000000
+
+CHECK: .debug_info contents:
+CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000007d, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000081)
+CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGELIST_OFFSET:[0-9a-f]+]]
+CHECK-NEXT: [0x[[RANGELIST_OFFSET_START:[0-9a-f]+]], 0x[[RANGELIST_OFFSET_END:[0-9a-f]+]]))
+CHECK: 0x00000050: DW_TAG_formal_parameter [3] (0x00000033)
+CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOCLIST_OFFSET:[0-9a-f]+]]:
+CHECK-NEXT: [0x[[LOCLIST_OFFSET_START:[0-9a-f]+]], 0x[[LOCLIST_OFFSET_END:[0-9a-f]+]]): [[LOCLIST_EXPR:.*]]
+CHECK-NEXT: [0x[[LOCLIST_OFFSET_START2:[0-9a-f]+]], 0x[[LOCLIST_OFFSET_END2:[0-9a-f]+]]): [[LOCLIST_EXPR2:.*]])
+
+CHECK: 0x00000081: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000000f7)
+CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000
+CHECK-NEXT: [0x00000000000200[[RANGE_OFFSET_START:[0-9a-f][0-9a-f]]], 0x00000000000200[[RANGE_OFFSET_END:[0-9a-f][0-9a-f]]]))
+CHECK:0x000000d0: DW_TAG_formal_parameter [3] (0x000000b3)
+CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]:
+CHECK-NEXT: [0x00000000000200[[LOC_OFFSET_START:[0-9a-f][0-9a-f]]], 0x00000000000200[[LOC_OFFSET_END:[0-9a-f][0-9a-f]]]): [[LOC_EXPR:.*]]
+CHECK-NEXT: [0x00000000000200[[LOC_OFFSET_START2:[0-9a-f][0-9a-f]]], 0x00000000000200[[LOC_OFFSET_END2:[0-9a-f][0-9a-f]]]): [[LOC_EXPR2:.*]])
+
+CHECK: .debug_loc contents:
+CHECK-NEXT: 0x[[LOC_OFFSET]]:
+CHECK-NEXT: (0x0000000000000000, 0x0000000000000004): [[LOC_EXPR:.*]]
+CHECK-NEXT: (0x0000000000000004, 0x0000000000000008): [[LOC_EXPR2:.*]]
+
+CHECK: .debug_loclists contents:
+CHECK-NEXT: 0x00000000: locations list header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
+CHECK-NEXT: 0x[[LOCLIST_OFFSET]]:
+CHECK-NEXT: DW_LLE_start_length {{.*}}
+CHECK-NEXT: => [0x[[LOCLIST_OFFSET_START]], 0x[[LOCLIST_OFFSET_END]]): [[LOCLIST_EXPR]]
+CHECK-NEXT: DW_LLE_start_length {{.*}}
+CHECK-NEXT: => [0x[[LOCLIST_OFFSET_START2]], 0x[[LOCLIST_OFFSET_END2]]): [[LOCLIST_EXPR2]]
+CHECK-NEXT: DW_LLE_end_of_list ()
+
+CHECK: .debug_line contents:
+CHECK-NEXT: debug_line[0x00000000]
+CHECK-NEXT: Line table prologue:
+CHECK-NEXT: total_length: 0x00000050
+CHECK-NEXT: format: DWARF32
+CHECK-NEXT: version: 5
+CHECK-NEXT: address_size: 8
+CHECK-NEXT: seg_select_size: 0
+CHECK-NEXT: prologue_length: 0x00000025
+CHECK-NEXT: min_inst_length: 1
+CHECK-NEXT: max_ops_per_inst: 1
+CHECK-NEXT: default_is_stmt: 1
+CHECK-NEXT: line_base: -5
+CHECK-NEXT: line_range: 14
+CHECK-NEXT: opcode_base: 13
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1
+CHECK-NEXT: include_directories[ 0] = .debug_line_str[0x00000000] = "/Users/shubham/Development/test109275485"
+CHECK-NEXT: file_names[ 0]:
+CHECK-NEXT: name: .debug_line_str[0x00000029] = "a.cpp"
+CHECK-NEXT: dir_index: 0
+
+CHECK: debug_line[0x00000054]
+CHECK-NEXT: Line table prologue:
+CHECK-NEXT: total_length: 0x0000003b
+CHECK-NEXT: format: DWARF32
+CHECK-NEXT: version: 4
+CHECK-NEXT: prologue_length: 0x0000001d
+CHECK-NEXT: min_inst_length: 1
+CHECK-NEXT: max_ops_per_inst: 1
+CHECK-NEXT: default_is_stmt: 1
+CHECK-NEXT: line_base: -5
+CHECK-NEXT: line_range: 14
+CHECK-NEXT: opcode_base: 13
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1
+CHECK-NEXT: file_names[ 1]:
+CHECK-NEXT: name: "b.cpp"
+CHECK-NEXT: dir_index: 0
+CHECK-NEXT: mod_time: 0x00000000
+CHECK-NEXT: length: 0x00000000
+
+CHECK: .debug_str contents:
+
+CHECK: .debug_line_str contents:
+CHECK-NEXT: 0x00000000: "/Users/shubham/Development/test109275485"
+CHECK-NEXT: 0x00000029: "a.cpp"
+
+CHECK: .debug_ranges contents:
+CHECK-NEXT: 00000000 00000000000000[[RANGE_OFFSET_START]] 00000000000000[[RANGE_OFFSET_END]]
+
+CHECK: .debug_rnglists contents:
+CHECK-NEXT: 0x00000000: range list header: length = 0x00000013, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
+CHECK-NEXT: ranges:
+CHECK-NEXT: [[RANGELIST_OFFSET]]: [DW_RLE_start_length]: {{.*}}[0x[[RANGELIST_OFFSET_START]], 0x[[RANGELIST_OFFSET_END]])
+
+CHECK: .debug_names contents:
+CHECK-NEXT: Name Index @ 0x0 {
+CHECK-NEXT: Header {
+CHECK-NEXT: Length: 0xD4
+CHECK-NEXT: Format: DWARF32
+CHECK-NEXT: Version: 5
+CHECK-NEXT: CU count: 2
+CHECK-NEXT: Local TU count: 0
+CHECK-NEXT: Foreign TU count: 0
+CHECK-NEXT: Bucket count: 6
+CHECK-NEXT: Name count: 6
+CHECK-NEXT: Abbreviations table size: 0x11
+CHECK-NEXT: Augmentation: 'LLVM0700'
+CHECK-NEXT: }
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test b/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test
new file mode 100644
index 0000000000000..0823debc8b552
--- /dev/null
+++ b/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test
@@ -0,0 +1,103 @@
+; This test checks to that DWARF v5 debug info can be correctly linked
+; into a dSYM bundle by dsymutil, with the correct section names and DWARF v5
+; headers for the
diff erent sections.
+
+; 1.o was produced with the source file:
+
+; a.cpp
+; __attribute__((section("1,__text_foo"))) void foo() {}
+;
+; int foo2(int a) {
+; return a+5;
+; }
+; int main () {
+; return 1;
+; }
+
+; clang -g -c -O1 a.cpp -Xclang -gdwarf-5 -o 1.o
+
+
+RUN: rm -rf %t.dir && mkdir -p %t.dir
+RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM
+RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s
+
+CHECK:.debug_abbrev contents:
+CHECK-NEXT: Abbrev table for offset: 0x00000000
+
+CHECK: .debug_info contents:
+CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000007d, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000081)
+CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGE_OFFSET:[0-9a-f]+]]
+CHECK-NEXT: [0x[[RANGE_OFFSET_START:[0-9a-f]+]], 0x[[RANGE_OFFSET_END:[0-9a-f]+]]))
+CHECK: 0x00000050: DW_TAG_formal_parameter [3] (0x00000033)
+CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]:
+CHECK-NEXT: [0x[[LOC_OFFSET_START:[0-9a-f]+]], 0x[[LOC_OFFSET_END:[0-9a-f]+]]): [[LOC_EXPR:.*]]
+CHECK-NEXT: [0x[[LOC_OFFSET_START2:[0-9a-f]+]], 0x[[LOC_OFFSET_END2:[0-9a-f]+]]): [[LOC_EXPR2:.*]])
+
+CHECK: .debug_loclists contents:
+CHECK-NEXT: 0x00000000: locations list header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
+CHECK-NEXT: 0x[[LOC_OFFSET]]:
+CHECK-NEXT: DW_LLE_start_length {{.*}}
+CHECK-NEXT: => [0x[[LOC_OFFSET_START]], 0x[[LOC_OFFSET_END]]): [[LOC_EXPR]]
+CHECK-NEXT: DW_LLE_start_length {{.*}}
+CHECK-NEXT: => [0x[[LOC_OFFSET_START2]], 0x[[LOC_OFFSET_END2]]): [[LOC_EXPR2]]
+CHECK-NEXT: DW_LLE_end_of_list ()
+
+CHECK: .debug_line contents:
+CHECK-NEXT: debug_line[0x00000000]
+CHECK-NEXT: Line table prologue:
+CHECK-NEXT: total_length: 0x00000050
+CHECK-NEXT: format: DWARF32
+CHECK-NEXT: version: 5
+CHECK-NEXT: address_size: 8
+CHECK-NEXT: seg_select_size: 0
+CHECK-NEXT: prologue_length: 0x00000025
+CHECK-NEXT: min_inst_length: 1
+CHECK-NEXT: max_ops_per_inst: 1
+CHECK-NEXT: default_is_stmt: 1
+CHECK-NEXT: line_base: -5
+CHECK-NEXT: line_range: 14
+CHECK-NEXT: opcode_base: 13
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
+CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1
+CHECK-NEXT: include_directories[ 0] = .debug_line_str[0x00000000] = "/Users/shubham/Development/test109275485"
+CHECK-NEXT: file_names[ 0]:
+CHECK-NEXT: name: .debug_line_str[0x00000029] = "a.cpp"
+CHECK-NEXT: dir_index: 0
+
+
+CHECK: .debug_str contents:
+
+CHECK: .debug_line_str contents:
+CHECK-NEXT: 0x00000000: "/Users/shubham/Development/test109275485"
+CHECK-NEXT: 0x00000029: "a.cpp"
+
+CHECK: .debug_rnglists contents:
+CHECK-NEXT: 0x00000000: range list header: length = 0x00000013, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
+CHECK-NEXT: ranges:
+CHECK-NEXT: [[RANGE_OFFSET]]: [DW_RLE_start_length]: {{.*}}[0x[[RANGE_OFFSET_START]], 0x[[RANGE_OFFSET_END]])
+
+CHECK: .debug_names contents:
+CHECK-NEXT: Name Index @ 0x0 {
+CHECK-NEXT: Header {
+CHECK-NEXT: Length: 0x94
+CHECK-NEXT: Format: DWARF32
+CHECK-NEXT: Version: 5
+CHECK-NEXT: CU count: 1
+CHECK-NEXT: Local TU count: 0
+CHECK-NEXT: Foreign TU count: 0
+CHECK-NEXT: Bucket count: 4
+CHECK-NEXT: Name count: 4
+CHECK-NEXT: Abbreviations table size: 0xD
+CHECK-NEXT: Augmentation: 'LLVM0700'
+CHECK-NEXT: }
+
diff --git a/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/1.o b/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/1.o
new file mode 100644
index 0000000000000..117a534b07917
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/1.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/2.o b/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/2.o
new file mode 100644
index 0000000000000..8ff440f260027
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/DWARF5-DWARF4-combination/2.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/DWARF5/1.o b/llvm/test/tools/dsymutil/Inputs/DWARF5/1.o
new file mode 100644
index 0000000000000..117a534b07917
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/DWARF5/1.o
diff er
More information about the llvm-commits
mailing list