From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 8/8] Fix regression due to Pragma Import series
Date: Fri, 07 Apr 2023 10:40:01 -0600 [thread overview]
Message-ID: <20230314-submit-pragma-import-export-v2-8-dcff927191fb@adacore.com> (raw)
In-Reply-To: <20230314-submit-pragma-import-export-v2-0-dcff927191fb@adacore.com>
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.
---
gdb/ada-lang.c | 14 ++++++++++++++
gdb/testsuite/gdb.ada/import.exp | 2 ++
gdb/testsuite/gdb.ada/import/pkg.adb | 7 +++++++
gdb/testsuite/gdb.ada/import/pkg.ads | 5 +++++
4 files changed, 28 insertions(+)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 091faba3037..224850b7a69 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5080,6 +5080,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;
--
2.39.1
next prev parent reply other threads:[~2023-04-07 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 16:39 [PATCH v2 0/8] Implement Ada Pragma Import and Pragma Export Tom Tromey
2023-04-07 16:39 ` [PATCH v2 1/8] Introduce lookup_minimal_symbol_linkage Tom Tromey
2023-04-07 16:39 ` [PATCH v2 2/8] Bump MAX_SYMBOL_IMPLS Tom Tromey
2023-04-07 16:39 ` [PATCH v2 3/8] Define symbol::value_block separately Tom Tromey
2023-04-07 16:39 ` [PATCH v2 4/8] Introduce symbol_block_ops::get_block_value Tom Tromey
2023-04-07 16:39 ` [PATCH v2 5/8] Handle Ada Pragma Import and Pragma Export Tom Tromey
2023-04-07 16:39 ` [PATCH v2 6/8] Use reference parameter in remove_extra_symbols Tom Tromey
2023-04-07 16:40 ` [PATCH v2 7/8] Use bool and early loop exit " Tom Tromey
2023-04-07 16:40 ` Tom Tromey [this message]
2023-05-12 19:25 ` [PATCH v2 0/8] Implement Ada Pragma Import and Pragma Export Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230314-submit-pragma-import-export-v2-8-dcff927191fb@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).