[Lldb-commits] [lldb] [llvm] [llvm][lldb] Handle oversized LEB128 operands in DWARF expressions (PR #219149)

via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 11 04:59:40 PDT 2026


================
@@ -420,6 +420,20 @@ TEST(DWARFExpression, DW_OP_const) {
   EXPECT_THAT_EXPECTED(
       Evaluate({DW_OP_consts, 0x81, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x40}),
       ExpectScalar(32, 0x01010101, true));
+
+  // A value wider than the 32-bit generic type is truncated before its
+  // signedness is applied.
+  const uint8_t oversized_sconst[] = {
+      DW_OP_consts, 0xff, 0xff, 0xff, 0xff, 0x8f,
+      0x80,         0x80, 0x80, 0x80, 0x02, DW_OP_stack_value};
+  DataExtractor extractor(oversized_sconst, sizeof(oversized_sconst),
+                          lldb::eByteOrderLittle, /*addr_size=*/4);
+  EXPECT_THAT_EXPECTED(
+      DWARFExpression::Evaluate(
+          /*exe_ctx=*/nullptr, /*reg_ctx=*/nullptr, /*module_sp=*/{}, extractor,
+          /*unit=*/nullptr, lldb::eRegisterKindLLDB,
+          /*initial_value_ptr=*/nullptr, /*object_address_ptr=*/nullptr),
+      ExpectScalar(32, UINT32_MAX, true));
----------------
MrEven132 wrote:

Agreed. `ExpectScalar(32, UINT32_MAX, true)` is semantically a signed 32-bit `-1`, but expressing the expected value as `-1` makes the test clearer. I'vd updated the test accordingly.

https://github.com/llvm/llvm-project/pull/219149


More information about the lldb-commits mailing list