Skip to content

Commit a85bf60

Browse files
committed
Merge remote-tracking branch 'origin/swift-4.1-branch' into stable
2 parents ac15995 + 1d34549 commit a85bf60

21 files changed

+599
-449
lines changed

include/llvm/DebugInfo/DWARF/DWARFDebugLine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ class DWARFDebugLine {
217217
void clear();
218218

219219
/// Parse prologue and all rows.
220-
bool parse(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr);
220+
bool parse(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
221+
raw_ostream *OS = nullptr);
221222

222223
using RowVector = std::vector<Row>;
223224
using RowIter = RowVector::const_iterator;

lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,14 @@ void DWARFContext::dump(
335335
isLittleEndian(), savedAddressByteSize);
336336
DWARFDebugLine::LineTable LineTable;
337337
uint32_t Offset = *StmtOffset;
338-
LineTable.parse(lineData, &Offset);
339-
LineTable.dump(OS);
338+
// Verbose dumping is done during parsing and not on the intermediate
339+
// representation.
340+
if (DumpOpts.Verbose) {
341+
LineTable.parse(lineData, &Offset, &OS);
342+
} else {
343+
LineTable.parse(lineData, &Offset);
344+
LineTable.dump(OS);
345+
}
340346
}
341347
}
342348
}

lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ DWARFDebugLine::getOrParseLineTable(const DWARFDataExtractor &DebugLineData,
394394
}
395395

396396
bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
397-
uint32_t *OffsetPtr) {
397+
uint32_t *OffsetPtr, raw_ostream *OS) {
398398
const uint32_t DebugLineOffset = *OffsetPtr;
399399

400400
clear();
@@ -405,14 +405,23 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
405405
return false;
406406
}
407407

408+
if (OS)
409+
Prologue.dump(*OS);
410+
408411
const uint32_t EndOffset =
409412
DebugLineOffset + Prologue.TotalLength + Prologue.sizeofTotalLength();
410413

411414
ParsingState State(this);
412415

