Fix offsets to access fpregset_t in sparc64-linux targets.

The %fsr register is not being properly accessed from gdb in
sparc64.  This is because sparc64_supply_fpregset and
sparc64_collect_fpregset are using the offsets from the
sparc32_bsd_fpregset constant instead of sparc64_bsd_fpregset.
This patch fixes this by registering the proper offsets for
sparc64-linux targets.

2014-02-14  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Register
	the proper offsets to access fpregset_t.
* target.c (target_write_partial): Fix result type.
daily update
daily update
Hurd: Adapt to changed MIG output.

	gdb/
	* reply_mig_hack.awk: Don't expect to see the auto keyword.

Based on a patch by David Michael <fedora.dm0@gmail.com>.
Hurd: Make MIG output parsing more robust.

	gdb/
	* reply_mig_hack.awk: In phase 5, keep going if we have not yet
	collected the type check structures.

Based on a patch by David Michael <fedora.dm0@gmail.com>.
Hurd: New RPC reply stub functions.

	gdb/
	* gnu-nat.c (ill_rpc): Remove function; replaced with this...
	(ILL_RPC): ... new macro.
	(do_mach_notify_no_senders, do_mach_notify_port_deleted)
	(do_mach_notify_msg_accepted, do_mach_notify_port_destroyed)
	(do_mach_notify_send_once, S_proc_setmsgport_reply)
	(S_proc_getmsgport_reply, S_msg_sig_post_reply): Generate stub
	functions with ILL_RPC macro.
	(S_proc_pid2task_reply, S_proc_task2pid_reply)
	(S_proc_task2proc_reply, S_proc_proc2task_reply)
	(S_proc_pid2proc_reply, S_proc_getprocinfo_reply)
	(S_proc_getprocargs_reply, S_proc_getprocenv_reply)
	(S_proc_getloginid_reply, S_proc_getloginpids_reply)
	(S_proc_getlogin_reply, S_proc_getsid_reply)
	(S_proc_getsessionpgids_reply, S_proc_getsessionpids_reply)
	(S_proc_getsidport_reply, S_proc_getpgrp_reply)
	(S_proc_getpgrppids_reply, S_proc_get_tty_reply)
	(S_proc_getnports_reply, S_proc_is_important_reply)
	(S_proc_get_code_reply): New stub functions, generated with
	ILL_RPC macro.

Based on a patch by David Michael <fedora.dm0@gmail.com>.
Hurd: Adjust to startup-with-shell changes.

In commit 98882a26513e25b2161b41dfd4bed97b59b2c01a, STARTUP_WITH_SHELL was made
a runtime toggle, startup-with-shell.  The Hurd code was missed to be adjusted;
it had a value hard-coded instead of using START_INFERIOR_TRAPS_EXPECTED.  Fix
that, and also simplify gnu-nat's pending_execs handling from counting to just
a flag.

	gdb/
	* gnu-nat.c (struct inf): Change pending_execs member to a 1-bit
	flag.  Adjust all users; in particular...
	(gnu_wait): ..., don't decrement its value in here...
	(gnu_create_inferior): ..., and instead set the flag in here,
	around the startup_inferior call, and call that one with
	START_INFERIOR_TRAPS_EXPECTED.
ld: Remove Hurd-specific XFAILs related to weak symbols.

This has been fixed properly, in glibc.

	ld/testsuite/
	* ld-elfweak/elfweak.exp (setup_xfail_gnu_hurd): Remove function
	and all usage of it.
Missing ChangeLog entry from commit 60ef20e28534cf093d5bd799b3830c68381bb27f.
Fix "ERROR: no fileid for" in the testsuite.

If GDB has crashed then gdb_spawn_id still exists (although it does not work).
So my patch does not change anything.  And also currently it will leave the
stale gdbserver running anyway.

In general if gdb_spawn_id does not exist then send_gdb + gdb_expect just do
not make sense anyway.  So this patch just prevents the error in such case.

The killing of stale gdbserver could be improved multiple ways (also as
suggested by Pedro in the original thread) but that is IMO outside of the
scope of this patch.  Apparently if there is no good response from GDB then
gdb_finish() should try to call gdb_start just to kill that gdbserver, IIUC.

gdb/testsuite/
2014-02-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix "ERROR: no fileid for" in the testsuite.
	* lib/gdb.exp (gdb_finish): Check gdb_spawn_id.

Message-ID: <20140206205814.GA18495@host2.jankratochvil.net>
daily update
Fix -Wformat warnings in gnu-nat.c

I've seen some -Wformat warnings when build native gdb for hurd.

../../../git/gdb/gnu-nat.c:2384:8: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'vm_address_t' [-Werror=format]
../../../git/gdb/gnu-nat.c:2394:8: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'vm_address_t' [-Werror=format]
../../../git/gdb/gnu-nat.c: In function 'steal_exc_port':
../../../git/gdb/gnu-nat.c:2898:5: error: format '%d' expects argument of type 'int', but argument 2 has type 'mach_port_t' [-Werror=format]

in usr/include/mach/port.h, we have:

typedef vm_offset_t mach_port_t;

and in usr/include/mach/machine/vm_types.h, we have:

typedef       unsigned long   vm_offset_t;

so this patch changes '%d' to '%lu' in format string for mach_port_t
variables.

Similarly, in usr/include/mach/std_types.h, we have,

typedef      vm_offset_t     vm_address_t;

this patch also changes '%x' to '%lx' in gnu_write_inferior.

gdb:

2014-02-17  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (proc_get_exception_port): Use 'lu' insetad of 'd'
	in format string.
	(proc_steal_exc_port, make_proc, inf_set_pid): Likewise.
	(inf_validate_procs, inf_signal): Likewise.
	(S_exception_raise_request): Likewise.
	(do_mach_notify_dead_name): Likewise.
	(steal_exc_port): Likewise.
	(gnu_read_inferior): Change 'copy_count''s type to
	mach_msg_type_number_t.
	(gnu_write_inferior): Likewise.  Use 'lx' instead of 'x' in
	format string.
Fix -Werror=pointer-sign warnings

../../../git/gdb/gnu-nat.c: In function 'gnu_read_inferior':
../../../git/gdb/gnu-nat.c:2282:3: error: pointer targets in passing argument 5 of 'vm_read' differ in signedness [-Werror=pointer-sign]
In file included from /home/yao/Software/hurd-toolchain/bin/../i686-pc-gnu/libc/usr/include/mach.h:38:0,
                 from ./nm.h:23,
                 from ../../../git/gdb/defs.h:500,
                 from ../../../git/gdb/gnu-nat.c:23:
/home/yao/Software/hurd-toolchain/bin/../i686-pc-gnu/libc/usr/include/mach/mach_interface.h:843:15: note: expected 'mach_msg_type_number_t *' but argument is of type 'int *'
../../../git/gdb/gnu-nat.c: In function 'gnu_write_inferior':
../../../git/gdb/gnu-nat.c:2339:4: error: pointer targets in passing argument 5 of 'vm_read' differ in signedness [-Werror=pointer-sign]
In file included from /home/yao/Software/hurd-toolchain/bin/../i686-pc-gnu/libc/usr/include/mach.h:38:0,
                 from ./nm.h:23,
                 from ../../../git/gdb/defs.h:500,
                 from ../../../git/gdb/gnu-nat.c:23:
/home/yao/Software/hurd-toolchain/bin/../i686-pc-gnu/libc/usr/include/mach/mach_interface.h:843:15: note: expected 'mach_msg_type_number_t *' but argument is of type 'int *'

This patch fixes these warnings.

gdb:

2014-02-17  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (gnu_read_inferior): Change 'copy_count' type to
	mach_msg_type_number_t.
	(gnu_write_inferior): Likewise.
Fix missing-prototypes warnings in gnu-nat.c

A recent change (commit 3398af6aa352b0611bc9d66aed72080a876e42d4)
in gnu-nat.c causes the some missing-prototypes warnings,

../../../git/gdb/gnu-nat.c:1864:1: error: no previous prototype for 'S_proc_pid2task_reply' [-Werror=missing-prototypes]
../../../git/gdb/gnu-nat.c:1866:1: error: no previous prototype for 'S_proc_task2pid_reply' [-Werror=missing-prototypes]
../../../git/gdb/gnu-nat.c:1868:1: error: no previous prototype for 'S_proc_task2proc_reply' [-Werror=missing-prototypes]

A new macro ILL_RPC was added recently, which defines some external
functions.  However, they are not declared and GCC complains about this.

This patch is to add the declarations of these external function in
macro ILL_RPC.

gdb:

2014-02-17  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (ILL_RPC): Declare defined function.
Resort scm-gsmob.c entry in Makefile.in

	* Makefile.in (SUBDIR_GUILE_OBS): Resort alphabetically.
	(SUBDIR_GUILE_SRCS): Ditto.
	(scm-gsmob.o): Ditto.
Fix date in previous entry.
ppc476 workaround for ld -r fixes

This fixes the glaring error that the ppc476 workaround wasn't
actually enabled for ld -r, and adjusts relocations to match moved
code.

bfd/
	* elf32-ppc.c (ppc_elf_relocate_section): Move relocs on insns
	patched for ppc476 workaround.  Reapply branch taken/not taken
	relocs.
ld/
	* emultempl/ppc32elf.em (ppc_after_open_output): Really enable
	ppc476 workaround for ld -r.
Consolidate ppc64 ld/bfd communication

Moves assorted variables used to communicate between ld and bfd into
a struct, hooks it into the bfd link_hash_table early, and removes
all other places where such variables were passed piecemeal.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params): Define.
	(ppc64_elf_init_stub_bfd, ppc64_elf_edit_opd, ppc64_elf_tls_setup,
	ppc64_elf_setup_section_lists, ppc64_elf_size_stubs,
	ppc64_elf_build_stubs): Update prototype.
	* elf64-ppp.c (struct ppc_link_hash_table): Add params, delete other
	fields now in params.  Adjust code throughout file.
	(ppc64_elf_init_stub_bfd): Delete "abfd" parameter, add "params".
	Save params pointer in htab.
	(ppc64_elf_edit_opd, ppc64_elf_tls_setup,
	ppc64_elf_setup_section_lists, ppc64_elf_size_stubs,
	ppc64_elf_build_stubs): Remove parameters now in "params".
ld/
	* emultemps/ppc64elf.em (params): New static struct replacing
	various other static vars.  Adjust code throughout file.
PR binutils/16595

abfd->section_count unexpectedly changes between 218 and 248 in:

150 bfd_simple_get_relocated_section_contents (bfd *abfd,
[...]
218   saved_offsets = malloc (sizeof (struct saved_output_info)
219                           * abfd->section_count);
[...]
230	  _bfd_generic_link_add_symbols (abfd, &link_info);
[...]
248   bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets);

_bfd_generic_link_add_symbols increases section_count

and simple_restore_output_info later reads unallocated part of saved_offsets.

READ of size 8 at 0x601c0000c5c0 thread T0
    #0 0x1124770 in simple_restore_output_info (.../gdb/gdb+0x1124770)
    #1 0x10ecd51 in bfd_map_over_sections (.../gdb/gdb+0x10ecd51)
    #2 0x1125150 in bfd_simple_get_relocated_section_contents (.../gdb/gdb+0x1125150)

bfd/
2014-02-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR binutils/16595
	* simple.c (struct saved_offsets): New.
	(simple_save_output_info): Use it for ptr.
	(simple_restore_output_info): Use it for ptr.  Check section_count.
	(bfd_simple_get_relocated_section_contents): Use it for saved_offsets.