Browse Source

* symtab.c (find_addr_symbol): New routine that will find the nearest

symbol associated with an address.  It does so by exhaustive
search of the symtabs, so it's slow but complete.
gdb-4_18-branch
John Gilmore 33 years ago
parent
commit
e0ea0fbd41
  1. 6
      gdb/ChangeLog
  2. 65
      gdb/symtab.c

6
gdb/ChangeLog

@ -1,3 +1,9 @@
Wed Jan 12 00:16:26 1994 John Gilmore (gnu@cygnus.com)
* symtab.c (find_addr_symbol): New routine that will find the nearest
symbol associated with an address. It does so by exhaustive
search of the symtabs, so it's slow but complete.
Tue Jan 11 23:57:30 1994 John Gilmore (gnu@cygnus.com)
* coffread.c (read_coff_symtab): Set PC bounds of _globals_ symtab

65
gdb/symtab.c

@ -1026,6 +1026,71 @@ find_pc_symtab (pc)
}
return (s);
}
/* Find the closest symbol value (of any sort -- function or variable)
for a given address value. Slow but complete. */
struct symbol *
find_addr_symbol (addr)
CORE_ADDR addr;
{
struct symtab *symtab;
struct objfile *objfile;
register int bot, top;
register struct symbol *sym;
register CORE_ADDR sym_addr;
struct block *block;
int blocknum;
/* Info on best symbol seen so far */
register CORE_ADDR best_sym_addr = 0;
struct symbol *best_sym = 0;
/* FIXME -- we should pull in all the psymtabs, too! */
ALL_SYMTABS (objfile, symtab)
{
/* Search the global and static blocks in this symtab for
the closest symbol-address to the desired address. */
for (blocknum = GLOBAL_BLOCK; blocknum <= STATIC_BLOCK; blocknum++)
{
QUIT;
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), blocknum);
top = BLOCK_NSYMS (block);
for (bot = 0; bot < top; bot++)
{
sym = BLOCK_SYM (block, bot);
switch (SYMBOL_CLASS (sym))
{
case LOC_STATIC:
case LOC_LABEL:
sym_addr = SYMBOL_VALUE_ADDRESS (sym);
break;
case LOC_BLOCK:
sym_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
break;
default:
continue;
}
if (sym_addr <= addr)
if (sym_addr > best_sym_addr)
{
/* Quit if we found an exact match. */
if (sym_addr == addr)
return sym;
best_sym = sym;
best_sym_addr = sym_addr;
}
}
}
}
return best_sym;
}
/* Find the source file and line number for a given PC value.
Return a structure containing a symtab pointer, a line number,

Loading…
Cancel
Save