[PATCH] D75189: [DebugInfo] Add check for .debug_line minimum_instruction_length of 0
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 08:42:04 PST 2020
jhenderson created this revision.
jhenderson added reviewers: ikudrin, labath, probinson, dblaikie, JDevlieghere.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
If the minimum_instruction_length of a debug line program is 0, no address advancing via special opcodes, DW_LNS_const_add_pc, and DW_LNS_advance_pc can occur, since the minimum_instruction_length is used in a multiplication. This patch adds a warning reporting when this issue occurs.
Depends on D74819 <https://reviews.llvm.org/D74819>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75189
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
@@ -993,6 +993,39 @@
Values(std::make_tuple(0, true), // Test zero value (error).
std::make_tuple(14, false)), ); // Test non-zero value (no error).
+struct BadMinInstLenFixture : public TestWithParam<std::tuple<uint8_t, bool>>,
+ public AdjustAddressFixtureBase {
+ void SetUp() { std::tie(MinInstLength, IsErrorExpected) = GetParam(); }
+
+ uint64_t editPrologue(LineTable <) override {
+ DWARFDebugLine::Prologue Prologue = LT.createBasicPrologue();
+ Prologue.MinInstLength = MinInstLength;
+ LT.setPrologue(Prologue);
+ return Prologue.TotalLength + Prologue.sizeofTotalLength();
+ }
+
+ uint64_t getAdjustedAddr(uint64_t Base, uint64_t ConstIncr,
+ uint64_t SpecialIncr,
+ uint64_t AdvanceIncr) override {
+ return MinInstLength != 0 ? AdjustAddressFixtureBase::getAdjustedAddr(
+ Base, ConstIncr, SpecialIncr, AdvanceIncr)
+ : Base;
+ }
+
+ uint8_t MinInstLength;
+};
+
+TEST_P(BadMinInstLenFixture, MinInstLengthProblemsReportedCorrectly) {
+ runTest(/*CheckAdvancePC=*/true,
+ "but the prologue minimum_instruction_length value is 0, which "
+ "prevents any address advancing");
+}
+
+INSTANTIATE_TEST_CASE_P(
+ BadMinInstLenParams, BadMinInstLenFixture,
+ Values(std::make_tuple(0, true), // Test zero value (error).
+ std::make_tuple(1, false)), ); // Test non-zero value (no error).
+
TEST_F(DebugLineBasicFixture, ParserParsesCorrectly) {
if (!setupGenerator())
return;
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -613,6 +613,14 @@
", but the prologue maximum_operations_per_instruction value is %" PRId8
", which is unsupported. Assuming a value of 1 instead",
TableOffset, OpcodeName.data(), OpcodeOffset, Prologue.MaxOpsPerInst));
+ if (ReportAdvanceAddrProblem && Prologue.MinInstLength == 0)
+ ErrorHandler(
+ createStringError(errc::invalid_argument,
+ "line table program at offset 0x%8.8" PRIx64
+ " contains a %s opcode at offset 0x%8.8" PRIx64
+ ", but the prologue minimum_instruction_length value "
+ "is 0, which prevents any address advancing",
+ TableOffset, OpcodeName.data(), OpcodeOffset));
ReportAdvanceAddrProblem = false;
return OperationAdvance * Prologue.MinInstLength;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75189.246747.patch
Type: text/x-patch
Size: 2939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/7daf47d7/attachment.bin>
More information about the llvm-commits
mailing list