-Wpointer-sign: gdb_byte -> char.

This is sort of the opposite of a previous patch.  Places that
manipulate strings or interfaces that return strings are changed to
use char* instead of gdb_byte*.

gdb/
2013-04-12  Pedro Alves  <palves@redhat.com>

	* avr-tdep.c (avr_io_reg_read_command): New local 'bufstr'.  Use
	it to get a string view of the byte buffer.
	* i386-cygwin-tdep.c (core_process_module_section): Change local 'buf'
	type to gdb_byte *.  Adjust.
	* linux-tdep.c (linux_info_proc, linux_find_memory_regions_full):
	Change local to char *.
	* solib-darwin.c (find_program_interpreter): Change return type to
	char *.  Adjust.
	(darwin_solib_get_all_image_info_addr_at_init): Adjust.
	* solib-dsbt.c (enable_break2): Change local 'buf' to char *.
	* solib-frv.c (enable_break2): Change local 'buf' to char *.
	* solib-spu.c (spu_current_sos): Add gdb_byte * cast.
	* solib-svr4.c (find_program_interpreter): Change return type to
	char *.  Adjust.
	(enable_break): Change local 'interp_name' to char *.
	* spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'.
	* spu-tdep.c (spu_pseudo_register_read_spu): Add cast to 'char *'.
	(spu_pseudo_register_write_spu): Use char for string buffer.
	Adjust.
	(info_spu_event_command, info_spu_signal_command): Add casts to
	'char *'.
cris-tdep.c: Use unsigned variable for unsigned command.

"set cris-version" is an unsigned command:

    /* CRIS-specific user-commands.  */
    add_setshow_uinteger_cmd ("cris-version", class_support,
  			    &usr_cmd_cris_version,
  			    _("Set the current CRIS version."),
  			    _("Show the current CRIS version."),
  			    _("\
  Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
  Defaults to 10. "),

Tested by building on x86_64 Fedora 17.
alpha-tdep.c/mips-tdep.c: "set heuristic-fence-post" is signed/zinteger.

These commands are currently var_zinteger, hence their control
variable is signed.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* alpha-tdep.c (heuristic_fence_post): Change type to int.
	(alpha_heuristic_proc_start): Adjust to check -1 instead of
	UINT_MAX.
	* mips-tdep.c (heuristic_fence_post): Change type to int.
	(heuristic_proc_start): Adjust to check -1 instead of UINT_MAX.
mep-tdep.c: Wrong signness for instruction buffer.

There seems to be no reason for this to be signed.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* mep-tdep.c (mep_get_insn): Change 'insn' parameter type to
	unsigned long *.
mips-tdep.c: Wrong signness for local holding PC register.

Addresses on MIPS are signed, and we're indeed using
regcache_cooked_read_signed to read the PC, but, we're passing it the
address of an unsigned variable, which triggers a -Wpointer-sign
warning.  I've chosen to change the variable's type.  I believe this
will end up being the same (though I can't test it).

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* mips-tdep.c (mips_read_pc): Change local 'pc' type to LONGEST.
ppc-linux-tdep.c: Wrong signness for buffer holding instructions.

There seems to be no reason for this buffer to be signed.  We pass it
around to functions expecting it to be unsigned (which triggers
-Wpointer-sign warnings).

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* ppc-linux-tdep.c (ppc_skip_trampoline_code): Change local
	'insnbuf' buffer type to unsigned int[].
-Wpointer-sign: s390-tdep.c.

-Wpointer-sign reveals a bunch of:

../../src/gdb/s390-tdep.c:1342:7: error: pointer targets in passing argument 4 of ‘is_rx’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:1038:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/s390-tdep.c:1343:9: error: pointer targets in passing argument 5 of ‘is_rxy’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:1055:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/s390-tdep.c:1344:9: error: pointer targets in passing argument 5 of ‘is_rxy’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:1055:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
...
../../src/gdb/s390-tdep.c:1363:7: error: pointer targets in passing argument 5 of ‘is_rs’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:966:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/s390-tdep.c:1364:9: error: pointer targets in passing argument 6 of ‘is_rsy’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:983:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/s390-tdep.c:1365:9: error: pointer targets in passing argument 6 of ‘is_rsy’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/s390-tdep.c:983:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
...

I don't know much about s390, but from reading the code I believe the
right fix is to treat d2 as signed.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* s390-tdep.c (is_rs, is_rsy, is_rx, is_rxy): Change type of 'd2'
	parameter to int *.
-Wpointer-sign: aarch64-tdep.c.

../../src/gdb/aarch64-tdep.c: In function ‘aarch64_analyze_prologue’:
../../src/gdb/aarch64-tdep.c:713:7: error: pointer targets in passing argument 3 of ‘decode_cb’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/aarch64-tdep.c:386:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/aarch64-tdep.c:747:7: error: pointer targets in passing argument 3 of ‘decode_stur’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/aarch64-tdep.c:597:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’


'is64' is just used as a boolean; signed/unsigned doesn't really matter.

2013-04-11  Pedro Alves  <palves@redhat.com>

	* aarch64-tdep.c (aarch64_analyze_prologue): Change type of local
	'is64' to signed 'int'.
-Wpointer-sign: xtensa-tdep.c.

../../src/gdb/xtensa-tdep.c:2914:4: error: pointer targets in passing argument 7 of ‘xtensa_operand_get_field’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:487:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/xtensa-tdep.c:2916:4: error: pointer targets in passing argument 4 of ‘xtensa_operand_decode’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:507:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/xtensa-tdep.c:2918:4: error: pointer targets in passing argument 7 of ‘xtensa_operand_get_field’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:487:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/xtensa-tdep.c:2920:4: error: pointer targets in passing argument 4 of ‘xtensa_operand_decode’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:507:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/xtensa-tdep.c:2922:4: error: pointer targets in passing argument 7 of ‘xtensa_operand_get_field’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:487:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’
../../src/gdb/xtensa-tdep.c:2924:4: error: pointer targets in passing argument 4 of ‘xtensa_operand_decode’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/xtensa-tdep.c:53:0:
../../src/gdb/../include/xtensa-isa.h:507:1: note: expected ‘unsigned int *’ but argument is of type ‘int *’

Those bfd functions that decode instructions output uint32_t values.
Hence this fix:

2013-04-11  Pedro Alves  <palves@redhat.com>

	* xtensa-tdep.c (execute_l32e, execute_s32e): Change type of
	parameters 'at', 'as' and 'offset' to uint32_t.

'func' is either execute_l32e or execute_s32e.  AFAICT from the xtensa
assembly I found, l32e/s32e work with a a signed offset.  This
preserves that, as the 'offset' variable is still implicitly cast to
signed int in the 'func' call.
-Wpointer-sign: alpha-tdep.c.

../../src/gdb/alpha-tdep.c: In function ‘alpha_extract_return_value’:
../../src/gdb/alpha-tdep.c:520:4: error: pointer targets in passing argument 3 of ‘regcache_cooked_read_signed’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/alpha-tdep.c:36:0:

We use regcache_cooked_read_unsigned everywhere else too.

2013-04-11  Pedro Alves  <palves@redhat.com>

	* alpha-tdep.c (alpha_extract_return_value): Use
	regcache_cooked_read_unsigned to read 'v0'.
Cast result of obstack_base to gdb_byte * in a couple spots.

obstack_base returns char *.  Need to cast to gdb_byte * in a couple spots.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* c-lang.c (evaluate_subexp_c): Cast result of obstack_base to
	gdb_byte *.
	* linux-tdep.c (linux_make_mappings_corefile_notes): Likewise.
serial_write: change prototype to take a void-pointer buffer.

While remote.c works with "char *" buffers most of the time, other
remote targets have binary-ish-er protocols, and choose to use
"unsigned char" throughout, like e.g., remote-mips.c or
remote-m32r-sdi.c.  That results in -Wpointer-sign warnings in those
targets, unless we add casts in calls to serial_write.  Since
serial_write is only concerned about sending raw host bytes out, and
serial_ops->write_prim already works with "void *"/"size_t", a similar
interface to the "write" or "send" system calls, I find it natural to
change serial_write's prototype accordingly, avoiding the need for
casts.

Tested on x86_64 Fedora 17, and also by building a x86_64-mingw32
-hosted gdb.  I don't have a set up for testing DJGPP/go32.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* ser-base.c (ser_base_write): Change prototype -- take 'void *'
	buffer and size_t size.  Adjust.
	* ser-base.h (ser_base_write): Adjust.
	* ser-go32.c (dos_write): Change prototype -- take 'void *'
	buffer and size_t size.  Adjust.
	* serial.c (serial_write): Likewise.
	* serial.h (serial_write): Adjust.
	(struct serial_ops) <write>: Change prototype -- take 'void *'
	buffer and size_t size.  Adjust.
gdb_byte for binary buffer, char for string: remote.c, tracepoint.c.

While the RSP is largely ASCII based (hence the packet buffer type is
char *), at places we pass around 8-bit binary packets in that buffer.
Functions like hex2bin or remote_escape_output conceptually are
handling binary buffers, so I left them as working with gdb_byte, and
added casts where necessary.  Whether these are host bytes or target
bytes is blurry at present, so this is largely a matter of taste.
Switching some of these functions to take "char *" or "void *" would
be equally good.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_write_bytes_aux, compare_sections_command)
	(remote_read_qxfer)
	(remote_search_memory, remote_hostio_pwrite, remote_hostio_pread)
	(remote_hostio_readlink, remote_bfd_iovec_pread)
	(remote_set_trace_notes): Use gdb_byte when RSP buffer is used as
	binary buffer, and char when buffer is used as string.
	* tracepoint.c (encode_source_string, tfile_write_uploaded_tp)
	(trace_save, tfile_open, traceframe_walk_blocks)
	(tfile_fetch_registers): Likewise.
gdb_byte for binary buffer, char for string: common/agent.c.

Similarly to the remote code, agent commands are mostly ascii.  Cast to
gdb_byte when treating the command buffer as raw memory bytes.

2013-04-11  Pedro Alves  <palves@redhat.com>

	* common/agent.c (agent_run_command): Add cast to gdb_byte *.
-Wpointer-sign: remote-mips.c.

remote-mips.c has a bunch of -Wpointer-sign warnings:

../../src/gdb/remote-mips.c: In function ‘mips_receive_packet’:
../../src/gdb/remote-mips.c:1128:7: error: pointer targets in passing argument 2 of ‘mips_cksum’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:830:1: note: expected ‘const unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c:1135:7: error: pointer targets in passing argument 2 of ‘mips_cksum’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:830:1: note: expected ‘const unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c: In function ‘mips_load_srec’:
../../src/gdb/remote-mips.c:2830:12: error: pointer targets in passing argument 4 of ‘mips_make_srec’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:134:12: note: expected ‘unsigned char *’ but argument is of type ‘char *’
../../src/gdb/remote-mips.c: In function ‘pmon_zeroset’:
../../src/gdb/remote-mips.c:3030:3: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c: In function ‘pmon_make_fastrec’:
../../src/gdb/remote-mips.c:3124:6: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3126:4: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3148:3: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3153:3: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3154:8: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c: In function ‘pmon_load_fast’:
../../src/gdb/remote-mips.c:3423:2: error: pointer targets in passing argument 4 of ‘pmon_makeb64’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:2977:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3457:4: error: pointer targets in passing argument 3 of ‘pmon_checkset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3051:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3484:8: error: pointer targets in passing argument 3 of ‘pmon_zeroset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3025:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’
../../src/gdb/remote-mips.c:3489:3: error: pointer targets in passing argument 3 of ‘pmon_checkset’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/remote-mips.c:3051:1: note: expected ‘int *’ but argument is of type ‘unsigned int *’

The mips packet payload is ASCII, so it makes sense for
mips_send_packet and mips_receive_packet to expose 'char *'-based
interfaces, as currently they do.  But, mips packets have a binary
header, so if you look at e.g., mips_receive_packet's implementation,
you'll see "unsigned char" buffers in use.  I find it the most natural
to make the payload pointer passed to mips_cksum 'char *' too.

The other changes are straightforward adjustments -- a checksum is
naturally unsigned, and there's one point where we're reading a bfd section.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* remote-mips.c (mips_cksum): Rename 'data' parameter to 'datastr'
	and change its type to 'const char *'.  Adjust.
	(mips_send_packet): Add cast to 'char *', and remove cast to
	'unsigned char *'.
	(mips_receive_packet): Remove cast to 'unsigned char *'.
	(mips_load_srec): Use bfd_byte.
	(pmon_makeb64, pmon_zeroset): Make 'chksum' parameter unsigned.
	(pmon_checkset): Make 'value' parameter unsigned.
-Wpointer-sign: python/.

This fixes -Wpointer-sign warnings in the python/ code in the manner
that seems most appropriate to me.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* python/py-inferior.c (infpy_write_memory): Add cast to gdb_byte
	* python/py-prettyprint.c (print_string_repr): Change type of
	'output' local to char *.  Add cast to gdb_byte * in
	LA_PRINT_STRING call.
	(print_children): Change type of 'output' local to char *.
	* python/py-value.c (valpy_string): Add cast to const char * in
	PyUnicode_Decode call.
-Wpointer-sign: bookmarks.

Bookmarks are opaque to the core code -- by design, the target is free
to use any sort of blob as bookmark identifier.

The record target chooses to use strings for bookmarks.  This adds
casts following that direction, fixing -Wpointer-sign warnings.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* record-full.c (record_full_get_bookmark): Change local 'ret'
	type to char * and add cast to gdb_byte *.
	(record_full_goto_bookmark): Handle 'bookmark' argument as a
	string.
	* reverse.c (goto_bookmark_command): Add casts to gdb_byte *.
-Wpointer-sign: coff-pe-read.c: treat strings in PE/COFF data as char *.

A couple places take a pointer to the middle of some raw section
buffer and treat them as strings.  Add casts to char * as appropriate,
fixing -Wpointer-sign warnings.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* coff-pe-read.c (read_pe_exported_syms): Handle strings as char.
-Wpointer-sign: xcoffread.c.

../../src/gdb/xcoffread.c: In function ‘xcoff_initial_scan’:
../../src/gdb/xcoffread.c:2982:17: error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]

'debugsec' is a 'bfd_byte *', holding the result of a
bfd_get_full_section_contents.  'info->debugsec' holds the same
contents throughout the whole xcoff read, and everywhere it's used to
read symbol names.  Simply adding a cast feels appropriate.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* xcoffread.c (xcoff_initial_scan): Add cast to 'char *'.
-Wpointer-sign: dwarf2read.c.

This fixes the remaining issues necessary to make the DWARF reader
-Wpointer-sign clean.  The 'filename' bit should be obvious.
'constant_pool' holds the contents of an obstack, which are 'char *'.
gdb_byte would work too, but it'd need more casts elsewhere, so I just
chose the minimal approach.  Any way would be fine with me.

gdb/
2013-04-11  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (dwarf2_get_dwz_file): Add cast to const char *.
	(read_index_from_section): Add cast to 'char *'.