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.
guile: Fix typos in the manual.

gdb/
2014-02-17  Ludovic Courtès  <ludo@gnu.org>

	* doc/guile.texi (Writing a Guile Pretty-Printer) <example>:
	Remove 'string-begins-with' procedure.  Add 'pretty-printer'
	parameter to 'str-lookup-function' procedure.  Look for
	the "std::string<" prefix.
	(Frames In Guile): Add 'frame' parameter to 'frame-read-var'.
	Adjust description.
Move entry from ChangeLog to doc/ChangeLog.

	* doc/guile.texi (Writing a Guile Pretty-Printer) <example>:
	[...]
Remove doc/ in recent entries.
Split python docs into separate file.

	* Makefile.in (GDB_DOC_FILES): Add python.texi.
	* gdb.texinfo (Python): Moved to ...
	* python.texi: ... here.  New file.
Add g10 support to rl78-tdep.c.

The g10 is an rl78 variant which has fewer registers.  Aside from the
obvious addition of a new register_name() function which omits
registers which the g10 lacks, this change also updates the
return_value() function with the conventions specified by the ABI for
finding and setting return values.

	* rl78-tdep.c (rl78_g10_register_name): New function.
	(rl78_return_value): Add g10 support.
	(rl78_gdbarch_init): Register rl78_g10_register_name for the
	g10.
sim: ppc: drop $(LIBS) from psim dependency

When cross-compiling GDB for PPC, there's a prerequisite "-lz" for psim
that results in a build failure. With such prerequisite, GNU Make will
try to search the library from build machine's /usr/lib which is wrong.
On 64-bit Linux build machines the compilation will fail because of this.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=12202
daily update
sim: delete duplicate SIGINT handling

Many of the simulators change the SIGINT handler.
E.g., moxie/interp.c:

  sigsave = signal (SIGINT, interrupt);

However, this is unnecessary.
remote-sim.h already provides an API for asynchronously stopping
a sim; and both gdb and the drivers (run.c and nrun.c at least,
I didn't check the others) install a SIGINT handler which
calls this method.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=16450
Reported-by: Tom Tromey <tromey@redhat.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
	Revise signal mapping function in GDB interface for RX sim.

	sim/rx/gdb-if.c had a function named `rx_signal_to_host'.  This
	function mapped signal numbers used by the BSP to host signal
	numbers which, at one time a while back, were used by GDB
	as target signal numbers.  This change updates the signal
	numbers returned to be those names prefixed with "GDB_SIGNAL_"
	as defined in include/gdb/signals.h.

	It also changes the name of the function somewhat to better
	match what the function currently does.  I noticed that this
	function is not static - and there's no reason for it not
	to be - so I made it static too.

	* gdb-if.c (rx_signal_to_host):  Rename to
	`rx_signal_to_gdb_signal'.  Make static.  Update all callers
	to use new name.  Use signal names from include/gdb/signals.h.
Initial libasm.la as.c links of this convience lib also
  - Preprocess as.h with -D_GAS so its useable as api
  - libasm gitignore (no ignore file in binutils)
  - bfd.h error on include without config.h remove
  - fix as.h so it can be used outside of gas tree