Commit Graph

99 Commits

Author SHA1 Message Date
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Doug Evans 1994afbf19 Look up primitive types as symbols.
gdb/ChangeLog:

	* ada-lang.c (user_select_syms): Only fetch symtab if symbol is
	objfile-owned.
	(cache_symbol): Ignore symbols that are not objfile-owned.
	* block.c (block_objfile): New function.
	(block_gdbarch): New function.
	* block.h (block_objfile): Declare.
	(block_gdbarch): Declare.
	* c-exp.y (classify_name): Remove call to
	language_lookup_primitive_type.  No longer necessary.
	* gdbtypes.c (lookup_typename): Call lookup_symbol_in_language.
	Remove call to language_lookup_primitive_type.  No longer necessary.
	* guile/scm-symbol.c (syscm_gdbarch_data_key): New static global.
	(syscm_gdbarch_data): New struct.
	(syscm_init_arch_symbols): New function.
	(syscm_get_symbol_map): Renamed from syscm_objfile_symbol_map.
	All callers updated.  Handle symbols owned by arches.
	(gdbscm_symbol_symtab): Handle symbols owned by arches.
	(gdbscm_initialize_symbols): Initialize syscm_gdbarch_data_key.
	* language.c (language_lookup_primitive_type_1): New function.
	(language_lookup_primitive_type): Call it.
	(language_alloc_type_symbol): New function.
	(language_init_primitive_type_symbols): New function.
	(language_lookup_primitive_type_as_symbol): New function.
	* language.h (struct language_arch_info) <primitive_type_symbols>:
	New member.
	(language_lookup_primitive_type): Add function comment.
	(language_lookup_primitive_type_as_symbol): Declare.
	* printcmd.c (address_info): Handle arch-owned symbols.
	* python/py-symbol.c (sympy_get_symtab): Ditto.
	(set_symbol): Ditto.
	(sympy_dealloc): Ditto.
	* symmisc.c (print_symbol): Ditto.
	* symtab.c (fixup_symbol_section): Ditto.
	(lookup_symbol_aux): Initialize block_found.
	(basic_lookup_symbol_nonlocal): Try looking up the symbol as a
	primitive type.
	(initialize_objfile_symbol_1): New function.
	(initialize_objfile_symbol): Call it.
	(allocate_symbol): Call it.
	(allocate_template_symbol): Call it.
	(symbol_objfile): Assert symbol is objfile-owned.
	(symbol_arch, symbol_symtab, symbol_set_symtab): Ditto.
	* symtab.h (struct symbol) <owner>: Replaces member "symtab".
	(struct symbol) <is_objfile_owned>: New member.
	(SYMBOL_OBJFILE_OWNED): New macro.
	* cp-namespace.c (cp_lookup_bare_symbol): New arg langdef.
	All callers updated.  Try to find the symbol as a primitive type.
	(lookup_namespace_scope): New arg langdef.  All callers updated.
	Call cp_lookup_bare_symbol directly for simple bare symbols.
2014-12-23 07:58:14 -08:00
Doug Evans f606139ae8 Add langdef arg to la_lookup_symbol_nonlocal.
gdb/ChangeLog:

	* language.h (struct language_defn) <la_lookup_symbol_nonlocal>:
	New arg language_defn.  All uses updated.
2014-12-23 07:24:48 -08:00
Doug Evans 08be3fe322 Replace some symbol accessor macros with functions.
gdb/ChangeLog:

	* symtab.h (SYMBOL_SYMTAB): Delete
	(SYMBOL_OBJFILE): Delete.
	(symbol_symtab, symbol_set_symtab): Declare.
	(symbol_objfile, symbol_arch): Declare.
	* symtab.c (symbol_symtab): Replaces SYMBOL_SYMTAB.  All uses updated.
	All references to symbol->symtab redirected through here.
	(symbol_set_symtab): New function.  All assignments to SYMBOL_SYMTAB
	redirected through here.
	(symbol_arch): New function.
	(symbol_objfile): New function.  Replaces SYMBOL_OBJFILE.
	All uses updated.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Call
	symbol_arch.
	* findvar.c (default_read_var_value): Call symbol_arch.
	* guile/scm-frame.c (gdbscm_frame_block): Call symbol_objfile.
	* jv-lang.c (add_class_symtab_symbol): Call symbol_arch.
	* printcmd.c (address_info): Call symbol_arch.
	* tracepoint.c (scope_info): Call symbol_arch.
2014-12-23 07:21:10 -08:00
Doug Evans f953163fe9 cp-namespace.c (cp_lookup_symbol_via_all_imports): New function.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_via_all_imports): New function.
	(cp_lookup_symbol_namespace): Call it.
	(cp_lookup_symbol_nonlocal): Ditto.
2014-12-22 09:29:25 -08:00
Doug Evans 4bd0864e21 cp-namespace.c (cp_lookup_symbol_via_imports): New arg "search_scope_first".
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_via_imports): New arg
	"search_scope_first".  All callers updated.
2014-12-22 09:20:50 -08:00
Doug Evans 6f27419a4d cp-namespace.c (cp_lookup_nested_symbol_1): New function.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_nested_symbol_1): New function.
	(cp_basic_lookup_symbol): Renamed from lookup_symbol_file.  Delete
	arg "search".  All callers updated.
	(cp_lookup_bare_symbol): New function.
	(cp_search_static_and_baseclasses): New function.
	(cp_lookup_symbol_in_namespace): Rewrite, move more logic here.
	(find_symbol_in_baseclass): Simplify, call cp_lookup_nested_symbol_1.
	(cp_lookup_nested_symbol): Ditto.
