aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
diff options
context:
space:
mode:
authorJames Henderson <james.henderson@sony.com>2020-02-25 16:07:16 +0000
committerJames Henderson <james.henderson@sony.com>2020-03-09 12:59:44 +0000
commit684d6fdee208a1fa12e9cbe0a45f3c5b4b575ad7 (patch)
tree81d53ed1eee585c031d4d498e72daf4e177b3a4b /llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
parent6e0c9e46967e1dc701a8be66c5fd250c78d9a73e (diff)
downloadllvm-684d6fdee208a1fa12e9cbe0a45f3c5b4b575ad7.zip
llvm-684d6fdee208a1fa12e9cbe0a45f3c5b4b575ad7.tar.gz
llvm-684d6fdee208a1fa12e9cbe0a45f3c5b4b575ad7.tar.bz2
[DebugInfo] Add check for .debug_line minimum_instruction_length of 0
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. Reviewed by: probinson Differential Revision: https://reviews.llvm.org/D75189
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp')
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
index 5585a59..2ffad82 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -1001,6 +1001,41 @@ INSTANTIATE_TEST_CASE_P(
Values(std::make_tuple(0, true), // Test zero value (error).
std::make_tuple(14, false)), ); // Test non-zero value (no error).
+struct BadMinInstLenFixture : TestWithParam<std::tuple<uint8_t, bool>>,
+ AdjustAddressFixtureBase {
+ void SetUp() override {
+ std::tie(MinInstLength, IsErrorExpected) = GetParam();
+ }
+
+ uint64_t editPrologue(LineTable &LT) 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;