Move find_minimal_symbol_address to minsyms.c
Commit Message
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(-)
Comments
Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:
> I found find_minimal_symbol_address in parse.c, but it seems to me
> that it belongs in minsyms.c.
No objections from me. Seems sensible.
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
> ---
> 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,
>
>
>
> -/* 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
@@ -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;
+ }
+}
@@ -92,86 +92,6 @@ innermost_block_tracker::update (const struct block *b,
-/* 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)