#include "cp-support.h"
#include "language.h"
#include "cli/cli-utils.h"
-#include "common/symbol.h"
+#include "gdbsupport/symbol.h"
#include <algorithm>
#include "safe-ctype.h"
lookup_minimal_symbol (const char *name, const char *sfile,
struct objfile *objf)
{
- struct objfile *objfile;
found_minimal_symbols found;
unsigned int mangled_hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- for (objfile = object_files;
- objfile != NULL && found.external_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found.external_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
return lookup_minimal_symbol (name, NULL, NULL);
}
-/* See common/symbol.h. */
+/* See gdbsupport/symbol.h. */
int
find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
struct bound_minimal_symbol
lookup_minimal_symbol_text (const char *name, struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct bound_minimal_symbol found_symbol = { NULL, NULL };
struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL && found_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
return NULL;
}
-/* See minsyms.h. */
-
-struct bound_minimal_symbol
-lookup_minimal_symbol_solib_trampoline (const char *name,
- struct objfile *objf)
-{
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
- struct bound_minimal_symbol found_symbol = { NULL, NULL };
-
- unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
-
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
- {
- if (objf == NULL || objf == objfile
- || objf == objfile->separate_debug_objfile_backlink)
- {
- for (msymbol = objfile->per_bfd->msymbol_hash[hash];
- msymbol != NULL;
- msymbol = msymbol->hash_next)
- {
- if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0 &&
- MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
- {
- found_symbol.objfile = objfile;
- found_symbol.minsym = msymbol;
- return found_symbol;
- }
- }
- }
- }
-
- return found_symbol;
-}
-
/* A helper function that makes *PC section-relative. This searches
the sections of OBJFILE and if *PC is in a section, it subtracts
the section offset and returns true. Otherwise it returns
int lo;
int hi;
int newobj;
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct minimal_symbol *best_symbol = NULL;
struct objfile *best_objfile = NULL;
gdb_assert (section != NULL);
- for (objfile = section->objfile;
- objfile != NULL;
- objfile = objfile_separate_debug_iterate (section->objfile, objfile))
+ for (objfile *objfile : section->objfile->separate_debug_objfiles ())
{
CORE_ADDR pc = pc_in;
CORE_ADDR
minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
{
- int i;
short section;
struct obj_section *obj_section;
CORE_ADDR result;
- struct minimal_symbol *msymbol;
+ struct minimal_symbol *iter, *msymbol;
gdb_assert (minsym.minsym != NULL);
other sections, to find the next symbol in this section with a
different address. */
+ struct minimal_symbol *past_the_end
+ = (minsym.objfile->per_bfd->msymbols.get ()
+ + minsym.objfile->per_bfd->minimal_symbol_count);
msymbol = minsym.minsym;
section = MSYMBOL_SECTION (msymbol);
- for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
+ for (iter = msymbol + 1; iter != past_the_end; ++iter)
{
- if ((MSYMBOL_VALUE_RAW_ADDRESS (msymbol + i)
+ if ((MSYMBOL_VALUE_RAW_ADDRESS (iter)
!= MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
- && MSYMBOL_SECTION (msymbol + i) == section)
+ && MSYMBOL_SECTION (iter) == section)
break;
}
obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
- if (MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL
- && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i)
+ if (iter != past_the_end
+ && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter)
< obj_section_endaddr (obj_section)))
- result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i);
+ result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter);
else
/* We got the start address from the last msymbol in the objfile.
So the end address is the end of the section. */