From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Merge both implementations of debug_names::insert
Date: Sun, 25 Sep 2022 11:34:43 -0600 [thread overview]
Message-ID: <20220925173443.3561411-1-tom@tromey.com> (raw)
The class debug_names has two 'insert' overloads, but only one of them
is ever called externally, and it simply forwards to the other
implementation. It seems cleaner to me to have a single method, so
this patch merges the two.
---
gdb/dwarf2/index-write.c | 51 +++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 4cc0ee53070..4827b594994 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -519,10 +519,29 @@ class debug_names
enum class unit_kind { cu, tu };
/* Insert one symbol. */
- void insert (int dwarf_tag, const char *name, int cu_index, bool is_static,
- unit_kind kind, enum language lang)
+ void insert (const cooked_index_entry *entry)
{
- if (lang == language_ada)
+ const auto it = m_cu_index_htab.find (entry->per_cu);
+ gdb_assert (it != m_cu_index_htab.cend ());
+ const char *name = entry->full_name (&m_string_obstack);
+
+ /* This is incorrect but it mirrors gdb's historical behavior; and
+ because the current .debug_names generation is also incorrect,
+ it seems better to follow what was done before, rather than
+ introduce a mismatch between the newer and older gdb. */
+ dwarf_tag tag = entry->tag;
+ if (tag != DW_TAG_typedef && tag_is_type (tag))
+ tag = DW_TAG_structure_type;
+ else if (tag == DW_TAG_enumerator || tag == DW_TAG_constant)
+ tag = DW_TAG_variable;
+
+ int cu_index = it->second;
+ bool is_static = (entry->flags & IS_STATIC) != 0;
+ unit_kind kind = (entry->per_cu->is_debug_types
+ ? unit_kind::tu
+ : unit_kind::cu);
+
+ if (entry->per_cu->lang () == language_ada)
{
/* We want to ensure that the Ada main function's name appears
verbatim in the index. However, this name will be of the
@@ -535,8 +554,7 @@ class debug_names
= m_name_to_value_set.emplace (c_str_view (name),
std::set<symbol_value> ());
std::set<symbol_value> &value_set = insertpair.first->second;
- value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static,
- kind));
+ value_set.emplace (symbol_value (tag, cu_index, is_static, kind));
}
/* In order for the index to work when read back into gdb, it
@@ -562,28 +580,7 @@ class debug_names
= m_name_to_value_set.emplace (c_str_view (name),
std::set<symbol_value> ());
std::set<symbol_value> &value_set = insertpair.first->second;
- value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind));
- }
-
- void insert (const cooked_index_entry *entry)
- {
- const auto it = m_cu_index_htab.find (entry->per_cu);
- gdb_assert (it != m_cu_index_htab.cend ());
- const char *name = entry->full_name (&m_string_obstack);
-
- /* This is incorrect but it mirrors gdb's historical behavior; and
- because the current .debug_names generation is also incorrect,
- it seems better to follow what was done before, rather than
- introduce a mismatch between the newer and older gdb. */
- dwarf_tag tag = entry->tag;
- if (tag != DW_TAG_typedef && tag_is_type (tag))
- tag = DW_TAG_structure_type;
- else if (tag == DW_TAG_enumerator || tag == DW_TAG_constant)
- tag = DW_TAG_variable;
-
- insert (tag, name, it->second, (entry->flags & IS_STATIC) != 0,
- entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu,
- entry->per_cu->lang ());
+ value_set.emplace (symbol_value (tag, cu_index, is_static, kind));
}
/* Build all the tables. All symbols must be already inserted.
--
2.34.3
next reply other threads:[~2022-09-25 17:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-25 17:34 Tom Tromey [this message]
2022-10-08 15:04 ` 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=20220925173443.3561411-1-tom@tromey.com \
--to=tom@tromey.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).