[PATCH] D71274: [DebugInfo] Fix printing of DW_LNS_set_isa
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 07:42:34 PST 2019
jhenderson created this revision.
jhenderson added reviewers: dblaikie, probinson, aprantl, JDevlieghere, ikudrin.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
The `Isa` register is a `uint8_t`, but at least on windows this is internally an `unsigned char`, which meant that prior to this patch it got formatted as an ASCII character, rather than a decimal number. This patch fixes this by casting it to a `uint64_t` before printing. I did it this way instead of using a `uint8_t` formatter because a) it is simpler, and b) it allows us to change the internal type of `Isa` in the future without this code breaking.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71274
Files:
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -675,4 +675,52 @@
EXPECT_FALSE(Unrecoverable);
}
+TEST_F(DebugLineBasicFixture, ParserPrintsStandardOpcodesWhenRequested) {
+ if (!setupGenerator())
+ return;
+
+ using ValLen = dwarfgen::LineTable::ValueAndLength;
+ LineTable < = Gen->addLineTable(DWARF32);
+ LT.addStandardOpcode(DW_LNS_copy, {});
+ LT.addStandardOpcode(DW_LNS_advance_pc, {ValLen{11, LineTable::ULEB}});
+ LT.addStandardOpcode(DW_LNS_advance_line, {ValLen{22, LineTable::SLEB}});
+ LT.addStandardOpcode(DW_LNS_set_file, {ValLen{33, LineTable::ULEB}});
+ LT.addStandardOpcode(DW_LNS_set_column, {ValLen{44, LineTable::ULEB}});
+ LT.addStandardOpcode(DW_LNS_negate_stmt, {});
+ LT.addStandardOpcode(DW_LNS_set_basic_block, {});
+ LT.addStandardOpcode(DW_LNS_const_add_pc, {});
+ LT.addStandardOpcode(DW_LNS_fixed_advance_pc, {ValLen{55, LineTable::Half}});
+ LT.addStandardOpcode(DW_LNS_set_prologue_end, {});
+ LT.addStandardOpcode(DW_LNS_set_epilogue_begin, {});
+ LT.addStandardOpcode(DW_LNS_set_isa, {ValLen{66, LineTable::ULEB}});
+ LT.addExtendedOpcode(1, DW_LNE_end_sequence, {});
+ generate();
+
+ DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
+ std::string Output;
+ raw_string_ostream OS(Output);
+ Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS);
+
+ EXPECT_FALSE(Recoverable);
+ EXPECT_FALSE(Unrecoverable);
+ auto InOutput = [&Output](char const *Str) {
+ return Output.find(Str) != std::string::npos;
+ };
+ EXPECT_TRUE(InOutput("0x0000002e: 01 DW_LNS_copy\n")) << Output;
+ EXPECT_TRUE(InOutput("0x0000002f: 02 DW_LNS_advance_pc (11)\n")) << Output;
+ EXPECT_TRUE(InOutput("0x00000031: 03 DW_LNS_advance_line (23)\n")) << Output;
+ EXPECT_TRUE(InOutput("0x00000033: 04 DW_LNS_set_file (33)\n")) << Output;
+ EXPECT_TRUE(InOutput("0x00000035: 05 DW_LNS_set_column (44)\n")) << Output;
+ EXPECT_TRUE(InOutput("0x00000037: 06 DW_LNS_negate_stmt\n")) << Output;
+ EXPECT_TRUE(InOutput("0x00000038: 07 DW_LNS_set_basic_block\n")) << Output;
+ EXPECT_TRUE(
+ InOutput("0x00000039: 08 DW_LNS_const_add_pc (0x0000000000000011)\n"))
+ << Output;
+ EXPECT_TRUE(InOutput("0x0000003a: 09 DW_LNS_fixed_advance_pc (0x0037)\n"))
+ << Output;
+ EXPECT_TRUE(InOutput("0x0000003d: 0a DW_LNS_set_prologue_end\n")) << Output;
+ EXPECT_TRUE(InOutput("0x0000003e: 0b DW_LNS_set_epilogue_begin\n")) << Output;
+ EXPECT_TRUE(InOutput("0x0000003f: 0c DW_LNS_set_isa (66)\n")) << Output;
+}
+
} // end anonymous namespace
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -813,7 +813,7 @@
// column register of the state machine.
State.Row.Isa = DebugLineData.getULEB128(OffsetPtr);
if (OS)
- *OS << " (" << State.Row.Isa << ")";
+ *OS << " (" << (uint64_t)State.Row.Isa << ")";
break;
default:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71274.233099.patch
Type: text/x-patch
Size: 3234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191210/34d917a3/attachment.bin>
More information about the llvm-commits
mailing list