================
@@ -1344,6 +1344,35 @@ TEST_F(DWARFExpressionMockProcessTest, DW_OP_bregx) {
ExpectLoadAddress(0x2010));
}
+TEST_F(DWARFExpressionMockProcessTest, DW_OP_breg_address_size) {
+ TestContext ctx;
+ ASSERT_TRUE(
+ CreateTestContext(&ctx, "i386-pc-linux", RegisterValue(uint32_t{0x2a})));
+ ExecutionContext exe_ctx(ctx.process_sp);
+
+ // Address arithmetic wraps at the target address size. In particular,
+ // 0xffffffff + 1 is zero on this 32-bit target.
+ EXPECT_THAT_EXPECTED(
+ Evaluate({DW_OP_breg0, 0x7f, DW_OP_const4u, 0xff, 0xff, 0xff, 0xff,
+ DW_OP_plus, DW_OP_lit1, DW_OP_plus, DW_OP_stack_value},
+ {}, {}, &exe_ctx, ctx.reg_ctx_sp.get()),
+ ExpectScalar(32, 0x29, false));
+}
+
+TEST_F(DWARFExpressionMockProcessTest, DW_OP_bregx_address_size) {
+ TestContext ctx;
+ ASSERT_TRUE(CreateTestContext(&ctx, "i386-pc-linux",
+ RegisterValue(uint64_t{0x10000002a})));
+ ExecutionContext exe_ctx(ctx.process_sp);
+
+ // The register backend may expose a value wider than the target address.
+ EXPECT_THAT_EXPECTED(
+ Evaluate({DW_OP_bregx, 0x40, 0x7f, DW_OP_const4u, 0xff, 0xff, 0xff, 0xff,
+ DW_OP_plus, DW_OP_lit1, DW_OP_plus, DW_OP_stack_value},
+ {}, {}, &exe_ctx, ctx.reg_ctx_sp.get()),
+ ExpectScalar(32, 0x29, false));
+}
----------------
firmiana402 wrote:
Same here.
https://github.com/llvm/llvm-project/pull/216291
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits