Move ChangeLog entry to proper place.

gdb/
2014-06-09  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (linux_child_follow_fork): Initialize status with
	W_STOPCODE (0) instead of 0.  Remove shodowing 'status' local from
	inner block.  Only pass the signal to PTRACE_DETACH if in pass
	state.
don't use directory in test name

I noticed that a few tests in completion.exp put the directory name
into the name of the resulting test.  While the directory name is
relative, this still makes for spurious differences depending on
whether the test was run in serial or parallel mode.

This patch fixes the problem.  I'm checking it in.

2014-06-12  Tom Tromey  <tromey@redhat.com>

	* gdb.base/completion.exp: Don't use directory name in test.
link gdbserver against libiberty

This builds a libiberty just for gdbserver and arranges for gdbserver
to use it.  I've tripped across the lack of libiberty in gdbserver at
least once, and I have seen other threads where it would have been
useful.

2014-06-12  Tom Tromey  <tromey@redhat.com>

	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
	(parse_debug_format_options): Likewise.
	(gdbserver_usage): Likewise.
	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
	against libiberty.
	($(LIBGNU)): Depend on libiberty.
	(all-lib): Recurse into all subdirs.
	(install-only): Invoke "install" target in subdirs.
	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
	targets.
	* configure: Rebuild.
	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
	for vasprintf, vsnprintf, or gettimeofday.
	* configure.srv: Don't add safe-ctype.o or lbasename.o to
	srv_tgtobj.
delete gdbserver's freeargv

gdbserver defines freeargv, but it is now trivial to just use the one
in libiberty.

2014-06-12  Tom Tromey  <tromey@redhat.com>

	* utils.c (freeargv): Remove.
daily update
Add missing ld makefile dependency for nios.

	* Makefile.am (ALL_EMULATION_SOURCES): Add enios2elf.c, enios2linux.c.
	* Makefile.in: Regenerate.
Make bfd.link_next field a union

This field of struct bfd is currently only used to chain together
linker input files.  This patch prepares to use the field to stash
the linker hash table, which is always created on the linker output
file.

bfd/
	* bfd.c (struct bfd): Replace link_next with a union.
	* aoutx.h, * bfd.c, * coff-ppc.c, * coff-rs6000.c, * cofflink.c,
	* ecoff.c, * elf-m10300.c, * elf32-arm.c, * elf32-avr.c,
	* elf32-hppa.c, * elf32-i386.c, * elf32-lm32.c, * elf32-m32c.c,
	* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-metag.c,
	* elf32-microblaze.c, * elf32-nds32.c, * elf32-nios2.c,
	* elf32-or1k.c, * elf32-ppc.c, * elf32-rl78.c, * elf32-s390.c,
	* elf32-score.c, * elf32-score7.c, * elf32-sh.c, * elf32-spu.c,
	* elf32-tic6x.c, * elf32-tilepro.c, * elf32-xstormy16.c,
	* elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c,
	* elf64-mmix.c, * elf64-ppc.c, * elf64-s390.c, * elf64-x86-64.c,
	* elflink.c, * elfnn-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * linker.c, * pdp11.c, * peXXigen.c, * simple.c,
	* sunos.c, * vms-alpha.c, * xcofflink.c: Update for above.
	* bfd-in2.h: Regenerate.
include/
	* bfdlink.h: Update for bfd.link_next change.
ld/
	* emultempl/cr16elf.em, * emultempl/elf32.em, * emultempl/genelf.em,
	* emultempl/m68kcoff.em, * emultempl/m68kelf.em,
	* emultempl/nds32elf.em, * emultempl/pe.em, * emultempl/pep.em,
	* ldlang.c, * ldmain.c, * pe-dll.c: Update for bfd.link_next change.
Move link_hash_table_free functions earlier

Move some code around, in preparation for a followup patch.

	* elf-m10300.c, * elf32-arm.c, * elf32-avr.c, * elf32-hppa.c,
	* elf32-i386.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-metag.c,
	* elf32-nios2.c, * elf64-ia64-vms.c, * elf64-ppc.c, * elf64-x86-64.c,
	* elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-sparc.c, * xcofflink.c:
	Move link_hash_table_free functions before their corresponding
	link_hash_table_create functions.
Don't call bfd_link_hash_table_free

Freeing the linker hash table is a royal pain.  It can't be freed
before the _bfd_write_contents call in bfd_close, because some target
bfd_write_contents functions access the hash table.  It can't be freed
after bfd_close either, since bfd_alloc memory holding side data
structures disappears (PR17047).  Clearly the only place it can be freed
is actually in bfd_close.  This patch doesn't do that, but kills off
the existing means of freeing the hash table via a bfd target xvec call.