2014-12-22 09:11:44 -08:00
Doug Evans d276311738 cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_in_namespace): Simplify.
2014-12-22 08:44:50 -08:00
Doug Evans 791244bea2 cp-namespace.c: Whitespace cleanup.
gdb/ChangeLog:

	* cp-namespace.c: Whitespace cleanup.
2014-12-22 08:42:02 -08:00
Doug Evans cc485e6201 New parameter "debug symbol-lookup".
gdb/ChangeLog:

	New parameter "debug symbol-lookup".
	* NEWS: Mention it.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Add debug
	output.
	(cp_lookup_symbol_namespace, cp_lookup_symbol_nonlocal): Ditto.
	(cp_lookup_nested_symbol): Ditto.
	* language.c (language_lookup_primitive_type_by_name): Add debug
	output.
	* minsyms.c (lookup_minimal_symbol): Add debug output.
	* objfiles.c (objfile_debug_name): Moved here, and renamed ...
	* symfile-debug.c (debug_objfile_name): ... from here.  All callers
	updated.
	* objfiles.h (objfile_debug_name): Declare.
	* symtab.h (symbol_lookup_debug): Declare.
	* symtab.c (symbol_lookup_debug): New global.
	(lookup_language_this): Add debug output.
	(lookup_symbol_aux, lookup_symbol_in_block): Ditto.
	(lookup_symbol_in_objfile_symtabs, lookup_symbol_via_quick_fns): Ditto.
	(lookup_symbol_in_static_block, lookup_symbol_in_objfile): Ditto.
	(_initialize_symtab): Add new parameter "debug symbol-lookup".

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Document "debug symbol-lookup".
2014-12-17 00:17:27 -08:00
Doug Evans 55accf4a1e cp_lookup_symbol_via_imports: Renamed from cp_lookup_symbol_imports.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_via_imports): Renamed from
	cp_lookup_symbol_imports.  All callers updated.
2014-12-16 22:19:15 -08:00
Doug Evans a07e3e182d cp_find_type_baseclass_by_name: Renamed from find_type_baseclass_by_name.
gdb/ChangeLog:

	* cp-namespace.c (cp_find_type_baseclass_by_name): Renamed from
	find_type_baseclass_by_name.  All callers updated.
2014-12-16 22:13:57 -08:00
Doug Evans 59da4d04cb Rename cp_is_anonymous to cp_is_in_anonymous.
gdb/ChangeLog:

	* cp-support.h (cp_is_in_anonymous): Renamed from cp_is_anonymous.
	All callers updated.  Rename arg "namespace" to "symbol_name".
2014-12-12 22:33:26 -08:00
Doug Evans 05a6c3c813 cp-namespace.c (cp_lookup_nested_symbol): Fix comments.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_nested_symbol): Fix comments.
2014-12-11 12:05:25 -08:00
Doug Evans 56286edfdc cp_lookup_symbol_nonlocal: Move definition closer to its subroutines.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_nonlocal): Move definition,
	closer to its subroutines.
2014-12-10 10:42:22 -08:00
Doug Evans 34ef845277 cp-namespace.c (lookup_symbol_file): Move next to only caller.
gdb/ChangeLog:

	* cp-namespace.c (lookup_symbol_file): Move next to only caller.
2014-12-10 10:21:31 -08:00
Doug Evans 9a80057aa0 cp_lookup_symbol_imports: Make static.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_imports): Make static.
	* cp-support.c (cp_lookup_symbol_imports): Delete.
2014-12-10 10:05:32 -08:00
Doug Evans 07a1c2c3c7 cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.
2014-11-22 10:46:52 -08:00
Doug Evans aff0895837 Use SYMBOL_OBJFILE more.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Use
	SYMBOL_OBJFILE.
	* findvar.c (default_read_var_value): Ditto.
	* jv-lang.c (add_class_symtab_symbol): Ditto.
	* parse.c (operator_check_standard): Ditto.
	* printcmd.c (address_info): Ditto.
	* symtab.c (fixup_symbol_section): Ditto.
	(skip_prologue_sal): Ditto.
	* tracepoint.c (scope_info): Ditto.
	* valops.c (find_function_in_inferior): Ditto.
	* guile/scm-symbol.c (syscm_eq_symbol_smob): Ditto.
	* python/py-symbol.c (set_symbol): Ditto.
2014-11-18 08:54:06 -08:00
Doug Evans 08724ab7ca Rename lookup_symbol_global to lookup_global_symbol.
gdb/ChangeLog:

	* symtab.c (lookup_global_symbol): Renamed from lookup_symbol_global.
	All callers updated.
	* symtab.h (lookup_global_symbol): Update decl.
	(lookup_static_symbol): Move decl to better location.
2014-11-06 23:48:18 -08:00
Doug Evans d1a2d36d58 lookup_symbol_in_block: Renamed from lookup_symbol_aux_block.
gdb/ChangeLog:

	* symtab.c (lookup_symbol_in_block): Renamed from
	lookup_symbol_aux_block.  All callers updated.
2014-11-06 23:04:15 -08:00
Doug Evans 24d864bb95 Rename lookup_symbol_static to lookup_symbol_in_static_block,
and lookup_static_symbol_aux to lookup_static_symbol.

gdb/ChangeLog:

	* symtab.c (lookup_static_symbol): Renamed from
	lookup_static_symbol_aux.  All callers updated.
	(lookup_symbol_in_static_block): Renamed from lookup_symbol_static.
	All callers updated.
