fix PR c++/16117

This patch fixes PR c++/16117.

gdb has an extension so that users can use expressions like FILE::NAME
to choose a variable of the given name from the given file.  The bug
is that this extension takes precedence over ordinary C++ expressions
of the same form.  You might think this is merely hypothetical, but
now that C++ headers commonly do not use an extension, it is more
common.

This patch fixes the bug by making two related changes.  First, it
changes gdb to prefer the ordinary C++ meaning of a symbol over the
extended meaning.  Second, it arranges for single-quoting of the
symbol to indicate a preference for the extension.

Built and regtested on x86-64 Fedora 18.
New test case included.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	PR c++/16117:
	* c-exp.y (lex_one_token): Add "is_quoted_name" argument.
	(classify_name): Likewise.  Prefer a field of "this" over a
	filename.
	(classify_inner_name, yylex): Update.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Variables): Note gdb rules for ambiguous cases.
	Add example.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/includefile: New file.
	* gdb.cp/filename.exp: New file.
	* gdb.cp/filename.cc: New file.
Start inferior before running test listing Ada exceptions.

This patch fixes some spurious failures when the inferior is linked
against the shared version of libgnat by default, as appears to be
the case on many GNU/Linux distributions.  When that happens, we have
to start the program in order to ensure that the GNAT runtime is
mapped to memory, in order for us to find the standard exceptions
(defined within the runtime).  Otherwise, they will not be shown,
as expected, by the debugger.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc.exp: Start inferior before starting
        the "info exceptions" tests.
        * gdb.ada/mi_exc_info.exp: Start inferior before starting
        the "-info-ada-exceptions" tests.
Fix GDB crash with upstream GCC due to memcpy(NULL, ...)

Similar to qsort(), the glibc version of memcpy() also declares its
arguments with __attribute__(__nonnull__(...)).  If NULL is passed
anyway, upstream GCC's new pass '-fisolate-erroneous-paths' typically
causes a trap in such cases.  I've encountered this with GDB in
chain_candidate() when trying to execute the break.exp test case.

gdb/
2013-11-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* dwarf2loc.c (chain_candidate): Prevent invoking memcpy with
	NULL.
gdb.ada/info_exc.exp,mi_exc_info.exp: handle runtimes with full debug info.

If the runtime has full debug info, then the non-standard exceptions
declared in the GNAT runtime will appear in the list of exceptions
printed by GDB ("info exceptions" or "-info-ada-exceptions").
This is valid output, so this patch allows for it.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc.exp: Allow other global exceptions to be
        listed in the output of "info exceptions".
        * gdb.ada/mi_exc_info.exp: Allow other global exceptions to be
        listed in the output of "-info-ada-exceptions".
* cp-demangle.c (d_copy_templates): Cast result of malloc to (struct d_print_template *). (d_print_comp): Cast result of realloc to (struct d_saved scope *).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204713 138bc75d-0d04-0410-961f-82ee72b054a4
Make room for PLT0 directly

	* elf32-i386.c (elf_i386_allocate_dynrelocs): Make room for
	PLT0 directly.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.
gdb/NEWS: Fix typo

gdb/
2013-11-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* NEWS (Changes in GDB 7.5) (New commands) (explore): Fix typo.
	* lib/mi-support.exp (mi_gdb_test): Expect different formats
	of inferior output for remote and native sessions.
	* gdb.mi/mi-console.exp: Remove obsolete comment.
	Check for semihosted inferior output pattern.
	(semihosted_string): New function.
MIPS/opcodes: Add MFCR and MTCR data dependencies

	* mips-opc.c (mips_builtin_opcodes): Add RD_2 to "mfcr" and
	"mtcr".
daily update
gas/

	* config/tc-aarch64.c (set_other_error): New function.
	(parse_sys_reg): Add new parameter 'sys_reg' and if non-NULL set
	the variable to which it points with 'o'.
	(parse_operands): Update; check for write to read-only system
	registers or read from write-only ones.

gas/testsuite/

	* gas/aarch64/diagnostic.s: Add tests.
	* gas/aarch64/diagnostic.l: Update.
	* gas/aarch64/tracereg-illegal.d: New file.
	* gas/aarch64/tracereg-illegal.l: Ditto.
	* gas/aarch64/tracereg-illegal.s: Ditto.
	* gas/aarch64/tracereg.d: Ditto.
	* gas/aarch64/tracereg.s: Ditto.

include/opcode

	* aarch64.h (aarch64_sys_reg_readonly_p): New declaration.
	(aarch64_sys_reg_writeonly_p): Ditto.

opcodes/

	* aarch64-opc.c (CPENT): New define.
	(F_READONLY, F_WRITEONLY): Likewise.
	(aarch64_sys_regs): Add trace unit registers.
	(aarch64_sys_reg_readonly_p): New function.
	(aarch64_sys_reg_writeonly_p): Ditto.
gdb.ada/info_exc.exp,mi_exc_info.exp: Use more unique exception name.

In the case where the GNAT runtime was built with full debugging info,
several of the exceptions defined there might have a name contain
the word "global". To make this less likely, this patch renames
the exception name, replacing "Global" by "Global_GDB". It still
keeps the exeption name relatively short, while it is unlikely that
the GNAT runtime has an exception whose name explicitly mentions GDB,
and even less likely that it contains "Global_GDB".

gdb/testsuite/ChangeLog:

        * info_exc/const.ads (Aint_Global_GDB_E): Renames Aint_Global_E.
        * info_exc/foo.adb: Adjust to new exception name.
        * info_exc.exp: Adjust after exception renaming in const.ads.
        Update "info exception global" test to test "info exceptions
        global_gdb" instead.

        * mi_exc_info/const.ads (Aint_Global_GDB_E): Renames Aint_Global_E.
        * mi_exc_info/foo.adb (Adjust to new exception name.
        * mi_exc_info.exp: Adjust after exception renaming in const.ads.
        Update "-info-ada-exceptions global" test to test
        "-info-ada-exceptions global_gdb" instead.
daily update
Rename "read_reg" into "read_addr_from_reg" in struct dwarf_expr_context_funcs

This is to help make it slightly clearer how this method is expected
to extract data from the given register.

gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs)
        <read_addr_from_reg>: Renames "read_reg".
        * dwarf2-frame.c (read_addr_from_reg): Renames "read_reg".
        Adjust comment.
        (dwarf2_frame_ctx_funcs, execute_stack_op, dwarf2_frame_cache):
        Use read_addr_from_reg in place of read_reg.
        * dwarf2expr.c (execute_stack_op): Use read_addr_from_reg
        in place of read_reg.
        * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Renames
        dwarf_expr_read_reg.
        (dwarf_expr_ctx_funcs): Replace dwarf_expr_read_reg
        with dwarf_expr_read_addr_from_reg.
        (needs_frame_read_addr_from_reg): Renames needs_frame_read_reg.
        (needs_frame_ctx_funcs): Replace needs_frame_read_reg with
        needs_frame_read_addr_from_reg.
Add R_X86_64_PC32_BND and R_X86_64_PLT32_BND

bfd/

	* elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_PC32_BND
	and R_X86_64_PLT32_BND.
	(R_X86_64_standard): Replace R_X86_64_RELATIVE64 with
	R_X86_64_PLT32_BND.
	(IS_X86_64_PCREL_TYPE): Add R_X86_64_PLT32_BND.
	(x86_64_reloc_map): Add BFD_RELOC_X86_64_PC32_BND and
	BFD_RELOC_X86_64_PLT32_BND.
	(elf_x86_64_check_relocs): Handle R_X86_64_PC32_BND and
	R_X86_64_PLT32_BND.
	(elf_x86_64_gc_sweep_hook): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	* reloc.c (bfd_reloc_code_real): Add BFD_RELOC_X86_64_PC32_BND
	and BFD_RELOC_X86_64_PLT32_BND.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

gas/

	* config/tc-i386.c (reloc): Add an argument, bnd_prefix, to
	indicate if instruction has the BND prefix.  Return
	BFD_RELOC_X86_64_PC32_BND instead of BFD_RELOC_32_PCREL if
	bnd_prefix isn't zero.
	(output_branch): Pass BFD_RELOC_X86_64_PC32_BND to frag_var
	if needed.
	(output_jump): Update reloc call.
	(output_interseg_jump): Likewise.
	(output_disp): Likewise.
	(output_imm): Likewise.
	(x86_cons_fix_new): Likewise.
	(lex_got): Add an argument, bnd_prefix, to indicate if
	instruction has the BND prefix.  Use BFD_RELOC_X86_64_PLT32_BND
	if needed.
	(x86_cons): Update lex_got call.
	(i386_immediate): Likewise.
	(i386_displacement): Likewise.
	(md_apply_fix): Handle BFD_RELOC_X86_64_PC32_BND and
	BFD_RELOC_X86_64_PLT32_BND.
	(tc_gen_reloc): Likewise.
	* config/tc-i386-intel.c (i386_operator): Update lex_got call.

gas/testsuite/

	* gas/i386/i386.exp: Run x86-64-mpx-branch-1 and
	x86-64-mpx-branch-2 on 64-bit ELF targets.
	* gas/i386/x86-64-mpx-branch-1.d: New file.
	* gas/i386/x86-64-mpx-branch-1.s: Likewise.
	* gas/i386/x86-64-mpx-branch-2.d: Likewise.
	* gas/i386/x86-64-mpx-branch-2.s: Likewise.

include/elf/

	* x86-64.h: Add R_X86_64_PC32_BND and R_X86_64_PLT32_BND.

ld/testsuite/

	* ld-x86-64/mpx.exp: New file.
	* ld-x86-64/mpx1.out: Likewise.
	* ld-x86-64/mpx1a.c: Likewise.
	* ld-x86-64/mpx1a.rd: Likewise.
	* ld-x86-64/mpx1b.c: Likewise.
	* ld-x86-64/mpx1c.c: Likewise.
	* ld-x86-64/mpx1c.rd: Likewise.
daily update
Add "language-option" to -list-features

Following the addition of the --language optiton to all GDB/MI
commands,  I realized that there was no easy way for front-ends
to figure out whether this features is available or not. So I added
a "language-option" entry to -list-features.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): Add "language-options"
        to -list-features output.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new
        "language-option" entry in the output of the "-list-features"
        command.
Revert "Add support for AArch64 trace unit registers."

This reverts commit 75468c93c14e9f14dd9020712538c5303a455876.
gas/

	* config/tc-aarch64.c (parse_sys_reg): Support
	S2_<op1>_<Cn>_<Cm>_<op2>.

gas/testsuite/

	* gas/testsuite/sysreg.s: Add test.
	* gas/testsuite/sysreg.d: Update.
mi-language.exp: Check "langauge-option" in -list-features output.

gdb/testsuite/ChangeLog:

        * mi-language.exp: Add "-list-features" test verifying that
        its output contains "language-option".