Gracefully handle non-1 stack sizes in printCompactDWARFExpr rather than
assert. Add support for DW_OP_nop and test the zero-sized stack case.
This is intended to be nearly NFC.
Differential Revision: https://reviews.llvm.org/D147269
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
++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 << "]";
{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");
+}