413416
while (*OffsetPtr < EndOffset) {
417+
if (OS)
418+
*OS << format("0x%08.08" PRIx32 ": ", *OffsetPtr);
419+
414420
uint8_t Opcode = DebugLineData.getU8(OffsetPtr);
415421

422+
if (OS)
423+
*OS << format("%02.02" PRIx8 " ", Opcode);
424+
416425
if (Opcode == 0) {
417426
// Extended Opcodes always start with a zero opcode followed by
418427
// a uleb128 length so you can skip ones you don't know about
@@ -421,6 +430,8 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
421430
uint32_t ArgSize = Len - (*OffsetPtr - ExtOffset);
422431

423432
uint8_t SubOpcode = DebugLineData.getU8(OffsetPtr);
433+
if (OS)
434+
*OS << LNExtendedString(SubOpcode);
424435
switch (SubOpcode) {
425436
case DW_LNE_end_sequence:
426437
// Set the end_sequence register of the state machine to true and
@@ -432,6 +443,11 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
432443
// of the sequence.
433444
State.Row.EndSequence = true;
434445
State.appendRowToMatrix(*OffsetPtr);
446+
if (OS) {
447+
*OS << "\n";
448+
OS->indent(12);
449+
State.Row.dump(*OS);
450+
}
435451
State.resetRowAndSequence();
436452
break;
437453

@@ -443,6 +459,8 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
443459
// that affect the address register add a delta to it. This instruction
444460
// stores a relocatable value into it instead.
445461
State.Row.Address = DebugLineData.getRelocatedAddress(OffsetPtr);
462+
if (OS)
463+
*OS << format(" (0x%16.16" PRIx64 ")", State.Row.Address);
446464
break;
447465

448466
case DW_LNE_define_file:
@@ -473,11 +491,18 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
473491
FileEntry.ModTime = DebugLineData.getULEB128(OffsetPtr);
474492
FileEntry.Length = DebugLineData.getULEB128(OffsetPtr);
475493
Prologue.FileNames.push_back(FileEntry);
494+
if (OS)
495+
*OS << " (" << FileEntry.Name.str()
496+
<< ", dir=" << FileEntry.DirIdx << ", mod_time="
497+
<< format("(0x%16.16" PRIx64 ")", FileEntry.ModTime)
498+
<< ", length=" << FileEntry.Length << ")";
476499
}
477500
break;
478501

479502
case DW_LNE_set_discriminator:
480503
State.Row.Discriminator = DebugLineData.getULEB128(OffsetPtr);
504+
if (OS)
505+
*OS << " (" << State.Row.Discriminator << ")";
481506
break;
482507

483508
default:
@@ -487,39 +512,58 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
487512
break;
488513
}
489514
} else if (Opcode < Prologue.OpcodeBase) {
515+
if (OS)
516+
*OS << LNStandardString(Opcode);
490517
switch (Opcode) {
491518
// Standard Opcodes
492519
case DW_LNS_copy:
493520
// Takes no arguments. Append a row to the matrix using the
494521
// current values of the state-machine registers. Then set
495522
// the basic_block register to false.
496523
State.appendRowToMatrix(*OffsetPtr);
524+
if (OS) {
525+
*OS << "\n";
526+
OS->indent(12);
527+
State.Row.dump(*OS);
528+
*OS << "\n";
529+
}
497530
break;
498531

499532
case DW_LNS_advance_pc:
500533
// Takes a single unsigned LEB128 operand, multiplies it by the
501534
// min_inst_length field of the prologue, and adds the
502535
// result to the address register of the state machine.
503-
State.Row.Address +=
504-
DebugLineData.getULEB128(OffsetPtr) * Prologue.MinInstLength;
536+
{
537+
uint64_t AddrOffset =
538+
DebugLineData.getULEB128(OffsetPtr) * Prologue.MinInstLength;
539+
State.Row.Address += AddrOffset;
540+
if (OS)
541+
*OS << " (" << AddrOffset << ")";
542+
}
505543
break;
506544

507545
case DW_LNS_advance_line:
508546
// Takes a single signed LEB128 operand and adds that value to
509547
// the line register of the state machine.
510548
State.Row.Line += DebugLineData.getSLEB128(OffsetPtr);
549+
if (OS)
550+
*OS << " (" << State.Row.Line << ")";
511551
break;
512552

513553
case DW_LNS_set_file:
514554
// Takes a single unsigned LEB128 operand and stores it in the file
515555
// register of the state machine.
516556
State.Row.File = DebugLineData.getULEB128(OffsetPtr);
557+
if (OS)
558+
*OS << " (" << State.Row.File << ")";
517559
break;
518560

519561
case DW_LNS_set_column:
520562
// Takes a single unsigned LEB128 operand and stores it in the
521563
// column register of the state machine.
522564
State.Row.Column = DebugLineData.getULEB128(OffsetPtr);
565+
if (OS)
566+
*OS << " (" << State.Row.Column << ")";
523567
break;
524568

525569
case DW_LNS_negate_stmt:
@@ -551,6 +595,9 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
551595
uint64_t AddrOffset =
552596
(AdjustOpcode / Prologue.LineRange) * Prologue.MinInstLength;
553597
State.Row.Address += AddrOffset;
598+
if (OS)
599+
*OS
600+
<< format(" (0x%16.16" PRIx64 ")", AddrOffset);
554601
}
555602
break;
556603

@@ -564,7 +611,13 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
564611
// judge when the computation of a special opcode overflows and
565612
// requires the use of DW_LNS_advance_pc. Such assemblers, however,
566613
// can use DW_LNS_fixed_advance_pc instead, sacrificing compression.
567-
State.Row.Address += DebugLineData.getU16(OffsetPtr);
614+
{
615+
uint16_t PCOffset = DebugLineData.getU16(OffsetPtr);
616+
State.Row.Address += PCOffset;
617+
if (OS)
618+
*OS
619+
<< format(" (0x%16.16" PRIx64 ")", PCOffset);
620+
}
568621
break;
569622

570623
case DW_LNS_set_prologue_end:
@@ -583,6 +636,8 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
583636
// Takes a single unsigned LEB128 operand and stores it in the
584637
// column register of the state machine.
585638
State.Row.Isa = DebugLineData.getULEB128(OffsetPtr);
639+
if (OS)
640+
*OS << " (" << State.Row.Isa << ")";
586641
break;
587642

588643
default:
@@ -592,8 +647,12 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
592647
{
593648
assert(Opcode - 1U < Prologue.StandardOpcodeLengths.size());
594649
uint8_t OpcodeLength = Prologue.StandardOpcodeLengths[Opcode - 1];
595-
for (uint8_t I = 0; I < OpcodeLength; ++I)
596-
DebugLineData.getULEB128(OffsetPtr);
650+
for (uint8_t I = 0; I < OpcodeLength; ++I) {
651+
uint64_t Value = DebugLineData.getULEB128(OffsetPtr);
652+
if (OS)
653+
*OS << format("Skipping ULEB128 value: 0x%16.16" PRIx64 ")\n",
654+
Value);
655+
}
597656
}
598657
break;
599658
}
@@ -638,10 +697,20 @@ bool DWARFDebugLine::LineTable::parse(const DWARFDataExtractor &DebugLineData,
638697
Prologue.LineBase + (AdjustOpcode % Prologue.LineRange);
639698
State.Row.Line += LineOffset;
640699
State.Row.Address += AddrOffset;
700+
701+
if (OS) {
702+
*OS << "address += " << ((uint32_t)AdjustOpcode)
703+
<< ", line += " << LineOffset << "\n";
704+
OS->indent(12);
705+
State.Row.dump(*OS);
706+
}
707+
641708
State.appendRowToMatrix(*OffsetPtr);
642709
// Reset discriminator to 0.
643710
State.Row.Discriminator = 0;
644711
}
712+
if(OS)
713+
*OS << "\n";
645714
}
646715

