public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: check for groups with duplicate names in reggroups:add
Date: Wed, 19 Oct 2022 02:12:26 +0000 (GMT)	[thread overview]
Message-ID: <20221019021226.A6DBC3858D39@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9454c9ce88b25646d279feed329c9cdba69b4905

commit 9454c9ce88b25646d279feed329c9cdba69b4905
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Oct 18 10:17:33 2022 -0400

    gdb: check for groups with duplicate names in reggroups:add
    
    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
    Approved-By: Tom Tromey <tom@tromey.com>

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

diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 8e4af303c54..a012bf08526 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);
   }

                 reply	other threads:[~2022-10-19  2:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221019021226.A6DBC3858D39@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@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).