aboutsummaryrefslogtreecommitdiff
path: root/gdb/findvar.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r--gdb/findvar.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 9009e6f..ed7903c 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -562,7 +562,15 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
struct minimal_symbol *msym;
struct obj_section *obj_section;
- msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
+ /* First, try locating the associated minimal symbol within
+ the same objfile. This prevents us from selecting another
+ symbol with the same name but located in a different objfile. */
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL,
+ SYMBOL_SYMTAB (var)->objfile);
+ /* If the lookup failed, try expanding the search to all
+ objfiles. */
+ if (msym == NULL)
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
if (msym == NULL)
error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var));
if (overlay_debugging)