aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-12-23 07:55:39 -0800
committerDoug Evans <xdje42@gmail.com>2014-12-23 07:58:14 -0800
commit1994afbf19892c9e614a034fbf1a5233e9addce3 (patch)
treeaf1c6640f99921a6f636e860dc10914dc53cedea /gdb/guile
parent9d7b48dc6e8415e95f5228a6f66b414827eb0204 (diff)
downloadgdb-1994afbf19892c9e614a034fbf1a5233e9addce3.zip
gdb-1994afbf19892c9e614a034fbf1a5233e9addce3.tar.gz
gdb-1994afbf19892c9e614a034fbf1a5233e9addce3.tar.bz2
Look up primitive types as symbols.
gdb/ChangeLog: * ada-lang.c (user_select_syms): Only fetch symtab if symbol is objfile-owned. (cache_symbol): Ignore symbols that are not objfile-owned. * block.c (block_objfile): New function. (block_gdbarch): New function. * block.h (block_objfile): Declare. (block_gdbarch): Declare. * c-exp.y (classify_name): Remove call to language_lookup_primitive_type. No longer necessary. * gdbtypes.c (lookup_typename): Call lookup_symbol_in_language. Remove call to language_lookup_primitive_type. No longer necessary. * guile/scm-symbol.c (syscm_gdbarch_data_key): New static global. (syscm_gdbarch_data): New struct. (syscm_init_arch_symbols): New function. (syscm_get_symbol_map): Renamed from syscm_objfile_symbol_map. All callers updated. Handle symbols owned by arches. (gdbscm_symbol_symtab): Handle symbols owned by arches. (gdbscm_initialize_symbols): Initialize syscm_gdbarch_data_key. * language.c (language_lookup_primitive_type_1): New function. (language_lookup_primitive_type): Call it. (language_alloc_type_symbol): New function. (language_init_primitive_type_symbols): New function. (language_lookup_primitive_type_as_symbol): New function. * language.h (struct language_arch_info) <primitive_type_symbols>: New member. (language_lookup_primitive_type): Add function comment. (language_lookup_primitive_type_as_symbol): Declare. * printcmd.c (address_info): Handle arch-owned symbols. * python/py-symbol.c (sympy_get_symtab): Ditto. (set_symbol): Ditto. (sympy_dealloc): Ditto. * symmisc.c (print_symbol): Ditto. * symtab.c (fixup_symbol_section): Ditto. (lookup_symbol_aux): Initialize block_found. (basic_lookup_symbol_nonlocal): Try looking up the symbol as a primitive type. (initialize_objfile_symbol_1): New function. (initialize_objfile_symbol): Call it. (allocate_symbol): Call it. (allocate_template_symbol): Call it. (symbol_objfile): Assert symbol is objfile-owned. (symbol_arch, symbol_symtab, symbol_set_symtab): Ditto. * symtab.h (struct symbol) <owner>: Replaces member "symtab". (struct symbol) <is_objfile_owned>: New member. (SYMBOL_OBJFILE_OWNED): New macro. * cp-namespace.c (cp_lookup_bare_symbol): New arg langdef. All callers updated. Try to find the symbol as a primitive type. (lookup_namespace_scope): New arg langdef. All callers updated. Call cp_lookup_bare_symbol directly for simple bare symbols.
Diffstat (limited to 'gdb/guile')
-rw-r--r--gdb/guile/scm-symbol.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 6a19648..a627f94 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -50,6 +50,13 @@ static SCM domain_keyword;
static SCM frame_keyword;
static const struct objfile_data *syscm_objfile_data_key;
+static struct gdbarch_data *syscm_gdbarch_data_key;
+
+struct syscm_gdbarch_data
+{
+ /* Hash table to implement eqable gdbarch symbols. */
+ htab_t htab;
+};
/* Administrivia for symbol smobs. */
@@ -75,20 +82,44 @@ syscm_eq_symbol_smob (const void *ap, const void *bp)
&& a->symbol != NULL);
}
+static void *
+syscm_init_arch_symbols (struct gdbarch *gdbarch)
+{
+ struct syscm_gdbarch_data *data
+ = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct syscm_gdbarch_data);
+
+ data->htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob,
+ syscm_eq_symbol_smob);
+ return data;
+}
+
/* Return the struct symbol pointer -> SCM mapping table.
It is created if necessary. */
static htab_t
-syscm_objfile_symbol_map (struct symbol *symbol)
+syscm_get_symbol_map (struct symbol *symbol)
{
- struct objfile *objfile = symbol_objfile (symbol);
- htab_t htab = objfile_data (objfile, syscm_objfile_data_key);
+ htab_t htab;
- if (htab == NULL)
+ if (SYMBOL_OBJFILE_OWNED (symbol))
{
- htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob,
- syscm_eq_symbol_smob);
- set_objfile_data (objfile, syscm_objfile_data_key, htab);
+ struct objfile *objfile = symbol_objfile (symbol);
+
+ htab = objfile_data (objfile, syscm_objfile_data_key);
+ if (htab == NULL)
+ {
+ htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob,
+ syscm_eq_symbol_smob);
+ set_objfile_data (objfile, syscm_objfile_data_key, htab);
+ }
+ }
+ else
+ {
+ struct gdbarch *gdbarch = symbol_arch (symbol);
+ struct syscm_gdbarch_data *data = gdbarch_data (gdbarch,
+ syscm_gdbarch_data_key);
+
+ htab = data->htab;
}
return htab;
@@ -103,7 +134,7 @@ syscm_free_symbol_smob (SCM self)
if (s_smob->symbol != NULL)
{
- htab_t htab = syscm_objfile_symbol_map (s_smob->symbol);
+ htab_t htab = syscm_get_symbol_map (s_smob->symbol);
gdbscm_clear_eqable_gsmob_ptr_slot (htab, &s_smob->base);
}
@@ -181,7 +212,7 @@ syscm_scm_from_symbol (struct symbol *symbol)
/* If we've already created a gsmob for this symbol, return it.
This makes symbols eq?-able. */
- htab = syscm_objfile_symbol_map (symbol);
+ htab = syscm_get_symbol_map (symbol);
s_smob_for_lookup.symbol = symbol;
slot = gdbscm_find_eqable_gsmob_ptr_slot (htab, &s_smob_for_lookup.base);
if (*slot != NULL)
@@ -319,8 +350,9 @@ gdbscm_symbol_type (SCM self)
return tyscm_scm_from_type (SYMBOL_TYPE (symbol));
}
-/* (symbol-symtab <gdb:symbol>) -> <gdb:symtab>
- Return the symbol table of SELF. */
+/* (symbol-symtab <gdb:symbol>) -> <gdb:symtab> | #f
+ Return the symbol table of SELF.
+ If SELF does not have a symtab (it is arch-owned) return #f. */
static SCM
gdbscm_symbol_symtab (SCM self)
@@ -329,6 +361,8 @@ gdbscm_symbol_symtab (SCM self)
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
+ if (!SYMBOL_OBJFILE_OWNED (symbol))
+ return SCM_BOOL_F;
return stscm_scm_from_symtab (symbol_symtab (symbol));
}
@@ -761,4 +795,8 @@ gdbscm_initialize_symbols (void)
invalidate symbols when an object file is about to be deleted. */
syscm_objfile_data_key
= register_objfile_data_with_cleanup (NULL, syscm_del_objfile_symbols);
+
+ /* Arch-specific symbol data. */
+ syscm_gdbarch_data_key
+ = gdbarch_data_register_post_init (syscm_init_arch_symbols);
}