647716
if (!State.Sequence.Empty) {

test/DebugInfo/Generic/unconditional-branch.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; PR 19261
33

44
; RUN: %llc_dwarf -fast-isel=false -O0 -filetype=obj %s -o %t
5-
; RUN: llvm-dwarfdump -v %t | FileCheck %s
5+
; RUN: llvm-dwarfdump -a %t | FileCheck %s
66

77
; CHECK: {{0x[0-9a-f]+}} 1 0 1 0 0 is_stmt
88
; CHECK: {{0x[0-9a-f]+}} 2 0 1 0 0 is_stmt

test/DebugInfo/MIR/X86/empty-inline.mir

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s
1+
# RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -a - | FileCheck %s
22
#
33
# This testcase has an implicit def pseudo-iunstruction with a debug location.
44
#
55
# CHECK: .debug_info contents:
66
# CHECK: DW_TAG_subprogram
7-
# CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
7+
# CHECK: DW_AT_low_pc (0x0000000000000000)
88
# CHECK-NOT: DW_TAG
99
# CHECK: DW_AT_specification {{.*}} "_ZN1C5m_fn3Ev"
1010
# CHECK-NOT: DW_TAG
@@ -20,38 +20,38 @@
2020
source_filename = "t.ll"
2121
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2222
target triple = "x86_64-apple-macosx"
23-
23+
2424
%class.E = type { %class.D }
2525
%class.D = type { %class.B }
2626
%class.B = type { %class.A, %class.A }
2727
%class.A = type { i8 }
2828
%class.C = type <{ %class.E*, %class.B, [2 x i8] }>
29-
29+
3030
@a = local_unnamed_addr global %class.E* null, align 4
31-
31+
3232
define i32 @_ZN1C5m_fn3Ev(%class.C* nocapture) local_unnamed_addr align 2 !dbg !6 {
3333
%2 = alloca %class.B, align 1
3434
%3 = load %class.E*, %class.E** @a, align 4
3535
%4 = icmp eq %class.E* %3, null
3636
br i1 %4, label %10, label %5
37-
37+
3838
; <label>:5: ; preds = %1
3939
%6 = bitcast %class.C* %0 to %class.D**
4040
%7 = load %class.D*, %class.D** %6, align 4
4141
%8 = bitcast %class.D* %7 to i8*
4242
%9 = load i8, i8* %8, align 1
4343
br label %10
44-
44+
4545
; <label>:10: ; preds = %5, %1
4646
%11 = phi i8 [ %9, %5 ], [ undef, %1 ], !dbg !10
4747
%12 = getelementptr inbounds %class.C, %class.C* %0, i32 0, i32 1, i32 0, i32 0
4848
store i8 %11, i8* %12, align 1, !dbg !14
4949
ret i32 undef
5050
}
51-
51+
5252
!llvm.dbg.cu = !{!0}
5353
!llvm.module.flags = !{!3, !4, !5}
54-
54+
5555
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "Apple LLVM version 8.1.0 (clang-802.0.30.3)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
5656
!1 = !DIFile(filename: "test.ii", directory: "/")
5757
!2 = !{}
@@ -77,9 +77,9 @@ legalized: false
7777
regBankSelected: false
7878
selected: false
7979
tracksRegLiveness: true
80-
liveins:
80+
liveins:
8181
- { reg: '%rdi' }
82-
frameInfo:
82+
frameInfo:
8383
isFrameAddressTaken: false
8484
isReturnAddressTaken: false
8585
hasStackMap: false
@@ -93,27 +93,27 @@ frameInfo:
9393
hasOpaqueSPAdjustment: false
9494
hasVAStart: false
9595
hasMustTailInVarArgFunc: false
96-
#stack:
96+
#stack:
9797
# - { id: 0, name: '<unnamed alloca>', offset: -16, size: 2, alignment: 8 }
9898
body: |
9999
bb.0 (%ir-block.1):
100100
successors: %bb.1(0x30000000), %bb.2(0x50000000)
101101
liveins: %rdi
102-
102+
103103
CMP64mi8 %rip, 1, _, @a, _, 0, implicit-def %eflags :: (dereferenceable load 8 from @a, align 4)
104104
JE_1 %bb.1, implicit %eflags
105-
105+
106106
bb.2 (%ir-block.5):
107107
liveins: %rdi
108-
108+
109109
%rax = MOV64rm %rdi, 1, _, 0, _ :: (load 8 from %ir.6, align 4)
110110
%al = MOV8rm killed %rax, 1, _, 0, _ :: (load 1 from %ir.8)
111111
MOV8mr killed %rdi, 1, _, 8, _, killed %al, debug-location !14 :: (store 1 into %ir.12)
112112
RETQ undef %eax
113-
113+
114114
bb.1:
115115
liveins: %rdi
116-
116+
117117
%al = IMPLICIT_DEF debug-location !10
118118
MOV8mr killed %rdi, 1, _, 8, _, killed %al, debug-location !14 :: (store 1 into %ir.12)
119119
RETQ undef %eax

test/DebugInfo/Mips/delay-slot.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -filetype=obj -O0 -relocation-model=pic < %s -mtriple mips-unknown-linux-gnu | llvm-dwarfdump -v - | FileCheck %s
1+
; RUN: llc -filetype=obj -O0 -relocation-model=pic < %s -mtriple mips-unknown-linux-gnu | llvm-dwarfdump -a - | FileCheck %s
22
; PR19815
33

44
; Generated using clang -target mips-linux-gnu -g test.c -S -o - -flto|opt -sroa -S

test/MC/ARM/dwarf-asm-multiple-sections-dwarf-2.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp -dwarf-version 2 2>&1 | FileCheck -check-prefix MESSAGES %s
2-
// RUN: llvm-dwarfdump -v %t | FileCheck -check-prefix DWARF %s
2+
// RUN: llvm-dwarfdump -a %t | FileCheck -check-prefix DWARF %s
33
// RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
44

55
.section .text, "ax"
@@ -24,13 +24,13 @@ b:
2424
// DWARF: DW_AT_language DW_FORM_data2
2525

2626
// DWARF: .debug_info contents:
27-
// DWARF: 0x{{[0-9a-f]+}}: DW_TAG_compile_unit [1]
27+
// DWARF: DW_TAG_compile_unit
2828
// DWARF-NOT: DW_TAG_
29-
// DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
30-
// DWARF: DW_AT_high_pc [DW_FORM_addr] (0x0000000000000004)
29+
// DWARF: DW_AT_low_pc {{.*}}(0x0000000000000000)
30+
// DWARF: DW_AT_high_pc {{.*}}(0x0000000000000004)
3131

32-
// DWARF: 0x{{[0-9a-f]+}}: DW_TAG_label [2] *
33-
// DWARF-NEXT: DW_AT_name [DW_FORM_string] ("a")
32+
// DWARF: DW_TAG_label
33+
// DWARF-NEXT: DW_AT_name {{.*}}("a")
3434

3535

3636
// DWARF: .debug_aranges contents:

0 commit comments

Comments
 (0)