From 1dd34eff4bb106e77b798e854f4b06cf1eb7d4b2 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 11 Aug 2021 08:17:36 -0600 Subject: Fix Ada regression due to DWARF expression series Commit 0579205aec4 ("Simplify dwarf_expr_context class interface") caused a regression in the internal AdaCore test suite. I didn't try to reproduce this with the GDB test suite, but the test is identical to gdb.dwarf2/dynarr-ptr.exp. The problem is that this change: case DW_OP_push_object_address: /* Return the address of the object we are currently observing. */ - if (this->data_view.data () == nullptr - && this->obj_address == 0) + if (this->m_addr_info == nullptr) ... slightly changes the logic here. In particular, it's possible for the caller to pass in a non-NULL m_addr_info, but one that looks like: (top) p *this.m_addr_info $15 = { type = 0x29b7a70, valaddr = { m_array = 0x0, m_size = 0 }, addr = 0, next = 0x0 } In this case, an additional check is needed. With the current code, what happens instead is that the computation computes an incorrect address -- but one that does not fail in read_memory, due to the precise memory map of the embedded target in question. This patch restores the old logic. --- gdb/dwarf2/expr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index cc1a72d..85088e9 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -2338,7 +2338,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_push_object_address: /* Return the address of the object we are currently observing. */ - if (this->m_addr_info == nullptr) + if (this->m_addr_info == nullptr + || (this->m_addr_info->valaddr.data () == nullptr + && this->m_addr_info->addr == 0)) error (_("Location address is not set.")); result_val -- cgit v1.1