From 2b762697564ca1e12e0e974e93ceeb4c3420505c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 5 Dec 2015 03:41:53 +0000 Subject: [PATCH 1/1] [llvm-dwp] Add coverage for both the presence and absence of type units, and fix/remove the emission of a broken tu_index when no type units are present git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254833 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-dwp/Inputs/simple/a.dwo | Bin 0 -> 1193 bytes test/tools/llvm-dwp/Inputs/simple/b.dwo | Bin 0 -> 1241 bytes .../X86/{type_units.test => simple.test} | 58 +++++++++++------- tools/llvm-dwp/llvm-dwp.cpp | 12 ++-- 4 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 test/tools/llvm-dwp/Inputs/simple/a.dwo create mode 100644 test/tools/llvm-dwp/Inputs/simple/b.dwo rename test/tools/llvm-dwp/X86/{type_units.test => simple.test} (54%) diff --git a/test/tools/llvm-dwp/Inputs/simple/a.dwo b/test/tools/llvm-dwp/Inputs/simple/a.dwo new file mode 100644 index 0000000000000000000000000000000000000000..7bdb2a7b9f826e0dfcbafb94b64ef9285b42f4c6 GIT binary patch literal 1193 zcmbtTT}s115T4ytTP=#EFN!Y#5n3N&wTf1;EsBC5;tgtAQ!S=RNqaHDd+~HrgfYZvW8JtxbWTT1RyNqS7Wk=hfB>29j%Xx`; ztjk<&eH3I?6(f32BQ!qp%mZ2`ghABrI>U;t@#a?^&{jhjM7`I?imvhIPce}cC_(S# zbta1nev7=PXgt;DIj34rK*K)(`l2?8$Uoe;;P`O|#`UQC`(i%oJ~8?yuwUDTBP@Dj W+#_lezMoh|yOF`TrpWUre(OK6DqH*j literal 0 HcmV?d00001 diff --git a/test/tools/llvm-dwp/Inputs/simple/b.dwo b/test/tools/llvm-dwp/Inputs/simple/b.dwo new file mode 100644 index 0000000000000000000000000000000000000000..f41243dc722b011d346dccede7fd91268525d578 GIT binary patch literal 1241 zcmbtU%`O8`6h8M(>#rfHT2yRiBf(;{8ll7(f`nLDk=RtHrZmQkOsiOl+FI}gEG>Bo zPayFgmNw4my)(wmBo=OR?m6FgzVkC}r`PM-8=Nr+4+9f^P{;zj#7L`4TQC5#95{n^(LJ-yMq zI&D>L^sPYn<1jjO?DM0F>(`9K3m*&tF{!|cU#~ZvRx?gFyt*I9Rof1ncARk=p3}v+ z!@tiMc8GnIQ9mn+eg~>{3e&_De#^j;cw6Da`p}m#AI5R%odhFsGC{kOz){H)U3g}N zi*9w+0cKQ=#P4+BSrab0Rc(M7l_T+}B(qVa2vjZQHAO>kN(wtlPOT@*6%E0HcuC+{ z=K9gokGD@^@nQfFpEUnN)+f!AE&g;`;wMA%k~StjX%ph*GRi~^(h4J>_#04C-$$xq AOaK4? literal 0 HcmV?d00001 diff --git a/test/tools/llvm-dwp/X86/type_units.test b/test/tools/llvm-dwp/X86/simple.test similarity index 54% rename from test/tools/llvm-dwp/X86/type_units.test rename to test/tools/llvm-dwp/X86/simple.test index c49d60d47bb..962e270a594 100644 --- a/test/tools/llvm-dwp/X86/type_units.test +++ b/test/tools/llvm-dwp/X86/simple.test @@ -1,5 +1,8 @@ +RUN: llvm-dwp %p/../Inputs/simple/a.dwo %p/../Inputs/simple/b.dwo -o %t +RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=NOTYP %s +RUN: llvm-objdump -h %t | FileCheck --check-prefix=NOTYPOBJ %s RUN: llvm-dwp %p/../Inputs/type_units/a.dwo %p/../Inputs/type_units/b.dwo -o %t -RUN: llvm-dwarfdump %t | FileCheck %s +RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=TYPES %s FIXME: For some reason, piping straight from llvm-dwp to llvm-dwarfdump doesn't behave well - looks like dwarfdump is reading/closes before dwp has finished. @@ -28,7 +31,7 @@ CHECK: DW_TAG_formal_parameter CHECK: .debug_info.dwo contents: CHECK: [[AOFF:0x[0-9a-f]*]]: -CHECK-LABEL: Compile Unit: length = 0x00000029 version = 0x0004 abbr_offset = +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = CHECK: 0x[[AAOFF]] addr_size = 0x08 (next unit at [[BOFF:.*]]) CHECK: DW_TAG_compile_unit CHECK: DW_AT_name {{.*}} "a.cpp" @@ -36,42 +39,51 @@ CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOA:.*]]) CHECK: DW_TAG_variable CHECK: DW_AT_name {{.*}} "a" CHECK: DW_TAG_structure_type -CHECK: DW_AT_signature {{.*}} ([[FOOSIG:.*]]) +NOTYP: DW_AT_name {{.*}} "foo" +TYPES: DW_AT_signature {{.*}} ([[FOOSIG:.*]]) CHECK: [[BOFF]]: -CHECK-LABEL: Compile Unit: length = 0x00000035 version = 0x0004 abbr_offset = +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = CHECK: 0x[[BAOFF]] addr_size = 0x08 (next unit at [[XOFF:.*]]) CHECK: DW_AT_name {{.*}} "b.cpp" CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOB:.*]]) CHECK: DW_TAG_structure_type -CHECK: DW_AT_signature {{.*}} ([[BARSIG:.*]]) +NOTYP: DW_AT_name {{.*}} "bar" +TYPES: DW_AT_signature {{.*}} ([[BARSIG:.*]]) CHECK: DW_TAG_subprogram CHECK: DW_AT_name {{.*}} "b" CHECK: DW_TAG_formal_parameter -CHECK-LABEL: .debug_types.dwo contents: -CHECK: [[FOOUOFF:0x[0-9a-f]*]]: -CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = -CHECK: 0x[[AAOFF]] addr_size = 0x08 type_signature = [[FOOSIG]] type_offset = 0x[[FOOOFF:.*]] (next unit at [[BARUOFF:.*]]) -CHECK: DW_TAG_type_unit -CHECK: [[FOOOFF]]: DW_TAG_structure_type -CHECK: DW_AT_name {{.*}} "foo" -CHECK: [[BARUOFF]]: -CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = -CHECK: 0x[[BAOFF]] addr_size = 0x08 type_signature = [[BARSIG]] type_offset = 0x001e (next unit at [[XUOFF:.*]]) -CHECK: DW_TAG_type_unit -CHECK: 0x00000042: DW_TAG_structure_type -CHECK: DW_AT_name {{.*}} "bar" +NOTYP-NOT: .debug_types.dwo contents: +TYPES-LABEL: .debug_types.dwo contents: +TYPES: [[FOOUOFF:0x[0-9a-f]*]]: +TYPES-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +TYPES: 0x[[AAOFF]] addr_size = 0x08 type_signature = [[FOOSIG]] type_offset = 0x[[FOOOFF:.*]] (next unit at [[BARUOFF:.*]]) +TYPES: DW_TAG_type_unit +TYPES: [[FOOOFF]]: DW_TAG_structure_type +TYPES: DW_AT_name {{.*}} "foo" +TYPES: [[BARUOFF]]: +TYPES-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +TYPES: 0x[[BAOFF]] addr_size = 0x08 type_signature = [[BARSIG]] type_offset = 0x001e (next unit at [[XUOFF:.*]]) +TYPES: DW_TAG_type_unit +TYPES: 0x00000042: DW_TAG_structure_type +TYPES: DW_AT_name {{.*}} "bar" CHECK-LABEL: .debug_cu_index contents: CHECK: Index Signature INFO ABBREV LINE STR_OFFSETS -CHECK: 1 [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) -CHECK: 3 [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) +TYPES: 1 [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) +TYPES: 3 [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) +NOTYP: 3 [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x00000011) [0x00000000, 0x00000010) +NOTYP: 4 [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x00000075) [0x00000011, 0x00000022) [0x00000010, 0x00000024) CHECK-LABEL: .debug_tu_index contents: -CHECK: Index Signature TYPES ABBREV LINE STR_OFFSETS -CHECK: 1 [[FOOSIG]] {{\[}}[[FOOUOFF]], [[BARUOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) -CHECK: 4 [[BARSIG]] {{\[}}[[BARUOFF]], [[XUOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) +NOTYP-NOT: Index +TYPES: Index Signature TYPES ABBREV LINE STR_OFFSETS +TYPES: 1 [[FOOSIG]] {{\[}}[[FOOUOFF]], [[BARUOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) +TYPES: 4 [[BARSIG]] {{\[}}[[BARUOFF]], [[XUOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) + +Ensure we do not create a debug_tu_index, even an empty or malformed one. +NOTYPOBJ-NOT: .debug_tu_index CHECK-LABEL: .debug_str.dwo contents: CHECK: "clang version diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index 2583e2e2081..9a9440574e8 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -310,11 +310,13 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { return Err; } - // Lie about there being no info contributions so the TU index only includes - // the type unit contribution - ContributionOffsets[0] = 0; - writeIndex(Out, MCOFI.getDwarfTUIndexSection(), ContributionOffsets, - TypeIndexEntries); + if (!TypeIndexEntries.empty()) { + // Lie about there being no info contributions so the TU index only includes + // the type unit contribution + ContributionOffsets[0] = 0; + writeIndex(Out, MCOFI.getDwarfTUIndexSection(), ContributionOffsets, + TypeIndexEntries); + } // Lie about the type contribution ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO] = 0; -- 2.34.1