diff options
author | Tom Tromey <tromey@adacore.com> | 2023-03-01 10:33:27 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-03-29 10:16:23 -0600 |
commit | 2fc3b8a4cb8439fc53975c4e70336d76e3ddc531 (patch) | |
tree | 7a97dc3b1cbfb066a01ae8165c51a590f58c677d /gdb | |
parent | 168f9f95995d7958d8ae35a54c0691f46961c209 (diff) | |
download | binutils-2fc3b8a4cb8439fc53975c4e70336d76e3ddc531.zip binutils-2fc3b8a4cb8439fc53975c4e70336d76e3ddc531.tar.gz binutils-2fc3b8a4cb8439fc53975c4e70336d76e3ddc531.tar.bz2 |
Use the correct frame when evaluating a dynamic property
The test case in this patch shows an unusual situation: an Ada array
has a dynamic bound, but the bound comes from a frame that's referred
to by the static link. This frame is correctly found when evaluating
the array variable itself, but is lost when evaluating the array's
bounds.
This patch fixes the problem by passing this frame through to
value_at_lazy in the DWARF expression evaluator.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/dwarf2/expr.c | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/static-link.exp | 33 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/static-link/pck.ads | 18 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/static-link/prog.adb | 35 |
4 files changed, 88 insertions, 2 deletions
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index d245bc6..4aa4542 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1005,8 +1005,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, } address = value_as_address (value_from_pointer (ptr_type, address)); - retval = value_at_lazy (subobj_type, - address + subobj_offset); + retval = value_at_lazy (subobj_type, address + subobj_offset, + m_frame); if (in_stack_memory) retval->set_stack (true); } diff --git a/gdb/testsuite/gdb.ada/static-link.exp b/gdb/testsuite/gdb.ada/static-link.exp new file mode 100644 index 0000000..86f2fb5 --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link.exp @@ -0,0 +1,33 @@ +# Copyright 2023 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile prog + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/prog.adb] +if {![runto "prog.adb:$bp_location"]} { + return -1 +} + +gdb_test "ptype value" [string_to_regexp "type = array (1 .. 3) of integer"] diff --git a/gdb/testsuite/gdb.ada/static-link/pck.ads b/gdb/testsuite/gdb.ada/static-link/pck.ads new file mode 100644 index 0000000..a37f7bb --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link/pck.ads @@ -0,0 +1,18 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +package Pck is + Some_Value : Integer := 3; +end Pck; diff --git a/gdb/testsuite/gdb.ada/static-link/prog.adb b/gdb/testsuite/gdb.ada/static-link/prog.adb new file mode 100644 index 0000000..a14817b --- /dev/null +++ b/gdb/testsuite/gdb.ada/static-link/prog.adb @@ -0,0 +1,35 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +with Pck; use Pck; + +procedure Prog is + + Upper : Integer := Some_Value; + Value : array (1 .. Upper) of Integer := (23, 24, 25); + + procedure Inner_Most is + begin + null; -- STOP + end; + + procedure Intermediate is + begin + Inner_Most; + end; + +begin + Intermediate; +end Prog; |