X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fblockframe.c;h=d9c28e0a0176a1d91fec1df089fdc4aa382e8672;hb=2365f8d70c50afbfd6be69a4076ea6e78fb5485d;hp=6dc736ea5ed2cde4bfaac2a98f339c47f6ab0d62;hpb=fc811edd39fcdf6e52c95ebd2d975debee700223;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 6dc736ea5e..d9c28e0a01 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -1,7 +1,7 @@ /* Get info from stack frames; convert between frames, blocks, functions and pc values. - Copyright (C) 1986-2018 Free Software Foundation, Inc. + Copyright (C) 1986-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -96,7 +96,7 @@ get_pc_function_start (CORE_ADDR pc) if (symbol) { bl = SYMBOL_BLOCK_VALUE (symbol); - return BLOCK_START (bl); + return BLOCK_ENTRY_PC (bl); } } @@ -209,7 +209,7 @@ clear_pc_function_cache (void) /* See symtab.h. */ -int +bool find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block) { @@ -217,10 +217,9 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, 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 @@ -237,18 +236,19 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, 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; - } + for (objfile *objfile : current_program_space->objfiles ()) + { + if (objfile->sf) + { + compunit_symtab + = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol, + mapped_pc, + section, + 0); + } + if (compunit_symtab != NULL) + break; + } if (compunit_symtab != NULL) { @@ -269,7 +269,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, { const struct block *b = SYMBOL_BLOCK_VALUE (f); - cache_pc_function_name = SYMBOL_LINKAGE_NAME (f); + cache_pc_function_name = f->linkage_name (); cache_pc_function_section = section; cache_pc_function_block = b; @@ -331,11 +331,13 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, *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_name = msymbol.minsym->linkage_name (); cache_pc_function_section = section; cache_pc_function_high = minimal_symbol_upper_bound (msymbol); cache_pc_function_block = nullptr; @@ -372,7 +374,44 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, if (block != nullptr) *block = cache_pc_function_block; - return 1; + return true; +} + +/* See symtab.h. */ + +bool +find_function_entry_range_from_pc (CORE_ADDR pc, const char **name, + CORE_ADDR *address, CORE_ADDR *endaddr) +{ + const struct block *block; + bool status = find_pc_partial_function (pc, name, address, endaddr, &block); + + if (status && block != nullptr && !BLOCK_CONTIGUOUS_P (block)) + { + 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); + + if (endaddr != nullptr) + *endaddr = BLOCK_RANGE_END (block, i); + + return status; + } + } + + /* It's an internal error if we exit the above loop without finding + the range. */ + internal_error (__FILE__, __LINE__, + _("Entry block not found in find_function_entry_range_from_pc")); + } + + return status; } /* See symtab.h. */ @@ -382,7 +421,7 @@ find_function_type (CORE_ADDR pc) { struct symbol *sym = find_pc_function (pc); - if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc) + if (sym != NULL && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == pc) return SYMBOL_TYPE (sym); return NULL;