--- gdb/linespec.c | 95 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 8a2c8e3..702ffb3 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3446,6 +3446,9 @@ struct collect_minsyms /* The objfile we're examining. */ struct objfile *objfile; + /* Only search the given symtab, or NULL to search for all symbols. */ + struct symtab *symtab; + /* The funfirstline setting from the initial call. */ int funfirstline; @@ -3505,6 +3508,24 @@ add_minsym (struct minimal_symbol *minsym, void *d) mo.minsym = minsym; mo.objfile = info->objfile; + if (info->symtab != NULL) + { + CORE_ADDR pc; + struct symtab_and_line sal; + struct gdbarch *gdbarch = get_objfile_arch (info->objfile); + + sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (info->objfile, minsym), + NULL, 0); + sal.section = MSYMBOL_OBJ_SECTION (info->objfile, minsym); + pc + = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, ¤t_target); + if (pc != sal.pc) + sal = find_pc_sect_line (pc, NULL, 0); + + if (info->symtab != sal.symtab) + return; + } + /* Exclude data symbols when looking for breakpoint locations. */ if (!info->list_mode) switch (minsym->type) @@ -3531,40 +3552,59 @@ add_minsym (struct minimal_symbol *minsym, void *d) VEC_safe_push (bound_minimal_symbol_d, info->msyms, &mo); } -/* Search minimal symbols in all objfiles for NAME. If SEARCH_PSPACE +/* Search for minimal symbols called NAME. If SEARCH_PSPACE is not NULL, the search is restricted to just that program - space. */ + space. + + If SYMTAB is NULL, search all objfiles, otherwise + restrict results to the given SYMTAB. */ static void search_minsyms_for_name (struct collect_info *info, const char *name, - struct program_space *search_pspace) + struct program_space *search_pspace, + struct symtab *symtab) { - struct objfile *objfile; - struct program_space *pspace; + struct collect_minsyms local; + struct cleanup *cleanup; - ALL_PSPACES (pspace) - { - struct collect_minsyms local; - struct cleanup *cleanup; + memset (&local, 0, sizeof (local)); + local.funfirstline = info->state->funfirstline; + local.list_mode = info->state->list_mode; + local.symtab = symtab; - if (search_pspace != NULL && search_pspace != pspace) - continue; - if (pspace->executing_startup) - continue; + cleanup = make_cleanup (VEC_cleanup (bound_minimal_symbol_d), &local.msyms); - set_current_program_space (pspace); + if (symtab == NULL) + { + struct program_space *pspace; + + ALL_PSPACES (pspace) + { + struct objfile *objfile; - memset (&local, 0, sizeof (local)); - local.funfirstline = info->state->funfirstline; - local.list_mode = info->state->list_mode; + if (search_pspace != NULL && search_pspace != pspace) + continue; + if (pspace->executing_startup) + continue; - cleanup = make_cleanup (VEC_cleanup (bound_minimal_symbol_d), - &local.msyms); + set_current_program_space (pspace); - ALL_OBJFILES (objfile) + ALL_OBJFILES (objfile) + { + local.objfile = objfile; + iterate_over_minimal_symbols (objfile, name, add_minsym, &local); + } + } + } + else { - local.objfile = objfile; - iterate_over_minimal_symbols (objfile, name, add_minsym, &local); + if (search_pspace == NULL || SYMTAB_PSPACE (symtab) == search_pspace) + { + set_current_program_space (SYMTAB_PSPACE (symtab)); + local.objfile = symtab->objfile; + iterate_over_minimal_symbols (local.objfile, name, add_minsym, + &local); + } } if (!VEC_empty (bound_minimal_symbol_d, local.msyms)) @@ -3597,7 +3637,6 @@ search_minsyms_for_name (struct collect_info *info, const char *name, } do_cleanups (cleanup); - } } /* A helper function to add all symbols matching NAME to INFO. If @@ -3619,7 +3658,7 @@ add_matching_symbols_to_info (const char *name, iterate_over_all_matching_symtabs (info->state, name, VAR_DOMAIN, collect_symbols, info, pspace, 1); - search_minsyms_for_name (info, name, pspace); + search_minsyms_for_name (info, name, pspace, NULL); } else if (pspace == NULL || pspace == SYMTAB_PSPACE (elt)) { @@ -3629,6 +3668,14 @@ add_matching_symbols_to_info (const char *name, set_current_program_space (SYMTAB_PSPACE (elt)); iterate_over_file_blocks (elt, name, VAR_DOMAIN, collect_symbols, info); + + /* If no symbols were found and this symtab is in + assembler, we might actually be looking for a + label for which we don't have debug info. Check + for a minimal symbol in this case. */ + if (VEC_empty (symbolp, info->result.symbols) + && elt->language == language_asm) + search_minsyms_for_name (info, name, pspace, elt); } } } -- 1.9.3