Support lexical blocks and function bodies that occupy
non-contiguous address ranges. * addrmap.c, addrmap.h: New files. * block.h (struct addrmap): New forward declaration. (struct blockvector): New member, 'map'. (BLOCKVECTOR_MAP): New accessor macro. * block.c: #include "addrmap.h" (blockvector_for_pc_sect): If the blockvector we've found has an address map, use it instead of searching the blocks. * buildsym.c: #include "addrmap.h" (pending_addrmap_obstack, pending_addrmap_interesting): New static variables. (really_free_pendings): If we have a pending addrmap, free it too. (record_block_range): New function. (make_blockvector): If we have an interesting pending addrmap, record it in the new blockvector. (start_symtab, buildsym_init): Assert that there is no pending addrmap now; we should have cleaned up any addrmaps we'd built previously. (end_symtab): If there is a pending addrmap left over that didn't get included in the blockvector, free it. * buildsym.h (struct addrmap): New forward declaration. (record_block_range): New prototype. * objfiles.c: #include "addrmap.h". (objfile_relocate): Relocate the blockvector's address map, if present. * dwarf2read.c (dwarf2_record_block_ranges): New function. (read_func_scope, read_lexical_block_scope): Call it. * Makefile.in (SFILES): Add addrmap.c. (addrmap_h): New header dependency variable. (COMMON_OBS): Add addrmap.o. (addrmap.o): New rule.l (block.o, objfiles.o, buildsym.o): Depend on $(addrmap_h). * block.c (blockvector_for_pc, blockvector_for_pc_sect): Return a pointer to the block, not its index in the blockvector. (block_for_pc_sect): Use the returned block, instead of looking it up ourselves. * block.h (blockvector_for_pc, blockvector_for_pc_sect): Update declarations. * breakpoint.c (resolve_sal_pc): Use returned block, instead of looking it up ourselves. * stack.c (print_frame_label_vars): Disable function, which depends on the block's index. * buildsym.c (finish_block): Return the block we've built. * buildsym.h (finish_block): Update prototype. * defs.h (CORE_ADDR_MAX): New constant.
This commit is contained in:
parent
c420411fe8
commit
801e3a5b56
13 changed files with 947 additions and 32 deletions
45
gdb/block.c
45
gdb/block.c
|
@ -23,6 +23,7 @@
|
|||
#include "symfile.h"
|
||||
#include "gdb_obstack.h"
|
||||
#include "cp-support.h"
|
||||
#include "addrmap.h"
|
||||
|
||||
/* This is used by struct block to store namespace-related info for
|
||||
C++ files, namely using declarations and the current namespace in
|
||||
|
@ -63,14 +64,14 @@ block_function (const struct block *bl)
|
|||
return BLOCK_FUNCTION (bl);
|
||||
}
|
||||
|
||||
/* Return the blockvector immediately containing the innermost lexical block
|
||||
containing the specified pc value and section, or 0 if there is none.
|
||||
PINDEX is a pointer to the index value of the block. If PINDEX
|
||||
is NULL, we don't pass this information back to the caller. */
|
||||
/* Return the blockvector immediately containing the innermost lexical
|
||||
block containing the specified pc value and section, or 0 if there
|
||||
is none. PBLOCK is a pointer to the block. If PBLOCK is NULL, we
|
||||
don't pass this information back to the caller. */
|
||||
|
||||
struct blockvector *
|
||||
blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
|
||||
int *pindex, struct symtab *symtab)
|
||||
struct block **pblock, struct symtab *symtab)
|
||||
{
|
||||
struct block *b;
|
||||
int bot, top, half;
|
||||
|
@ -85,11 +86,27 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
|
|||
}
|
||||
|
||||
bl = BLOCKVECTOR (symtab);
|
||||
b = BLOCKVECTOR_BLOCK (bl, 0);
|
||||
|
||||
/* Then search that symtab for the smallest block that wins. */
|
||||
/* Use binary search to find the last block that starts before PC. */
|
||||
|
||||
/* If we have an addrmap mapping code addresses to blocks, then use
|
||||
that. */
|
||||
if (BLOCKVECTOR_MAP (bl))
|
||||
{
|
||||
b = addrmap_find (BLOCKVECTOR_MAP (bl), pc);
|
||||
if (b)
|
||||
{
|
||||
if (pblock)
|
||||
*pblock = b;
|
||||
return bl;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Otherwise, use binary search to find the last block that starts
|
||||
before PC. */
|
||||
bot = 0;
|
||||
top = BLOCKVECTOR_NBLOCKS (bl);
|
||||
|
||||
|
@ -110,8 +127,8 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
|
|||
b = BLOCKVECTOR_BLOCK (bl, bot);
|
||||
if (BLOCK_END (b) > pc)
|
||||
{
|
||||
if (pindex)
|
||||
*pindex = bot;
|
||||
if (pblock)
|
||||
*pblock = b;
|
||||
return bl;
|
||||
}
|
||||
bot--;
|
||||
|
@ -124,10 +141,10 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
|
|||
Backward compatibility, no section. */
|
||||
|
||||
struct blockvector *
|
||||
blockvector_for_pc (CORE_ADDR pc, int *pindex)
|
||||
blockvector_for_pc (CORE_ADDR pc, struct block **pblock)
|
||||
{
|
||||
return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc),
|
||||
pindex, NULL);
|
||||
pblock, NULL);
|
||||
}
|
||||
|
||||
/* Return the innermost lexical block containing the specified pc value
|
||||
|
@ -137,11 +154,11 @@ struct block *
|
|||
block_for_pc_sect (CORE_ADDR pc, struct bfd_section *section)
|
||||
{
|
||||
struct blockvector *bl;
|
||||
int index;
|
||||
struct block *b;
|
||||
|
||||
bl = blockvector_for_pc_sect (pc, section, &index, NULL);
|
||||
bl = blockvector_for_pc_sect (pc, section, &b, NULL);
|
||||
if (bl)
|
||||
return BLOCKVECTOR_BLOCK (bl, index);
|
||||
return b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue