41 changes: 20 additions & 21 deletions llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ CHECK: DW_AT_high_pc [DW_FORM_data4] (0x0000000b)
CHECK: DW_TAG_subprogram [2] *
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f40)
CHECK: DW_AT_high_pc [DW_FORM_data4] (0x0000000b)
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 )
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000027] = "main")
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_prototyped [DW_FORM_flag_present] (true)
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000000a1)
CHECK: DW_AT_external [DW_FORM_flag_present] (true)
CHECK: DW_TAG_formal_parameter [3]
CHECK: DW_AT_location [DW_FORM_exprloc] (<0x3> 55 93 04 )
CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000002c] = "argc")
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000000a1)
CHECK: DW_TAG_formal_parameter [4]
CHECK: DW_AT_location [DW_FORM_exprloc] (<0x1> 54 )
CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_reg4 RSI)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000031] = "argv")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0060 => {0x00000060})
CHECK: NULL
Expand All @@ -55,25 +55,26 @@ CHECK: DW_TAG_base_type [7]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000044] = "int")
CHECK: DW_TAG_variable [8]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000048] = "baz")
CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 00 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x100001000)
CHECK: DW_TAG_variable [8]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000004c] = "private_int")
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 08 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x100001008)
CHECK: DW_TAG_subprogram [9]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000058] = "inc")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1})
CHECK: DW_AT_inline [DW_FORM_data1] (DW_INL_inlined)
CHECK: DW_TAG_subprogram [10] *
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f50)
CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000037)
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 )
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005c] = "foo")
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_prototyped [DW_FORM_flag_present] (true)
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1})
CHECK: DW_TAG_formal_parameter [11]
CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000)
CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000
CHECK: 0x0000000000000000 - 0x000000000000000c: DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "arg")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1})
CHECK: DW_TAG_inlined_subroutine [12]
Expand All @@ -94,18 +95,20 @@ CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000024)
CHECK: DW_TAG_variable [13]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006d] = "val")
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic3.c")
CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 04 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x100001004)
CHECK: DW_TAG_volatile_type [14]
CHECK: DW_TAG_subprogram [15]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000058] = "inc")
CHECK: DW_AT_inline [DW_FORM_data1] (DW_INL_inlined)
CHECK: DW_TAG_subprogram [2] *
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f90)
CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000024)
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 )
CHECK: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6 RBP)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000071] = "bar")
CHECK: DW_TAG_formal_parameter [16]
CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000025)
CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000025
CHECK: 0x0000000000000000 - 0x000000000000000f: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK: 0x0000000000000019 - 0x000000000000001d: DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "arg")
CHECK: DW_TAG_inlined_subroutine [17]
CHECK: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0044 => {0x0000015f} "inc")
Expand All @@ -118,17 +121,13 @@ CHECK: NULL


CHECK: .debug_loc contents:
CHECK-NEXT: 0x00000000: Beginning address offset: 0x0000000000000000
CHECK-NEXT: Ending address offset: 0x000000000000000c
CHECK-NEXT: Location description: 55 93 04
CHECK-NEXT: {{^$}}
CHECK-NEXT: 0x00000025: Beginning address offset: 0x0000000000000000
CHECK-NEXT: Ending address offset: 0x000000000000000f
CHECK-NEXT: Location description: 55 93 04
CHECK-NEXT: {{^$}}
CHECK-NEXT: Beginning address offset: 0x0000000000000019
CHECK-NEXT: Ending address offset: 0x000000000000001d
CHECK-NEXT: Location description: 55 93 04
CHECK-NEXT: 0x00000000:
CHECK-NEXT: 0x0000000000000000 - 0x000000000000000c: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NOT: :
CHECK: 0x00000025:
CHECK-NEXT: 0x0000000000000000 - 0x000000000000000f: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NEXT: 0x0000000000000019 - 0x000000000000001d: DW_OP_reg5 RDI, DW_OP_piece 0x4