2014-11-06 22:56:46 -08:00
Gary Benson dccbb60975 Include gdb_assert.h in common-defs.h
This commit includes gdb_assert.h in common-defs.h and removes all
other inclusions.

gdb/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* common/common-defs.h: Include gdb_assert.h.
	* aarch64-tdep.c: Do not include gdb_assert.h.
	* addrmap.c: Likewise.
	* aix-thread.c: Likewise.
	* alpha-linux-tdep.c: Likewise.
	* alpha-mdebug-tdep.c: Likewise.
	* alphanbsd-tdep.c: Likewise.
	* amd64-nat.c: Likewise.
	* amd64-tdep.c: Likewise.
	* amd64bsd-nat.c: Likewise.
	* amd64fbsd-nat.c: Likewise.
	* amd64fbsd-tdep.c: Likewise.
	* amd64nbsd-nat.c: Likewise.
	* amd64nbsd-tdep.c: Likewise.
	* amd64obsd-nat.c: Likewise.
	* amd64obsd-tdep.c: Likewise.
	* arch-utils.c: Likewise.
	* arm-tdep.c: Likewise.
	* armbsd-tdep.c: Likewise.
	* auxv.c: Likewise.
	* bcache.c: Likewise.
	* bfin-tdep.c: Likewise.
	* blockframe.c: Likewise.
	* breakpoint.c: Likewise.
	* bsd-kvm.c: Likewise.
	* bsd-uthread.c: Likewise.
	* buildsym.c: Likewise.
	* c-exp.y: Likewise.
	* c-lang.c: Likewise.
	* charset.c: Likewise.
	* cleanups.c: Likewise.
	* cli-out.c: Likewise.
	* cli/cli-decode.c: Likewise.
	* cli/cli-dump.c: Likewise.
	* cli/cli-logging.c: Likewise.
	* cli/cli-script.c: Likewise.
	* cli/cli-utils.c: Likewise.
	* coffread.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/queue.h: Likewise.
	* common/signals.c: Likewise.
	* common/vec.h: Likewise.
	* complaints.c: Likewise.
	* completer.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-name-parser.y: Likewise.
	* cp-namespace.c: Likewise.
	* cp-support.c: Likewise.
	* cris-tdep.c: Likewise.
	* dbxread.c: Likewise.
	* dictionary.c: Likewise.
	* doublest.c: Likewise.
	* dsrec.c: Likewise.
	* dummy-frame.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2expr.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* exceptions.c: Likewise.
	* expprint.c: Likewise.
	* f-valprint.c: Likewise.
	* fbsd-nat.c: Likewise.
	* findvar.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* frv-tdep.c: Likewise.
	* gcore.c: Likewise.
	* gdb-dlfcn.c: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbarch.c: Likewise.
	* gdbarch.sh: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-nat.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-lang.c: Likewise.
	* guile/scm-exception.c: Likewise.
	* guile/scm-gsmob.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-math.c: Likewise.
	* guile/scm-pretty-print.c: Likewise.
	* guile/scm-safe-call.c: Likewise.
	* guile/scm-utils.c: Likewise.
	* guile/scm-value.c: Likewise.
	* h8300-tdep.c: Likewise.
	* hppa-hpux-nat.c: Likewise.
	* hppa-tdep.c: Likewise.
	* hppanbsd-tdep.c: Likewise.
	* hppaobsd-tdep.c: Likewise.
	* i386-darwin-nat.c: Likewise.
	* i386-darwin-tdep.c: Likewise.
	* i386-nto-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* i386bsd-nat.c: Likewise.
	* i386fbsd-tdep.c: Likewise.
	* i386gnu-nat.c: Likewise.
	* i386nbsd-tdep.c: Likewise.
	* i386obsd-tdep.c: Likewise.
	* i387-tdep.c: Likewise.
	* ia64-libunwind-tdep.c: Likewise.
	* ia64-tdep.c: Likewise.
	* inf-ptrace.c: Likewise.
	* inf-ttrace.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* inline-frame.c: Likewise.
	* interps.c: Likewise.
	* jv-lang.c: Likewise.
	* jv-typeprint.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32c-tdep.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m68k-tdep.c: Likewise.
	* m68kbsd-nat.c: Likewise.
	* m68kbsd-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* machoread.c: Likewise.
	* macroexp.c: Likewise.
	* macrotab.c: Likewise.
	* maint.c: Likewise.
	* mdebugread.c: Likewise.
	* memory-map.c: Likewise.
	* mep-tdep.c: Likewise.
	* mi/mi-common.c: Likewise.
	* microblaze-tdep.c: Likewise.
	* mingw-hdep.c: Likewise.
	* mips-linux-nat.c: Likewise.
	* mips-linux-tdep.c: Likewise.
	* mips-tdep.c: Likewise.
	* mips64obsd-tdep.c: Likewise.
	* mipsnbsd-tdep.c: Likewise.
	* mn10300-linux-tdep.c: Likewise.
	* mn10300-tdep.c: Likewise.
	* moxie-tdep.c: Likewise.
	* mt-tdep.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* nios2-linux-tdep.c: Likewise.
	* nios2-tdep.c: Likewise.
	* objc-lang.c: Likewise.
	* objfiles.c: Likewise.
	* obsd-nat.c: Likewise.
	* opencl-lang.c: Likewise.
	* osabi.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* ppcfbsd-nat.c: Likewise.
	* ppcfbsd-tdep.c: Likewise.
	* ppcnbsd-nat.c: Likewise.
	* ppcnbsd-tdep.c: Likewise.
	* ppcobsd-nat.c: Likewise.
	* ppcobsd-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* procfs.c: Likewise.
	* prologue-value.c: Likewise.
	* psymtab.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-value.c: Likewise.
	* regcache.c: Likewise.
	* reggroups.c: Likewise.
	* registry.c: Likewise.
	* remote-sim.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-tdep.c: Likewise.
	* s390-linux-tdep.c: Likewise.
	* score-tdep.c: Likewise.
	* ser-base.c: Likewise.
	* ser-mingw.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* source.c: Likewise.
	* sparc-nat.c: Likewise.
	* sparc-sol2-tdep.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-sol2-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* sparc64fbsd-tdep.c: Likewise.
	* sparc64nbsd-tdep.c: Likewise.
	* sparc64obsd-tdep.c: Likewise.
	* sparcnbsd-tdep.c: Likewise.
	* sparcobsd-tdep.c: Likewise.
	* spu-multiarch.c: Likewise.
	* spu-tdep.c: Likewise.
	* stabsread.c: Likewise.
	* stack.c: Likewise.
	* symfile.c: Likewise.
	* symtab.c: Likewise.
	* target-descriptions.c: Likewise.
	* target-memory.c: Likewise.
	* target.c: Likewise.
	* tic6x-linux-tdep.c: Likewise.
	* tic6x-tdep.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* top.c: Likewise.
	* tramp-frame.c: Likewise.
	* tui/tui-out.c: Likewise.
	* tui/tui-winsource.c: Likewise.
	* ui-out.c: Likewise.
	* user-regs.c: Likewise.
	* utils.c: Likewise.
	* v850-tdep.c: Likewise.
	* valops.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* vax-nat.c: Likewise.
	* xml-syscall.c: Likewise.
	* xml-tdesc.c: Likewise.
	* xstormy16-tdep.c: Likewise.
	* xtensa-linux-nat.c: Likewise.
	* xtensa-tdep.c: Likewise.

