aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-03-03 10:29:06 -0700
committerTom Tromey <tromey@adacore.com>2023-04-21 07:13:45 -0600
commit532d55c0ab4bda1d5da90c6301c7d28ddd98ad18 (patch)
tree0d1accde94c6c7a390aceb3a604593444f6a5285 /gdb
parent32c8e7265a55ab4cf14fa255115a81134c62fb16 (diff)
downloadgdb-532d55c0ab4bda1d5da90c6301c7d28ddd98ad18.zip
gdb-532d55c0ab4bda1d5da90c6301c7d28ddd98ad18.tar.gz
gdb-532d55c0ab4bda1d5da90c6301c7d28ddd98ad18.tar.bz2
Handle function descriptors in call_site_target
call_site_target::iterate_over_addresses may look up a minimal symbol. On platforms like PPC64 that use function descriptors, this may find an unexpected address. The fix is to use gdbarch_convert_from_func_ptr_addr to convert from a function descriptor to the address recorded at the call site. I've added a new test case that is based on the internal AdaCore test that provoked this bug. However, I'm unable to test it as-is on PPC64.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/loc.c6
-rw-r--r--gdb/testsuite/gdb.ada/finish-large.exp30
-rw-r--r--gdb/testsuite/gdb.ada/finish-large/p.adb24
-rw-r--r--gdb/testsuite/gdb.ada/finish-large/pck.adb28
-rw-r--r--gdb/testsuite/gdb.ada/finish-large/pck.ads37
5 files changed, 124 insertions, 1 deletions
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 914e016..d961587 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -711,7 +711,11 @@ call_site_target::iterate_over_addresses
: msym.minsym->print_name ()));
}
- callback (msym.value_address ());
+
+ CORE_ADDR addr = (gdbarch_convert_from_func_ptr_addr
+ (call_site_gdbarch, msym.value_address (),
+ current_inferior ()->top_target ()));
+ callback (addr);
}
break;
diff --git a/gdb/testsuite/gdb.ada/finish-large.exp b/gdb/testsuite/gdb.ada/finish-large.exp
new file mode 100644
index 0000000..5661d13
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/finish-large.exp
@@ -0,0 +1,30 @@
+# 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 p
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+runto "pck.create_large"
+
+set value "= (i => 1, j => 2, k => 3, l => 4, m => 5, n => 6, o => 7, p => 8, q => 9, r => 10, s => 11, t => 12)"
+gdb_test "finish" [string_to_regexp $value]
diff --git a/gdb/testsuite/gdb.ada/finish-large/p.adb b/gdb/testsuite/gdb.ada/finish-large/p.adb
new file mode 100644
index 0000000..ce7631e
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/finish-large/p.adb
@@ -0,0 +1,24 @@
+-- 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 P is
+ Large : Data_Large;
+begin
+ Large := Create_Large;
+ Large.P := 42;
+ Break_Me;
+end P;
diff --git a/gdb/testsuite/gdb.ada/finish-large/pck.adb b/gdb/testsuite/gdb.ada/finish-large/pck.adb
new file mode 100644
index 0000000..18ed031
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/finish-large/pck.adb
@@ -0,0 +1,28 @@
+-- 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 body Pck is
+
+ function Create_Large return Data_Large is
+ begin
+ return (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
+ end Create_Large;
+
+ procedure Break_Me is
+ begin
+ null;
+ end Break_Me;
+
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/finish-large/pck.ads b/gdb/testsuite/gdb.ada/finish-large/pck.ads
new file mode 100644
index 0000000..0ed49a7
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/finish-large/pck.ads
@@ -0,0 +1,37 @@
+-- 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
+
+ type Data_Large is record
+ I : Integer;
+ J : Integer;
+ K : Integer;
+ L : Integer;
+ M : Integer;
+ N : Integer;
+ O : Integer;
+ P : Integer;
+ Q : Integer;
+ R : Integer;
+ S : Integer;
+ T : Integer;
+ end record;
+
+ function Create_Large return Data_Large;
+
+ procedure Break_Me;
+
+end Pck;