bfd/
	PR 17047
	* targets.c (BFD_JUMP_TABLE): Delete NAME##_bfd_link_hash_table_free.
	(struct bfd_target <_bfd_link_hash_table_free>): Delete.
	* bfd.c (bfd_link_hash_table_free): Don't define.
	* aout-adobe.c, * aout-target.h, * aout-tic30.c, * binary.c, * bout.c,
	* coff64-rs6000.c, * coffcode.h, * elf-m10300.c, * elf32-arm.c,
	* elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc11.c,
	* elf32-m68hc12.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c,
	* elf32-sparc.c, * elf32-xgate.c, * elf64-ia64-vms.c, * elf64-ppc.c,
	* elf64-sparc.c, * elf64-x86-64.c, * elfnn-aarch64.c, * elfnn-ia64.c,
	* elfxx-target.h, * i386msdos.c, * i386os9k.c, * ieee.c, * ihex.c,
	* libbfd-in.h, * libecoff.h, * mach-o-target.c, * mmo.c,
	* nlm-target.h, * oasys.c, * pef.c, * plugin.c, * ppcboot.c, * som.c,
	* srec.c, * tekhex.c, * verilog.c, * versados.c, * vms-alpha.c,
	* xsym.c: Don't define various link_hash_table_free defines, and
	remove from bfd_target vars.  Temporarily reference some of the
	target link_hash_table_free functions to avoid warnings.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
ld/
	PR 17047
	* ldlang.c (output_bfd_hash_table_free_fn): Delete.
	(open_output): Don't set it..
	* ldmain.c (ld_cleanup): ..or call it.
Free linker hash table from bfd_close.

Also tidies numerous error exit paths in various link_hash_table_create
functions that failed to free memory.

include/
	* bfdlink.h (struct bfd_link_hash_table): Add hash_table_free field.
bfd/
	* archive.c: Include bfdlink.h.
	(_bfd_archive_close_and_cleanup): Call linker hash_table_free.
	* bfd.c (struct bfd): Add is_linker_output field.
	* elf-bfd.h (_bfd_elf_link_hash_table_free): Update prototype.
	* linker.c (_bfd_link_hash_table_init): Set up hash_table_free,
	link.hash and is_linker_output.
	(_bfd_generic_link_hash_table_free): Replace bfd_link_hash_table*
	param with bfd*.  Assert is_linker_output and link.hash, and
	clear them before exit.
	* elf-m10300.c (elf32_mn10300_link_hash_table_free): Replace
	bfd_link_hash_table* param with bfd*.  Hack is_linker_output
	and link.hash so we can free two linker hash tables.
	(elf32_mn10300_link_hash_table_create): Create static_hash_table
	first.  Clean up on errors.  Set hash_table_free pointer.
	* elf32-arm.c (elf32_arm_link_hash_table_free): Replace
	bfd_link_hash_table* param with bfd*.
	(elf32_arm_link_hash_table_create): Clean up on errors.  Set
	hash_table_free pointer.
	* elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc1x.c,
	* elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c, * elf32-xgate.c,
	* elf64-ia64-vms.c, * elf64-ppc.c, * elf64-x86-64.c, * elflink.c,
	* elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-sparc.c,
	* xcofflink.c: Similarly.
	* simple.c (bfd_simple_get_relocated_section_contents): Save and
	clear link.next before creating linker hash table.  Clean up on
	errors, and restore link.next on exit.
	* elf32-m68hc1x.h (m68hc11_elf_bfd_link_hash_table_free): Delete.
	* elf32-xgate.h (xgate_elf_bfd_link_hash_table_free): Delete.
	* elfxx-sparc.h (_bfd_sparc_elf_link_hash_table_free): Delete.
	* libcoff-in.h (_bfd_xcoff_bfd_link_hash_table_free): Delete.
	* hash.c (bfd_hash_table_init_n): Free table on error.
	* libbfd-in.h (_bfd_generic_link_hash_table_free): Update proto.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
Invalidate a register in cache when a remote target failed to write it.

As shown by the bug report, GDB crashes when the remote target was unable to
write to a register (the program counter) with the 'P' packet. This was reported
for AVR but can be reproduced on any architecture with a gdbserver that fails to
handle a 'P' packet.

Issue
=====

This GDB session was done with a custom gdbserver patched to send an error
packet when trying to set the program counter with a 'P' packet:

~~~
(gdb) file Debug/ATMega2560-simple-program.elf
Reading symbols from Debug/ATMega2560-simple-program.elf...done.
(gdb) target remote :51000
Remote debugging using :51000
0x00000000 in __vectors ()
(gdb) load
Loading section .text, size 0x1fc lma 0x0
Start address 0x0, load size 508
Transfer rate: 248 KB/sec, 169 bytes/write.
(gdb) b main
Breakpoint 1 at 0x164: file .././ATMega2560-simple-program.c, line 39.
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
main () at .././ATMega2560-simple-program.c:42
42		DDRD |= LED0_MASK;// | LED1_MASK;
(gdb) info line 43
Line 43 of ".././ATMega2560-simple-program.c" is at address 0x178 <main+40> but contains no code.
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178	0x178 <main+40>
(gdb) s
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n)
~~~

