llvm.org GIT mirror llvm / 54c40cf
[dsymutil] Use the new MCDwarfLineTableParams customization to emit linetables llvm-dsymutil has to be able to process debug info produced by other compilers which use different line table settings. The testcase wasn't generated by another compiler, but by a modified clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244319 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
4 changed file(s) with 63 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
1919 return bar(arg+val) + inc() + baz++;
2020 }
2121
22 /* This file was also used to create basic2-custom-linetable.macho.x86_64.o
23 with a custom clang that had different settings for the linetable
24 encoding constants: line_base == -1 and line_range == 4.
25
26 clang -c -g basic2.c -o basic2-custom-linetable.macho.x86_64.o
27 */
0 # RUN: llvm-dsymutil -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - -debug-dump=line | FileCheck %s
1
2 # This test runs dsymutil on an object file with non-standard (as far
3 # as llvm is concerned) line table settings.
4
5 ---
6 triple: 'x86_64-apple-darwin'
7 objects:
8 - filename: basic2-custom-linetable.macho.x86_64.o
9 symbols:
10 - { sym: _foo, objAddr: 0x0, binAddr: 0x1000, size: 0x12 }
11
12 # CHECK: 0x0000000000001000 19 0 {{.*}} is_stmt
13 # CHECK: 0x0000000000001012 20 14 {{.*}} is_stmt prologue_end
14 # CHECK: 0x0000000000001015 20 18 {{.*}}
15 # CHECK: 0x0000000000001017 20 17 {{.*}}
16 # CHECK: 0x0000000000001019 20 10 {{.*}}
17 # CHECK: 0x000000000000101e 20 25 {{.*}}
18 # CHECK: 0x0000000000001026 20 23 {{.*}}
19 # CHECK: 0x000000000000102b 20 36 {{.*}}
20 # CHECK: 0x000000000000103c 20 31 {{.*}}
21 # CHECK: 0x000000000000103e 20 3 {{.*}}
22 # CHECK: 0x0000000000001046 20 3 {{.*}} end_sequence
23
24 - { sym: _inc, objAddr: 0x0, binAddr: 0x2000, size: 0x12 }
25
26 # CHECK: 0x0000000000002000 14 0 {{.*}} is_stmt
27 # CHECK: 0x0000000000002004 15 10 {{.*}} is_stmt prologue_end
28 # CHECK: 0x0000000000002013 15 3 {{.*}}
29 # CHECK: 0x0000000000002015 15 3 {{.*}} end_sequence
30
31 - { sym: _unused1, objAddr: 0x0, binAddr: 0x3000, size: 0x12 }
32
33 # CHECK: 0x0000000000003000 10 0 {{.*}} is_stmt
34 # CHECK: 0x0000000000003004 11 7 {{.*}} is_stmt prologue_end
35 # CHECK: 0x000000000000300e 11 3 {{.*}}
36 # CHECK: 0x0000000000003013 12 1 {{.*}} is_stmt
37 # CHECK: 0x000000000000301c 12 1 {{.*}} is_stmt end_sequence
38 ...
39
617617
618618 /// \brief Emit the line table described in \p Rows into the
619619 /// debug_line section.
620 void emitLineTableForUnit(StringRef PrologueBytes, unsigned MinInstLength,
620 void emitLineTableForUnit(MCDwarfLineTableParams Params,
621 StringRef PrologueBytes, unsigned MinInstLength,
621622 std::vector &Rows,
622623 unsigned AdddressSize);
623624
941942 }
942943 }
943944
944 void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes,
945 void DwarfStreamer::emitLineTableForUnit(MCDwarfLineTableParams Params,
946 StringRef PrologueBytes,
945947 unsigned MinInstLength,
946948 std::vector &Rows,
947949 unsigned PointerSize) {
964966 if (Rows.empty()) {
965967 // We only have the dummy entry, dsymutil emits an entry with a 0
966968 // address in that case.
967 MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS);
969 MCDwarfLineAddr::Encode(*MC, Params, INT64_MAX, 0, EncodingOS);
968970 MS->EmitBytes(EncodingOS.str());
969971 LineSectionSize += EncodingBuffer.size();
970972 MS->EmitLabel(LineEndSym);
10461048
10471049 int64_t LineDelta = int64_t(Row.Line) - LastLine;
10481050 if (!Row.EndSequence) {
1049 MCDwarfLineAddr::Encode(*MC, LineDelta, AddressDelta, EncodingOS);
1051 MCDwarfLineAddr::Encode(*MC, Params, LineDelta, AddressDelta, EncodingOS);
10501052 MS->EmitBytes(EncodingOS.str());
10511053 LineSectionSize += EncodingBuffer.size();
10521054 EncodingBuffer.resize(0);
10651067 MS->EmitULEB128IntValue(AddressDelta);
10661068 LineSectionSize += 1 + getULEB128Size(AddressDelta);
10671069 }
1068 MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS);
1070 MCDwarfLineAddr::Encode(*MC, Params, INT64_MAX, 0, EncodingOS);
10691071 MS->EmitBytes(EncodingOS.str());
10701072 LineSectionSize += EncodingBuffer.size();
10711073 EncodingBuffer.resize(0);
10771079 }
10781080
10791081 if (RowsSinceLastSequence) {
1080 MCDwarfLineAddr::Encode(*MC, INT64_MAX, 0, EncodingOS);
1082 MCDwarfLineAddr::Encode(*MC, Params, INT64_MAX, 0, EncodingOS);
10811083 MS->EmitBytes(EncodingOS.str());
10821084 LineSectionSize += EncodingBuffer.size();
10831085 EncodingBuffer.resize(0);
29142916 // table emitter.
29152917 if (LineTable.Prologue.Version != 2 ||
29162918 LineTable.Prologue.DefaultIsStmt != DWARF2_LINE_DEFAULT_IS_STMT ||
2917 LineTable.Prologue.LineBase != -5 || LineTable.Prologue.LineRange != 14 ||
2918 LineTable.Prologue.OpcodeBase != 13)
2919 LineTable.Prologue.OpcodeBase > 13)
29192920 reportWarning("line table paramters mismatch. Cannot emit.");
2920 else
2921 Streamer->emitLineTableForUnit(LineData.slice(StmtList + 4, PrologueEnd),
2921 else {
2922 MCDwarfLineTableParams Params;
2923 Params.DWARF2LineOpcodeBase = LineTable.Prologue.OpcodeBase;
2924 Params.DWARF2LineBase = LineTable.Prologue.LineBase;
2925 Params.DWARF2LineRange = LineTable.Prologue.LineRange;
2926 Streamer->emitLineTableForUnit(Params,
2927 LineData.slice(StmtList + 4, PrologueEnd),
29222928 LineTable.Prologue.MinInstLength, NewRows,
29232929 Unit.getOrigUnit().getAddressByteSize());
2930 }
29242931 }
29252932
29262933 void DwarfLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {