diff options
author | Tom Tromey <tromey@adacore.com> | 2023-04-04 09:25:21 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-05-12 13:25:28 -0600 |
commit | e9151f7d626a6988e91320d5523778d02851c92f (patch) | |
tree | cfab2103a58e9c7765844dfc866b5e79c73e4cba /gdb | |
parent | 44a37a985325184e36743685ce496b042da7a816 (diff) | |
download | binutils-gdb-e9151f7d626a6988e91320d5523778d02851c92f.tar.gz |
Fix regression due to Pragma Import series
A co-worker here at AdaCore discovered that the Pragma Import series
caused a rgression. When debugging gnat1, gdb started asking for
overload resolution like:
(gdb) call pp(n)
Multiple matches for pp
[0] cancel
[1] pp (types.union_id) at ../../gcc/gcc/ada/treepr.adb:511
[2] treepr.pp (types.union_id) at ../../gcc/gcc/ada/treepr.adb:511
This worked before the series, and is strange anyway, because the
matches refer to the same function.
This patch adds a test case for this situation and fixes the bug by
pruning identical functions in remove_extra_symbols.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ada-lang.c | 14 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/import.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/import/pkg.adb | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/import/pkg.ads | 5 |
4 files changed, 28 insertions, 0 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b54ef19ad6a..21f3348a161 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5079,6 +5079,20 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms) } } + /* Two functions with the same block are identical. */ + + else if (syms[i].symbol->aclass () == LOC_BLOCK) + { + for (j = 0; !remove_p && j < syms.size (); j += 1) + { + if (i != j + && syms[j].symbol->aclass () == LOC_BLOCK + && (syms[i].symbol->value_block () + == syms[j].symbol->value_block ())) + remove_p = true; + } + } + if (remove_p) syms.erase (syms.begin () + i); else diff --git a/gdb/testsuite/gdb.ada/import.exp b/gdb/testsuite/gdb.ada/import.exp index 866b431aac5..90cffa48e9c 100644 --- a/gdb/testsuite/gdb.ada/import.exp +++ b/gdb/testsuite/gdb.ada/import.exp @@ -56,3 +56,5 @@ gdb_breakpoint "local_imported_func" message gdb_breakpoint "pkg.exported_func_ada" message gdb_breakpoint "exported_func_ada" message gdb_breakpoint "exported_func" message + +gdb_test "print copy" " = 42" diff --git a/gdb/testsuite/gdb.ada/import/pkg.adb b/gdb/testsuite/gdb.ada/import/pkg.adb index e4f1c1a88b7..1c706188c69 100644 --- a/gdb/testsuite/gdb.ada/import/pkg.adb +++ b/gdb/testsuite/gdb.ada/import/pkg.adb @@ -20,6 +20,13 @@ package body Pkg is return Imported_Var_Ada; end Exported_Func_Ada; + function base return Integer is + begin + return Imported_Var_Ada; + end base; + + function copy return Integer renames base; + procedure Do_Nothing (A : System.Address) is begin null; diff --git a/gdb/testsuite/gdb.ada/import/pkg.ads b/gdb/testsuite/gdb.ada/import/pkg.ads index 5576d1b92d7..e30781a436e 100644 --- a/gdb/testsuite/gdb.ada/import/pkg.ads +++ b/gdb/testsuite/gdb.ada/import/pkg.ads @@ -28,6 +28,11 @@ package Pkg is function Exported_Func_Ada return Integer; pragma Export (C, Exported_Func_Ada, "exported_func"); + function base return Integer; + pragma Export (Ada, base); + function copy return Integer; + pragma Export (Ada, copy); + procedure Do_Nothing (A : System.Address); end Pkg; |