summaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2007-07-03 12:14:44 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2007-07-03 12:14:44 +0000
commit90dc6d24a73a2eced4b4c78541a5ab8053c56f2d (patch)
tree2082ce40789cddd123b1f83cc88bc2cc55d96bbc /gdb/symtab.c
parent085ed399be8404e2c9bcad7b0a6d0960a236eeb2 (diff)
downloadgdb-90dc6d24a73a2eced4b4c78541a5ab8053c56f2d.tar.gz
2007-07-03 Markus Deuling <deuling@de.ibm.com>
* cp-namespace.c (lookup_symbol_file): Add block to lookup_symbol_global call. * Makefile.in (solist_h): Add dependency on symtab header. (symtab.o): Add dependency on solist header. * solib.c (solib_global_lookup): New function. * solib-svr4.c (scan_dyntag): Likewise. (elf_locate_base): Call helper routine scan_dyntag. (elf_lookup_lib_symbol): New function. (_initialize_svr4_solib): Add elf_lookup_lib_symbol to svr4_so_ops. * solist.h (symtab.h): New include. (struct target_so_ops): New member lookup_lib_global_symbol. (solib_global_lookup): New prototype. * symtab.c: New include solist.h. (lookup_objfile_from_block): New function. (lookup_global_symbol_from_objfile): New function. (basic_lookup_symbol_nonlocal): Add block to lookup_symbol_global call. (lookup_symbol_global): Call library-specific lookup procedure. * symtab.h (lookup_global_symbol_from_objfile): New prototype. * NEWS: Document framework. testsuite/ * gdb.base/solib-symbol.exp: New file (testcase multiple symbol lookup). * gdb.base/solib-symbol-lib.c: Likewise. * gdb.base/solib-symbol-main.c: Likewise.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6a9ef41880d..2bb414b084f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -57,6 +57,7 @@
#include "cp-abi.h"
#include "observer.h"
#include "gdb_assert.h"
+#include "solist.h"
/* Prototypes for local functions */
@@ -1261,6 +1262,26 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
return NULL;
}
+/* Look up OBJFILE to BLOCK. */
+
+static struct objfile *
+lookup_objfile_from_block (const struct block *block)
+{
+ struct objfile *obj;
+ struct symtab *s;
+
+ if (block == NULL)
+ return NULL;
+
+ block = block_global_block (block);
+ /* Go through SYMTABS. */
+ ALL_SYMTABS (obj, s)
+ if (block == BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK))
+ return obj;
+
+ return NULL;
+}
+
/* Look up a symbol in a block; if found, locate its symtab, fixup the
symbol, and set block_found appropriately. */
@@ -1302,6 +1323,57 @@ lookup_symbol_aux_block (const char *name, const char *linkage_name,
return NULL;
}
+/* Check all global symbols in OBJFILE in symtabs and
+ psymtabs. */
+
+struct symbol *
+lookup_global_symbol_from_objfile (const struct objfile *objfile,
+ const char *name,
+ const char *linkage_name,
+ const domain_enum domain,
+ struct symtab **symtab)
+{
+ struct symbol *sym;
+ struct blockvector *bv;
+ const struct block *block;
+ struct symtab *s;
+ struct partial_symtab *ps;
+
+ /* Go through symtabs. */
+ ALL_OBJFILE_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, linkage_name, domain);
+ if (sym)
+ {
+ block_found = block;
+ if (symtab != NULL)
+ *symtab = s;
+ return fixup_symbol_section (sym, (struct objfile *)objfile);
+ }
+ }
+
+ /* Now go through psymtabs. */
+ ALL_OBJFILE_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin
+ && lookup_partial_symbol (ps, name, linkage_name,
+ 1, domain))
+ {
+ s = PSYMTAB_TO_SYMTAB (ps);
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, linkage_name, domain);
+ if (symtab != NULL)
+ *symtab = s;
+ return fixup_symbol_section (sym, (struct objfile *)objfile);
+ }
+ }
+
+ return NULL;
+}
+
/* Check to see if the symbol is defined in one of the symtabs.
BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
depending on whether or not we want to search global symbols or
@@ -1567,7 +1639,7 @@ basic_lookup_symbol_nonlocal (const char *name,
if (sym != NULL)
return sym;
- return lookup_symbol_global (name, linkage_name, domain, symtab);
+ return lookup_symbol_global (name, linkage_name, block, domain, symtab);
}
/* Lookup a symbol in the static block associated to BLOCK, if there
@@ -1595,10 +1667,19 @@ lookup_symbol_static (const char *name,
struct symbol *
lookup_symbol_global (const char *name,
const char *linkage_name,
+ const struct block *block,
const domain_enum domain,
struct symtab **symtab)
{
- struct symbol *sym;
+ struct symbol *sym = NULL;
+ struct objfile *objfile = NULL;
+
+ /* Call library-specific lookup procedure. */
+ objfile = lookup_objfile_from_block (block);
+ if (objfile != NULL)
+ sym = solib_global_lookup (objfile, name, linkage_name, domain, symtab);
+ if (sym != NULL)
+ return sym;
sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name,
domain, symtab);