gdb/gdbserver/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* server.h: Do not include gdb_assert.h.
2014-08-07 09:06:45 +01:00
Keith Seitz 4186eb54dd Revert patchset for c++/16253: it causes a large performance regression.
See the bug for further information.
2014-06-07 10:40:39 -07:00
Keith Seitz c4f87ca6db PR c++/16597
[forgot to commit/push these with previous push]

If lookup_symbol_file tries to locate a member variable with NULL name:

      /* A simple lookup failed.  Check if the symbol was defined in
         a base class.  */

      cleanup = make_cleanup (null_cleanup, NULL);

      /* Find the name of the class and the name of the method,
         variable, etc.  */
      prefix_len = cp_entire_prefix_len (name);

      /* If no prefix was found, search "this".  */
      if (prefix_len == 0)
        {
          struct type *type;
          struct symbol *this;

         this = lookup_language_this (language_def (language_cplus), block);
          if (this == NULL)
            {
              do_cleanups (cleanup);
              return NULL;
            }

          type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
          klass = xstrdup (TYPE_NAME (type));
          nested = xstrdup (name);
        }

TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!

This can happen, e.g., with clang++.  See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.

This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.
2014-04-16 14:20:19 -07:00
Keith Seitz b50c861487 Remove symbol_matches_domain. This fixes
PR c++/16253.

symbol_matches_domain was permitting searches for a VAR_DOMAIN
symbol to also match STRUCT_DOMAIN symbols for languages like C++
where STRUCT_DOMAIN symbols also define a typedef of the same name,
e.g., "struct foo {}" introduces a typedef of the name "foo".

Problems occur if there exists both a VAR_DOMAIN and STRUCT_DOMAIN
symbol of the same name. Then it is essentially a race between which
symbol is found first. The other symbol is obscurred.
[This is a relatively common idiom: enum e { ... } e;]

This patchset moves this "language defines a typedef" logic to
lookup_symbol[_in_language], looking first for a symbol in the given
domain and falling back to searching STRUCT_DOMAIN when/if appropriate.

