/* Get info from stack frames; convert between frames, blocks,
functions and pc values.
- Copyright (C) 1986-2018 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
static CORE_ADDR cache_pc_function_low = 0;
static CORE_ADDR cache_pc_function_high = 0;
-static const char *cache_pc_function_name = 0;
+static const general_symbol_info *cache_pc_function_sym = nullptr;
static struct obj_section *cache_pc_function_section = NULL;
static const struct block *cache_pc_function_block = nullptr;
{
cache_pc_function_low = 0;
cache_pc_function_high = 0;
- cache_pc_function_name = (char *) 0;
+ cache_pc_function_sym = nullptr;
cache_pc_function_section = NULL;
cache_pc_function_block = nullptr;
}
/* See symtab.h. */
-int
-find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
- CORE_ADDR *endaddr, const struct block **block)
+bool
+find_pc_partial_function_sym (CORE_ADDR pc,
+ const struct general_symbol_info **sym,
+ CORE_ADDR *address, CORE_ADDR *endaddr,
+ const struct block **block)
{
struct obj_section *section;
struct symbol *f;
struct bound_minimal_symbol msymbol;
struct compunit_symtab *compunit_symtab = NULL;
- struct objfile *objfile;
CORE_ADDR mapped_pc;
- /* To ensure that the symbol returned belongs to the correct setion
+ /* To ensure that the symbol returned belongs to the correct section
(and that the last [random] symbol from the previous section
isn't returned) try to find the section containing PC. First try
the overlay code (which by default returns NULL); and second try
goto return_cached_value;
msymbol = lookup_minimal_symbol_by_pc_section (mapped_pc, section);
- ALL_OBJFILES (objfile)
- {
- if (objfile->sf)
- {
- compunit_symtab
- = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
- mapped_pc, section,
- 0);
- }
- if (compunit_symtab != NULL)
- break;
- }
+ compunit_symtab = find_pc_sect_compunit_symtab (mapped_pc, section);
if (compunit_symtab != NULL)
{
{
const struct block *b = SYMBOL_BLOCK_VALUE (f);
- cache_pc_function_name = SYMBOL_LINKAGE_NAME (f);
+ cache_pc_function_sym = f;
cache_pc_function_section = section;
cache_pc_function_block = b;
{
int i;
for (i = 0; i < BLOCK_NRANGES (b); i++)
- {
+ {
if (BLOCK_RANGE_START (b, i) <= mapped_pc
&& mapped_pc < BLOCK_RANGE_END (b, i))
{
if (msymbol.minsym == NULL)
{
/* No available symbol. */
- if (name != NULL)
- *name = 0;
+ if (sym != nullptr)
+ *sym = 0;
if (address != NULL)
*address = 0;
if (endaddr != NULL)
*endaddr = 0;
- return 0;
+ if (block != nullptr)
+ *block = nullptr;
+ return false;
}
cache_pc_function_low = BMSYMBOL_VALUE_ADDRESS (msymbol);
- cache_pc_function_name = MSYMBOL_LINKAGE_NAME (msymbol.minsym);
+ cache_pc_function_sym = msymbol.minsym;
cache_pc_function_section = section;
cache_pc_function_high = minimal_symbol_upper_bound (msymbol);
cache_pc_function_block = nullptr;
*address = cache_pc_function_low;
}
- if (name)
- *name = cache_pc_function_name;
+ if (sym != nullptr)
+ *sym = cache_pc_function_sym;
if (endaddr)
{
if (block != nullptr)
*block = cache_pc_function_block;
- return 1;
+ return true;
+}
+
+/* See symtab.h. */
+
+bool
+find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address,
+ CORE_ADDR *endaddr, const struct block **block)
+{
+ const general_symbol_info *gsi;
+ bool r = find_pc_partial_function_sym (pc, &gsi, address, endaddr, block);
+ if (name != nullptr)
+ *name = r ? gsi->linkage_name () : nullptr;
+ return r;
}
+
/* See symtab.h. */
bool
CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block);
for (int i = 0; i < BLOCK_NRANGES (block); i++)
- {
+ {
if (BLOCK_RANGE_START (block, i) <= entry_pc
&& entry_pc < BLOCK_RANGE_END (block, i))
{
if (address != nullptr)
- *address = BLOCK_RANGE_START (block, i);
+ *address = BLOCK_RANGE_START (block, i);
if (endaddr != nullptr)
- *endaddr = BLOCK_RANGE_END (block, i);
+ *endaddr = BLOCK_RANGE_END (block, i);
return status;
}
}
/* It's an internal error if we exit the above loop without finding
- the range. */
+ the range. */
internal_error (__FILE__, __LINE__,
- _("Entry block not found in find_function_entry_range_from_pc"));
+ _("Entry block not found in find_function_entry_range_from_pc"));
}
return status;
/* If we found a pointer to function, then the resolved type
is the type of the pointed-to function. */
- if (TYPE_CODE (resolver_ret_type) == TYPE_CODE_PTR)
+ if (resolver_ret_type->code () == TYPE_CODE_PTR)
{
struct type *resolved_type
= TYPE_TARGET_TYPE (resolver_ret_type);
- if (TYPE_CODE (check_typedef (resolved_type)) == TYPE_CODE_FUNC)
+ if (check_typedef (resolved_type)->code () == TYPE_CODE_FUNC)
return resolved_type;
}
}
struct frame_info *
block_innermost_frame (const struct block *block)
{
- struct frame_info *frame;
-
if (block == NULL)
return NULL;
- frame = get_selected_frame_if_set ();
- if (frame == NULL)
- frame = get_current_frame ();
+ frame_info *frame = get_selected_frame ();
while (frame != NULL)
{
const struct block *frame_block = get_frame_block (frame, NULL);