[PATCH] D147269: [DebugInfo] printCompactDWARFExpr: don't assert on stack size
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 13:49:39 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f596bb50944: [DebugInfo] printCompactDWARFExpr: don't assert on stack size (authored by scott.linder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147269/new/
https://reviews.llvm.org/D147269
Files:
llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
llvm/unittests/DebugInfo/DWARF/DWARFExpressionCompactPrinterTest.cpp
Index: llvm/unittests/DebugInfo/DWARF/DWARFExpressionCompactPrinterTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFExpressionCompactPrinterTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFExpressionCompactPrinterTest.cpp
@@ -124,3 +124,11 @@
{DW_OP_entry_value, 0x02, DW_OP_breg13, 0x10, DW_OP_stack_value},
"entry([SP+16])");
}
+
+TEST_F(DWARFExpressionCompactPrinterTest, Test_OP_nop) {
+ TestExprPrinter({DW_OP_nop}, "<stack of size 0, expected 1>");
+}
+
+TEST_F(DWARFExpressionCompactPrinterTest, Test_OP_nop_OP_reg) {
+ TestExprPrinter({DW_OP_nop, DW_OP_reg0}, "R0");
+}
Index: llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
@@ -454,6 +454,9 @@
Stack.back().Kind = PrintedExpr::Value;
break;
}
+ case dwarf::DW_OP_nop: {
+ break;
+ }
default:
if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
// DW_OP_reg<N>: A register, with the register num implied by the
@@ -487,7 +490,10 @@
++I;
}
- assert(Stack.size() == 1 && "expected one value on stack");
+ if (Stack.size() != 1) {
+ OS << "<stack of size " << Stack.size() << ", expected 1>";
+ return false;
+ }
if (Stack.front().Kind == PrintedExpr::Address)
OS << "[" << Stack.front().String << "]";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147269.515082.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230419/1848a57a/attachment.bin>
More information about the llvm-commits
mailing list