From 101d1bb40a3a0c351958ed83a05806e2e321854a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 20 Mar 2013 18:33:04 +0000 Subject: 2013-03-20 Jan Kratochvil Tom Tromey PR symtab/8421: * coffread.c (coff_register_index): New global. (process_coff_symbol, coff_read_enum_type): Set SYMBOL_ACLASS_INDEX. (_initialize_coffread): Initialize new global. * dwarf2loc.c (locexpr_find_frame_base_location) (dwarf2_block_frame_base_locexpr_funcs) (loclist_find_frame_base_location) (dwarf2_block_frame_base_loclist_funcs): New. (dwarf_expr_frame_base_1): Call SYMBOL_BLOCK_OPS, remove internal_error. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Add location_has_loclist. * dwarf2loc.h (dwarf2_block_frame_base_locexpr_funcs) (dwarf2_block_frame_base_loclist_funcs): New. * dwarf2read.c (dwarf2_locexpr_index, dwarf2_loclist_index) (dwarf2_locexpr_block_index, dwarf2_loclist_block_index): New globals. (read_func_scope): Update. (fixup_go_packaging, mark_common_block_symbol_computed) (var_decode_location, new_symbol_full, dwarf2_const_value): Set SYMBOL_ACLASS_INDEX. (dwarf2_symbol_mark_computed): Likewise. Add 'is_block' argument. (_initialize_dwarf2_read): Initialize new globals. * jit.c (finalize_symtab): Set SYMBOL_ACLASS_INDEX. * jv-lang.c (add_class_symbol): Set SYMBOL_ACLASS_INDEX. * mdebugread.c (mdebug_register_index, mdebug_regparm_index): New globals. (parse_symbol, psymtab_to_symtab_1): Set SYMBOL_ACLASS_INDEX. (_initialize_mdebugread): Initialize new globals. * psympriv.h (struct partial_symbol) : Update comment. * stabsread.c (patch_block_stabs): Set SYMBOL_ACLASS_INDEX. (stab_register_index, stab_regparm_index): New globals. (define_symbol, read_enum_type, common_block_end): Set SYMBOL_ACLASS_INDEX. (_initialize_stabsread): Initialize new globals. * symtab.c (next_aclass_value, symbol_impl, symbol_impls): New globals. (MAX_SYMBOL_IMPLS): New define. (register_symbol_computed_impl, register_symbol_block_impl) (register_symbol_register_impl) (initialize_ordinary_address_classes): New functions. (_initialize_symtab): Call initialize_ordinary_address_classes. * symtab.h (enum address_class) : New constant. (struct symbol_impl): New. (SYMBOL_ACLASS_BITS): New define. (struct symbol) : Remove fields. : New field. (symbol_impls): Declare. (SYMBOL_CLASS, SYMBOL_COMPUTED_OPS, SYMBOL_REGISTER_OPS): Redefine. (SYMBOL_IMPL, SYMBOL_ACLASS_INDEX): New defines. (register_symbol_computed_impl, register_symbol_block_impl) (register_symbol_register_impl): Declare. (struct symbol_computed_ops): Add location_has_loclist. (struct symbol_block_ops): New. (SYMBOL_BLOCK_OPS): New. * xcoffread.c (process_xcoff_symbol): Set SYMBOL_ACLASS_INDEX. --- gdb/symtab.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'gdb/symtab.c') diff --git a/gdb/symtab.c b/gdb/symtab.c index efdcf165975..a46cdb81f1e 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5012,9 +5012,111 @@ producer_is_realview (const char *producer) return 0; } + + +/* The next index to hand out in response to a registration request. */ + +static int next_aclass_value = LOC_FINAL_VALUE; + +/* The maximum number of "aclass" registrations we support. This is + constant for convenience. */ +#define MAX_SYMBOL_IMPLS (LOC_FINAL_VALUE + 10) + +/* The objects representing the various "aclass" values. The elements + from 0 up to LOC_FINAL_VALUE-1 represent themselves, and subsequent + elements are those registered at gdb initialization time. */ + +static struct symbol_impl symbol_impl[MAX_SYMBOL_IMPLS]; + +/* The globally visible pointer. This is separate from 'symbol_impl' + so that it can be const. */ + +const struct symbol_impl *symbol_impls = &symbol_impl[0]; + +/* Make sure we saved enough room in struct symbol. */ + +gdb_static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_ACLASS_BITS)); + +/* Register a computed symbol type. ACLASS must be LOC_COMPUTED. OPS + is the ops vector associated with this index. This returns the new + index, which should be used as the aclass_index field for symbols + of this type. */ + +int +register_symbol_computed_impl (enum address_class aclass, + const struct symbol_computed_ops *ops) +{ + int result = next_aclass_value++; + + gdb_assert (aclass == LOC_COMPUTED); + gdb_assert (result < MAX_SYMBOL_IMPLS); + symbol_impl[result].aclass = aclass; + symbol_impl[result].ops_computed = ops; + + return result; +} + +/* Register a function with frame base type. ACLASS must be LOC_BLOCK. + OPS is the ops vector associated with this index. This returns the + new index, which should be used as the aclass_index field for symbols + of this type. */ + +int +register_symbol_block_impl (enum address_class aclass, + const struct symbol_block_ops *ops) +{ + int result = next_aclass_value++; + + gdb_assert (aclass == LOC_BLOCK); + gdb_assert (result < MAX_SYMBOL_IMPLS); + symbol_impl[result].aclass = aclass; + symbol_impl[result].ops_block = ops; + + /* Sanity check OPS. */ + gdb_assert (ops != NULL); + gdb_assert (ops->find_frame_base_location != NULL); + + return result; +} + +/* Register a register symbol type. ACLASS must be LOC_REGISTER or + LOC_REGPARM_ADDR. OPS is the register ops vector associated with + this index. This returns the new index, which should be used as + the aclass_index field for symbols of this type. */ + +int +register_symbol_register_impl (enum address_class aclass, + const struct symbol_register_ops *ops) +{ + int result = next_aclass_value++; + + gdb_assert (aclass == LOC_REGISTER || aclass == LOC_REGPARM_ADDR); + gdb_assert (result < MAX_SYMBOL_IMPLS); + symbol_impl[result].aclass = aclass; + symbol_impl[result].ops_register = ops; + + return result; +} + +/* Initialize elements of 'symbol_impl' for the constants in enum + address_class. */ + +static void +initialize_ordinary_address_classes (void) +{ + int i; + + for (i = 0; i < LOC_FINAL_VALUE; ++i) + symbol_impl[i].aclass = i; +} + + + void _initialize_symtab (void) { + initialize_ordinary_address_classes (); + add_info ("variables", variables_info, _("\ All global and static variable names, or those matching REGEXP.")); if (dbx_commands) -- cgit v1.2.1