make_corefile_notes: have caller free returned memory

The various make_corefile_notes implementations for gdbarch as well as target
currently make an xfree cleanup on the data they return.  This causes problems
when trying to put a TRY_CATCH around the make_corefile_notes call.
Specifically, we get a stale cleanup error in restore_my_cleanups.

Omit the make_cleanup and have the caller free the memory.

gdb/
	* fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call.
	* gcore.c (write_gcore_file): Free memory returned from
	make_corefile_notes.
	* linux-tdep.c (linux_make_corefile_notes): Remove make_cleanup call.
	* procfs.c (procfs_make_note_section): Remove make_cleanup call.
gcore, target: allow target to prepare/cleanup for/after core file generation

Add new target functions to_prepare_to_generate_core and
to_done_generating_core that are called before and after generating a core
file, respectively.

This allows targets to prepare for core file generation and to clean up
afterwards.

gdb/
	* target.h (target_ops) <to_prepare_to_generate_core>
	<to_done_generating_core>: New.
	(target_prepare_to_generate_core, target_done_generating_core): New.
	* target.c (target_prepare_to_generate_core)
	(target_done_generating_core): New.
	* target-delegates.c: Regenerate.
	* gcore.c: (write_gcore_file): Rename to ...
	(write_gcore_file_1): ...this.
	(write_gcore_file): Call target_prepare_to_generate_core
	and target_done_generating_core.
btrace: pretend we're not replaying when generating a core file

When generating a core file using the "generate-core-file" command while
replaying with the btrace record target, we won't be able to access all
registers and all memory.  This leads to the following assertion:

    gdb/regcache.c:1034: internal-error: regcache_raw_supply: Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n) FAIL: gdb.btrace/gcore.exp: generate-core-file core (GDB internal error)
    Resyncing due to internal error.

Pretend that we are not replaying while generating a core file.  This will
forward fetch and store registers as well as xfer memory calls to the target
beneath.

gdb/
	* record-btrace.c (record_btrace_generating_corefile)
	(record_btrace_prepare_to_generate_core)
	(record_btrace_done_generating_core): New.
	(record_btrace_xfer_partial, record_btrace_fetch_registers)
	(record_btrace_store_registers, record_btrace_prepare_to_store):
	Forward request when generating a core file.
	(record_btrace_open): Set record_btrace_generating_corefile to zero.
	(init_record_btrace_ops): Set to_prepare_to_generate_core and
	to_done_generating_core.

testsuite/
	* gdb.btrace/gcore.exp: New.
ld/arm: adjust offsets in tls-gdierelax2.d

Addition of DF_STATIC_TLS in eea6dad2 results in the addition of
flags to the dynamic section, which in turn changes these addresses.
Fix them up to match their new positions.

ld/testsuite/Changelog:

2014-06-24  Kyle McMartin  <kyle@redhat.com>

	* ld-arm/tls-gdierelax2.d: Fix expected offsets.
Fixes to allow a toolchain configured with --enable-all to build on a 32-bit host.

	* Makefile.am (ALL_EMULATION_SOURCES): Move ei386pep.c from
	here...
	(ALL_64_EMULATION_SOURCES): ... to here.
	(ALL_EMUL_EXTRA_OFILES): Move pep-dll.o from here...
	(ALL_64_EMUL_EXTRA_OFILES): New.  ... to here.
	* configure.in (EMUL_EXTRA_OFILES): Include
	ALL_64_EMUL_EXTRA_OFILES when making a 64-bit enabled build.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
daily update
[Patch, microblaze]: Add wdc.ext.clear and wdc.ext.flush insns

Added two new instructions, wdc.ext.clear and wdc.ext.flush,
to enable MicroBlaze to flush an external cache, which is
used with the new coherency support for multiprocessing.

Signed-off-by:nagaraju <nmekala@xilix.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[Patch, microblaze]: Add mlittle-endian and mbig-endian flags

Added support in gas for mlittle-endian and mbig-endian flags
as options.

Updated show usage for MicroBlaze specific assembler options
to include new entries.

Signed-off-by:nagaraju <nmekala@xilix.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[Patch, microblaze]: Initial port of microblaze core reading support

Added support for reading notes in linux core dumps
Support for reading of PRSTATUS and PSINFO information for rebuilding
".reg" sections of core dumps at run time.

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
[Patch, microblaze]: Communicate in larger blocks with the target

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
[Patch, microblaze]: Add mb singlestepping.

Fix prologue analysis for little-endian.
Always provide a frame base.

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
[Patch, microblaze]: Add initial port of linux gdbserver

add gdb_proc_service_h to gdbserver microblaze-linux

gdbserver needs to initialise the microblaze registers

other archs use this step to run a *_arch_setup() to carry out all
architecture specific setup - may need to add in future

 * add linux-ptrace.o to gdbserver configure
 * gdb/configure.tgt: Set build_gdbserver=yes
 * Update breakpoint opcode
 * fix segfault on connecting gdbserver
 * add microblaze_linux_memory_remove_breakpoint
 * add set_solib_svr4_fetch_link_map_offsets
 * add set_gdbarch_fetch_tls_load_module_address
 * Force reading of r0 as 0, prevent stores

Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
[Patch, microblaze]: Add slr and shr regs and little-endian breakpoint

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[Patch, microblaze]: Added Backtrace support to GDB

Added backtrace support without debugging information.

Earlier backtrace used to work only when debug information is available.
Previous pc & sp values are calculated incorrectly due to which backtrace
was failing.

In this patch, previous frame sp & pc values are calculated correctly
in microblaze_frame_cache function and supplied them to
microblaze_frame_prev_register function

Signed-off-by:nagaraju <nmekala@xilix.com>
[Patch, microblaze]: Initial support for native gdb

microblaze: Follow PPC method of getting setting registers
using PTRACE PEEK/POKE

Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
[Patch, gdb]: Robustify inline function support

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
[Patch, gdb]: Fix debug message when register is unavailable

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[LOCAL]: Disable the warning message for eh_frame_hdr

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
[LOCAL]: Fix relaxation of assembler resolved references
[LOCAL]: Fixup debug_loc sections after linker relaxation

Adds a new reloctype R_MICROBLAZE_32_NONE, used for passing
reloc info from the assembler to the linker when the linker
manages to fully resolve a local symbol reference.

This is a workaround for design flaws in the assembler to
linker interface with regards to linker relaxation.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>