From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Move find_minimal_symbol_address to minsyms.c
Date: Fri, 28 Apr 2023 06:49:56 -0600 [thread overview]
Message-ID: <20230428124956.1093451-1-tromey@adacore.com> (raw)
I found find_minimal_symbol_address in parse.c, but it seems to me
that it belongs in minsyms.c.
---
gdb/minsyms.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
gdb/parse.c | 80 ---------------------------------------------------
2 files changed, 78 insertions(+), 80 deletions(-)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a2c139db24d..5fcc7242626 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1611,3 +1611,81 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
return result;
}
+
+/* See minsyms.h. */
+
+type *
+find_minsym_type_and_address (minimal_symbol *msymbol,
+ struct objfile *objfile,
+ CORE_ADDR *address_p)
+{
+ bound_minimal_symbol bound_msym = {msymbol, objfile};
+ struct obj_section *section = msymbol->obj_section (objfile);
+ enum minimal_symbol_type type = msymbol->type ();
+
+ bool is_tls = (section != NULL
+ && section->the_bfd_section->flags & SEC_THREAD_LOCAL);
+
+ /* The minimal symbol might point to a function descriptor;
+ resolve it to the actual code address instead. */
+ CORE_ADDR addr;
+ if (is_tls)
+ {
+ /* Addresses of TLS symbols are really offsets into a
+ per-objfile/per-thread storage block. */
+ addr = CORE_ADDR (bound_msym.minsym->unrelocated_address ());
+ }
+ else if (msymbol_is_function (objfile, msymbol, &addr))
+ {
+ if (addr != bound_msym.value_address ())
+ {
+ /* This means we resolved a function descriptor, and we now
+ have an address for a code/text symbol instead of a data
+ symbol. */
+ if (msymbol->type () == mst_data_gnu_ifunc)
+ type = mst_text_gnu_ifunc;
+ else
+ type = mst_text;
+ section = NULL;
+ }
+ }
+ else
+ addr = bound_msym.value_address ();
+
+ if (overlay_debugging)
+ addr = symbol_overlayed_address (addr, section);
+
+ if (is_tls)
+ {
+ /* Skip translation if caller does not need the address. */
+ if (address_p != NULL)
+ *address_p = target_translate_tls_address (objfile, addr);
+ return builtin_type (objfile)->nodebug_tls_symbol;
+ }
+
+ if (address_p != NULL)
+ *address_p = addr;
+
+ switch (type)
+ {
+ case mst_text:
+ case mst_file_text:
+ case mst_solib_trampoline:
+ return builtin_type (objfile)->nodebug_text_symbol;
+
+ case mst_text_gnu_ifunc:
+ return builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol;
+
+ case mst_data:
+ case mst_file_data:
+ case mst_bss:
+ case mst_file_bss:
+ return builtin_type (objfile)->nodebug_data_symbol;
+
+ case mst_slot_got_plt:
+ return builtin_type (objfile)->nodebug_got_plt_symbol;
+
+ default:
+ return builtin_type (objfile)->nodebug_unknown_symbol;
+ }
+}
diff --git a/gdb/parse.c b/gdb/parse.c
index 85a6caf14ba..a84b4b64fdb 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -92,86 +92,6 @@ innermost_block_tracker::update (const struct block *b,
\f
-/* Return the type of MSYMBOL, a minimal symbol of OBJFILE. If
- ADDRESS_P is not NULL, set it to the MSYMBOL's resolved
- address. */
-
-type *
-find_minsym_type_and_address (minimal_symbol *msymbol,
- struct objfile *objfile,
- CORE_ADDR *address_p)
-{
- bound_minimal_symbol bound_msym = {msymbol, objfile};
- struct obj_section *section = msymbol->obj_section (objfile);
- enum minimal_symbol_type type = msymbol->type ();
-
- bool is_tls = (section != NULL
- && section->the_bfd_section->flags & SEC_THREAD_LOCAL);
-
- /* The minimal symbol might point to a function descriptor;
- resolve it to the actual code address instead. */
- CORE_ADDR addr;
- if (is_tls)
- {
- /* Addresses of TLS symbols are really offsets into a
- per-objfile/per-thread storage block. */
- addr = CORE_ADDR (bound_msym.minsym->unrelocated_address ());
- }
- else if (msymbol_is_function (objfile, msymbol, &addr))
- {
- if (addr != bound_msym.value_address ())
- {
- /* This means we resolved a function descriptor, and we now
- have an address for a code/text symbol instead of a data
- symbol. */
- if (msymbol->type () == mst_data_gnu_ifunc)
- type = mst_text_gnu_ifunc;
- else
- type = mst_text;
- section = NULL;
- }
- }
- else
- addr = bound_msym.value_address ();
-
- if (overlay_debugging)
- addr = symbol_overlayed_address (addr, section);
-
- if (is_tls)
- {
- /* Skip translation if caller does not need the address. */
- if (address_p != NULL)
- *address_p = target_translate_tls_address (objfile, addr);
- return builtin_type (objfile)->nodebug_tls_symbol;
- }
-
- if (address_p != NULL)
- *address_p = addr;
-
- switch (type)
- {
- case mst_text:
- case mst_file_text:
- case mst_solib_trampoline:
- return builtin_type (objfile)->nodebug_text_symbol;
-
- case mst_text_gnu_ifunc:
- return builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol;
-
- case mst_data:
- case mst_file_data:
- case mst_bss:
- case mst_file_bss:
- return builtin_type (objfile)->nodebug_data_symbol;
-
- case mst_slot_got_plt:
- return builtin_type (objfile)->nodebug_got_plt_symbol;
-
- default:
- return builtin_type (objfile)->nodebug_unknown_symbol;
- }
-}
-
bool
expr_complete_tag::complete (struct expression *exp,
completion_tracker &tracker)
--
2.39.1
next reply other threads:[~2023-04-28 12:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 12:49 Tom Tromey [this message]
2023-04-28 14:42 ` Andrew Burgess
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=20230428124956.1093451-1-tromey@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).