2014-04-14  Keith Seitz  <keiths@redhat.com>

	PR c++/16253
	* ada-lang.c (ada_symbol_matches_domain): Moved here and renamed
	from symbol_matches_domain in symtab.c. All local callers
	of symbol_matches_domain updated.
	(standard_lookup): If DOMAIN is VAR_DOMAIN and no symbol is found,
	search STRUCT_DOMAIN.
	(ada_find_any_type_symbol): Do not search STRUCT_DOMAIN
	independently.  standard_lookup will do that automatically.
	* cp-namespace.c (cp_lookup_symbol_nonlocal): Explain when/why
	VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
	(cp_lookup_symbol_in_namespace): Likewise.
	If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN.
	(cp_lookup_symbol_exports): Explain when/why VAR_DOMAIN searches
	may return a STRUCT_DOMAIN match.
	(lookup_symbol_file): Search for the class name in STRUCT_DOMAIN.
	* cp-support.c: Include language.h.
	(inspect_type): Explicitly search STRUCT_DOMAIN before searching
	VAR_DOMAIN.
	* psymtab.c (match_partial_symbol): Compare the requested
	domain with the symbol's domain directly.
	(lookup_partial_symbol): Likewise.
	* symtab.c (lookup_symbol_in_language): Explain when/why
	VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
	If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN for
	appropriate languages.
	(symbol_matches_domain): Renamed `ada_symbol_matches_domain'
	and moved to ada-lang.c
	(lookup_block_symbol): Explain that this function only returns
	symbol matching the requested DOMAIN.
	Compare the requested domain with the symbol's domain directly.
	(iterate_over_symbols): Compare the requested domain with the
	symbol's domain directly.
	* symtab.h (symbol_matches_domain): Remove.

2014-04-14  Keith Seitz  <keiths@redhat.com>

	PR c++/16253
	* gdb.cp/var-tag.cc: New file.
	* gdb.cp/var-tag.exp: New file.
	* gdb.dwarf2/dw2-ada-ffffffff.exp: Set the language to C++.
	* gdb.dwarf2/dw2-anon-mptr.exp: Likewise.
	* gdb.dwarf2/dw2-double-set-die-type.exp: Likewise.
	* gdb.dwarf2/dw2-inheritance.exp: Likewise.
2014-04-14 15:47:15 -07:00
Tom Tromey 3d567982ac implement support for "enum class"
This adds support for the C++11 "enum class" feature.  This is
PR c++/15246.

I chose to use the existing TYPE_DECLARED_CLASS rather than introduce
a new type code.  This seemed both simple and clear to me.

I made overloading support for the new enum types strict.  This is how
it works in C++; and it didn't seem like an undue burden to keep this,
particularly because enum constants are printed symbolically by gdb.

Built and regtested on x86-64 Fedora 20.

2014-04-14  Tom Tromey  <tromey@redhat.com>

	PR c++/15246:
	* c-exp.y (type_aggregate_p): New function.
	(qualified_name, classify_inner_name): Use it.
	* c-typeprint.c (c_type_print_base): Handle TYPE_DECLARED_CLASS
	and TYPE_TARGET_TYPE of an enum type.
	* dwarf2read.c (read_enumeration_type): Set TYPE_DECLARED_CLASS on
	an enum type.
	(determine_prefix) <case DW_TAG_enumeration_type>: New case;
	handle TYPE_DECLARED_CLASS.
	* gdbtypes.c (rank_one_type): Handle TYPE_DECLARED_CLASS on enum
	types.
	* gdbtypes.h (TYPE_DECLARED_CLASS): Update comment.
	* valops.c (enum_constant_from_type): New function.
	(value_aggregate_elt): Use it.
	* cp-namespace.c (cp_lookup_nested_symbol): Handle
	TYPE_CODE_ENUM.

2014-04-14  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/classes.exp (test_enums): Handle underlying type.
	* gdb.dwarf2/enum-type.exp: Add test for enum with underlying
	type.
	* gdb.cp/enum-class.exp: New file.
	* gdb.cp/enum-class.cc: New file.
2014-04-14 11:42:18 -06:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Keven Boell 530e8392d7 fortran: enable ptype/whatis for modules.
Added new domain MODULE_DOMAIN for fortran modules to avoid
issues with sharing namespaces (e.g. when a variable currently
in scope has the same name as a module).

	(gdb) ptype modname
	old> No symbol "modname" in current context.
	new> type = module modname

This fixes PR 15209 and also addresses the issue
with sharing namespaces:
https://sourceware.org/ml/gdb-patches/2013-02/msg00643.html

2013-11-19  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* cp-namespace.c (cp_lookup_nested_symbol): Enable
	nested lookups for fortran modules.
	* dwarf2read.c (read_module): Add fortran module to
	the symbol table.
	(add_partial_symbol, add_partial_module): Add fortran
	module to the partial symbol table.
	(new_symbol_full): Create full symbol for fortran module.
	* f-exp.y (yylex): Add new module domain to be parsed.
	* symtab.h: New domain for fortran modules.

testsuite/

	* gdb.fortran/module.exp: Completion matches fortran module
	names as well. ptype/whatis on modules return a proper type.
	Add new check for having the correct scope.
2013-12-19 13:18:21 +01:00
Keith Seitz f7e3ecae9f PR c++/14819: Explicit class:: inside class scope does not work
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
2013-11-25 13:37:08 -08:00
Tom Tromey df6d544176 move gdbarch object from objfile to per-BFD
This moves the "gdbarch" field from the objfile into the BFD.

This field's value is derived from the BFD and is immutable over the
lifetime of the BFD.  This makes it a reasonable candidate for pushing
into the per-BFD object.

This is part of the long-term objfile splitting project.  In the long
run I think this patch will make it simpler to moves types from the
objfile to the per-BFD object; but the patch makes sense as a minor
cleanup by itself.

Built and regtested on x86-64 Fedora 18.

	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Use
	get_objfile_arch.
	* elfread.c (elf_rel_plt_read, elf_gnu_ifunc_record_cache)
	(elf_gnu_ifunc_resolve_by_got): Use get_objfile_arch.
	* jit.c (jit_object_close_impl): Update.
	* jv-lang.c (get_dynamics_objfile): Update.
	* linespec.c (add_minsym): Use get_dynamics_objfile.
	* objfiles.c (get_objfile_bfd_data): Initialize 'gdbarch' field.
	(allocate_objfile): Don't initialize 'gdbarch' field.
	(get_objfile_arch): Update.
	* objfiles.h (struct objfile_per_bfd_storage) <gdbarch>: New field,
	moved from...
	(struct objfile) <gdbarch>: ... here.  Remove.
	* stap-probe.c (stap_can_evaluate_probe_arguments): Use
	get_objfile_arch.
	* symfile.c (init_entry_point_info): Use get_objfile_arch.
2013-08-20 15:04:51 +00:00
Doug Evans 69fc87c263 PR 15519
* cp-namespace.c (find_symbol_in_baseclass): Call
	cp_lookup_symbol_in_namespace instead of cp_lookup_symbol_namespace.
	Check result of call to lookup_symbol_static.
	Call lookup_static_symbol_aux unconditionally.
	Call check_typedef on base types before accessing them.
	(cp_lookup_nested_symbol): Fix comment.

	testsuite/
	* gdb.cp/derivation2.cc: New file.
	* gdb.cp/derivation.cc (main): Call foo2.
	* gdb.cp/derivation.exp: Add tests for typedefs in another
	file, and when there's an active block.
2013-06-05 22:28:51 +00:00
Tom Tromey c27e16e3f1 fix cp-namespace.c
cp_lookup_symbol_imports_or_template could return without
running cleanups.

	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Call
	do_cleanups on all return paths.
2013-05-30 17:29:06 +00:00
Sergio Durigan Junior bb869963da From: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix for PR c++/15203 and PR c++/15210
Date: Sat, 09 Mar 2013 02:50:49 -0300 (5 days, 4 hours, 57 minutes ago)
Message-ID: <m3a9qdnmti.fsf@redhat.com>

Hi,

This bug was reported internally at our Bugzilla, along with a proposed
fix.  After talking to Keith about it, he investigated and came up with
another patch needed to really fix the issue on CVS HEAD.

The first part of the fix is the patch to cp-namespace.c.  It handles
the case when we are accessing a static variable inside a function
(inside a class) by the full linespec (is it right, Keith?).  E.g.:

    class foo
    {
    public:
        int bar()
        {
            static int var = 0;
        }
    };

And then, printing the value of `var':

    (gdb) print 'foo::bar()::var'

