Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: check for groups with duplicate names in reggroups:add
@ 2022-10-18 14:17 Simon Marchi via Gdb-patches
  2022-10-18 18:42 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-10-18 14:17 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

In the downstream ROCm GDB port, we would create multiple register
groups with duplicate names.  While it did not really hurt, it certainly
wasn't the intent.  And I don't think it ever makes sense to do so.

To catch these, change the assert in reggroups::add to check for
duplicate names.  It's no longer necessary to check for duplicate
reggroup pointers, because adding the same group twice would be caught
by the duplicate name check.

Change-Id: Id216a58acf91f1b314d3cba2d02de73656f8851d
---
 gdb/reggroups.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 8e4af303c545..a012bf085265 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -71,8 +71,13 @@ struct reggroups
   void add (const reggroup *group)
   {
     gdb_assert (group != nullptr);
-    gdb_assert (std::find (m_groups.begin(), m_groups.end(), group)
-		== m_groups.end());
+
+    auto find_by_name = [group] (const reggroup *g)
+      {
+	return streq (group->name (), g->name ());
+      };
+    gdb_assert (std::find_if (m_groups.begin (), m_groups.end (), find_by_name)
+		== m_groups.end ());
 
     m_groups.push_back (group);
   }
-- 
2.38.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-19  2:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 14:17 [PATCH] gdb: check for groups with duplicate names in reggroups:add Simon Marchi via Gdb-patches
2022-10-18 18:42 ` Tom Tromey
2022-10-18 18:54   ` Simon Marchi via Gdb-patches
2022-10-18 19:01     ` Tom Tromey
2022-10-18 20:47       ` Simon Marchi via Gdb-patches
2022-10-19  1:54         ` Tom Tromey
2022-10-19  2:12           ` Simon Marchi via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox