Don't access elf tdata in dwarf.c without first checking for an ELF bfd

_bfd_dwarf2_find_nearest_line may be called on a COFF bfd.

	* dwarf2.c (read_address): Check bfd_target_elf_flavour before
	calling get_elf_backend_data.
	(_bfd_dwarf2_find_nearest_line): Fix parens.
Don't return DW_AT_name for function name in C++

DW_AT_name for functions typically just contains the base function
name, so lacks namespace, class and parameter information.  It would
be possible to extract all these from the DWARF, but at a considerable
complication of the parser in dwarf2.c, and then you'd need to mangle
it all together.  Much simpler is to look up the actual symbol.  This
patch does that, avoiding the extra symbol lookup when the language
doesn't do name mangling.

	PR 17541
	* dwarf2.c (struct comp_unit): Add "lang".
	(non_mangled): New function.
	(struct funcinfo): Add "is_linkage".  Reorder for better packing.
	Make "name" a const char*.
	(lookup_address_in_function_table): Delete functionname_ptr param.
	(find_abstract_instance_name): Add is_linkage param.  Set if we
	have DW_AT_linkage_name or non_mangled DW_AT_name.
	(scan_unit_for_symbols): Similarly set func->is_linkage.
	(parse_comp_unit): Stash DW_AT_language.
	(comp_unit_find_nearest_line): Replace functionname_ptr param
	with function_ptr param.
	(_bfd_dwarf2_find_nearest_line): Adjust above calls.  Set
	functionname_ptr from function->name.  Call _bfd_elf_find_function
	to retrieve symbol for function if not linkage name.
	(_bfd_elf_find_function): Add bfd_target_elf_flavour test, moved from..
	* elf.c (elf_find_function): ..here.
	(_bfd_elf_find_nearest_line): Adjust calls.
	* elf-bfd.h (_bfd_elf_find_function): Declare.
Don't always build coffgen.o

Removes a bunch of unused functions from libbfd when building ELF or
AOUT.  Split off the bits we need externally when not building a COFF
target into coff-bfd.c and coff-bfd.h.

bfd/
	* Makefile.am (BFD32_LIBS, BFD32_LIBS_CFILES): Remove dwarf2
	and coffgen.  Add coff-bfd.  Sort.
	(BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add coffgen and dwarf2.
	* bfd-in.h (bfd_coff_get_syment, bfd_coff_get_auxent): Delete.
	(struct coff_comdat_info, bfd_coff_get_comdat_section): Delete.
	* coffgen.c (coff_symbol_from): Move to coff-bfd.h as macro,
	without unused param.  Update uses.
	(bfd_coff_get_comdat_section): Move to coff-bfd.h as macro.
	(bfd_coff_get_syment, bfd_coff_get_auxent): Move to coff-bfd.c.
	* libcoff-in.h: #include "coff-bfd.h".
	(struct coff_section_tdata, coff_section_data): Move to coff-bfd.h.
	(coff_symbol_from): Delete.
	* coff-bfd.c: New file.
	* coff-bfd.h: New file.
	* coff-i386.c: Update coff_symbol_from occurrences.
	* coff-i960.c: Likewise.
	* coff-m68k.c: Likewise.
	* coff-sh.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coffcode.h: Likewise.
	* pe-mips.c: Likewise.
	* configure.ac (elf): Add dwarf2.lo.
	(coffgen, coff, ecoff, xcoff): Define.  Use when mapping bfd
	target vectors to .o files.  Add dwarf2 for mach-o targets.
	Fix the sh target FIXME.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* bfd-in2.h: Regenerate.
	* libcoff.h: Regenerate.
binutils/
	* objdump.c: #include "coff-bfd.h".
ld/
	* ldmisc.c: #include "coff-bfd.h"
Restore terminal state in mi_thread_exit (PR gdb/17627)

When a thread exits, the terminal is left in mode "terminal_is_ours"
while the target executes.  This patch fixes that.

We need to manually restore the terminal setting in this particular
observer.  In the case of the other MI observers that call
target_terminal_ours, gdb will end up resuming the inferior later in the
execution and call target_terminal_inferior.  In the case of the thread
exit event, we still need to call target_terminal_ours to be able to
print something, but there is nothing that gdb will need to resume after
that. We therefore need to call target_terminal_inferior ourselves.

gdb/ChangeLog:

	PR gdb/17627
	* target.c (cleanup_restore_target_terminal): New function.
	(make_cleanup_restore_target_terminal): New function.
	* target.h (make_cleanup_restore_target_terminal): New
	declaration.
	* mi/mi-interp.c (mi_thread_exit): Use the new cleanup.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
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.
cp-namespace.c (lookup_symbol_file): Move next to only caller.

gdb/ChangeLog:

	* cp-namespace.c (lookup_symbol_file): Move next to only caller.
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.
Introduce target_is_gdbserver

This patch introduces a function in gdbserver-support.exp to find out
whether the current target is GDBserver.

The code was inspired from gdb.trace/qtro.exp, so it replaces the code
there by a call to the new function.

gdb/testsuite/ChangeLog:

	* gdb.trace/qtro.exp: Replace gdbserver detection code by...
	* lib/gdb.exp (target_is_gdbserver): New
	procedure.
Only leave dprintf inserted if it is marked as persistent (PR breakpoints/17012)

On Linux native, if dprintfs are inserted when detaching, they are left
in the inferior which causes it to crash from a SIGTRAP. It also happens
with dprintfs on remote targets, when set disconnected-dprintf is off.

The rationale of the line modified by the patch was to leave dprintfs
inserted in order to support disconnected dprintfs. However, not all
dprintfs are persistent. Also, there's no reason other kinds of
breakpoints can't be persistent either. So this replaces the bp_dprintf
check with a check on whether the location is persistent.

bl->target_info.persist will be 1 only if disconnected-dprintf is on and
we are debugging a remote target. On native, it will always be 0,
regardless of the value of disconnected-dprintf. This makes sense, since
disconnected dprintfs are not supported by the native target.

One issue about the test is that it does not pass when using
--target_board=native-extended-gdbserver, partly due to bug 17302 [1].

One quick hack I tried for this was to add a useless "next" between the
call to getpid() and detach, which avoids the bug. There is still one
case where the test fails, and that is with:

- breakpoint always-inserted on
- dprintf-style agent
- disconnected-dprintf on

What happens is that my detach does not actually detach the process,
because some persistent commands (the disconnected dprintf) is present.
However since gdbserver is ran with --once, when gdb disconnects,
gdbserver goes down and takes with it all the processes it spawned and
that are still under its control (which includes my test process).
When the test checks if the test process is still alive, it obvisouly
fails. Investigating about that led me to ask a question on the ML [2]
about the behavior of detach.

Until the remote case is sorted out, the problematic test is marked as
KFAIL.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=17302
[2] https://sourceware.org/ml/gdb/2014-08/msg00115.html

gdb/Changelog:

	PR breakpoints/17012
	* breakpoint.c (remove_breakpoints_pid): Skip removing
	breakpoint if it is marked as persistent.

gdb/testsuite/ChangeLog:

	PR breakpoints/17012
	* gdb.base/dprintf-detach.c: New file.
	* gdb.base/dprintf-detach.exp: New file.
Give informative error message for stub-group-size

This patch gives current stub-group-size in error message when stub
is too far away.

	* aarch64.cc (Target_aarch64): Add new variable: stub_group_size_.
	(AArch64_relocate_functions::maybe_apply_stub): Add new parameter.
	Update error message.
	(Target_aarch64::do_relax): Use absolute value of option
	stub_group_size. Replace local variable with class member
	stub_group_size_.
Automatic date update in version.in