GDB would fall in an internal_error:

    gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.

This is because `cp_lookup_nested_symbol' is not handling the case when
TYPE_CODE is either _FUNC or _METHOD.  This patch fixes it by returning
NULL in this case.

The second part of the fix is the patch to elfread.c.  It is needed
because the BSF_GNU_UNIQUE flag was added to some symbols in
<http://sourceware.org/ml/binutils/2009-06/msg00016.html>.  Because of
that, (still) the command:

    (gdb) print 'foo::bar()::var'

where `var' is a static variable returns:

    "No symbol "foo::bar()::var" in current context."

So with the second patch applied the command finally DTRT:

    (gdb) print 'foo::bar()::var'
    $1 = 0

This may not be the ideal solution, according to Keith it would be good
to implement productions on c-exp.y in order to recognize
CLASS::FUNCTION::VARIABLE, but it is a solution which works with what we
have today.

I regtested it in Fedora 17 x86_64 with -m64 and -m32, including
gdbserver, without regressions.

gdb/:
2013-03-14  Keith Seitz  <keiths@redhat.com>
	    Alan Matsuoka  <alanm@redhat.com>

	PR c++/15203
	PR c++/15210
	* cp-namespace.c (cp_lookup_nested_symbol): Handle TYPE_CODE_FUNC and
	TYPE_CODE_METHOD.
	* elfread.c (elf_symtab_read): Handle BSF_GNU_UNIQUE for certain
	symbols.