CHECK: .debug_aranges contents:
CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
Expand Down
42 changes: 20 additions & 22 deletions llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ CHECK: DW_AT_external [DW_FORM_flag] (0x01)
CHECK: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f40)
CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f4b)
CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 )
CHECK: DW_AT_frame_base [DW_FORM_block1] (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter [3]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000056] = "argc")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0063 => {0x00000063})
CHECK: DW_AT_location [DW_FORM_block1] (<0x03> 55 93 04 )
CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_formal_parameter [3]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005b] = "argv")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x006a => {0x0000006a})
CHECK: DW_AT_location [DW_FORM_block1] (<0x01> 54 )
CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI)
CHECK: NULL
CHECK: DW_TAG_base_type [4]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "int")
Expand Down Expand Up @@ -62,21 +62,22 @@ CHECK: DW_TAG_variable [7]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000072] = "private_int")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 08 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x100001008)
CHECK: DW_TAG_variable [7]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000007e] = "baz")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x100001000)
CHECK: DW_TAG_subprogram [8] *
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000082] = "foo")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f50)
CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f89)
CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 )
CHECK: DW_AT_frame_base [DW_FORM_block1] (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter [9]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_location [DW_FORM_data4] (0x00000000)
CHECK: DW_AT_location [DW_FORM_data4] (0x00000000
CHECK: 0x0000000000000000 - 0x000000000000000e: DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_inlined_subroutine [10]
CHECK: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x00a7 => {0x00000128} "inc")
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f63)
Expand All @@ -101,19 +102,21 @@ CHECK: DW_TAG_variable [12]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000097] = "val")
CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x003c => {0x00000176})
CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic3.c")
CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 04 10 00 00 01 00 00 00 )
CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x100001004)
CHECK: DW_TAG_volatile_type [13]
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_TAG_subprogram [8] *
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000009b] = "bar")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f90)
CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fb4)
CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 )
CHECK: DW_AT_frame_base [DW_FORM_block1] (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter [9]
CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: DW_AT_location [DW_FORM_data4] (0x00000025)
CHECK: DW_AT_location [DW_FORM_data4] (0x00000025
CHECK: 0x0000000000000000 - 0x000000000000000f: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK: 0x0000000000000019 - 0x000000000000001d: DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_lexical_block [14] *
CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f94)
CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fa7)
Expand All @@ -129,18 +132,13 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000008a] = "inc")
CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063)
CHECK: NULL

CHECK:.debug_loc contents:
CHECK-NEXT: 0x00000000: Beginning address offset: 0x0000000000000000
CHECK-NEXT: Ending address offset: 0x000000000000000e
CHECK-NEXT: Location description: 55 93 04
CHECK-NEXT: {{^$}}
CHECK-NEXT: 0x00000025: Beginning address offset: 0x0000000000000000
CHECK-NEXT: Ending address offset: 0x000000000000000f
CHECK-NEXT: Location description: 55 93 04
CHECK-NEXT: {{^$}}
CHECK-NEXT: Beginning address offset: 0x0000000000000019
CHECK-NEXT: Ending address offset: 0x000000000000001d
CHECK-NEXT: Location description: 55 93 04
CHECK: .debug_loc contents:
CHECK-NEXT: 0x00000000:
CHECK-NEXT: 0x0000000000000000 - 0x000000000000000e: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NOT: :
CHECK: 0x00000025:
CHECK-NEXT: 0x0000000000000000 - 0x000000000000000f: DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NEXT: 0x0000000000000019 - 0x000000000000001d: DW_OP_reg5 RDI, DW_OP_piece 0x4

CHECK: .debug_aranges contents:
CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/dsymutil/X86/common-sym.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $ clang common.macho.x86_64.o -o common.macho.x86_64
CHECK: DW_TAG_variable
CHECK: DW_AT_name {{.*}} "common"
CHECK-NOT: {{NULL|DW_TAG}}
CHECK: DW_AT_location {{.*}} (<0x09> 03 00 10 00 00 01 00 00 00 )
CHECK: DW_AT_location {{.*}} (DW_OP_addr 0x100001000)

CHECK: DW_TAG_subprogram
CHECK-NEXT: DW_AT_low_pc{{.*}}(0x0000000100000f80)
Expand Down
3 changes: 3 additions & 0 deletions llvm/tools/llvm-dwarfdump/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set(LLVM_LINK_COMPONENTS
DebugInfoDWARF
AllTargetsDescs
AllTargetsInfos
MC
Object
Support
)
Expand Down
8 changes: 7 additions & 1 deletion llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstring>
Expand Down Expand Up @@ -94,7 +95,9 @@ static void error(StringRef Filename, std::error_code EC) {
}

static void DumpObjectFile(ObjectFile &Obj, Twine Filename) {
std::unique_ptr<DIContext> DICtx = DWARFContext::create(Obj);
std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(Obj);
logAllUnhandledErrors(DICtx->loadRegisterInfo(Obj), errs(),
Filename.str() + ": ");

outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName()
<< "\n\n";
Expand Down Expand Up @@ -209,6 +212,9 @@ int main(int argc, char **argv) {
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.

llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();

cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n");

// Defaults to a.out if no filenames specified.
Expand Down