We can see that even though GDB reports that writing to the register failed, the
register cache was updated:

~~~
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178	0x178 <main+40>
~~~

The root of the problem is of course in the gdbserver but I thought GDB should
keep a register cache consistent with the hardware even in case of a failure.

Changes
=======

This patch adds routines to add a regcache_invalidate cleanup to the current
chain.

We can then register one before calling target_store_registers. This way if the
target throws an error, the register we wanted to write to will be invalidated
in cache. If target_store_registers succeeds, we can discard the new cleanup.

2014-06-12  Pierre Langlois  <pierre.langlois@embecosm.com>

	* regcache.c (struct register_to_invalidate): New structure.
	(do_register_invalidate, make_cleanup_regcache_invalidate): New
	functions.
	(regcache_raw_write): Call make_cleanup_regcache_invalidate.
A simple replacement of sprintf (xxx, "%s", xxx) with strcpy.

	* config/tc-score7.c: Replace sprintf with strcpy where
	appropriate.
Fix seg-faults when fetching the frags of local symbols.

	* config/tc-score7.c: (s7_b32_relax_to_b16): Use symbol_get_frag() to access a symbol's frag.
	* config/tc-score.c (s3_relax_branch_inst16): Likewise.
	(s3_relax_cmpbranch_inst32): Likewise.
make calls to help_list use enumerator

Currently there are many calls to help_list that pass the constant -1
as the "class" value.  However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.

This patch fixes the error everywhere it occurs in the gdb sources.

Tested by rebuilding.

2014-06-13  Tom Tromey  <tromey@redhat.com>

	* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
	to help_list.
	* guile/guile.c (info_guile_command): Pass all_commands, not -1,
	to help_list.
	* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
	help_list.
	* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
	help_list.Pass all_commands, not -1, to help_list.
	* cli/cli-dump.c (dump_command, append_command)
	(srec_dump_command, ihex_dump_command, tekhex_dump_command)
	(binary_dump_command, binary_append_command): Pass all_commands,
	not -1, to help_list.
	* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
	-1, to help_list.
	* valprint.c (set_print, set_print_raw): Pass all_commands, not
	-1, to help_list.
	* typeprint.c (set_print_type): Pass all_commands, not -1, to
	help_list.
	* top.c (set_history): Pass all_commands, not -1, to help_list.
	* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
	all_commands, not -1, to help_list.
	* symfile.c (overlay_command): Pass all_commands, not -1, to
	help_list.
	* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
	help_list.
	* serial.c (serial_set_cmd): Pass all_commands, not -1, to
	help_list.
	* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
	-1, to help_list.
	* remote.c (remote_command, set_remote_cmd): Pass all_commands,
	not -1, to help_list.
	* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
	not -1, to help_list.
	* maint.c (maintenance_command, maintenance_info_command)
	(maintenance_print_command, maintenance_set_cmd): Pass
	all_commands, not -1, to help_list.
	* macrocmd.c (macro_command): Pass all_commands, not -1, to
	help_list.
	* language.c (set_check): Pass all_commands, not -1, to help_list.
	* infcmd.c (unset_command): Pass all_commands, not -1, to
	help_list.
	* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
	help_list.
	* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
	help_list.
	* dcache.c (set_dcache_command): Pass all_commands, not -1, to
	help_list.
	* breakpoint.c (save_command): Pass all_commands, not -1, to
	help_list.
	* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
	all_commands, not -1, to help_list.
Add support for reading Aarch64 core dumps.

	* elfxx-aarch64.c (stdarg.h): Include.
	(string.h): Include.
	(_bfd_aarch64_elf_grok_prstatus): Updated.
	(_bfd_aarch64_elf_grok_psinfo): New function.
	(_bfd_aarch64_elf_write_core_note): New function.
	* elfxx-aarch64.h (elf_backend_grok_psinfo): Define.
	(elf_backend_write_core_note): Define.
daily update
Include --with-guile in 'show configuration's output.

	* top.c (print_gdb_configuration) [HAVE_GUILE]: Print --with-guile
	or --without-guile, according to how GDB was built.
daily update
daily update
Fix uninitialised CRIS insn

gas/
	* config/tc-cris.c (md_create_long_jump): Follow "short" jump
	with a nop rather than leaving uninitialised.
gas/testsuite/
	* gas/cris/rd-bkw4v32.d: Update.