gdb/testsuite/:
2013-03-14  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR c++/15203
	PR c++/15210
	* gdb.cp/m-static.cc (keepalive_int): New function.
	(gnu_obj_1::method): New variable `sintvar', call `keepalive_int'.
	* gdb.cp/m-static.exp: New test for `sintvar'.
2013-03-14 11:13:36 +00:00
Aleksandar Ristovski 5799c0b969 2013-01-31 Aleksandar Ristovski <aristovski@qnx.com>
* charset.c (intermediate_encoding): Remove unused i.
	* completer.c (signal_completer): Remove unused i.
	* continuations.c (discard_my_continuations_1): Remove unused
	continuation_ptr.
	* corelow.c (core_close): Remove unuseD name.
	(get_core_siginfo): Remove unused pid.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Remove unused
	i, cps.
	* dwarf2loc.c (dwarf2_compile_expr_to_ax): Remove unused base_offset.
	(loclist_describe_location): Remove unused first.
	* event-top.c (command_line_handler): Remove unused got_eof.
	* exec.c (exec_close_1): Remove unused need_symtab_cleanup.
	(resize_section_table): Remove unused old_value.
	* gdb_bfd.c (gdb_bfd_map_section): Remove unused header.
	* gnu-v3-abi.c (compute_vtable_size): Remove unused addr.
	* i386-tdep.c (i386_process_record): Remove unused rex.
	* infcmd.c (get_return_value): Remove unused uiout.
	* jv-lang.c (type_from_class): Remove unused is_array.
	* jv-valprint.c (java_val_print): Remove unused i.
	* linux-nat.c (linux_nat_stop_lwp): Remove unused ptid.
	* linux-thread-db.c (thread_db_find_new_threads_2): Remove unuseD pid.
	* m2-typeprint.c (m2_print_type): Remove unused code.
	* macroexp.c (get_character_constant): Remove unused body_start.
	(macro_stringify): Remove unused result.
	* objc-lang.c (find_methods): Remove unused gdbarch.
	* objfiles.c (filter_overlapping_sections): Remove unused abfd1, abfd2.
	* regcache.c (regcache_cooked_read): Remove unused gdbarch.
	* stack.c (print_frame_args): Remove unused summary.
	* thread.c (thread_apply_command): Remove unused p.
	* valarith.c (value_x_unop): Remove unused mangle_ptr.
	* valops.c (search_struct_method): Remove unused skip.
	* valprint.c (generic_val_print): Remove unused byte_order.
	* varobj.c (varobj_update): Remove unused changed.
	* cli/cli-cmds.c (complete_command): Remove unused next_item.
	(alias_command): Remove unused c.
	* mi/mi-cmd-catch.c (mi_catch_load_unload): Remove unused c.
	* mi/mi-main.c (mi_cmd_data_write_register_values): Remove unused
	format.
	(mi_cmd_data_write_memory): Remove unused word_format.
	(mi_cmd_data_write_memory_bytes): Remove unused r.
	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Remove unused
	p_start, p_end.
	* python/python.c (_initialize_python): Remove unused cmd_name, cmd.
	* tui/tui-disasm.c (tui_set_disassem_content): Remove unused
	line_width.

Reference: http://sourceware.org/ml/gdb-patches/2013-01/msg00766.html
2013-01-31 18:37:39 +00:00
Tom Tromey 195a3f6cae * cp-namespace.c (cp_set_block_scope): Remove.
* cp-support.h (cp_set_block_scope): Remove.
	* dbxread.c: Include block.h.
	(cp_set_block_scope): New function.
	(process_one_symbol): Update.
	* dwarf2read.c (read_func_scope): Use block_set_scope.
2013-01-25 17:55:24 +00:00
Tom Tromey 12aaed36e3 * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
(cp_add_using_directive): Add 'copy_names' argument.
	* cp-support.h (cp_add_using_directive): Update.
	(struct using_direct) <import_src, import_dest, alias,
	declaration>: Now const.
	* dwarf2read.c (read_import_statement): Use obconcat.
	Don't copy names passed to cp_add_using_directive.
2013-01-25 17:36:01 +00:00
Tom Tromey 10f0c4bbfa * symfile.h (obsavestring): Don't declare.
* symfile.c (obsavestring): Remove.
	* ada-exp.y: Use obstack_copy0, not obsavestring.
	* ada-lang.c: Use obstack_copy0, not obsavestring.
	* coffread.c: Use obstack_copy0, not obsavestring.
	* cp-namespace.c: Use obstack_copy0, not obsavestring.
	* dbxread.c: Use obstack_copy0, not obsavestring.
	* dwarf2read.c: Use obstack_copy0, not obsavestring.
	* jit.c: Use obstack_copy0, not obsavestring.
	* mdebugread.c: Use obstack_copy0, not obsavestring.
	* psymtab.c: Use obstack_copy0, not obsavestring.
	* stabsread.c: Use obstack_copy0, not obsavestring.
	* xcoffread.c: Use obstack_copy0, not obsavestring.
2013-01-21 18:13:14 +00:00
Joel Brobecker 28e7fd6234 Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:33:28 +00:00
Keith Seitz 8dea366bbe PR c++/13615
* cp-namespace.c (cp_lookup_symbol_in_namespace): Add SEARCH
	parameter and pass it to lookup_symbol_file.
	(cp_lookup_symbol_imports): Tell cp_lookup_symbol_in_namespace
	to search base classes.
	(cp_lookup_symbol_namespace): Likewise.
	(lookup_namespace_scope): Likewise.
	(lookup_symbol_file): Add SEARCH parameter.
	If SEARCH is non-zero and no symbol is found, lookup the class
	and call cp_lookup_nested_symbol.
	(find_symbol_in_baseclass): New function.
	(cp_lookup_nested_symbol): Do not let
	cp_lookup_symbol_in_namespace search through base classes.
	Do that later when there is no global symbol match.

	PR c++/13615
	* gdb.cp/baseenum.cc: New file.
	* gdb.cp/baseenum.exp: New file.
	* gdb.cp/derivation.cc (A): Add copyright.
	Add a typedef.
	(B): Use A::value_type instead of int.  Change all references.
	(D): Use value_type instead of int.  Change all references.
	(E): Likewise.
	(F); Likewise.
	(Z): New class.
	(ZZ): New class.
 	(N, Base, Derived): New namespace and classes.
	(main): Add instances of Z and ZZ.
	Make sure all symbols from N are kept.
	* gdb.cp/derivation.exp: Update typedef changes in tests.
	Add tests for class typedefs both before and after starting
	the inferior.
	Add tests for searching for a typedef while stopped in a
	method.
2012-11-16 20:54:30 +00:00
Pierre Muller 08850b56ed ARI fixes: Avoid sprintf function use rule.
* charset.c (convert_between_encodings): Use xsnprintf.
	* cli-out.c (cli_field_int): Likewise.
	* cp-namespace.c (cp_lookup_nested_symbol): Likewise.
	* expprint.c (op_name_standard): Likewise.
	* frv-tdep.c (set_variant_num_gprs): Likewise.
	(set_variant_num_fprs): Likewise.
	* m68hc11-tdep.c (m68hc11_initialize_register_info): Likewise.
	* nto-tdep.c (nto_find_and_open_solib): Likewise.
	(nto_init_solib_absolute_prefix): Likewise.
	* source.c (init_source_path): Likewise.
	(print_source_lines_base): Likewise.
	* valprint.c (print_wchar): Likewise.
	* mi/mi-out.c (mi_field_int): Likewise.
	windows-nat.c (windows_pid_to_exec_file): Likewise.
	(windows_create_inferior): Likewise.
	(_initialize_check_for_gdb_ini): Likewise.
2012-11-13 09:46:11 +00:00
Jan Kratochvil 50af5481d5 gdb/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
	* c-exp.y (classify_inner_name): Remove caller assumptions in the
	function comment.  Return ERROR for unresolved cases.  Implement
	returning proper NAME.
	(yylex): Accept also NAME from classify_inner_name.
	* cp-namespace.c (cp_lookup_nested_type): Rename to ...
	(cp_lookup_nested_symbol): ... here.  Return any found symbol, not just
	LOC_TYPEDEF type.
	* cp-support.h (cp_lookup_nested_type): Update its declaration.

gdb/testsuite/
	PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
	* gdb.cp/cpexprs.cc (class CV, CV::i, ATTRIBUTE_USED, CV_f): New.
	(test_function): Call CV_f.
	* gdb.cp/cpexprs.exp (p 'CV::m(int)', p CV::m(int))
	(p 'CV::m(int) const', p CV::m(int) const, p 'CV::m(int) volatile')
	(p CV::m(int) volatile, p 'CV::m(int) const volatile')
	(p CV::m(int) const volatile, p CV_f(int), p CV_f(CV::t))
	(p CV_f(CV::i)): New tests.
2012-06-13 16:10:10 +00:00
Joel Brobecker 0b30217134 Copyright year update in most files of the GDB Project.
gdb/ChangeLog:

        Copyright year update in most files of the GDB Project.
2012-01-04 08:17:56 +00:00
Tom Tromey a1d705ee1b * cp-namespace.c (cp_lookup_symbol_imports): Reindent. 2011-11-04 16:37:17 +00:00
Aleksandar Ristovski a10964d12c * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
arguments by adding OBJFILE.  Instead of getting objfile from
	symbol's symtab, use new argument OBJFILE.
	* cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
	arguments by adding OBJFILE.
	* gdb/dwarf2read.c (new_symbol_full): Change call to
	cp_scan_for_anonymous_namespaces to match new signature.
	* gdb/stabsread.c (define_symbol): Change call to
	cp_scan_for_anonymous_namespaces to match new signature.
2011-10-20 20:06:14 +00:00
Jan Kratochvil 32019081a7 gdb/
Fix non-only rename list for Fortran modules import.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
	cp_add_using_directive caller.
	(cp_add_using_directive): New parameter excludes, describe it.  New
	variables ix and param.  Compare if also excludes match.  Allocate NEW
	with variable size, initialize EXCLUDES there.
	(cp_lookup_symbol_imports): New variable excludep, test
	current->EXCLUDES with it.
	* cp-support.h: Include vec.h.
	(struct using_direct): New field excludes, describe it.
	(DEF_VEC_P (const_char_ptr)): New.
	(cp_add_using_directive): New parameter excludes.
	* defs.h (const_char_ptr): New typedef.
	* dwarf2read.c (read_import_statement): New variables child_die,
	excludes and cleanups, read in excludes.
	(read_namespace): Adjust the cp_add_using_directive caller.

gdb/testsuite/
	Fix non-only rename list for Fortran modules import.
	* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
	tests.
	* gdb.fortran/module.f90 (module moduse): New.
	(program module): use moduse, test var_x, var_y and var_z.
2011-06-29 22:05:16 +00:00
Jan Kratochvil 70c622a3d2 gdb/
Code cleanup.
	* cp-namespace.c (cp_add_using_directive): Turn positive comparison to
	negative comparisons.
2011-06-29 22:02:58 +00:00
Keith Seitz 2b1dbab03d PR symtab/12704
* cp-namespace.c (ANONYMOUS_NAMESPACE_LEN): Remove.
	(cp_scan_for_anonymous_namespaces): Use CP_ANONYMOUS_NAMESPACE_STR
	and CP_ANONYMOUS_NAMESPACE_LEN.
	(cp_is_anonymous): Likewise.
	* cp-support.h (CP_ANONYMOUS_NAMESPACE_STR): Define.
	(CP_ANONYMOUS_NAMESPACE_LEN): Define.
	* dwarf2read.c (namespace_name): Likewise.
	(fixup_partial_die): Likewise.
	* linespec.c (decode_compound): If CP_ANONYMOUS_NAMESPACE_STR is
	seen in the input, keep it.
2011-05-31 21:54:07 +00:00
Jan Kratochvil d8228535f5 gdb/
* c-exp.y (qualified_name): Call destructor_name_p with $1.type.
	(classify_inner_name): Call cp_lookup_nested_type with
	yylval.tsym.type.
	* cp-namespace.c (cp_lookup_nested_type): New variable
	saved_parent_type.  Call CHECK_TYPEDEF for parent_type.  Call
	type_name_no_tag_or_error with saved_parent_type.
	* dwarf2read.c (load_partial_dies): Read in any children of
	DW_TAG_typedef with complaint in such case.
	* gdbtypes.c (type_name_no_tag_or_error): New function.
	* gdbtypes.h (type_name_no_tag_or_error): New prototype.
	* valops.c (destructor_name_p): New comment for parameter type.  Remove
	type const.  Make dname and cp const.  Call type_name_no_tag_or_error.
	* value.h (destructor_name_p): Remove type const.
2011-05-06 14:12:18 +00:00
Tom Tromey 0c2e60193c gdb
* symfile.c (reread_symbols): Update.
	* objfiles.h (struct objfile) <cp_namespace_symtab>: Remove
	field.
	* objfiles.c (allocate_objfile): Update.
	* cp-support.h (cp_check_possible_namespace_symbols): Don't
	declare.
	* cp-namespace.c (lookup_symbol_file): Don't call
	lookup_possible_namespace_symbol.
	(initialize_namespace_symtab, get_possible_namespace_block)
	(free_namespace_block, cp_check_possible_namespace_symbols)
	(check_possible_namespace_symbols_loop)
	(check_one_possible_namespace_symbol)
	(lookup_possible_namespace_symbol): Remove.
	(maintenance_cplus_namespace): Replace with notice.
	(_initialize_cp_namespace): Deprecate `maint cplus namespace'.
gdb/testsuite
	* gdb.cp/maint.exp (test_help): Update.
	(test_namespace): Likewise.
2011-04-04 14:37:17 +00:00