diff options
author | Tom Tromey <tromey@adacore.com> | 2024-02-14 09:48:34 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-03-19 11:53:21 -0600 |
commit | 1ab9eefe3cea741aba17e11ff28ed48ac3a8293a (patch) | |
tree | 618699fc2561149ed37db02151ad2457c14339cf /gdb/testsuite/gdb.ada | |
parent | 12d5d5bfd0201711ac3b14d8cd92589919a82b7a (diff) | |
download | binutils-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.zip binutils-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.tar.gz binutils-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.tar.bz2 |
Speed up lookup of "type_specific_data"
I noticed that "info locals" on a certain large Ada program was very
slow. I tracked this down to ada_get_tsd_type expanding nearly every
CU in the program.
This patch fixes the problem by changing this code to use the more
efficient lookup_transparent_type which, unlike the Ada-specific
lookup functions, does not try to find all matching instances.
Note that I first tried fixing this by changing ada_find_any_type, but
this did not work -- I may revisit this approach at some later date.
Also note that the copyright dates on the test files are set that way
because I copied them from another test.
New in v2: the new test failed on the Linaro regression tester.
Looking at the logs, it seems that gdb was picking up a 'value' from
libgnat:
$1 = {<text variable, no debug info>} 0xf7e227a4 <ada.calendar.formatting.value>
This version renames the local variable in an attempt to work around
this.
v3: In v2, while trying to reproduce the problem locally, I
accidentally forgot to commit one of the changes.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup.exp | 61 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup/foo.adb | 23 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup/pck.adb | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup/pck.ads | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads | 22 |
6 files changed, 170 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/tagged-lookup.exp b/gdb/testsuite/gdb.ada/tagged-lookup.exp new file mode 100644 index 0000000..4bc088b --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup.exp @@ -0,0 +1,61 @@ +# Copyright 2024 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/>. + +# Check that we can print values of parameters of type 'pointer +# (access) to tagged type'. See PR gdb/22670. + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] +if {![runto "foo.adb:$bp_location"]} { + return +} + +gdb_test_no_output "set debug symtab-create 1" + +# The idea here is that just a single CU should be expanded while +# searching for the tsd type. +set found_pck 0 +set found_pck2 0 +gdb_test_multiple "print *the_local_var" "only one CU expanded" -lbl { + -re ".symtab-create. start_subfile: name = \[^,\]*pck\\.adb, name_for_id = \[^\r\n\]*\r\n" { + set found_pck 1 + exp_continue + } + -re ".symtab-create. start_subfile: name = \[^,\]*pck2\\.adb, name_for_id = \[^\r\n\]*\r\n" { + set found_pck2 1 + exp_continue + } + -re ".symtab-create. start_subfile: name = \[^,\]*, name_for_id = \[^\r\n\]*\r\n" { + exp_continue + } + -re -wrap ".* = \\\(n => $decimal\\\)" { + if {$found_pck + $found_pck2 == 1} { + pass $gdb_test_name + } else { + fail $gdb_test_name + } + } +} diff --git a/gdb/testsuite/gdb.ada/tagged-lookup/foo.adb b/gdb/testsuite/gdb.ada/tagged-lookup/foo.adb new file mode 100644 index 0000000..35e1aa3 --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup/foo.adb @@ -0,0 +1,23 @@ +-- Copyright 2017-2024 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; +with Pck2; use Pck2; +procedure Foo is + The_Local_Var : access Top_T2 := new Top_T2'(N => 2); +begin + Inspect (new Top_T'(N => 2)); -- STOP + Inspect2 (The_Local_Var); +end Foo; diff --git a/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb b/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb new file mode 100644 index 0000000..d5f843a --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb @@ -0,0 +1,22 @@ +-- Copyright 2017-2024 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 Pck2; use Pck2; +package body Pck is + procedure Inspect (Obj: access Top_T'Class) is + begin + null; + end Inspect; +end Pck; diff --git a/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads b/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads new file mode 100644 index 0000000..7731fe2 --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads @@ -0,0 +1,21 @@ +-- Copyright 2017-2024 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 Top_T is tagged record + N : Integer := 1; + end record; + procedure Inspect (Obj: access Top_T'Class); +end Pck; diff --git a/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb b/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb new file mode 100644 index 0000000..87f77e5 --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb @@ -0,0 +1,21 @@ +-- Copyright 2017-2024 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 Pck2 is + procedure Inspect2 (Obj: access Top_T2'Class) is + begin + null; + end Inspect2; +end Pck2; diff --git a/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads b/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads new file mode 100644 index 0000000..c45962b --- /dev/null +++ b/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads @@ -0,0 +1,22 @@ +-- Copyright 2017-2024 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; +package Pck2 is + type Top_T2 is tagged record + N : Integer := 1; + end record; + procedure Inspect2 (Obj: access Top_T2'Class); +end Pck2; |