2003-06-11 David Carlton <carlton@bactrian.org>

* dictionary.h: New.
	* dictionary.c: New.
	* block.h: Add opaque declaration for struct dictionary.
	(struct block): Add 'dict' member; delete 'hashtable', 'nsyms',
	'sym' members.
	(BLOCK_DICT): New macro.
	Delete macros BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM,
	BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE,
	BLOCK_SHOULD_SORT.
	(ALL_BLOCK_SYMBOLS): Update definition.
	* Makefile.in (SFILES): Add dictionary.c.
	(dictionary_h): New.
	(COMMON_OBS): Add dictionary.o.
	(dictionary.o): New.
	(ada-lang.o): Depend on dictionary_h.
	(buildsym.o, coffread.o, jv-lang.o, mdebugread.o, objfiles.o)
	(stack.o, symmisc.o, symtab.o, tracepoint.o, valops.o)
	(mi-cmd-stack.o): Ditto.
	(gdbtk-cmds.o): Update dependencies.
	(gdbtk-stack.o): Ditto.
	* ada-lang.c: Include dictionary.h.
	(symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS.
	(fill_in_ada_prototype, debug_print_block): Ditto.
	(ada_add_block_symbols): Update uses of ALL_BLOCK_SYMBOLS; replace
	explicit iteration by use of ALL_BLOCK_SYMBOLS.  Delete variable
	'is_sorted'.
	* mdebugread.c: Include dictionary.h.
	(struct parse_stack): Delete 'maxsyms' member.
	(parse_symbol): Update calls to new_block.  Delete calls to
	shrink_block.  Use dictionary methods.
	(psymtab_to_symtab_1): Delete calls to sort_symtab_syms.
	Update calls to new_symtab.  Don't maintain maxsyms data.
	(mylookup_symbol): Update use of ALL_BLOCK_SYMBOLS.
	(add_symbol): Just call dict_add_symbol.
	(new_symtab): Delete 'maxsyms' argument.
	(new_symtab): Update calls to new_block.
	(new_block): Delete 'maxsyms' argument; add 'function' argument.
	(shrink_block): Delete function.
	(fixup_sigtramp): Update call to new_block.  Add symbol via
	dict_add_symbol.
	* jv-lang.c: Include dictionary.h.
	(get_java_class_symtab): Set the BLOCK_DICT of the blocks
	appropriately.  Set class_symtab->free_func.  Make sure the
	blockvector is big enough to hold two blocks.
	(add_class_symtab_symbol): Use dictionary methods.
	(free_class_block): New function.
	(type_from_class): Replace explicit iteration by
	ALL_BLOCK_SYMBOLS.
	* symtab.h (struct symtab): Replace 'free_ptr' method by
	'free_func'.
	* dwarf2read.c (psymtab_to_symtab_1): Delete call to
	sort_symtab_syms.
	* dwarfread.c (psymtab_to_symtab_1): Delete call to
	sort_symtab_syms.
	* coffread.c (coff_symfile_read): Delete call to sort_symtab_syms.
	Include dictionary.h.
	(patch_opaque_types): Update use of ALL_BLOCK_SYMBOLS.
	* dbxread.c (dbx_psymtab_to_symtab_1): Delete call to
	sort_symtab_syms.
	* objfiles.c: Include dictionary.h.
	(objfile_relocate): Update use of ALL_BLOCK_SYMBOLS.
	* buildsym.c: Include dictionary.h.
	(finish_block): Use dictionary methods.
	(end_symtab): Set free_func to NULL, not free_ptr.
	* tracepoint.c: Include dictionary.h.
	(add_local_symbols): Update use of ALL_BLOCK_SYMBOLS.
	(scope_info): Ditto.
	* stack.c: Include dictionary.h.
	(print_block_frame_locals): Update use of ALL_BLOCK_SYMBOLS.
	(print_block_frame_labels, print_frame_arg_vars)
	(print_frame_args): Ditto.
	* symmisc.c (free_symtab_block): Use dictionary methods.
	(dump_symtab): Ditto.
	(free_symtab): Replace use of 'free_ptr' by 'free_func'.
	Include	dictionary.h.
	* symfile.h: Delete declarations of sort_block_syms,
	sort_symtab_syms.
	* symfile.c (sort_block_syms): Delete.
	(sort_symtab_syms): Delete.
	* symtab.c: Include dictionary.h.
	(lookup_block_symbol): Use dictionary iterators.
	(find_pc_sect_symtab): Update use of ALL_BLOCK_SYMBOLS.
	(search_symbols, make_symbol_completion_list): Ditto.
	(make_symbol_overload_list): Ditto.
	* valops.c (value_of_local): Use dict_empty.
	Include dictionary.h.

2003-06-11  David Carlton  <carlton@bactrian.org>

	* generic/gdbtk-stack.c: Include dictionary.h.
	(gdb_block_vars): Update use of ALL_BLOCK_SYMBOLS.
	(gdb_get_blocks, gdb_get_vars_command): Ditto.
	* generic/gdbtk-cmds.c: Include dictionary.h.
	(gdb_listfuncs): Update use of ALL_BLOCK_SYMBOLS.

2003-06-11  David Carlton  <carlton@bactrian.org>

	* mi-cmd-stack.c: Include dictionary.h.
	(list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
This commit is contained in:
David Carlton 2003-06-11 23:29:49 +00:00
parent cdfbf930b9
commit de4f826b0f
21 changed files with 1330 additions and 372 deletions

View File

@ -1,3 +1,92 @@
2003-06-11 David Carlton <carlton@bactrian.org>
* dictionary.h: New.
* dictionary.c: New.
* block.h: Add opaque declaration for struct dictionary.
(struct block): Add 'dict' member; delete 'hashtable', 'nsyms',
'sym' members.
(BLOCK_DICT): New macro.
Delete macros BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM,
BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE,
BLOCK_SHOULD_SORT.
(ALL_BLOCK_SYMBOLS): Update definition.
* Makefile.in (SFILES): Add dictionary.c.
(dictionary_h): New.
(COMMON_OBS): Add dictionary.o.
(dictionary.o): New.
(ada-lang.o): Depend on dictionary_h.
(buildsym.o, coffread.o, jv-lang.o, mdebugread.o, objfiles.o)
(stack.o, symmisc.o, symtab.o, tracepoint.o, valops.o)
(mi-cmd-stack.o): Ditto.
(gdbtk-cmds.o): Update dependencies.
(gdbtk-stack.o): Ditto.
* ada-lang.c: Include dictionary.h.
(symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS.
(fill_in_ada_prototype, debug_print_block): Ditto.
(ada_add_block_symbols): Update uses of ALL_BLOCK_SYMBOLS; replace
explicit iteration by use of ALL_BLOCK_SYMBOLS. Delete variable
'is_sorted'.
* mdebugread.c: Include dictionary.h.
(struct parse_stack): Delete 'maxsyms' member.
(parse_symbol): Update calls to new_block. Delete calls to
shrink_block. Use dictionary methods.
(psymtab_to_symtab_1): Delete calls to sort_symtab_syms.
Update calls to new_symtab. Don't maintain maxsyms data.
(mylookup_symbol): Update use of ALL_BLOCK_SYMBOLS.
(add_symbol): Just call dict_add_symbol.
(new_symtab): Delete 'maxsyms' argument.
(new_symtab): Update calls to new_block.
(new_block): Delete 'maxsyms' argument; add 'function' argument.
(shrink_block): Delete function.
(fixup_sigtramp): Update call to new_block. Add symbol via
dict_add_symbol.
* jv-lang.c: Include dictionary.h.
(get_java_class_symtab): Set the BLOCK_DICT of the blocks
appropriately. Set class_symtab->free_func. Make sure the
blockvector is big enough to hold two blocks.
(add_class_symtab_symbol): Use dictionary methods.
(free_class_block): New function.
(type_from_class): Replace explicit iteration by
ALL_BLOCK_SYMBOLS.
* symtab.h (struct symtab): Replace 'free_ptr' method by
'free_func'.
* dwarf2read.c (psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* dwarfread.c (psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* coffread.c (coff_symfile_read): Delete call to sort_symtab_syms.
Include dictionary.h.
(patch_opaque_types): Update use of ALL_BLOCK_SYMBOLS.
* dbxread.c (dbx_psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* objfiles.c: Include dictionary.h.
(objfile_relocate): Update use of ALL_BLOCK_SYMBOLS.
* buildsym.c: Include dictionary.h.
(finish_block): Use dictionary methods.
(end_symtab): Set free_func to NULL, not free_ptr.
* tracepoint.c: Include dictionary.h.
(add_local_symbols): Update use of ALL_BLOCK_SYMBOLS.
(scope_info): Ditto.
* stack.c: Include dictionary.h.
(print_block_frame_locals): Update use of ALL_BLOCK_SYMBOLS.
(print_block_frame_labels, print_frame_arg_vars)
(print_frame_args): Ditto.
* symmisc.c (free_symtab_block): Use dictionary methods.
(dump_symtab): Ditto.
(free_symtab): Replace use of 'free_ptr' by 'free_func'.
Include dictionary.h.
* symfile.h: Delete declarations of sort_block_syms,
sort_symtab_syms.
* symfile.c (sort_block_syms): Delete.
(sort_symtab_syms): Delete.
* symtab.c: Include dictionary.h.
(lookup_block_symbol): Use dictionary iterators.
(find_pc_sect_symtab): Update use of ALL_BLOCK_SYMBOLS.
(search_symbols, make_symbol_completion_list): Ditto.
(make_symbol_overload_list): Ditto.
* valops.c (value_of_local): Use dict_empty.
Include dictionary.h.
2003-06-11 J. Brobecker <brobecker@gnat.com>
* win32-nat.c (solib_symbols_add): Fix a small compilation error.

View File

@ -513,7 +513,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
charset.c cli-out.c coffread.c coff-pe-read.c \
complaints.c completer.c corefile.c \
cp-abi.c cp-support.c cp-namespace.c cp-valprint.c \
dbxread.c demangle.c disasm.c doublest.c dummy-frame.c \
dbxread.c demangle.c dictionary.c disasm.c doublest.c dummy-frame.c \
dwarfread.c dwarf2expr.c dwarf2loc.c dwarf2read.c dwarf2-frame.c \
elfread.c environ.c eval.c event-loop.c event-top.c expprint.c \
f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c frame.c \
@ -633,6 +633,7 @@ dcache_h = dcache.h
defs_h = defs.h $(config_h) $(gdb_locale_h) $(gdb_signals_h) $(ansidecl_h) \
$(libiberty_h) $(progress_h) $(bfd_h) $(tui_h) $(ui_file_h) $(xm_h) \
$(nm_h) $(tm_h) $(fopen_same_h) $(gdbarch_h) $(arch_utils_h)
dictionary_h = dictionary.h
disasm_h = disasm.h
doublest_h = doublest.h $(floatformat_h)
dst_h = dst.h
@ -843,7 +844,7 @@ TAGFILES_WITH_SRCDIR = $(HFILES_WITH_SRCDIR)
COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o regcache.o \
charset.o disasm.o dummy-frame.o \
source.o values.o eval.o valops.o valarith.o valprint.o printcmd.o \
block.o symtab.o symfile.o symmisc.o linespec.o \
block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
infcall.o \
infcmd.o infrun.o \
expprint.o environ.o stack.o thread.o \
@ -1501,7 +1502,7 @@ ada-lang.o: ada-lang.c $(gdb_string_h) $(demangle_h) $(defs_h) $(symtab_h) \
$(gdbtypes_h) $(gdbcmd_h) $(expression_h) $(parser_defs_h) \
$(language_h) $(c_lang_h) $(inferior_h) $(symfile_h) $(objfiles_h) \
$(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(ui_out_h) $(block_h) \
$(infcall_h)
$(infcall_h) $(dictionary_h)
ada-tasks.o: ada-tasks.c $(defs_h) $(command_h) $(value_h) $(language_h) \
$(inferior_h) $(symtab_h) $(target_h) $(gdbcore_h) $(gregset_h) \
$(ada_lang_h)
@ -1586,7 +1587,7 @@ buildsym.o: buildsym.c $(defs_h) $(bfd_h) $(gdb_obstack_h) $(symtab_h) \
$(symfile_h) $(objfiles_h) $(gdbtypes_h) $(gdb_assert_h) \
$(complaints_h) $(gdb_string_h) $(expression_h) $(language_h) \
$(bcache_h) $(filenames_h) $(macrotab_h) $(demangle_h) $(buildsym_h) \
$(stabsread_h) $(block_h) $(cp_support_h)
$(stabsread_h) $(block_h) $(cp_support_h) $(dictionary_h)
builtin-regs.o: builtin-regs.c $(defs_h) $(builtin_regs_h) $(gdbtypes_h) \
$(gdb_string_h) $(gdb_assert_h)
c-lang.o: c-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
@ -1610,7 +1611,8 @@ coffread.o: coffread.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(demangle_h) \
$(breakpoint_h) $(bfd_h) $(gdb_obstack_h) $(gdb_string_h) \
$(coff_internal_h) $(libcoff_h) $(symfile_h) $(objfiles_h) \
$(buildsym_h) $(gdb_stabs_h) $(stabsread_h) $(complaints_h) \
$(target_h) $(gdb_assert_h) $(block_h) $(coff_pe_read_h)
$(target_h) $(gdb_assert_h) $(block_h) $(dictionary_h) \
$(coff_pe_read_h)
coff-pe-read.o: coff-pe-read.c $(bfd_h) $(defs_h) $(symtab_h) \
$(gdbtypes_h) $(symfile_h) $(objfiles_h) $(coff_pe_read_h)
complaints.o: complaints.c $(defs_h) $(complaints_h) $(gdb_assert_h) \
@ -1664,6 +1666,8 @@ dcache.o: dcache.c $(defs_h) $(dcache_h) $(gdbcmd_h) $(gdb_string_h) \
delta68-nat.o: delta68-nat.c $(defs_h)
demangle.o: demangle.c $(defs_h) $(command_h) $(gdbcmd_h) $(demangle_h) \
$(gdb_string_h)
dictionary.o: dictionary.c $(defs_h) $(gdb_obstack_h) $(symtab_h) \
$(buildsym_h) $(gdb_assert_h) $(dictionary_h)
dink32-rom.o: dink32-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
$(serial_h) $(symfile_h) $(inferior_h) $(regcache_h)
disasm.o: disasm.c $(defs_h) $(gdb_string_h) $(target_h) $(value_h) \
@ -1886,7 +1890,7 @@ irix5-nat.o: irix5-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \
jv-lang.o: jv-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
$(parser_defs_h) $(language_h) $(gdbtypes_h) $(symtab_h) \
$(symfile_h) $(objfiles_h) $(gdb_string_h) $(value_h) $(c_lang_h) \
$(jv_lang_h) $(gdbcore_h) $(block_h) $(demangle_h)
$(jv_lang_h) $(gdbcore_h) $(block_h) $(demangle_h) $(dictionary_h)
jv-typeprint.o: jv-typeprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \
$(value_h) $(demangle_h) $(jv_lang_h) $(gdb_string_h) $(typeprint_h) \
$(c_lang_h) $(cp_abi_h)
@ -1967,7 +1971,7 @@ mcore-tdep.o: mcore-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(value_h) \
mdebugread.o: mdebugread.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
$(symfile_h) $(objfiles_h) $(gdb_obstack_h) $(buildsym_h) \
$(stabsread_h) $(complaints_h) $(demangle_h) $(gdb_assert_h) \
$(block_h) \
$(block_h) $(dictionary_h) \
$(coff_sym_h) $(coff_symconst_h) $(gdb_stat_h) $(gdb_string_h) \
$(bfd_h) $(coff_ecoff_h) $(libaout_h) $(aout_aout64_h) \
$(aout_stab_gnu_h) $(expression_h) $(language_h)
@ -2028,7 +2032,7 @@ objc-lang.o: objc-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \
$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(gdb_stat_h) \
$(gdb_obstack_h) $(gdb_string_h) $(breakpoint_h) $(mmalloc_h) \
$(block_h)
$(block_h) $(dictionary_h)
observer.o: observer.c $(observer_h) $(defs_h)
ocd.o: ocd.c $(defs_h) $(gdbcore_h) $(gdb_string_h) $(frame_h) $(inferior_h) \
$(bfd_h) $(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) \
@ -2270,7 +2274,7 @@ stack.o: stack.c $(defs_h) $(gdb_string_h) $(value_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(language_h) $(frame_h) $(gdbcmd_h) \
$(gdbcore_h) $(target_h) $(source_h) $(breakpoint_h) $(demangle_h) \
$(inferior_h) $(annotate_h) $(ui_out_h) $(block_h) $(stack_h) \
$(gdb_assert_h)
$(gdb_assert_h) $(dictionary_h)
standalone.o: standalone.c $(gdb_stat_h) $(defs_h) $(symtab_h) $(frame_h) \
$(inferior_h) $(gdb_wait_h)
std-regs.o: std-regs.c $(defs_h) $(builtin_regs_h) $(frame_h) $(gdbtypes_h) \
@ -2291,13 +2295,13 @@ symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
$(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
$(gdb_obstack_h) $(language_h) $(bcache_h) $(gdb_string_h) \
$(readline_h) $(block_h) $(gdb_regex_h)
$(readline_h) $(block_h) $(gdb_regex_h) $(dictionary_h)
symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
$(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
$(gdbcmd_h) $(call_cmds_h) $(gdb_regex_h) $(expression_h) \
$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) \
$(filenames_h) $(gdb_obstack_h) $(gdb_string_h) $(gdb_stat_h) \
$(cp_abi_h) $(source_h) $(block_h) $(objc_lang_h)
$(cp_abi_h) $(source_h) $(block_h) $(objc_lang_h) $(dictionary_h)
target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
$(gdb_wait_h) $(dcache_h) $(regcache_h)
@ -2318,7 +2322,7 @@ tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_h) \
$(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \
$(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \
$(linespec_h) $(regcache_h) $(completer_h) $(gdb_events_h) \
$(block_h) $(ax_h) $(ax_gdb_h) $(readline_h)
$(block_h) $(ax_h) $(ax_gdb_h) $(readline_h) $(dictionary_h)
trad-frame.o: trad-frame.c $(defs_h) $(frame_h) $(trad_frame_h) $(regcache_h)
typeprint.o: typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(command_h) \
@ -2345,7 +2349,7 @@ valarith.o: valarith.c $(defs_h) $(value_h) $(symtab_h) $(gdbtypes_h) \
valops.o: valops.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(value_h) $(frame_h) \
$(inferior_h) $(gdbcore_h) $(target_h) $(demangle_h) $(language_h) \
$(gdbcmd_h) $(regcache_h) $(cp_abi_h) $(gdb_string_h) \
$(gdb_assert_h) $(block_h)
$(gdb_assert_h) $(block_h) $(dictionary_h)
valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h)
@ -2514,9 +2518,10 @@ gdbtk-bp.o: $(srcdir)/gdbtk/generic/gdbtk-bp.c \
gdbtk-cmds.o: $(srcdir)/gdbtk/generic/gdbtk-cmds.c \
$(srcdir)/gdbtk/generic/gdbtk.h $(srcdir)/gdbtk/generic/gdbtk-cmds.h \
$(defs_h) $(symtab_h) $(inferior_h) \
$(command_h) $(bfd_h) $(top_h) $(symfile_h) $(objfiles_h) $(target_h) \
$(gdb_string_h) $(tracepoint_h) $(source_h) $(regcache_h)
$(defs_h) $(inferior_h) $(source_h) $(symfile_h) $(objfiles_h) \
$(gdbcore_h) $(demangle_h) $(linespec_h) $(tui_file_h) $(top_h) \
$(annotate_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
$(dis_asm_h) $(gdbcmd_h)
$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \
$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \
$(GDBTK_CFLAGS) $(srcdir)/gdbtk/generic/gdbtk-cmds.c \
@ -2557,8 +2562,8 @@ gdbtk-register.o: $(srcdir)/gdbtk/generic/gdbtk-register.c \
gdbtk-stack.o: $(srcdir)/gdbtk/generic/gdbtk-stack.c \
$(srcdir)/gdbtk/generic/gdbtk.h $(srcdir)/gdbtk/generic/gdbtk-cmds.h \
$(srcdir)/gdbtk/generic/gdbtk-wrapper.h \
$(defs_h) $(frame_h) $(value_h) $(target_h) $(breakpoint_h) \
$(linespec_h)
$(defs_h) $(target_h) $(breakpoint_h) $(linespec_h) \
$(block_h) $(dictionary_h)
$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \
$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \
$(GDBTK_CFLAGS) $(srcdir)/gdbtk/generic/gdbtk-stack.c \
@ -2599,7 +2604,8 @@ mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(inferior_h) $(value_h) \
$(environ_h) $(command_h) $(ui_out_h) $(top_h) $(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
$(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h) $(block_h) $(stack_h)
$(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h) $(block_h) $(stack_h) \
$(dictionary_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
$(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)

View File

@ -40,6 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ui-out.h"
#include "block.h"
#include "infcall.h"
#include "dictionary.h"
struct cleanup *unresolved_names;
@ -3433,7 +3434,8 @@ symtab_for_sym (struct symbol *sym)
struct objfile *objfile;
struct block *b;
struct symbol *tmp_sym;
int i, j;
struct dict_iterator iter;
int j;
ALL_SYMTABS (objfile, s)
{
@ -3447,10 +3449,10 @@ symtab_for_sym (struct symbol *sym)
case LOC_BLOCK:
case LOC_CONST_BYTES:
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
return s;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
return s;
break;
default:
@ -3474,7 +3476,7 @@ symtab_for_sym (struct symbol *sym)
j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1)
{
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j);
ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
return s;
}
break;
@ -3947,7 +3949,7 @@ ada_add_block_symbols (struct block *block, const char *name,
domain_enum domain, struct objfile *objfile,
int wild)
{
int i;
struct dict_iterator iter;
int name_len = strlen (name);
/* A matching argument symbol, if any. */
struct symbol *arg_sym;
@ -3960,7 +3962,7 @@ ada_add_block_symbols (struct block *block, const char *name,
if (wild)
{
struct symbol *sym;
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (SYMBOL_DOMAIN (sym) == domain &&
wild_match (name, name_len, DEPRECATED_SYMBOL_NAME (sym)))
@ -3989,7 +3991,7 @@ ada_add_block_symbols (struct block *block, const char *name,
}
else
{
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (SYMBOL_DOMAIN (sym) == domain)
{
@ -4034,7 +4036,7 @@ ada_add_block_symbols (struct block *block, const char *name,
arg_sym = NULL;
found_sym = 0;
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
struct symbol *sym = BLOCK_SYM (block, i);
@ -4098,7 +4100,7 @@ fill_in_ada_prototype (struct symbol *func)
{
struct block *b;
int nargs, nsyms;
int i;
struct dict_iterator iter;
struct type *ftype;
struct type *rtype;
size_t max_fields;
@ -4124,7 +4126,7 @@ fill_in_ada_prototype (struct symbol *func)
max_fields = 8;
TYPE_FIELDS (ftype) =
(struct field *) xmalloc (sizeof (struct field) * max_fields);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
GROW_VECT (TYPE_FIELDS (ftype), max_fields, nargs + 1);
@ -4697,8 +4699,8 @@ debug_print_lines (struct linetable *lt)
static void
debug_print_block (struct block *b)
{
int i;
struct symbol *i;
struct dict_iterator iter;
struct symbol *sym;
fprintf (stderr, "Block: %p; [0x%lx, 0x%lx]",
b, BLOCK_START (b), BLOCK_END (b));
@ -4707,10 +4709,8 @@ debug_print_block (struct block *b)
fprintf (stderr, "\n");
fprintf (stderr, "\t Superblock: %p\n", BLOCK_SUPERBLOCK (b));
fprintf (stderr, "\t Symbols:");
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (i > 0 && i % 4 == 0)
fprintf (stderr, "\n\t\t ");
fprintf (stderr, " %s", DEPRECATED_SYMBOL_NAME (sym));
}
fprintf (stderr, "\n");

View File

@ -29,6 +29,7 @@ struct symtab;
struct block_namespace_info;
struct using_direct;
struct obstack;
struct dictionary;
/* All of the name-scope contours of the program
are represented by `struct block' objects.
@ -77,6 +78,10 @@ struct block
struct block *superblock;
/* This is used to store the symbols in the block. */
struct dictionary *dict;
/* Used for language-specific info. */
union
@ -104,34 +109,6 @@ struct block
of this flag is undefined. */
unsigned char gcc_compile_flag;
/* The symbols for this block are either in a simple linear list or
in a simple hashtable. Blocks which correspond to a function
(which have a list of symbols corresponding to arguments) use
a linear list, as do some older symbol readers (currently only
mdebugread and dstread). Other blocks are hashed.
The hashtable uses the same hash function as the minsym hashtables,
found in minsyms.c:minsym_hash_iw. Symbols are hashed based on
their demangled name if appropriate, and on their name otherwise.
The hash function ignores space, and stops at the beginning of the
argument list if any.
The table is laid out in NSYMS/5 buckets and symbols are chained via
their hash_next field. */
/* If this is really a hashtable of the symbols, this flag is 1. */
unsigned char hashtable;
/* Number of local symbols. */
int nsyms;
/* The symbols. If some of them are arguments, then they must be
in the order in which we would like to print them. */
struct symbol *sym[1];
};
#define BLOCK_START(bl) (bl)->startaddr
@ -139,28 +116,15 @@ struct block
#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
#define BLOCK_DICT(bl) (bl)->dict
#define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace
#define BLOCK_HASHTABLE(bl) (bl)->hashtable
/* For blocks without a hashtable (BLOCK_HASHTABLE (bl) == 0) only. */
#define BLOCK_NSYMS(bl) (bl)->nsyms
#define BLOCK_SYM(bl, n) (bl)->sym[n]
/* Macro to loop through all symbols in a block BL, in no particular
order. ITER helps keep track of the iteration, and should be a
struct dict_iterator. SYM points to the current symbol. */
/* For blocks with a hashtable, but these are valid for non-hashed blocks as
well - each symbol will appear to be one bucket by itself. */
#define BLOCK_BUCKETS(bl) (bl)->nsyms
#define BLOCK_BUCKET(bl, n) (bl)->sym[n]
/* Macro used to set the size of a hashtable for N symbols. */
#define BLOCK_HASHTABLE_SIZE(n) ((n)/5 + 1)
/* Macro to loop through all symbols in a block BL, in no particular order.
i counts which bucket we are in, and sym points to the current symbol. */
#define ALL_BLOCK_SYMBOLS(bl, i, sym) \
for ((i) = 0; (i) < BLOCK_BUCKETS ((bl)); (i)++) \
for ((sym) = BLOCK_BUCKET ((bl), (i)); (sym); \
(sym) = (sym)->hash_next)
#define ALL_BLOCK_SYMBOLS(block, iter, sym) \
ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
struct blockvector
{

View File

@ -45,6 +45,7 @@
#include "demangle.h" /* Needed by SYMBOL_INIT_DEMANGLED_NAME. */
#include "block.h"
#include "cp-support.h"
#include "dictionary.h"
/* Ask buildsym.h to define the vars it normally declares `extern'. */
#define EXTERN
@ -229,62 +230,22 @@ finish_block (struct symbol *symbol, struct pending **listhead,
register struct block *block;
register struct pending_block *pblock;
struct pending_block *opblock;
register int i;
register int j;
/* Count the length of the list of symbols. */
for (next = *listhead, i = 0;
next;
i += next->nsyms, next = next->next)
{
/* EMPTY */ ;
}
/* Copy the symbols into the block. */
/* Initialize the block's dictionary. */
if (symbol)
{
block = (struct block *)
obstack_alloc (&objfile->symbol_obstack,
(sizeof (struct block) +
((i - 1) * sizeof (struct symbol *))));
BLOCK_NSYMS (block) = i;
for (next = *listhead; next; next = next->next)
for (j = next->nsyms - 1; j >= 0; j--)
{
BLOCK_SYM (block, --i) = next->symbol[j];
}
obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
BLOCK_DICT (block) = dict_create_linear (&objfile->symbol_obstack,
*listhead);
}
else
{
int htab_size = BLOCK_HASHTABLE_SIZE (i);
block = (struct block *)
obstack_alloc (&objfile->symbol_obstack,
(sizeof (struct block) +
((htab_size - 1) * sizeof (struct symbol *))));
for (j = 0; j < htab_size; j++)
{
BLOCK_BUCKET (block, j) = 0;
}
BLOCK_BUCKETS (block) = htab_size;
for (next = *listhead; next; next = next->next)
{
for (j = next->nsyms - 1; j >= 0; j--)
{
struct symbol *sym;
unsigned int hash_index;
const char *name = SYMBOL_DEMANGLED_NAME (next->symbol[j]);
if (name == NULL)
name = DEPRECATED_SYMBOL_NAME (next->symbol[j]);
hash_index = msymbol_hash_iw (name);
hash_index = hash_index % BLOCK_BUCKETS (block);
sym = BLOCK_BUCKET (block, hash_index);
BLOCK_BUCKET (block, hash_index) = next->symbol[j];
next->symbol[j]->hash_next = sym;
}
}
obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
BLOCK_DICT (block) = dict_create_hashed (&objfile->symbol_obstack,
*listhead);
}
BLOCK_START (block) = start;
@ -300,9 +261,9 @@ finish_block (struct symbol *symbol, struct pending **listhead,
if (symbol)
{
struct type *ftype = SYMBOL_TYPE (symbol);
struct dict_iterator iter;
SYMBOL_BLOCK_VALUE (symbol) = block;
BLOCK_FUNCTION (block) = symbol;
BLOCK_HASHTABLE (block) = 0;
if (TYPE_NFIELDS (ftype) <= 0)
{
@ -311,7 +272,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
parameter symbols. */
int nparams = 0, iparams;
struct symbol *sym;
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
@ -348,9 +309,12 @@ finish_block (struct symbol *symbol, struct pending **listhead,
TYPE_FIELDS (ftype) = (struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
for (i = iparams = 0; iparams < nparams; i++)
iparams = 0;
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
sym = BLOCK_SYM (block, i);
if (iparams == nparams)
break;
switch (SYMBOL_CLASS (sym))
{
case LOC_ARG:
@ -394,7 +358,6 @@ finish_block (struct symbol *symbol, struct pending **listhead,
else
{
BLOCK_FUNCTION (block) = NULL;
BLOCK_HASHTABLE (block) = 1;
}
/* Now "free" the links of the list, and empty the list. */
@ -476,6 +439,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
record_pending_block (objfile, block, opblock);
}
/* Record BLOCK on the list of all blocks in the file. Put it after
OPBLOCK, or at the beginning if opblock is NULL. This puts the
block in the list after all its subblocks.
@ -1031,7 +995,7 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
symtab->dirname = NULL;
}
symtab->free_code = free_linetable;
symtab->free_ptr = NULL;
symtab->free_func = NULL;
/* Use whatever language we have been using for this
subfile, not the one that was deduced in allocate_symtab

View File

@ -45,6 +45,7 @@
#include "target.h"
#include "gdb_assert.h"
#include "block.h"
#include "dictionary.h"
#include "coff-pe-read.h"
@ -1414,12 +1415,12 @@ static void
patch_opaque_types (struct symtab *s)
{
register struct block *b;
register int i;
struct dict_iterator iter;
register struct symbol *real_sym;
/* Go through the per-file symbols only */
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, real_sym)
ALL_BLOCK_SYMBOLS (b, iter, real_sym)
{
/* Find completed typedefs to use to fix opaque ones.
Remove syms from the chain when their types are stored,

836
gdb/dictionary.c Normal file
View File

@ -0,0 +1,836 @@
/* Routines for name->symbol lookups in GDB.
Copyright 2003 Free Software Foundation, Inc.
Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "gdb_obstack.h"
#include "symtab.h"
#include "buildsym.h"
#include "gdb_assert.h"
#include "dictionary.h"
/* This file implements dictionaries, which are tables that associate
symbols to names. They are represented by an opaque type 'struct
dictionary'. That type has various internal implementations, which
you can choose between depending on what properties you need
(e.g. fast lookup, order-preserving, expandable).
Each dictionary starts with a 'virtual function table' that
contains the functions that actually implement the various
operations that dictionaries provide. (Note, however, that, for
the sake of client code, we also provide some functions that can be
implemented generically in terms of the functions in the vtable.)
To add a new dictionary implementation <impl>, what you should do
is:
* Add a new element DICT_<IMPL> to dict_type.
* Create a new structure dictionary_<impl>. If your new
implementation is a variant of an existing one, make sure that
their structs have the same initial data members. Define accessor
macros for your new data members.
* Implement all the functions in dict_vector as static functions,
whose name is the same as the corresponding member of dict_vector
plus _<impl>. You don't have to do this for those members where
you can reuse existing generic functions
(e.g. add_symbol_nonexpandable, free_obstack) or in the case where
your new implementation is a variant of an existing implementation
and where the variant doesn't affect the member function in
question.
* Define a static const struct dict_vector dict_<impl>_vector.
* Define a function dict_create_<impl> to create these
gizmos. Add its declaration to dictionary.h.
To add a new operation <op> on all existing implementations, what
you should do is:
* Add a new member <op> to struct dict_vector.
* If there is useful generic behavior <op>, define a static
function <op>_something_informative that implements that behavior.
(E.g. add_symbol_nonexpandable, free_obstack.)
* For every implementation <impl> that should have its own specific
behavior for <op>, define a static function <op>_<impl>
implementing it.
* Modify all existing dict_vector_<impl>'s to include the appropriate
member.
* Define a function dict_<op> that looks up <op> in the dict_vector
and calls the appropriate function. Add a declaration for
dict_<op> to dictionary.h.
*/
/* An enum representing the various implementations of dictionaries.
Used only for debugging. */
enum dict_type
{
/* Symbols are stored in a fixed-size hash table. */
DICT_HASHED,
/* Symbols are stored in an expandable hash table. */
DICT_HASHED_EXPANDABLE,
/* Symbols are stored in a fixed-size array. */
DICT_LINEAR,
/* Symbols are stored in an expandable array. */
DICT_LINEAR_EXPANDABLE,
};
/* The virtual function table. */
struct dict_vector
{
/* The type of the dictionary. This is only here to make debugging
a bit easier; it's not actually used. */
enum dict_type type;
/* The function to free a dictionary. */
void (*free) (struct dictionary *dict);
/* Add a symbol to a dictionary, if possible. */
void (*add_symbol) (struct dictionary *dict, struct symbol *sym);
/* Iterator functions. */
struct symbol *(*iterator_first) (const struct dictionary *dict,
struct dict_iterator *iterator);
struct symbol *(*iterator_next) (struct dict_iterator *iterator);
/* Functions to iterate over symbols with a given name. */
struct symbol *(*iter_name_first) (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator);
struct symbol *(*iter_name_next) (const char *name,
struct dict_iterator *iterator);
/* A size function, for maint print symtabs. */
int (*size) (const struct dictionary *dict);
};
/* Now comes the structs used to store the data for different
implementations. If two implementations have data in common, put
the common data at the top of their structs, ordered in the same
way. */
struct dictionary_hashed
{
int nbuckets;
struct symbol **buckets;
};
struct dictionary_hashed_expandable
{
/* How many buckets we currently have. */
int nbuckets;
struct symbol **buckets;
/* How many syms we currently have; we need this so we will know
when to add more buckets. */
int nsyms;
};
struct dictionary_linear
{
int nsyms;
struct symbol **syms;
};
struct dictionary_linear_expandable
{
/* How many symbols we currently have. */
int nsyms;
struct symbol **syms;
/* How many symbols we can store before needing to reallocate. */
int capacity;
};
/* And now, the star of our show. */
struct dictionary
{
const struct dict_vector *vector;
union
{
struct dictionary_hashed hashed;
struct dictionary_hashed_expandable hashed_expandable;
struct dictionary_linear linear;
struct dictionary_linear_expandable linear_expandable;
}
data;
};
/* Accessor macros. */
#define DICT_VECTOR(d) (d)->vector
/* These can be used for DICT_HASHED_EXPANDABLE, too. */
#define DICT_HASHED_NBUCKETS(d) (d)->data.hashed.nbuckets
#define DICT_HASHED_BUCKETS(d) (d)->data.hashed.buckets
#define DICT_HASHED_BUCKET(d,i) DICT_HASHED_BUCKETS (d) [i]
#define DICT_HASHED_EXPANDABLE_NSYMS(d) (d)->data.hashed_expandable.nsyms
/* These can be used for DICT_LINEAR_EXPANDABLEs, too. */
#define DICT_LINEAR_NSYMS(d) (d)->data.linear.nsyms
#define DICT_LINEAR_SYMS(d) (d)->data.linear.syms
#define DICT_LINEAR_SYM(d,i) DICT_LINEAR_SYMS (d) [i]
#define DICT_LINEAR_EXPANDABLE_CAPACITY(d) \
(d)->data.linear_expandable.capacity
/* The initial size of a DICT_*_EXPANDABLE dictionary. */
#define DICT_EXPANDABLE_INITIAL_CAPACITY 10
/* This calculates the number of buckets we'll use in a hashtable,
given the number of symbols that it will contain. */
#define DICT_HASHTABLE_SIZE(n) ((n)/5 + 1)
/* Accessor macros for dict_iterators; they're here rather than
dictionary.h because code elsewhere should treat dict_iterators as
opaque. */
/* The dictionary that the iterator is associated to. */
#define DICT_ITERATOR_DICT(iter) (iter)->dict
/* For linear dictionaries, the index of the last symbol returned; for
hashed dictionaries, the bucket of the last symbol returned. */
#define DICT_ITERATOR_INDEX(iter) (iter)->index
/* For hashed dictionaries, this points to the last symbol returned;
otherwise, this is unused. */
#define DICT_ITERATOR_CURRENT(iter) (iter)->current
/* Declarations of functions for vectors. */
/* Functions that might work across a range of dictionary types. */
static void add_symbol_nonexpandable (struct dictionary *dict,
struct symbol *sym);
static void free_obstack (struct dictionary *dict);
/* Functions for DICT_HASHED and DICT_HASHED_EXPANDABLE
dictionaries. */
static struct symbol *iterator_first_hashed (const struct dictionary *dict,
struct dict_iterator *iterator);
static struct symbol *iterator_next_hashed (struct dict_iterator *iterator);
static struct symbol *iter_name_first_hashed (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator);
static struct symbol *iter_name_next_hashed (const char *name,
struct dict_iterator *iterator);
/* Functions only for DICT_HASHED. */
static int size_hashed (const struct dictionary *dict);
/* Functions only for DICT_HASHED_EXPANDABLE. */
static void free_hashed_expandable (struct dictionary *dict);
static void add_symbol_hashed_expandable (struct dictionary *dict,
struct symbol *sym);
static int size_hashed_expandable (const struct dictionary *dict);
/* Functions for DICT_LINEAR and DICT_LINEAR_EXPANDABLE
dictionaries. */
static struct symbol *iterator_first_linear (const struct dictionary *dict,
struct dict_iterator *iterator);
static struct symbol *iterator_next_linear (struct dict_iterator *iterator);
static struct symbol *iter_name_first_linear (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator);
static struct symbol *iter_name_next_linear (const char *name,
struct dict_iterator *iterator);
static int size_linear (const struct dictionary *dict);
/* Functions only for DICT_LINEAR_EXPANDABLE. */
static void free_linear_expandable (struct dictionary *dict);
static void add_symbol_linear_expandable (struct dictionary *dict,
struct symbol *sym);
/* Various vectors that we'll actually use. */
static const struct dict_vector dict_hashed_vector =
{
DICT_HASHED, /* type */
free_obstack, /* free */
add_symbol_nonexpandable, /* add_symbol */
iterator_first_hashed, /* iteractor_first */
iterator_next_hashed, /* iterator_next */
iter_name_first_hashed, /* iter_name_first */
iter_name_next_hashed, /* iter_name_next */
size_hashed, /* size */
};
static const struct dict_vector dict_hashed_expandable_vector =
{
DICT_HASHED_EXPANDABLE, /* type */
free_hashed_expandable, /* free */
add_symbol_hashed_expandable, /* add_symbol */
iterator_first_hashed, /* iteractor_first */
iterator_next_hashed, /* iterator_next */
iter_name_first_hashed, /* iter_name_first */
iter_name_next_hashed, /* iter_name_next */
size_hashed_expandable, /* size */
};
static const struct dict_vector dict_linear_vector =
{
DICT_LINEAR, /* type */
free_obstack, /* free */
add_symbol_nonexpandable, /* add_symbol */
iterator_first_linear, /* iteractor_first */
iterator_next_linear, /* iterator_next */
iter_name_first_linear, /* iter_name_first */
iter_name_next_linear, /* iter_name_next */
size_linear, /* size */
};
static const struct dict_vector dict_linear_expandable_vector =
{
DICT_LINEAR_EXPANDABLE, /* type */
free_linear_expandable, /* free */
add_symbol_linear_expandable, /* add_symbol */
iterator_first_linear, /* iteractor_first */
iterator_next_linear, /* iterator_next */
iter_name_first_linear, /* iter_name_first */
iter_name_next_linear, /* iter_name_next */
size_linear, /* size */
};
/* Declarations of helper functions (i.e. ones that don't go into
vectors). */
static struct symbol *iterator_hashed_advance (struct dict_iterator *iter);
static void insert_symbol_hashed (struct dictionary *dict,
struct symbol *sym);
static void expand_hashtable (struct dictionary *dict);
/* The creation functions. */
/* Create a dictionary implemented via a fixed-size hashtable. All
memory it uses is allocated on OBSTACK; the environment is
initialized from SYMBOL_LIST. */
struct dictionary *
dict_create_hashed (struct obstack *obstack,
const struct pending *symbol_list)
{
struct dictionary *retval;
int nsyms = 0, nbuckets, i;
struct symbol **buckets;
const struct pending *list_counter;
retval = obstack_alloc (obstack, sizeof (struct dictionary));
DICT_VECTOR (retval) = &dict_hashed_vector;
/* Calculate the number of symbols, and allocate space for them. */
for (list_counter = symbol_list;
list_counter != NULL;
list_counter = list_counter->next)
{
nsyms += list_counter->nsyms;
}
nbuckets = DICT_HASHTABLE_SIZE (nsyms);
DICT_HASHED_NBUCKETS (retval) = nbuckets;
buckets = obstack_alloc (obstack, nbuckets * sizeof (struct symbol *));
memset (buckets, 0, nbuckets * sizeof (struct symbol *));
DICT_HASHED_BUCKETS (retval) = buckets;
/* Now fill the buckets. */
for (list_counter = symbol_list;
list_counter != NULL;
list_counter = list_counter->next)
{
for (i = list_counter->nsyms - 1; i >= 0; --i)
{
insert_symbol_hashed (retval, list_counter->symbol[i]);
}
}
return retval;
}
/* Create a dictionary implemented via a hashtable that grows as
necessary. The dictionary is initially empty; to add symbols to
it, call dict_add_symbol(). Call dict_free() when you're done with
it. */
extern struct dictionary *
dict_create_hashed_expandable (void)
{
struct dictionary *retval;
retval = xmalloc (sizeof (struct dictionary));
DICT_VECTOR (retval) = &dict_hashed_expandable_vector;
DICT_HASHED_NBUCKETS (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY;
DICT_HASHED_BUCKETS (retval) = xcalloc (DICT_EXPANDABLE_INITIAL_CAPACITY,
sizeof (struct symbol *));
DICT_HASHED_EXPANDABLE_NSYMS (retval) = 0;
return retval;
}
/* Create a dictionary implemented via a fixed-size array. All memory
it uses is allocated on OBSTACK; the environment is initialized
from the SYMBOL_LIST. The symbols are ordered in the same order
that they're found in SYMBOL_LIST. */
struct dictionary *
dict_create_linear (struct obstack *obstack,
const struct pending *symbol_list)
{
struct dictionary *retval;
int nsyms = 0, i, j;
struct symbol **syms;
const struct pending *list_counter;
retval = obstack_alloc (obstack, sizeof (struct dictionary));
DICT_VECTOR (retval) = &dict_linear_vector;
/* Calculate the number of symbols, and allocate space for them. */
for (list_counter = symbol_list;
list_counter != NULL;
list_counter = list_counter->next)
{
nsyms += list_counter->nsyms;
}
DICT_LINEAR_NSYMS (retval) = nsyms;
syms = obstack_alloc (obstack, nsyms * sizeof (struct symbol *));
DICT_LINEAR_SYMS (retval) = syms;
/* Now fill in the symbols. Start filling in from the back, so as
to preserve the original order of the symbols. */
for (list_counter = symbol_list, j = nsyms - 1;
list_counter != NULL;
list_counter = list_counter->next)
{
for (i = list_counter->nsyms - 1;
i >= 0;
--i, --j)
{
syms[j] = list_counter->symbol[i];
}
}
return retval;
}
/* Create a dictionary implemented via an array that grows as
necessary. The dictionary is initially empty; to add symbols to
it, call dict_add_symbol(). Call dict_free() when you're done with
it. */
struct dictionary *
dict_create_linear_expandable (void)
{
struct dictionary *retval;
retval = xmalloc (sizeof (struct dictionary));
DICT_VECTOR (retval) = &dict_linear_expandable_vector;
DICT_LINEAR_NSYMS (retval) = 0;
DICT_LINEAR_EXPANDABLE_CAPACITY (retval)
= DICT_EXPANDABLE_INITIAL_CAPACITY;
DICT_LINEAR_SYMS (retval)
= xmalloc (DICT_LINEAR_EXPANDABLE_CAPACITY (retval)
* sizeof (struct symbol *));
return retval;
}
/* The functions providing the dictionary interface. */
/* Free the memory used by a dictionary that's not on an obstack. (If
any.) */
void
dict_free (struct dictionary *dict)
{
(DICT_VECTOR (dict))->free (dict);
}
/* Add SYM to DICT. DICT had better be expandable. */
void
dict_add_symbol (struct dictionary *dict, struct symbol *sym)
{
(DICT_VECTOR (dict))->add_symbol (dict, sym);
}
/* Initialize ITERATOR to point at the first symbol in DICT, and
return that first symbol, or NULL if DICT is empty. */
struct symbol *
dict_iterator_first (const struct dictionary *dict,
struct dict_iterator *iterator)
{
return (DICT_VECTOR (dict))->iterator_first (dict, iterator);
}
/* Advance ITERATOR, and return the next symbol, or NULL if there are
no more symbols. */
struct symbol *
dict_iterator_next (struct dict_iterator *iterator)
{
return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
->iterator_next (iterator);
}
struct symbol *
dict_iter_name_first (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator)
{
return (DICT_VECTOR (dict))->iter_name_first (dict, name, iterator);
}
struct symbol *
dict_iter_name_next (const char *name, struct dict_iterator *iterator)
{
return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
->iter_name_next (name, iterator);
}
int
dict_size (const struct dictionary *dict)
{
return (DICT_VECTOR (dict))->size (dict);
}
/* Now come functions (well, one function, currently) that are
implemented generically by means of the vtable. Typically, they're
rarely used. */
/* Test to see if DICT is empty. */
int
dict_empty (struct dictionary *dict)
{
struct dict_iterator iter;
return (dict_iterator_first (dict, &iter) == NULL);
}
/* The functions implementing the dictionary interface. */
/* Generic functions, where appropriate. */
static void
free_obstack (struct dictionary *dict)
{
/* Do nothing! */
}
static void
add_symbol_nonexpandable (struct dictionary *dict, struct symbol *sym)
{
internal_error (__FILE__, __LINE__,
"dict_add_symbol: non-expandable dictionary");
}
/* Functions for DICT_HASHED and DICT_HASHED_EXPANDABLE. */
static struct symbol *
iterator_first_hashed (const struct dictionary *dict,
struct dict_iterator *iterator)
{
DICT_ITERATOR_DICT (iterator) = dict;
DICT_ITERATOR_INDEX (iterator) = -1;
return iterator_hashed_advance (iterator);
}
static struct symbol *
iterator_next_hashed (struct dict_iterator *iterator)
{
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
struct symbol *next;
next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
if (next == NULL)
return iterator_hashed_advance (iterator);
else
{
DICT_ITERATOR_CURRENT (iterator) = next;
return next;
}
}
static struct symbol *
iterator_hashed_advance (struct dict_iterator *iterator)
{
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
int nbuckets = DICT_HASHED_NBUCKETS (dict);
int i;
for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nbuckets; ++i)
{
struct symbol *sym = DICT_HASHED_BUCKET (dict, i);
if (sym != NULL)
{
DICT_ITERATOR_INDEX (iterator) = i;
DICT_ITERATOR_CURRENT (iterator) = sym;
return sym;
}
}
return NULL;
}
static struct symbol *
iter_name_first_hashed (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator)
{
unsigned int hash_index
= msymbol_hash_iw (name) % DICT_HASHED_NBUCKETS (dict);
struct symbol *sym;
DICT_ITERATOR_DICT (iterator) = dict;
/* Loop through the symbols in the given bucket, breaking when SYM
first matches. If SYM never matches, it will be set to NULL;
either way, we have the right return value. */
for (sym = DICT_HASHED_BUCKET (dict, hash_index);
sym != NULL;
sym = sym->hash_next)
{
/* Warning: the order of arguments to strcmp_iw matters! */
if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0)
{
break;
}
}
DICT_ITERATOR_CURRENT (iterator) = sym;
return sym;
}
static struct symbol *
iter_name_next_hashed (const char *name, struct dict_iterator *iterator)
{
struct symbol *next;
for (next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
next != NULL;
next = next->hash_next)
{
if (strcmp_iw (SYMBOL_NATURAL_NAME (next), name) == 0)
break;
}
DICT_ITERATOR_CURRENT (iterator) = next;
return next;
}
/* Insert SYM into DICT. */
static void
insert_symbol_hashed (struct dictionary *dict,
struct symbol *sym)
{
unsigned int hash_index;
struct symbol **buckets = DICT_HASHED_BUCKETS (dict);
hash_index = (msymbol_hash_iw (SYMBOL_NATURAL_NAME (sym))
% DICT_HASHED_NBUCKETS (dict));
sym->hash_next = buckets[hash_index];
buckets[hash_index] = sym;
}
static int
size_hashed (const struct dictionary *dict)
{
return DICT_HASHED_NBUCKETS (dict);
}
/* Functions only for DICT_HASHED_EXPANDABLE. */
static void
free_hashed_expandable (struct dictionary *dict)
{
xfree (DICT_HASHED_BUCKETS (dict));
xfree (dict);
}
static void
add_symbol_hashed_expandable (struct dictionary *dict,
struct symbol *sym)
{
int nsyms = ++DICT_HASHED_EXPANDABLE_NSYMS (dict);
if (DICT_HASHTABLE_SIZE (nsyms) > DICT_HASHED_NBUCKETS (dict))
expand_hashtable (dict);
insert_symbol_hashed (dict, sym);
DICT_HASHED_EXPANDABLE_NSYMS (dict) = nsyms;
}
static int
size_hashed_expandable (const struct dictionary *dict)
{
return DICT_HASHED_EXPANDABLE_NSYMS (dict);
}
static void
expand_hashtable (struct dictionary *dict)
{
int old_nbuckets = DICT_HASHED_NBUCKETS (dict);
struct symbol **old_buckets = DICT_HASHED_BUCKETS (dict);
int new_nbuckets = 2*old_nbuckets + 1;
struct symbol **new_buckets = xcalloc (new_nbuckets,
sizeof (struct symbol *));
int i;
DICT_HASHED_NBUCKETS (dict) = new_nbuckets;
DICT_HASHED_BUCKETS (dict) = new_buckets;
for (i = 0; i < old_nbuckets; ++i) {
struct symbol *sym, *next_sym;
sym = old_buckets[i];
if (sym != NULL) {
for (next_sym = sym->hash_next;
next_sym != NULL;
next_sym = sym->hash_next) {
insert_symbol_hashed (dict, sym);
sym = next_sym;
}
insert_symbol_hashed (dict, sym);
}
}
xfree (old_buckets);
}
/* Functions for DICT_LINEAR and DICT_LINEAR_EXPANDABLE. */
static struct symbol *
iterator_first_linear (const struct dictionary *dict,
struct dict_iterator *iterator)
{
DICT_ITERATOR_DICT (iterator) = dict;
DICT_ITERATOR_INDEX (iterator) = 0;
return DICT_LINEAR_NSYMS (dict) ? DICT_LINEAR_SYM (dict, 0) : NULL;
}
static struct symbol *
iterator_next_linear (struct dict_iterator *iterator)
{
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
if (++DICT_ITERATOR_INDEX (iterator) >= DICT_LINEAR_NSYMS (dict))
return NULL;
else
return DICT_LINEAR_SYM (dict, DICT_ITERATOR_INDEX (iterator));
}
static struct symbol *
iter_name_first_linear (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator)
{
DICT_ITERATOR_DICT (iterator) = dict;
DICT_ITERATOR_INDEX (iterator) = -1;
return iter_name_next_linear (name, iterator);
}
static struct symbol *
iter_name_next_linear (const char *name, struct dict_iterator *iterator)
{
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
int i, nsyms = DICT_LINEAR_NSYMS (dict);
struct symbol *sym, *retval = NULL;
for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nsyms; ++i)
{
sym = DICT_LINEAR_SYM (dict, i);
if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0)
{
retval = sym;
break;
}
}
DICT_ITERATOR_INDEX (iterator) = i;
return retval;
}
static int
size_linear (const struct dictionary *dict)
{
return DICT_LINEAR_NSYMS (dict);
}
/* Functions only for DICT_LINEAR_EXPANDABLE. */
static void
free_linear_expandable (struct dictionary *dict)
{
xfree (DICT_LINEAR_SYMS (dict));
xfree (dict);
}
static void
add_symbol_linear_expandable (struct dictionary *dict,
struct symbol *sym)
{
int nsyms = ++DICT_LINEAR_NSYMS (dict);
/* Do we have enough room? If not, grow it. */
if (nsyms > DICT_LINEAR_EXPANDABLE_CAPACITY (dict)) {
DICT_LINEAR_EXPANDABLE_CAPACITY (dict) *= 2;
DICT_LINEAR_SYMS (dict)
= xrealloc (DICT_LINEAR_SYMS (dict),
DICT_LINEAR_EXPANDABLE_CAPACITY (dict)
* sizeof (struct symbol *));
}
DICT_LINEAR_SYM (dict, nsyms - 1) = sym;
}

156
gdb/dictionary.h Normal file
View File

@ -0,0 +1,156 @@
/* Routines for name->symbol lookups in GDB.
Copyright 2003 Free Software Foundation, Inc.
Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef DICTIONARY_H
#define DICTIONARY_H
/* An opaque type for dictionaries; only dictionary.c should know
about its innards. */
struct dictionary;
/* Other types needed for declarations. */
struct symbol;
struct obstack;
struct pending;
/* The creation functions for various implementations of
dictionaries. */
/* Create a dictionary implemented via a fixed-size hashtable. All
memory it uses is allocated on OBSTACK; the environment is
initialized from SYMBOL_LIST. */
extern struct dictionary *dict_create_hashed (struct obstack *obstack,
const struct pending
*symbol_list);
/* Create a dictionary implemented via a hashtable that grows as
necessary. The dictionary is initially empty; to add symbols to
it, call dict_add_symbol(). Call dict_free() when you're done with
it. */
extern struct dictionary *dict_create_hashed_expandable (void);
/* Create a dictionary implemented via a fixed-size array. All memory
it uses is allocated on OBSTACK; the environment is initialized
from the SYMBOL_LIST. The symbols are ordered in the same order
that they're found in SYMBOL_LIST. */
extern struct dictionary *dict_create_linear (struct obstack *obstack,
const struct pending
*symbol_list);
/* Create a dictionary implemented via an array that grows as
necessary. The dictionary is initially empty; to add symbols to
it, call dict_add_symbol(). Call dict_free() when you're done with
it. */
extern struct dictionary *dict_create_linear_expandable (void);
/* The functions providing the interface to dictionaries. Note that
the most common parts of the interface, namely symbol lookup, are
only provided via iterator functions. */
/* Free the memory used by a dictionary that's not on an obstack. (If
any.) */
extern void dict_free (struct dictionary *dict);
/* Add a symbol to an expandable dictionary. */
extern void dict_add_symbol (struct dictionary *dict, struct symbol *sym);
/* Is the dictionary empty? */
extern int dict_empty (struct dictionary *dict);
/* A type containing data that is used when iterating over all symbols
in a dictionary. Don't ever look at its innards; this type would
be opaque if we didn't need to be able to allocate it on the
stack. */
struct dict_iterator
{
/* The dictionary that this iterator is associated to. */
const struct dictionary *dict;
/* The next two members are data that is used in a way that depends
on DICT's implementation type. */
int index;
struct symbol *current;
};
/* Initialize ITERATOR to point at the first symbol in DICT, and
return that first symbol, or NULL if DICT is empty. */
extern struct symbol *dict_iterator_first (const struct dictionary *dict,
struct dict_iterator *iterator);
/* Advance ITERATOR, and return the next symbol, or NULL if there are
no more symbols. Don't call this if you've previously received
NULL from dict_iterator_first or dict_iterator_next on this
iteration. */
extern struct symbol *dict_iterator_next (struct dict_iterator *iterator);
/* Initialize ITERATOR to point at the first symbol in DICT whose
SYMBOL_BEST_NAME is NAME (as tested using strcmp_iw), and return
that first symbol, or NULL if there are no such symbols. */
extern struct symbol *dict_iter_name_first (const struct dictionary *dict,
const char *name,
struct dict_iterator *iterator);
/* Advance ITERATOR to point at the next symbol in DICT whose
SYMBOL_BEST_NAME is NAME (as tested using strcmp_iw), or NULL if
there are no more such symbols. Don't call this if you've
previously received NULL from dict_iterator_first or
dict_iterator_next on this iteration. And don't call it unless
ITERATOR was created by a previous call to dict_iter_name_first
with the same NAME. */
extern struct symbol *dict_iter_name_next (const char *name,
struct dict_iterator *iterator);
/* Return some notion of the size of the dictionary: the number of
symbols if we have that, the number of hash buckets otherwise. */
extern int dict_size (const struct dictionary *dict);
/* Macro to loop through all symbols in a dictionary DICT, in no
particular order. ITER is a struct dict_iterator (NOTE: __not__ a
struct dict_iterator *), and SYM points to the current symbol.
It's implemented as a single loop, so you can terminate the loop
early by a break if you desire. */
#define ALL_DICT_SYMBOLS(dict, iter, sym) \
for ((sym) = dict_iterator_first ((dict), &(iter)); \
(sym); \
(sym) = dict_iterator_next (&(iter)))
#endif /* DICTIONARY_H */

View File

@ -2711,6 +2711,7 @@ hpread_psymtab_to_symtab_1 (struct partial_symtab *pst)
hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
pst->textlow, pst->texthigh - pst->textlow,
pst->section_offsets, pst->filename);
sort_symtab_syms (pst->symtab);
do_cleanups (old_chain);
}

View File

@ -35,6 +35,7 @@
#include "gdbcore.h"
#include "block.h"
#include "demangle.h"
#include "dictionary.h"
#include <ctype.h>
struct type *java_int_type;
@ -91,9 +92,7 @@ get_dynamics_objfile (void)
static struct symtab *class_symtab = NULL;
/* Maximum number of class in class_symtab before relocation is needed. */
static int class_symtab_space;
static void free_class_block (struct symtab *symtab);
static struct symtab *
get_java_class_symtab (void)
@ -106,15 +105,16 @@ get_java_class_symtab (void)
class_symtab = allocate_symtab ("<java-classes>", objfile);
class_symtab->language = language_java;
bv = (struct blockvector *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct blockvector));
obstack_alloc (&objfile->symbol_obstack,
sizeof (struct blockvector) + sizeof (struct block *));
BLOCKVECTOR_NBLOCKS (bv) = 1;
BLOCKVECTOR (class_symtab) = bv;
/* Allocate dummy STATIC_BLOCK. */
bl = (struct block *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
BLOCK_NSYMS (bl) = 0;
BLOCK_HASHTABLE (bl) = 0;
BLOCK_DICT (bl) = dict_create_linear (&objfile->symbol_obstack,
NULL);
BLOCK_START (bl) = 0;
BLOCK_END (bl) = 0;
BLOCK_FUNCTION (bl) = NULL;
@ -124,13 +124,12 @@ get_java_class_symtab (void)
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
/* Allocate GLOBAL_BLOCK. This has to be relocatable. */
class_symtab_space = 128;
bl = xmmalloc (objfile->md,
sizeof (struct block)
+ ((class_symtab_space - 1) * sizeof (struct symbol *)));
bl = (struct block *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
*bl = *BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
BLOCK_DICT (bl) = dict_create_hashed_expandable ();
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
class_symtab->free_ptr = (char *) bl;
class_symtab->free_func = free_class_block;
}
return class_symtab;
}
@ -140,20 +139,7 @@ add_class_symtab_symbol (struct symbol *sym)
{
struct symtab *symtab = get_java_class_symtab ();
struct blockvector *bv = BLOCKVECTOR (symtab);
struct block *bl = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
if (BLOCK_NSYMS (bl) >= class_symtab_space)
{
/* Need to re-allocate. */
class_symtab_space *= 2;
bl = xmrealloc (symtab->objfile->md, bl,
sizeof (struct block)
+ ((class_symtab_space - 1) * sizeof (struct symbol *)));
class_symtab->free_ptr = (char *) bl;
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
}
BLOCK_SYM (bl, BLOCK_NSYMS (bl)) = sym;
BLOCK_NSYMS (bl) = BLOCK_NSYMS (bl) + 1;
dict_add_symbol (BLOCK_DICT (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)), sym);
}
static struct symbol *add_class_symbol (struct type *type, CORE_ADDR addr);
@ -174,6 +160,16 @@ add_class_symbol (struct type *type, CORE_ADDR addr)
SYMBOL_VALUE_ADDRESS (sym) = addr;
return sym;
}
/* Free the dynamic symbols block. */
static void
free_class_block (struct symtab *symtab)
{
struct blockvector *bv = BLOCKVECTOR (symtab);
struct block *bl = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
dict_free (BLOCK_DICT (bl));
}
#endif
struct type *
@ -268,7 +264,7 @@ type_from_class (struct value *clas)
char *nptr;
CORE_ADDR addr;
struct block *bl;
int i;
struct dict_iterator iter;
int is_array = 0;
type = check_typedef (VALUE_TYPE (clas));
@ -283,9 +279,8 @@ type_from_class (struct value *clas)
#if 0
get_java_class_symtab ();
bl = BLOCKVECTOR_BLOCK (BLOCKVECTOR (class_symtab), GLOBAL_BLOCK);
for (i = BLOCK_NSYMS (bl); --i >= 0;)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
struct symbol *sym = BLOCK_SYM (bl, i);
if (SYMBOL_VALUE_ADDRESS (sym) == addr)
return SYMBOL_TYPE (sym);
}

View File

@ -54,6 +54,7 @@
#include "demangle.h"
#include "gdb_assert.h"
#include "block.h"
#include "dictionary.h"
/* These are needed if the tm.h file does not contain the necessary
mips specific definitions. */
@ -284,9 +285,11 @@ static struct symbol *new_symbol (char *);
static struct type *new_type (char *);
static struct block *new_block (int);
enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
static struct symtab *new_symtab (char *, int, int, struct objfile *);
static struct block *new_block (enum block_type);
static struct symtab *new_symtab (char *, int, struct objfile *);
static struct linetable *new_linetable (int);
@ -298,8 +301,6 @@ static struct type *parse_type (int, union aux_ext *, unsigned int, int *,
static struct symbol *mylookup_symbol (char *, struct block *, domain_enum,
enum address_class);
static struct block *shrink_block (struct block *, struct symtab *);
static void sort_blocks (struct symtab *);
static struct partial_symtab *new_psymtab (char *, struct objfile *);
@ -483,7 +484,6 @@ static struct parse_stack
int blocktype;
int maxsyms; /* Max symbols in this block. */
struct type *cur_type; /* Type we parse fields for. */
int cur_field; /* Field number in cur_type. */
CORE_ADDR procadr; /* Start addres of this procedure */
@ -834,7 +834,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
TYPE_FLAGS (SYMBOL_TYPE (s)) |= TYPE_FLAG_PROTOTYPED;
/* Create and enter a new lexical context */
b = new_block (top_stack->maxsyms);
b = new_block (FUNCTION_BLOCK);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_FUNCTION (b) = s;
BLOCK_START (b) = BLOCK_END (b) = sh->value;
@ -1169,7 +1169,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
}
top_stack->blocktype = stBlock;
b = new_block (top_stack->maxsyms);
b = new_block (NON_FUNCTION_BLOCK);
BLOCK_START (b) = sh->value + top_stack->procadr;
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
top_stack->cur_block = b;
@ -1189,7 +1189,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* Finished with procedure */
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
struct mips_extra_func_info *e;
struct block *b;
struct block *b = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
int i;
@ -1209,9 +1209,6 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
e->pdr.framereg = -1;
add_symbol (s, top_stack->cur_block);
/* Reallocate symbols, saving memory */
b = shrink_block (top_stack->cur_block, top_stack->cur_st);
/* f77 emits proc-level with address bounds==[0,0],
So look for such child blocks, and patch them. */
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
@ -1236,13 +1233,17 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
if (nparams > 0)
{
struct dict_iterator iter;
TYPE_NFIELDS (ftype) = nparams;
TYPE_FIELDS (ftype) = (struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
for (i = iparams = 0; iparams < nparams; i++)
iparams = 0;
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
sym = BLOCK_SYM (b, i);
if (iparams == nparams)
break;
switch (SYMBOL_CLASS (sym))
{
case LOC_ARG:
@ -1266,7 +1267,6 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
displacement from the procedure`s start address of the
end of this block. */
BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
shrink_block (top_stack->cur_block, top_stack->cur_st);
}
else if (sh->sc == scText && top_stack->blocktype == stNil)
{
@ -4061,19 +4061,15 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
int maxlines;
EXTR *ext_ptr;
/* How many symbols will we need */
/* FIXME, this does not count enum values. */
f_max = pst->n_global_syms + pst->n_static_syms;
if (fh == 0)
{
maxlines = 0;
st = new_symtab ("unknown", f_max, 0, pst->objfile);
st = new_symtab ("unknown", 0, pst->objfile);
}
else
{
f_max += fh->csym + fh->cpd;
maxlines = 2 * fh->cline;
st = new_symtab (pst->filename, 2 * f_max, maxlines, pst->objfile);
st = new_symtab (pst->filename, maxlines, pst->objfile);
/* The proper language was already determined when building
the psymtab, use it. */
@ -4093,7 +4089,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
BLOCK_START (top_stack->cur_block) = pst->textlow;
BLOCK_END (top_stack->cur_block) = 0;
top_stack->blocktype = stFile;
top_stack->maxsyms = 2 * f_max;
top_stack->cur_type = 0;
top_stack->procadr = 0;
top_stack->numargs = 0;
@ -4177,10 +4172,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
GLOBAL_BLOCK);
top_stack->blocktype = stFile;
top_stack->maxsyms
= (debug_info->symbolic_header.isymMax
+ debug_info->symbolic_header.ipdMax
+ debug_info->symbolic_header.iextMax);
ext_ptr = PST_PRIVATE (pst)->extern_tab;
for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
@ -4450,11 +4441,12 @@ static struct symbol *
mylookup_symbol (char *name, register struct block *block,
domain_enum domain, enum address_class class)
{
int i, inc;
struct dict_iterator iter;
int inc;
struct symbol *sym;
inc = name[0];
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (DEPRECATED_SYMBOL_NAME (sym)[0] == inc
&& SYMBOL_DOMAIN (sym) == domain
@ -4470,41 +4462,12 @@ mylookup_symbol (char *name, register struct block *block,
}
/* Add a new symbol S to a block B.
Infrequently, we will need to reallocate the block to make it bigger.
We only detect this case when adding to top_stack->cur_block, since
that's the only time we know how big the block is. FIXME. */
/* Add a new symbol S to a block B. */
static void
add_symbol (struct symbol *s, struct block *b)
{
int nsyms = BLOCK_NSYMS (b)++;
struct block *origb;
struct parse_stack *stackp;
if (b == top_stack->cur_block &&
nsyms >= top_stack->maxsyms)
{
complaint (&symfile_complaints, "block containing %s overfilled",
DEPRECATED_SYMBOL_NAME (s));
/* In this case shrink_block is actually grow_block, since
BLOCK_NSYMS(b) is larger than its current size. */
origb = b;
b = shrink_block (top_stack->cur_block, top_stack->cur_st);
/* Now run through the stack replacing pointers to the
original block. shrink_block has already done this
for the blockvector and BLOCK_FUNCTION. */
for (stackp = top_stack; stackp; stackp = stackp->next)
{
if (stackp->cur_block == origb)
{
stackp->cur_block = b;
stackp->maxsyms = BLOCK_NSYMS (b);
}
}
}
BLOCK_SYM (b, nsyms) = s;
dict_add_symbol (BLOCK_DICT (b), s);
}
/* Add a new block B to a symtab S */
@ -4626,11 +4589,11 @@ sort_blocks (struct symtab *s)
/* Constructor/restructor/destructor procedures */
/* Allocate a new symtab for NAME. Needs an estimate of how many symbols
MAXSYMS and linenumbers MAXLINES we'll put in it */
/* Allocate a new symtab for NAME. Needs an estimate of how many
linenumbers MAXLINES we'll put in it */
static struct symtab *
new_symtab (char *name, int maxsyms, int maxlines, struct objfile *objfile)
new_symtab (char *name, int maxlines, struct objfile *objfile)
{
struct symtab *s = allocate_symtab (name, objfile);
@ -4638,8 +4601,10 @@ new_symtab (char *name, int maxsyms, int maxlines, struct objfile *objfile)
/* All symtabs must have at least two blocks */
BLOCKVECTOR (s) = new_bvect (2);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK) = new_block (maxsyms);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) = new_block (maxsyms);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
@ -4723,48 +4688,22 @@ new_bvect (int nblocks)
return bv;
}
/* Allocate and zero a new block of MAXSYMS symbols */
/* Allocate and zero a new block, and set its BLOCK_DICT. If function
is non-zero, assume the block is associated to a function, and make
sure that the symbols are stored linearly; otherwise, store them
hashed. */
static struct block *
new_block (int maxsyms)
new_block (enum block_type type)
{
int size = sizeof (struct block) + (maxsyms - 1) * sizeof (struct symbol *);
struct block *retval = xzalloc (sizeof (struct block));
return (struct block *) xzalloc (size);
}
if (type == FUNCTION_BLOCK)
BLOCK_DICT (retval) = dict_create_linear_expandable ();
else
BLOCK_DICT (retval) = dict_create_hashed_expandable ();
/* Ooops, too big. Shrink block B in symtab S to its minimal size.
Shrink_block can also be used by add_symbol to grow a block. */
static struct block *
shrink_block (struct block *b, struct symtab *s)
{
struct block *new;
struct blockvector *bv = BLOCKVECTOR (s);
int i;
/* Just reallocate it and fix references to the old one */
new = (struct block *) xrealloc ((void *) b,
(sizeof (struct block)
+ ((BLOCK_NSYMS (b) - 1)
* sizeof (struct symbol *))));
/* FIXME: Not worth hashing this block as it's built. */
/* All callers should have created the block with new_block (), which
would mean it was not previously hashed. Make sure. */
gdb_assert (BLOCK_HASHTABLE (new) == 0);
/* Should chase pointers to old one. Fortunately, that`s just
the block`s function and inferior blocks */
if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b)
SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
if (BLOCKVECTOR_BLOCK (bv, i) == b)
BLOCKVECTOR_BLOCK (bv, i) = new;
else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) == b)
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) = new;
return new;
return retval;
}
/* Create a new symbol with printname NAME */
@ -4901,7 +4840,7 @@ fixup_sigtramp (void)
TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = mdebug_type_void;
/* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
b = new_block (1);
b = new_block (NON_FUNCTION_BLOCK);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_START (b) = sigtramp_address;
BLOCK_END (b) = sigtramp_end;
@ -4944,7 +4883,7 @@ fixup_sigtramp (void)
current_objfile = NULL;
}
BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s;
dict_add_symbol (BLOCK_DICT (b), s);
}
#endif /* TM_MIPS_H */

View File

@ -1,3 +1,8 @@
2003-06-11 David Carlton <carlton@bactrian.org>
* mi-cmd-stack.c: Include dictionary.h.
(list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
2003-06-11 Andrew Cagney <cagney@redhat.com>
* mi-main.c (get_register): Replace REGISTER_CONVERTIBLE with

View File

@ -28,6 +28,7 @@
#include "symtab.h"
#include "block.h"
#include "stack.h"
#include "dictionary.h"
static void list_args_or_locals (int locals, int values, struct frame_info *fi);
@ -213,7 +214,8 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
{
struct block *block;
struct symbol *sym;
int i, nsyms;
struct dict_iterator iter;
int nsyms;
struct cleanup *cleanup_list;
static struct ui_stream *stb = NULL;
@ -225,7 +227,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
while (block != 0)
{
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
int print_me = 0;

View File

@ -43,6 +43,7 @@
#include "breakpoint.h"
#include "block.h"
#include "dictionary.h"
/* Prototypes for local functions */
@ -657,13 +658,13 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
{
struct block *b;
struct symbol *sym;
int j;
struct dict_iterator iter;
b = BLOCKVECTOR_BLOCK (bv, i);
BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
ALL_BLOCK_SYMBOLS (b, j, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, objfile);

View File

@ -42,6 +42,7 @@
#include "block.h"
#include "stack.h"
#include "gdb_assert.h"
#include "dictionary.h"
/* Prototypes for exported functions. */
@ -211,7 +212,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
{
struct block *b = NULL;
int first = 1;
register int i;
struct dict_iterator iter;
register struct symbol *sym;
struct value *val;
/* Offset of next stack argument beyond the one we have seen that is
@ -230,11 +231,8 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
if (func)
{
b = SYMBOL_BLOCK_VALUE (func);
/* Function blocks are order sensitive, and thus should not be
hashed. */
gdb_assert (BLOCK_HASHTABLE (b) == 0);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
QUIT;
@ -1311,14 +1309,15 @@ backtrace_full_command (char *arg, int from_tty)
Return 1 if any variables were printed; 0 otherwise. */
static int
print_block_frame_locals (struct block *b, register struct frame_info *fi,
int num_tabs, register struct ui_file *stream)
print_block_frame_locals (struct block *b, struct frame_info *fi,
int num_tabs, struct ui_file *stream)
{
register int i, j;
register struct symbol *sym;
register int values_printed = 0;
struct dict_iterator iter;
int j;
struct symbol *sym;
int values_printed = 0;
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
@ -1350,11 +1349,11 @@ static int
print_block_frame_labels (struct block *b, int *have_default,
register struct ui_file *stream)
{
register int i;
struct dict_iterator iter;
register struct symbol *sym;
register int values_printed = 0;
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (STREQ (DEPRECATED_SYMBOL_NAME (sym), "default"))
{
@ -1532,7 +1531,7 @@ print_frame_arg_vars (register struct frame_info *fi,
{
struct symbol *func = get_frame_function (fi);
register struct block *b;
register int i;
struct dict_iterator iter;
register struct symbol *sym, *sym2;
register int values_printed = 0;
@ -1543,7 +1542,7 @@ print_frame_arg_vars (register struct frame_info *fi,
}
b = SYMBOL_BLOCK_VALUE (func);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{

View File

@ -34,6 +34,7 @@
#include "bcache.h"
#include "block.h"
#include "gdb_regex.h"
#include "dictionary.h"
#include "gdb_string.h"
#include <readline/readline.h>
@ -87,22 +88,22 @@ static void free_symtab_block (struct objfile *, struct block *);
/* Free a struct block <- B and all the symbols defined in that block. */
/* FIXME: carlton/2003-04-28: I don't believe this is currently ever
used. */
static void
free_symtab_block (struct objfile *objfile, struct block *b)
{
register int i, n;
struct symbol *sym, *next_sym;
struct dict_iterator iter;
struct symbol *sym;
n = BLOCK_BUCKETS (b);
for (i = 0; i < n; i++)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym)
{
next_sym = sym->hash_next;
xmfree (objfile->md, DEPRECATED_SYMBOL_NAME (sym));
xmfree (objfile->md, sym);
}
xmfree (objfile->md, DEPRECATED_SYMBOL_NAME (sym));
xmfree (objfile->md, sym);
}
dict_free (BLOCK_DICT (b));
xmfree (objfile->md, b);
}
@ -141,7 +142,7 @@ free_symtab (register struct symtab *s)
/* Also free the linetable. */
case free_linetable:
/* Everything will be freed either by our `free_ptr'
/* Everything will be freed either by our `free_func'
or by some other symtab, except for our linetable.
Free that now. */
if (LINETABLE (s))
@ -150,8 +151,8 @@ free_symtab (register struct symtab *s)
}
/* If there is a single block of memory to free, free it. */
if (s->free_ptr != NULL)
xmfree (s->objfile->md, s->free_ptr);
if (s->free_func != NULL)
s->free_func (s);
/* Free source-related stuff */
if (s->line_charpos != NULL)
@ -444,12 +445,13 @@ static void
dump_symtab (struct objfile *objfile, struct symtab *symtab,
struct ui_file *outfile)
{
register int i, j;
int i;
struct dict_iterator iter;
int len, blen;
register struct linetable *l;
struct linetable *l;
struct blockvector *bv;
struct symbol *sym;
register struct block *b;
struct block *b;
int depth;
fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
@ -496,11 +498,8 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
/* drow/2002-07-10: We could save the total symbols count
even if we're using a hashtable, but nothing else but this message
wants it. */
blen = BLOCK_BUCKETS (b);
if (BLOCK_HASHTABLE (b))
fprintf_filtered (outfile, ", %d buckets in ", blen);
else
fprintf_filtered (outfile, ", %d syms in ", blen);
fprintf_filtered (outfile, ", %d syms/buckets in ",
dict_size (BLOCK_DICT (b)));
print_address_numeric (BLOCK_START (b), 1, outfile);
fprintf_filtered (outfile, "..");
print_address_numeric (BLOCK_END (b), 1, outfile);
@ -518,7 +517,7 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
fprintf_filtered (outfile, "\n");
/* Now print each symbol in this block (in no particular order, if
we're using a hashtable). */
ALL_BLOCK_SYMBOLS (b, j, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
struct print_symbol_args s;
s.symbol = sym;

View File

@ -46,6 +46,7 @@
#include "gdb_obstack.h"
#include "block.h"
#include "dictionary.h"
#include <sys/types.h>
#include <fcntl.h>
@ -1633,21 +1634,18 @@ lookup_block_symbol (register const struct block *block, const char *name,
const char *linkage_name,
const domain_enum domain)
{
register int bot, top, inc;
register struct symbol *sym;
register struct symbol *sym_found = NULL;
struct dict_iterator iter;
struct symbol *sym;
if (BLOCK_HASHTABLE (block))
if (!BLOCK_FUNCTION (block))
{
unsigned int hash_index;
hash_index = msymbol_hash_iw (name);
hash_index = hash_index % BLOCK_BUCKETS (block);
for (sym = BLOCK_BUCKET (block, hash_index); sym; sym = sym->hash_next)
for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
sym != NULL;
sym = dict_iter_name_next (name, &iter))
{
if (SYMBOL_DOMAIN (sym) == domain
&& (linkage_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), linkage_name) == 0
: SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
if (SYMBOL_DOMAIN (sym) == domain
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
return sym;
}
return NULL;
@ -1659,15 +1657,16 @@ lookup_block_symbol (register const struct block *block, const char *name,
parameter symbols first; it only uses parameter symbols as a
last resort. Note that this only takes up extra computation
time on a match. */
top = BLOCK_NSYMS (block);
bot = 0;
while (bot < top)
struct symbol *sym_found = NULL;
for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
sym != NULL;
sym = dict_iter_name_next (name, &iter))
{
sym = BLOCK_SYM (block, bot);
if (SYMBOL_DOMAIN (sym) == domain
&& (linkage_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), linkage_name) == 0
: SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
{
/* If SYM has aliases, then use any alias that is active
at the current PC. If no alias is active at the current
@ -1676,18 +1675,18 @@ lookup_block_symbol (register const struct block *block, const char *name,
?!? Is checking the current pc correct? Is this routine
ever called to look up a symbol from another context?
FIXME: No, it's not correct. If someone sets a
conditional breakpoint at an address, then the
breakpoint's `struct expression' should refer to the
`struct symbol' appropriate for the breakpoint's
address, which may not be the PC.
FIXME: No, it's not correct. If someone sets a
conditional breakpoint at an address, then the
breakpoint's `struct expression' should refer to the
`struct symbol' appropriate for the breakpoint's
address, which may not be the PC.
Even if it were never called from another context,
it's totally bizarre for lookup_symbol's behavior to
depend on the value of the inferior's current PC. We
should pass in the appropriate PC as well as the
block. The interface to lookup_symbol should change
to require the caller to provide a PC. */
Even if it were never called from another context,
it's totally bizarre for lookup_symbol's behavior to
depend on the value of the inferior's current PC. We
should pass in the appropriate PC as well as the
block. The interface to lookup_symbol should change
to require the caller to provide a PC. */
if (SYMBOL_ALIASES (sym))
sym = find_active_alias (sym, read_pc ());
@ -1704,10 +1703,8 @@ lookup_block_symbol (register const struct block *block, const char *name,
break;
}
}
bot++;
}
return (sym_found); /* Will be NULL if not found. */
return (sym_found); /* Will be NULL if not found. */
}
}
@ -1811,16 +1808,16 @@ find_pc_sect_symtab (CORE_ADDR pc, asection *section)
}
if (section != 0)
{
int i;
struct dict_iterator iter;
struct symbol *sym = NULL;
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, objfile);
if (section == SYMBOL_BFD_SECTION (sym))
break;
}
if ((i >= BLOCK_BUCKETS (b)) && (sym == NULL))
if (sym == NULL)
continue; /* no symbol in this symtab matches section */
}
distance = BLOCK_END (b) - BLOCK_START (b);
@ -2757,7 +2754,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
struct blockvector *prev_bv = 0;
register struct block *b;
register int i = 0;
register int j;
struct dict_iterator iter;
register struct symbol *sym;
struct partial_symbol **psym;
struct objfile *objfile;
@ -2946,7 +2943,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
struct symbol_search *prevtail = tail;
int nfound = 0;
b = BLOCKVECTOR_BLOCK (bv, i);
ALL_BLOCK_SYMBOLS (b, j, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
QUIT;
if (file_matches (s->filename, files, nfiles)
@ -3407,13 +3404,14 @@ language_search_unquoted_string (char *text, char *p)
char **
make_symbol_completion_list (char *text, char *word)
{
register struct symbol *sym;
register struct symtab *s;
register struct partial_symtab *ps;
register struct minimal_symbol *msymbol;
register struct objfile *objfile;
register struct block *b, *surrounding_static_block = 0;
register int i, j;
struct symbol *sym;
struct symtab *s;
struct partial_symtab *ps;
struct minimal_symbol *msymbol;
struct objfile *objfile;
struct block *b, *surrounding_static_block = 0;
struct dict_iterator iter;
int j;
struct partial_symbol **psym;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
@ -3536,7 +3534,7 @@ make_symbol_completion_list (char *text, char *word)
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
QUIT;
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
@ -3567,7 +3565,7 @@ make_symbol_completion_list (char *text, char *word)
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
@ -3580,7 +3578,7 @@ make_symbol_completion_list (char *text, char *word)
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
@ -3598,7 +3596,7 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
register struct symbol *sym;
register struct symtab *s;
register struct block *b;
register int i;
struct dict_iterator iter;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
/* Length of sym_text. */
@ -3677,13 +3675,13 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
symbols which match. */
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
@ -4034,7 +4032,7 @@ make_symbol_overload_list (struct symbol *fsym)
register struct partial_symtab *ps;
register struct objfile *objfile;
register struct block *b, *surrounding_static_block = 0;
register int i;
struct dict_iterator iter;
/* The name we are completing on. */
char *oload_name = NULL;
/* Length of name. */
@ -4091,7 +4089,7 @@ make_symbol_overload_list (struct symbol *fsym)
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}
@ -4104,7 +4102,7 @@ make_symbol_overload_list (struct symbol *fsym)
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}
@ -4117,7 +4115,7 @@ make_symbol_overload_list (struct symbol *fsym)
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
ALL_BLOCK_SYMBOLS (b, i, sym)
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}

View File

@ -801,10 +801,10 @@ struct symtab
}
free_code;
/* Pointer to one block of storage to be freed, if nonzero. */
/* This is IN ADDITION to the action indicated by free_code. */
/* A function to call to free space, if necessary. This is IN
ADDITION to the action indicated by free_code. */
char *free_ptr;
void (*free_func)(struct symtab *symtab);
/* Total number of lines found in source file. */

View File

@ -38,6 +38,7 @@
#include "completer.h"
#include "gdb-events.h"
#include "block.h"
#include "dictionary.h"
#include "ax.h"
#include "ax-gdb.h"
@ -1289,13 +1290,14 @@ add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
{
struct symbol *sym;
struct block *block;
int i, count = 0;
struct dict_iterator iter;
int count = 0;
block = block_for_pc (pc);
while (block != 0)
{
QUIT; /* allow user to bail out with ^C */
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
@ -2333,7 +2335,8 @@ scope_info (char *args, int from_tty)
struct minimal_symbol *msym;
struct block *block;
char **canonical, *symname, *save_args = args;
int i, j, count = 0;
struct dict_iterator iter;
int j, count = 0;
if (args == 0 || *args == 0)
error ("requires an argument (function, line or *addr) to define a scope");
@ -2349,7 +2352,7 @@ scope_info (char *args, int from_tty)
while (block != 0)
{
QUIT; /* allow user to bail out with ^C */
ALL_BLOCK_SYMBOLS (block, i, sym)
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
QUIT; /* allow user to bail out with ^C */
if (count == 0)

View File

@ -35,6 +35,7 @@
#include "cp-abi.h"
#include "block.h"
#include "infcall.h"
#include "dictionary.h"
#include <errno.h>
#include "gdb_string.h"
@ -2475,7 +2476,6 @@ value_of_local (const char *name, int complain)
{
struct symbol *func, *sym;
struct block *b;
int i;
struct value * ret;
if (deprecated_selected_frame == 0)
@ -2496,8 +2496,7 @@ value_of_local (const char *name, int complain)
}
b = SYMBOL_BLOCK_VALUE (func);
i = BLOCK_NSYMS (b);
if (i <= 0)
if (dict_empty (BLOCK_DICT (b)))
{
if (complain)
error ("no args, no `%s'", name);

View File

@ -1767,6 +1767,7 @@ xcoff_psymtab_to_symtab_1 (struct partial_symtab *pst)
old_chain = make_cleanup (really_free_pendings, 0);
read_xcoff_symtab (pst);
sort_symtab_syms (pst->symtab);
do_cleanups (old_chain);
}