summaryrefslogtreecommitdiff
path: root/gdb-8.3/gdb/psymtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb-8.3/gdb/psymtab.c')
-rw-r--r--gdb-8.3/gdb/psymtab.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/gdb-8.3/gdb/psymtab.c b/gdb-8.3/gdb/psymtab.c
index 0a4502e4f..682696a7e 100644
--- a/gdb-8.3/gdb/psymtab.c
+++ b/gdb-8.3/gdb/psymtab.c
@@ -312,14 +312,24 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
struct obj_section *section,
struct bound_minimal_symbol msymbol)
{
- CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
-
- /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
- than the later used TEXTLOW/TEXTHIGH one. */
-
- if (objfile->partial_symtabs->psymtabs_addrmap != NULL)
+ /* Try just the PSYMTABS_ADDRMAP mapping first as it has better
+ granularity than the later used TEXTLOW/TEXTHIGH one. However, we need
+ to take care as the PSYMTABS_ADDRMAP can hold things other than partial
+ symtabs in some cases.
+
+ This function should only be called for objfiles that are using partial
+ symtabs, not for objfiles that are using indexes (.gdb_index or
+ .debug_names), however 'maintenance print psymbols' calls this function
+ directly for all objfiles. If we assume that PSYMTABS_ADDRMAP contains
+ partial symtabs then we will end up returning a pointer to an object
+ that is not a partial_symtab, which doesn't end well. */
+
+ if (objfile->partial_symtabs->psymtabs != NULL
+ && objfile->partial_symtabs->psymtabs_addrmap != NULL)
{
+ CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile));
+
struct partial_symtab *pst
= ((struct partial_symtab *)
addrmap_find (objfile->partial_symtabs->psymtabs_addrmap,