* [PATCH 02/26] -Wpointer-sign: gdb_byte -> char.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
@ 2013-04-11 23:00 ` Pedro Alves
2013-04-12 12:34 ` Yao Qi
2013-04-11 23:00 ` [PATCH 01/26] -Wpointer-sign: char -> gdb_byte Pedro Alves
` (27 subsequent siblings)
28 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:00 UTC (permalink / raw)
To: gdb-patches
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-11 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 buffers
to gdb_byte *.
* 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 *.
Adjust.
* solib-frv.c (enable_break2): Change local 'buf' to char *.
Adjust.
* 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 *'.
---
gdb/avr-tdep.c | 8 +++++---
gdb/i386-cygwin-tdep.c | 6 +++---
gdb/linux-tdep.c | 4 ++--
gdb/solib-darwin.c | 6 +++---
gdb/solib-dsbt.c | 4 ++--
gdb/solib-frv.c | 4 ++--
gdb/solib-spu.c | 2 +-
gdb/solib-svr4.c | 6 +++---
gdb/spu-multiarch.c | 2 +-
gdb/spu-tdep.c | 16 +++++++++-------
10 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index b14bf83..0bc08a8 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1468,8 +1468,9 @@ avr_io_reg_read_command (char *args, int from_tty)
{
LONGEST bufsiz = 0;
gdb_byte *buf;
+ const char *bufstr;
char query[400];
- char *p;
+ const char *p;
unsigned int nreg = 0;
unsigned int val;
int i, j, k, step;
@@ -1477,6 +1478,7 @@ avr_io_reg_read_command (char *args, int from_tty)
/* Find out how many io registers the target has. */
bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR,
"avr.io_reg", &buf);
+ bufstr = (const char *) buf;
if (bufsiz <= 0)
{
@@ -1486,7 +1488,7 @@ avr_io_reg_read_command (char *args, int from_tty)
return;
}
- if (sscanf (buf, "%x", &nreg) != 1)
+ if (sscanf (bufstr, "%x", &nreg) != 1)
{
fprintf_unfiltered (gdb_stderr,
_("Error fetching number of io registers\n"));
@@ -1514,7 +1516,7 @@ avr_io_reg_read_command (char *args, int from_tty)
bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR,
query, &buf);
- p = buf;
+ p = (const char *) buf;
for (k = i; k < (i + j); k++)
{
if (sscanf (p, "%[^,],%x;", query, &val) == 2)
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index cee2adf..26ffbaa 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -125,11 +125,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
struct cpms_data *data = obj;
enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
- char *module_name;
+ gdb_byte *module_name;
size_t module_name_size;
CORE_ADDR base_addr;
- char *buf = NULL;
+ gdb_byte *buf = NULL;
if (strncmp (sect->name, ".module", 7) != 0)
return;
@@ -160,7 +160,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
/* The first module is the .exe itself. */
if (data->module_count != 0)
- windows_xfer_shared_library (module_name, base_addr,
+ windows_xfer_shared_library ((char *) module_name, base_addr,
data->gdbarch, data->obstack);
data->module_count++;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 9def108..9623d19 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -261,7 +261,7 @@ linux_info_proc (struct gdbarch *gdbarch, char *args,
int status_f = (what == IP_STATUS || what == IP_ALL);
int stat_f = (what == IP_STAT || what == IP_ALL);
char filename[100];
- gdb_byte *data;
+ char *data;
int target_errno;
if (args && isdigit (args[0]))
@@ -676,7 +676,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
void *obfd)
{
char mapsfilename[100];
- gdb_byte *data;
+ char *data;
/* We need to know the real target PID to access /proc. */
if (current_inferior ()->fake_pid_p)
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 8c2307e..c4c6308 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -210,10 +210,10 @@ lookup_symbol_from_bfd (bfd *abfd, char *symname)
/* Return program interpreter string. */
-static gdb_byte *
+static char *
find_program_interpreter (void)
{
- gdb_byte *buf = NULL;
+ char *buf = NULL;
/* If we have an exec_bfd, get the interpreter from the load commands. */
if (exec_bfd)
@@ -420,7 +420,7 @@ gdb_bfd_mach_o_fat_extract (bfd *abfd, bfd_format format,
static void
darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
{
- gdb_byte *interp_name;
+ char *interp_name;
CORE_ADDR load_addr = 0;
bfd *dyld_bfd = NULL;
struct cleanup *cleanup;
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index e2822c1..86ce062 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -840,7 +840,7 @@ enable_break2 (void)
if (interp_sect)
{
unsigned int interp_sect_size;
- gdb_byte *buf;
+ char *buf;
bfd *tmp_bfd = NULL;
CORE_ADDR addr;
gdb_byte addr_buf[TIC6X_PTR_SIZE];
@@ -852,7 +852,7 @@ enable_break2 (void)
interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
buf = alloca (interp_sect_size);
bfd_get_section_contents (exec_bfd, interp_sect,
- buf, 0, interp_sect_size);
+ (bfd_byte *) buf, 0, interp_sect_size);
/* Now we need to figure out where the dynamic linker was
loaded so that we can load its symbols and place a breakpoint
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 52588bc..1765969 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -535,7 +535,7 @@ enable_break2 (void)
if (interp_sect)
{
unsigned int interp_sect_size;
- gdb_byte *buf;
+ char *buf;
bfd *tmp_bfd = NULL;
int status;
CORE_ADDR addr, interp_loadmap_addr;
@@ -548,7 +548,7 @@ enable_break2 (void)
interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
buf = alloca (interp_sect_size);
bfd_get_section_contents (exec_bfd, interp_sect,
- buf, 0, interp_sect_size);
+ (gdb_byte *) buf, 0, interp_sect_size);
/* Now we need to figure out where the dynamic linker was
loaded so that we can load its symbols and place a breakpoint
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index 7be5232..3acf9c5 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -209,7 +209,7 @@ spu_current_sos (void)
yet. Skip such entries; we'll be back for them later. */
xsnprintf (annex, sizeof annex, "%d/object-id", fd);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
- id, 0, sizeof id);
+ (gdb_byte *) id, 0, sizeof id);
if (len <= 0 || len >= sizeof id)
continue;
id[len] = 0;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index bb2a4e9..f3bff6e 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -496,7 +496,7 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
/* Return program interpreter string. */
-static gdb_byte *
+static char *
find_program_interpreter (void)
{
gdb_byte *buf = NULL;
@@ -521,7 +521,7 @@ find_program_interpreter (void)
if (!buf)
buf = read_program_header (PT_INTERP, NULL, NULL);
- return buf;
+ return (char *) buf;
}
@@ -1446,7 +1446,7 @@ enable_break (struct svr4_info *info, int from_tty)
struct minimal_symbol *msymbol;
const char * const *bkpt_namep;
asection *interp_sect;
- gdb_byte *interp_name;
+ char *interp_name;
CORE_ADDR sym_addr;
info->interp_text_sect_low = info->interp_text_sect_high = 0;
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index 0922d04..a74bd30 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -285,7 +285,7 @@ spu_xfer_partial (struct target_ops *ops, enum target_object object,
0, sizeof buf) <= 0)
return ret;
- lslr = strtoulst (buf, NULL, 16);
+ lslr = strtoulst ((char *) buf, NULL, 16);
return ops_beneath->to_xfer_partial (ops_beneath, TARGET_OBJECT_SPU,
mem_annex, readbuf, writebuf,
addr & lslr, len);
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 32c8f1e..9ea9c73 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -192,6 +192,7 @@ spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
gdb_byte reg[32];
char annex[32];
ULONGEST id;
+ ULONGEST ul;
status = regcache_raw_read_unsigned (regcache, SPU_ID_REGNUM, &id);
if (status != REG_VALID)
@@ -201,7 +202,8 @@ spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
target_read (¤t_target, TARGET_OBJECT_SPU, annex,
reg, 0, sizeof reg);
- store_unsigned_integer (buf, 4, byte_order, strtoulst (reg, NULL, 16));
+ ul = strtoulst ((char *) reg, NULL, 16);
+ store_unsigned_integer (buf, 4, byte_order, ul);
return REG_VALID;
}
@@ -254,7 +256,7 @@ spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte reg[32];
+ char reg[32];
char annex[32];
ULONGEST id;
@@ -263,7 +265,7 @@ spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
xsnprintf (reg, sizeof reg, "0x%s",
phex_nz (extract_unsigned_integer (buf, 4, byte_order), 4));
target_write (¤t_target, TARGET_OBJECT_SPU, annex,
- reg, 0, strlen (reg));
+ (gdb_byte *) reg, 0, strlen (reg));
}
static void
@@ -2044,7 +2046,7 @@ info_spu_event_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read event_status."));
buf[len] = '\0';
- event_status = strtoulst (buf, NULL, 16);
+ event_status = strtoulst ((char *) buf, NULL, 16);
xsnprintf (annex, sizeof annex, "%d/event_mask", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
@@ -2052,7 +2054,7 @@ info_spu_event_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read event_mask."));
buf[len] = '\0';
- event_mask = strtoulst (buf, NULL, 16);
+ event_mask = strtoulst ((char *) buf, NULL, 16);
chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoEvent");
@@ -2111,7 +2113,7 @@ info_spu_signal_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read signal1_type."));
buf[len] = '\0';
- signal1_type = strtoulst (buf, NULL, 16);
+ signal1_type = strtoulst ((char *) buf, NULL, 16);
xsnprintf (annex, sizeof annex, "%d/signal2", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex, buf, 0, 4);
@@ -2129,7 +2131,7 @@ info_spu_signal_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read signal2_type."));
buf[len] = '\0';
- signal2_type = strtoulst (buf, NULL, 16);
+ signal2_type = strtoulst ((char *) buf, NULL, 16);
chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoSignal");
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 02/26] -Wpointer-sign: gdb_byte -> char.
2013-04-11 23:00 ` [PATCH 02/26] -Wpointer-sign: gdb_byte -> char Pedro Alves
@ 2013-04-12 12:34 ` Yao Qi
2013-04-12 14:42 ` Pedro Alves
0 siblings, 1 reply; 39+ messages in thread
From: Yao Qi @ 2013-04-12 12:34 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 04/12/2013 06:59 AM, Pedro Alves wrote:
> diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
> index cee2adf..26ffbaa 100644
> --- a/gdb/i386-cygwin-tdep.c
> +++ b/gdb/i386-cygwin-tdep.c
> @@ -125,11 +125,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
> struct cpms_data *data = obj;
> enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
>
> - char *module_name;
> + gdb_byte *module_name;
> size_t module_name_size;
> CORE_ADDR base_addr;
>
> - char *buf = NULL;
> + gdb_byte *buf = NULL;
>
> if (strncmp (sect->name, ".module", 7) != 0)
> return;
> @@ -160,7 +160,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
>
> /* The first module is the .exe itself. */
> if (data->module_count != 0)
> - windows_xfer_shared_library (module_name, base_addr,
> + windows_xfer_shared_library ((char *) module_name, base_addr,
> data->gdbarch, data->obstack);
> data->module_count++;
>
It would be nice to keep 'module_name' of type 'char *', because it is a
string.
> diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
> index e2822c1..86ce062 100644
> --- a/gdb/solib-dsbt.c
> +++ b/gdb/solib-dsbt.c
> @@ -840,7 +840,7 @@ enable_break2 (void)
> if (interp_sect)
> {
> unsigned int interp_sect_size;
> - gdb_byte *buf;
> + char *buf;
> bfd *tmp_bfd = NULL;
> CORE_ADDR addr;
> gdb_byte addr_buf[TIC6X_PTR_SIZE];
> @@ -852,7 +852,7 @@ enable_break2 (void)
> interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
> buf = alloca (interp_sect_size);
> bfd_get_section_contents (exec_bfd, interp_sect,
> - buf, 0, interp_sect_size);
> + (bfd_byte *) buf, 0, interp_sect_size);
The declaration of bfd_get_section_contents is,
bfd_boolean bfd_get_section_contents
(bfd *abfd, asection *section, void *location, file_ptr offset,
bfd_size_type count);
the parameter 'location' 's type is 'void *', do we really need to cast
'buf' to 'bfd_byte *'?
>
> /* Now we need to figure out where the dynamic linker was
> loaded so that we can load its symbols and place a breakpoint
> diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
> index 52588bc..1765969 100644
> --- a/gdb/solib-frv.c
> +++ b/gdb/solib-frv.c
> @@ -535,7 +535,7 @@ enable_break2 (void)
> if (interp_sect)
> {
> unsigned int interp_sect_size;
> - gdb_byte *buf;
> + char *buf;
> bfd *tmp_bfd = NULL;
> int status;
> CORE_ADDR addr, interp_loadmap_addr;
> @@ -548,7 +548,7 @@ enable_break2 (void)
> interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
> buf = alloca (interp_sect_size);
> bfd_get_section_contents (exec_bfd, interp_sect,
> - buf, 0, interp_sect_size);
> + (gdb_byte *) buf, 0, interp_sect_size);
Likewise.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 02/26] -Wpointer-sign: gdb_byte -> char.
2013-04-12 12:34 ` Yao Qi
@ 2013-04-12 14:42 ` Pedro Alves
0 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 14:42 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 04/12/2013 03:32 AM, Yao Qi wrote:
> On 04/12/2013 06:59 AM, Pedro Alves wrote:
>> diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
>> index cee2adf..26ffbaa 100644
>> --- a/gdb/i386-cygwin-tdep.c
>> +++ b/gdb/i386-cygwin-tdep.c
>> @@ -125,11 +125,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
>> struct cpms_data *data = obj;
>> enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
>>
>> - char *module_name;
>> + gdb_byte *module_name;
>> size_t module_name_size;
>> CORE_ADDR base_addr;
>>
>> - char *buf = NULL;
>> + gdb_byte *buf = NULL;
>>
>> if (strncmp (sect->name, ".module", 7) != 0)
>> return;
>> @@ -160,7 +160,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
>>
>> /* The first module is the .exe itself. */
>> if (data->module_count != 0)
>> - windows_xfer_shared_library (module_name, base_addr,
>> + windows_xfer_shared_library ((char *) module_name, base_addr,
>> data->gdbarch, data->obstack);
>> data->module_count++;
>>
>
> It would be nice to keep 'module_name' of type 'char *', because it is a string.
Hmm, in my original attempt, I tried it and ended up with more casts overall.
But I now notice that "module_name - buf" is "12". I've merged this in
into the patch:
gdb/i386-cygwin-tdep.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index 26ffbaa..dc5d614 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -125,7 +125,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
struct cpms_data *data = obj;
enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
- gdb_byte *module_name;
+ char *module_name;
size_t module_name_size;
CORE_ADDR base_addr;
@@ -154,13 +154,13 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
module_name_size =
extract_unsigned_integer (buf + 8, 4, byte_order);
- module_name = buf + 12;
- if (module_name - buf + module_name_size > bfd_get_section_size (sect))
+ if (12 + module_name_size > bfd_get_section_size (sect))
goto out;
+ module_name = (char *) buf + 12;
/* The first module is the .exe itself. */
if (data->module_count != 0)
- windows_xfer_shared_library ((char *) module_name, base_addr,
+ windows_xfer_shared_library (module_name, base_addr,
data->gdbarch, data->obstack);
data->module_count++;
I moved the "module_name =" line below because it's neater
to check overflow before causing it. Overall this does look nicer.
Thanks.
> bfd_boolean bfd_get_section_contents
> (bfd *abfd, asection *section, void *location, file_ptr offset,
> bfd_size_type count);
>
> the parameter 'location' 's type is 'void *', do we really need to cast 'buf' to 'bfd_byte *'?
Thanks. I really can't say why I added it.
> Likewise.
Both bits reverted.
Below's the current version. I've updated the github branch too.
-------------
-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 *'.
---
gdb/avr-tdep.c | 8 +++++---
gdb/i386-cygwin-tdep.c | 6 +++---
gdb/linux-tdep.c | 4 ++--
gdb/solib-darwin.c | 6 +++---
gdb/solib-dsbt.c | 2 +-
gdb/solib-frv.c | 2 +-
gdb/solib-spu.c | 2 +-
gdb/solib-svr4.c | 6 +++---
gdb/spu-multiarch.c | 2 +-
gdb/spu-tdep.c | 16 +++++++++-------
10 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index b14bf83..0bc08a8 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1468,8 +1468,9 @@ avr_io_reg_read_command (char *args, int from_tty)
{
LONGEST bufsiz = 0;
gdb_byte *buf;
+ const char *bufstr;
char query[400];
- char *p;
+ const char *p;
unsigned int nreg = 0;
unsigned int val;
int i, j, k, step;
@@ -1477,6 +1478,7 @@ avr_io_reg_read_command (char *args, int from_tty)
/* Find out how many io registers the target has. */
bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR,
"avr.io_reg", &buf);
+ bufstr = (const char *) buf;
if (bufsiz <= 0)
{
@@ -1486,7 +1488,7 @@ avr_io_reg_read_command (char *args, int from_tty)
return;
}
- if (sscanf (buf, "%x", &nreg) != 1)
+ if (sscanf (bufstr, "%x", &nreg) != 1)
{
fprintf_unfiltered (gdb_stderr,
_("Error fetching number of io registers\n"));
@@ -1514,7 +1516,7 @@ avr_io_reg_read_command (char *args, int from_tty)
bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR,
query, &buf);
- p = buf;
+ p = (const char *) buf;
for (k = i; k < (i + j); k++)
{
if (sscanf (p, "%[^,],%x;", query, &val) == 2)
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index cee2adf..dc5d614 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -129,7 +129,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
size_t module_name_size;
CORE_ADDR base_addr;
- char *buf = NULL;
+ gdb_byte *buf = NULL;
if (strncmp (sect->name, ".module", 7) != 0)
return;
@@ -154,9 +154,9 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
module_name_size =
extract_unsigned_integer (buf + 8, 4, byte_order);
- module_name = buf + 12;
- if (module_name - buf + module_name_size > bfd_get_section_size (sect))
+ if (12 + module_name_size > bfd_get_section_size (sect))
goto out;
+ module_name = (char *) buf + 12;
/* The first module is the .exe itself. */
if (data->module_count != 0)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 9def108..9623d19 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -261,7 +261,7 @@ linux_info_proc (struct gdbarch *gdbarch, char *args,
int status_f = (what == IP_STATUS || what == IP_ALL);
int stat_f = (what == IP_STAT || what == IP_ALL);
char filename[100];
- gdb_byte *data;
+ char *data;
int target_errno;
if (args && isdigit (args[0]))
@@ -676,7 +676,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
void *obfd)
{
char mapsfilename[100];
- gdb_byte *data;
+ char *data;
/* We need to know the real target PID to access /proc. */
if (current_inferior ()->fake_pid_p)
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 8c2307e..c4c6308 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -210,10 +210,10 @@ lookup_symbol_from_bfd (bfd *abfd, char *symname)
/* Return program interpreter string. */
-static gdb_byte *
+static char *
find_program_interpreter (void)
{
- gdb_byte *buf = NULL;
+ char *buf = NULL;
/* If we have an exec_bfd, get the interpreter from the load commands. */
if (exec_bfd)
@@ -420,7 +420,7 @@ gdb_bfd_mach_o_fat_extract (bfd *abfd, bfd_format format,
static void
darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
{
- gdb_byte *interp_name;
+ char *interp_name;
CORE_ADDR load_addr = 0;
bfd *dyld_bfd = NULL;
struct cleanup *cleanup;
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index e2822c1..90321d9 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -840,7 +840,7 @@ enable_break2 (void)
if (interp_sect)
{
unsigned int interp_sect_size;
- gdb_byte *buf;
+ char *buf;
bfd *tmp_bfd = NULL;
CORE_ADDR addr;
gdb_byte addr_buf[TIC6X_PTR_SIZE];
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 52588bc..0f3e5d7 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -535,7 +535,7 @@ enable_break2 (void)
if (interp_sect)
{
unsigned int interp_sect_size;
- gdb_byte *buf;
+ char *buf;
bfd *tmp_bfd = NULL;
int status;
CORE_ADDR addr, interp_loadmap_addr;
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index 7be5232..3acf9c5 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -209,7 +209,7 @@ spu_current_sos (void)
yet. Skip such entries; we'll be back for them later. */
xsnprintf (annex, sizeof annex, "%d/object-id", fd);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
- id, 0, sizeof id);
+ (gdb_byte *) id, 0, sizeof id);
if (len <= 0 || len >= sizeof id)
continue;
id[len] = 0;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index bb2a4e9..f3bff6e 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -496,7 +496,7 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
/* Return program interpreter string. */
-static gdb_byte *
+static char *
find_program_interpreter (void)
{
gdb_byte *buf = NULL;
@@ -521,7 +521,7 @@ find_program_interpreter (void)
if (!buf)
buf = read_program_header (PT_INTERP, NULL, NULL);
- return buf;
+ return (char *) buf;
}
@@ -1446,7 +1446,7 @@ enable_break (struct svr4_info *info, int from_tty)
struct minimal_symbol *msymbol;
const char * const *bkpt_namep;
asection *interp_sect;
- gdb_byte *interp_name;
+ char *interp_name;
CORE_ADDR sym_addr;
info->interp_text_sect_low = info->interp_text_sect_high = 0;
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index 0922d04..a74bd30 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -285,7 +285,7 @@ spu_xfer_partial (struct target_ops *ops, enum target_object object,
0, sizeof buf) <= 0)
return ret;
- lslr = strtoulst (buf, NULL, 16);
+ lslr = strtoulst ((char *) buf, NULL, 16);
return ops_beneath->to_xfer_partial (ops_beneath, TARGET_OBJECT_SPU,
mem_annex, readbuf, writebuf,
addr & lslr, len);
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 32c8f1e..9ea9c73 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -192,6 +192,7 @@ spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
gdb_byte reg[32];
char annex[32];
ULONGEST id;
+ ULONGEST ul;
status = regcache_raw_read_unsigned (regcache, SPU_ID_REGNUM, &id);
if (status != REG_VALID)
@@ -201,7 +202,8 @@ spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
target_read (¤t_target, TARGET_OBJECT_SPU, annex,
reg, 0, sizeof reg);
- store_unsigned_integer (buf, 4, byte_order, strtoulst (reg, NULL, 16));
+ ul = strtoulst ((char *) reg, NULL, 16);
+ store_unsigned_integer (buf, 4, byte_order, ul);
return REG_VALID;
}
@@ -254,7 +256,7 @@ spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte reg[32];
+ char reg[32];
char annex[32];
ULONGEST id;
@@ -263,7 +265,7 @@ spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
xsnprintf (reg, sizeof reg, "0x%s",
phex_nz (extract_unsigned_integer (buf, 4, byte_order), 4));
target_write (¤t_target, TARGET_OBJECT_SPU, annex,
- reg, 0, strlen (reg));
+ (gdb_byte *) reg, 0, strlen (reg));
}
static void
@@ -2044,7 +2046,7 @@ info_spu_event_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read event_status."));
buf[len] = '\0';
- event_status = strtoulst (buf, NULL, 16);
+ event_status = strtoulst ((char *) buf, NULL, 16);
xsnprintf (annex, sizeof annex, "%d/event_mask", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
@@ -2052,7 +2054,7 @@ info_spu_event_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read event_mask."));
buf[len] = '\0';
- event_mask = strtoulst (buf, NULL, 16);
+ event_mask = strtoulst ((char *) buf, NULL, 16);
chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoEvent");
@@ -2111,7 +2113,7 @@ info_spu_signal_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read signal1_type."));
buf[len] = '\0';
- signal1_type = strtoulst (buf, NULL, 16);
+ signal1_type = strtoulst ((char *) buf, NULL, 16);
xsnprintf (annex, sizeof annex, "%d/signal2", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex, buf, 0, 4);
@@ -2129,7 +2131,7 @@ info_spu_signal_command (char *args, int from_tty)
if (len <= 0)
error (_("Could not read signal2_type."));
buf[len] = '\0';
- signal2_type = strtoulst (buf, NULL, 16);
+ signal2_type = strtoulst ((char *) buf, NULL, 16);
chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoSignal");
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 01/26] -Wpointer-sign: char -> gdb_byte.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
2013-04-11 23:00 ` [PATCH 02/26] -Wpointer-sign: gdb_byte -> char Pedro Alves
@ 2013-04-11 23:00 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 04/26] alpha-tdep.c/mips-tdep.c: "set heuristic-fence-post" is signed/zinteger Pedro Alves
` (26 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:00 UTC (permalink / raw)
To: gdb-patches
-Wpointer-sign catches all these cases across the codebase that should
be using gdb_byte for raw target bytes. I think these are all
obvious, hence I've collapsed into a single patch.
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* aarch64-tdep.c (aarch64_default_breakpoint): Change type to
gdb_byte[].
(aarch64_breakpoint_from_pc): Change return type to gdb_byte *.
* ada-lang.c (ada_value_assign): Use gdb_byte.
* alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[].
(alphanbsd_sigtramp_offset): Use gdb_byte.
* arm-linux-tdep.c (arm_linux_arm_le_breakpoint)
(arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint)
(eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint)
(arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint)
(arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[].
* arm-tdep.c (arm_stub_unwind_sniffer)
(arm_displaced_init_closure): Use gdb_byte.
(arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint)
(arm_default_thumb_le_breakpoint)
(arm_default_thumb_be_breakpoint): Change type to gdb_byte[].
* arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint,
thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *.
* arm-wince-tdep.c (arm_wince_le_breakpoint)
(arm_wince_thumb_le_breakpoint): Change type to gdb_byte[].
* armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint)
(arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint)
(arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[].
* armobsd-tdep.c (arm_obsd_thumb_le_breakpoint)
(arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[].
* cris-tdep.c (push_stack_item, cris_push_dummy_call)
(cris_store_return_value, cris_extract_return_value): Use
gdb_byte.
(constraint): Change type of parameter to char * from signed
char*. Use gdb_byte.
* dwarf2loc.c (read_pieced_value, write_pieced_value): Change type
of local buffer to gdb_byte *.
* dwarf2read.c (read_index_from_section): Use gdb_byte.
(create_dwp_hash_table): Change type of locals to gdb_byte *.
(add_address_entry): Change type of local buffer to gdb_byte[].
* frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr)
(frv_push_dummy_call): Use gdb_byte.
* hppa-hpux-tdep.c (hppa_hpux_push_dummy_code)
(hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide)
(hppa_hpux_supply_save_state): Use gdb_byte.
* hppa-tdep.c (hppa32_push_dummy_call)
(hppa64_convert_code_addr_to_fptr): Use gdb_byte.
* i387-tdep.c (i387_print_float_info): Use gdb_byte.
* ia64-tdep.c (extract_bit_field, replace_bit_field)
(slotN_contents, replace_slotN_contents): Change type of parameter
to gdb_byte *.
(fetch_instruction, ia64_pseudo_register_write)
(ia64_register_to_value, ia64_value_to_register)
(ia64_extract_return_value, ia64_store_return_value)
(ia64_push_dummy_call): Use gdb_byte.
* m32c-tdep.c (m32c_return_value): Remove cast.
* m68hc11-tdep.c (m68hc11_pseudo_register_write)
(m68hc11_push_dummy_call, m68hc11_store_return_value): Use
gdb_byte.
* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte.
* mn10300-tdep.c (mn10300_store_return_value)
(mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use
gdb_byte.
* moxie-tdep.c (moxie_process_readu): Use gdb_byte.
(moxie_process_record): Remove casts.
* ppc-ravenscar-thread.c (supply_register_at_address)
(ppc_ravenscar_generic_store_registers): Use gdb_byte.
* ravenscar-thread.c (get_running_thread_id): Use gdb_byte.
* remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte.
* remote-mips.c (mips_xfer_memory): Use gdb_byte.
* remote.c (compare_sections_command): Use gdb_byte.
* score-tdep.c (score7_free_memblock): Change type of parameter to
gdb_byte *.
* sh-tdep.c (sh_justify_value_in_reg): Change return type to
gdb_byte *. Use gdb_byte.
(sh_push_dummy_call_fpu): Use gdb_byte.
(sh_extract_return_value_nofpu, sh_extract_return_value_fpu)
(sh_store_return_value_nofpu, sh_store_return_value_fpu)
(sh_register_convert_to_virtual, sh_register_convert_to_raw):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte.
* sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte.
(sh64_store_return_value, sh64_register_convert_to_virtual):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh64_pseudo_register_write): Use gdb_byte.
* solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'.
* solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte
buffer.
(irix_current_sos): Use gdb_byte.
* solib-som.c (som_current_sos): Use gdb_byte.
* sparc-ravenscar-thread.c (supply_register_at_address)
(sparc_ravenscar_generic_store_registers): Use gdb_byte.
* spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'.
* spu-tdep.c (spu_get_overlay_table): Use gdb_byte.
* tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to
'gdb_byte *'.
* tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to
'gdb_byte *'.
* tracepoint.c (tfile_fetch_registers): Use gdb_byte.
* xstormy16-tdep.c (xstormy16_extract_return_value)
(xstormy16_store_return_value): Change parameter type to
'gdb_byte *'. Adjust.
(xstormy16_push_dummy_call): Use gdb_byte.
* xtensa-tdep.c (xtensa_scan_prologue, call0_ret)
(call0_analyze_prologue, execute_code): Use gdb_byte.
---
gdb/aarch64-tdep.c | 4 ++--
gdb/ada-lang.c | 2 +-
gdb/alphanbsd-tdep.c | 8 ++++----
gdb/arm-linux-tdep.c | 16 ++++++++-------
gdb/arm-tdep.c | 12 ++++++-----
gdb/arm-tdep.h | 6 +++---
gdb/arm-wince-tdep.c | 4 ++--
gdb/armnbsd-tdep.c | 8 ++++----
gdb/armobsd-tdep.c | 4 ++--
gdb/cris-tdep.c | 18 +++++++++--------
gdb/dwarf2loc.c | 4 ++--
gdb/dwarf2read.c | 6 +++---
gdb/frv-tdep.c | 10 +++++-----
gdb/hppa-hpux-tdep.c | 16 ++++++++-------
gdb/hppa-tdep.c | 4 ++--
gdb/i387-tdep.c | 2 +-
gdb/ia64-tdep.c | 24 +++++++++++------------
gdb/m32c-tdep.c | 3 +--
gdb/m68hc11-tdep.c | 14 +++++++------
gdb/mipsnbsd-tdep.c | 2 +-
gdb/mn10300-tdep.c | 11 ++++++-----
gdb/moxie-tdep.c | 14 +++++--------
gdb/ppc-ravenscar-thread.c | 6 +++---
gdb/ravenscar-thread.c | 2 +-
gdb/remote-m32r-sdi.c | 2 +-
gdb/remote-mips.c | 2 +-
gdb/remote.c | 2 +-
gdb/score-tdep.c | 2 +-
gdb/sh-tdep.c | 44 +++++++++++++++++++++---------------------
gdb/sh64-tdep.c | 41 ++++++++++++++++++---------------------
gdb/solib-darwin.c | 4 ++--
gdb/solib-irix.c | 12 ++++++-----
gdb/solib-som.c | 2 +-
gdb/sparc-ravenscar-thread.c | 6 +++---
gdb/spu-tdep.c | 2 +-
gdb/tic6x-tdep.c | 2 +-
gdb/tic6x-tdep.h | 2 +-
gdb/tracepoint.c | 2 +-
gdb/xstormy16-tdep.c | 10 +++++-----
gdb/xtensa-tdep.c | 8 ++++----
40 files changed, 168 insertions(+), 175 deletions(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index ebc78d6..2a889fa 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1897,11 +1897,11 @@ aarch64_gdb_print_insn (bfd_vma memaddr, disassemble_info *info)
/* AArch64 BRK software debug mode instruction.
Note that AArch64 code is always little-endian.
1101.0100.0010.0000.0000.0000.0000.0000 = 0xd4200000. */
-static const char aarch64_default_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};
+static const gdb_byte aarch64_default_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};
/* Implement the "breakpoint_from_pc" gdbarch method. */
-static const unsigned char *
+static const gdb_byte *
aarch64_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
int *lenptr)
{
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0329dd9..4d07d4d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2518,7 +2518,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
int len = (value_bitpos (toval)
+ bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
int from_size;
- char *buffer = (char *) alloca (len);
+ gdb_byte *buffer = alloca (len);
struct value *val;
CORE_ADDR to_addr = value_address (toval);
diff --git a/gdb/alphanbsd-tdep.c b/gdb/alphanbsd-tdep.c
index dd76bea..757bc46 100644
--- a/gdb/alphanbsd-tdep.c
+++ b/gdb/alphanbsd-tdep.c
@@ -199,7 +199,7 @@ alphanbsd_regset_from_core_section (struct gdbarch *gdbarch,
sequence and can then check whether we really are executing in the
signal trampoline. If not, -1 is returned, otherwise the offset from the
start of the return sequence is returned. */
-static const unsigned char sigtramp_retcode[] =
+static const gdb_byte sigtramp_retcode[] =
{
0x00, 0x00, 0x1e, 0xa6, /* ldq a0, 0(sp) */
0x10, 0x00, 0xde, 0x23, /* lda sp, 16(sp) */
@@ -212,11 +212,11 @@ static const unsigned char sigtramp_retcode[] =
static LONGEST
alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- unsigned char ret[RETCODE_SIZE], w[4];
+ gdb_byte ret[RETCODE_SIZE], w[4];
LONGEST off;
int i;
- if (target_read_memory (pc, (char *) w, 4) != 0)
+ if (target_read_memory (pc, w, 4) != 0)
return -1;
for (i = 0; i < RETCODE_NWORDS; i++)
@@ -230,7 +230,7 @@ alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
off = i * 4;
pc -= off;
- if (target_read_memory (pc, (char *) ret, sizeof (ret)) != 0)
+ if (target_read_memory (pc, ret, sizeof (ret)) != 0)
return -1;
if (memcmp (ret, sigtramp_retcode, RETCODE_SIZE) == 0)
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 953e525..1502bdc 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -62,9 +62,9 @@ extern int arm_apcs_32;
of the software interrupt the kernel stops the inferior with a
SIGTRAP, and wakes the debugger. */
-static const char arm_linux_arm_le_breakpoint[] = { 0x01, 0x00, 0x9f, 0xef };
+static const gdb_byte arm_linux_arm_le_breakpoint[] = { 0x01, 0x00, 0x9f, 0xef };
-static const char arm_linux_arm_be_breakpoint[] = { 0xef, 0x9f, 0x00, 0x01 };
+static const gdb_byte arm_linux_arm_be_breakpoint[] = { 0xef, 0x9f, 0x00, 0x01 };
/* However, the EABI syscall interface (new in Nov. 2005) does not look at
the operand of the swi if old-ABI compatibility is disabled. Therefore,
@@ -72,24 +72,24 @@ static const char arm_linux_arm_be_breakpoint[] = { 0xef, 0x9f, 0x00, 0x01 };
version 2.5.70 (May 2003), so should be a safe assumption for EABI
binaries. */
-static const char eabi_linux_arm_le_breakpoint[] = { 0xf0, 0x01, 0xf0, 0xe7 };
+static const gdb_byte eabi_linux_arm_le_breakpoint[] = { 0xf0, 0x01, 0xf0, 0xe7 };
-static const char eabi_linux_arm_be_breakpoint[] = { 0xe7, 0xf0, 0x01, 0xf0 };
+static const gdb_byte eabi_linux_arm_be_breakpoint[] = { 0xe7, 0xf0, 0x01, 0xf0 };
/* All the kernels which support Thumb support using a specific undefined
instruction for the Thumb breakpoint. */
-static const char arm_linux_thumb_be_breakpoint[] = {0xde, 0x01};
+static const gdb_byte arm_linux_thumb_be_breakpoint[] = {0xde, 0x01};
-static const char arm_linux_thumb_le_breakpoint[] = {0x01, 0xde};
+static const gdb_byte arm_linux_thumb_le_breakpoint[] = {0x01, 0xde};
/* Because the 16-bit Thumb breakpoint is affected by Thumb-2 IT blocks,
we must use a length-appropriate breakpoint for 32-bit Thumb
instructions. See also thumb_get_next_pc. */
-static const char arm_linux_thumb2_be_breakpoint[] = { 0xf7, 0xf0, 0xa0, 0x00 };
+static const gdb_byte arm_linux_thumb2_be_breakpoint[] = { 0xf7, 0xf0, 0xa0, 0x00 };
-static const char arm_linux_thumb2_le_breakpoint[] = { 0xf0, 0xf7, 0x00, 0xa0 };
+static const gdb_byte arm_linux_thumb2_le_breakpoint[] = { 0xf0, 0xf7, 0x00, 0xa0 };
/* Description of the longjmp buffer. The buffer is treated as an array of
elements of size ARM_LINUX_JB_ELEMENT_SIZE.
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 2a11890..e353717 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -2904,7 +2904,7 @@ arm_stub_unwind_sniffer (const struct frame_unwind *self,
void **this_prologue_cache)
{
CORE_ADDR addr_in_block;
- char dummy[4];
+ gdb_byte dummy[4];
addr_in_block = get_frame_address_in_block (this_frame);
if (in_plt_section (addr_in_block, NULL)
@@ -8616,7 +8616,7 @@ arm_displaced_init_closure (struct gdbarch *gdbarch, CORE_ADDR from,
unsigned int i, len, offset;
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
int size = dsc->is_thumb? 2 : 4;
- const unsigned char *bkp_insn;
+ const gdb_byte *bkp_insn;
offset = 0;
/* Poke modified instruction(s). */
@@ -8775,10 +8775,10 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info)
#define THUMB_LE_BREAKPOINT {0xbe,0xbe}
#define THUMB_BE_BREAKPOINT {0xbe,0xbe}
-static const char arm_default_arm_le_breakpoint[] = ARM_LE_BREAKPOINT;
-static const char arm_default_arm_be_breakpoint[] = ARM_BE_BREAKPOINT;
-static const char arm_default_thumb_le_breakpoint[] = THUMB_LE_BREAKPOINT;
-static const char arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT;
+static const gdb_byte arm_default_arm_le_breakpoint[] = ARM_LE_BREAKPOINT;
+static const gdb_byte arm_default_arm_be_breakpoint[] = ARM_BE_BREAKPOINT;
+static const gdb_byte arm_default_thumb_le_breakpoint[] = THUMB_LE_BREAKPOINT;
+static const gdb_byte arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT;
/* Determine the type and size of breakpoint to insert at PCPTR. Uses
the program counter value to determine whether a 16-bit or 32-bit
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 6a3fa9a..a1a2be5 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -173,16 +173,16 @@ struct gdbarch_tdep
CORE_ADDR lowest_pc; /* Lowest address at which instructions
will appear. */
- const char *arm_breakpoint; /* Breakpoint pattern for an ARM insn. */
+ const gdb_byte *arm_breakpoint; /* Breakpoint pattern for an ARM insn. */
int arm_breakpoint_size; /* And its size. */
- const char *thumb_breakpoint; /* Breakpoint pattern for a Thumb insn. */
+ const gdb_byte *thumb_breakpoint; /* Breakpoint pattern for a Thumb insn. */
int thumb_breakpoint_size; /* And its size. */
/* If the Thumb breakpoint is an undefined instruction (which is
affected by IT blocks) rather than a BKPT instruction (which is
not), then we need a 32-bit Thumb breakpoint to preserve the
instruction count in IT blocks. */
- const char *thumb2_breakpoint;
+ const gdb_byte *thumb2_breakpoint;
int thumb2_breakpoint_size;
int jb_pc; /* Offset to PC value in jump buffer.
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index e00640c..61569e3 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -30,8 +30,8 @@
#include "arm-tdep.h"
-static const char arm_wince_le_breakpoint[] = { 0x10, 0x00, 0x00, 0xe6 };
-static const char arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
+static const gdb_byte arm_wince_le_breakpoint[] = { 0x10, 0x00, 0x00, 0xe6 };
+static const gdb_byte arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
/* Description of the longjmp buffer. */
#define ARM_WINCE_JB_ELEMENT_SIZE INT_REGISTER_SIZE
diff --git a/gdb/armnbsd-tdep.c b/gdb/armnbsd-tdep.c
index ed00d22..abb7637 100644
--- a/gdb/armnbsd-tdep.c
+++ b/gdb/armnbsd-tdep.c
@@ -31,10 +31,10 @@
/* For compatibility with previous implemenations of GDB on arm/NetBSD,
override the default little-endian breakpoint. */
-static const char arm_nbsd_arm_le_breakpoint[] = {0x11, 0x00, 0x00, 0xe6};
-static const char arm_nbsd_arm_be_breakpoint[] = {0xe6, 0x00, 0x00, 0x11};
-static const char arm_nbsd_thumb_le_breakpoint[] = {0xfe, 0xde};
-static const char arm_nbsd_thumb_be_breakpoint[] = {0xde, 0xfe};
+static const gdb_byte arm_nbsd_arm_le_breakpoint[] = {0x11, 0x00, 0x00, 0xe6};
+static const gdb_byte arm_nbsd_arm_be_breakpoint[] = {0xe6, 0x00, 0x00, 0x11};
+static const gdb_byte arm_nbsd_thumb_le_breakpoint[] = {0xfe, 0xde};
+static const gdb_byte arm_nbsd_thumb_be_breakpoint[] = {0xde, 0xfe};
static void
arm_netbsd_init_abi_common (struct gdbarch_info info,
diff --git a/gdb/armobsd-tdep.c b/gdb/armobsd-tdep.c
index 5611a2d..384ef87 100644
--- a/gdb/armobsd-tdep.c
+++ b/gdb/armobsd-tdep.c
@@ -71,8 +71,8 @@ static const struct tramp_frame armobsd_sigframe =
\f
/* Override default thumb breakpoints. */
-static const char arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
-static const char arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};
+static const gdb_byte arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
+static const gdb_byte arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};
static void
armobsd_init_abi (struct gdbarch_info info,
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index c1f07bb..2662513 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -676,7 +676,7 @@ struct stack_item
};
static struct stack_item *
-push_stack_item (struct stack_item *prev, void *contents, int len)
+push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
{
struct stack_item *si;
si = xmalloc (sizeof (struct stack_item));
@@ -850,12 +850,12 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argnum = 0; argnum < nargs; argnum++)
{
int len;
- char *val;
+ const gdb_byte *val;
int reg_demand;
int i;
len = TYPE_LENGTH (value_type (args[argnum]));
- val = (char *) value_contents (args[argnum]);
+ val = value_contents (args[argnum]);
/* How may registers worth of storage do we need for this argument? */
reg_demand = (len / 4) + (len % 4 != 0 ? 1 : 0);
@@ -1657,7 +1657,7 @@ crisv32_register_type (struct gdbarch *gdbarch, int regno)
static void
cris_store_return_value (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1675,7 +1675,7 @@ cris_store_return_value (struct type *type, struct regcache *regcache,
/* Put the return value in R10 and R11. */
val = extract_unsigned_integer (valbuf, 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
- val = extract_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order);
+ val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG2_REGNUM, val);
}
else
@@ -1828,7 +1828,7 @@ cris_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
static void
cris_extract_return_value (struct type *type, struct regcache *regcache,
- void *valbuf)
+ gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1847,7 +1847,7 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
store_unsigned_integer (valbuf, 4, byte_order, val);
regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val);
- store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val);
+ store_unsigned_integer (valbuf + 4, len - 4, byte_order, val);
}
else
error (_("cris_extract_return_value: type length too large"));
@@ -1879,13 +1879,13 @@ cris_return_value (struct gdbarch *gdbarch, struct value *function,
instruction. It stems from cris_constraint, found in cris-dis.c. */
static int
-constraint (unsigned int insn, const signed char *inst_args,
+constraint (unsigned int insn, const char *inst_args,
inst_env_type *inst_env)
{
int retval = 0;
int tmp, i;
- const char *s = inst_args;
+ const gdb_byte *s = (const gdb_byte *) inst_args;
for (; *s; s++)
switch (*s)
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 71220c6..ab4ecee 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1594,7 +1594,7 @@ read_pieced_value (struct value *v)
struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (v));
size_t type_len;
size_t buffer_size = 0;
- char *buffer = NULL;
+ gdb_byte *buffer = NULL;
struct cleanup *cleanup;
int bits_big_endian
= gdbarch_bits_big_endian (get_type_arch (value_type (v)));
@@ -1777,7 +1777,7 @@ write_pieced_value (struct value *to, struct value *from)
struct frame_info *frame = frame_find_by_id (VALUE_FRAME_ID (to));
size_t type_len;
size_t buffer_size = 0;
- char *buffer = NULL;
+ gdb_byte *buffer = NULL;
struct cleanup *cleanup;
int bits_big_endian
= gdbarch_bits_big_endian (get_type_arch (value_type (to)));
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ad78607..25dcfc9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2661,7 +2661,7 @@ read_index_from_section (struct objfile *objfile,
const gdb_byte **types_list,
offset_type *types_list_elements)
{
- char *addr;
+ gdb_byte *addr;
offset_type version;
offset_type *metadata;
int i;
@@ -8587,7 +8587,7 @@ create_dwp_hash_table (struct dwp_file *dwp_file, int is_debug_types)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *dbfd = dwp_file->dbfd;
- char *index_ptr, *index_end;
+ gdb_byte *index_ptr, *index_end;
struct dwarf2_section_info *index;
uint32_t version, nr_units, nr_slots;
struct dwp_hash_table *htab;
@@ -20296,7 +20296,7 @@ add_address_entry (struct objfile *objfile, struct obstack *obstack,
CORE_ADDR start, CORE_ADDR end, unsigned int cu_index)
{
offset_type cu_index_to_write;
- char addr[8];
+ gdb_byte addr[8];
CORE_ADDR baseaddr;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 3770667..4b725c3 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -456,7 +456,7 @@ frv_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
an instruction word whose packing bit is set to one. */
while (count-- > 0 && addr >= func_start)
{
- char instr[frv_instr_size];
+ gdb_byte instr[frv_instr_size];
int status;
status = target_read_memory (addr, instr, sizeof instr);
@@ -1154,7 +1154,7 @@ find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR descr;
- char valbuf[4];
+ gdb_byte valbuf[4];
CORE_ADDR start_addr;
/* If we can't find the function in the symbol table, then we assume
@@ -1206,8 +1206,8 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argreg;
int argnum;
- char *val;
- char valbuf[4];
+ const gdb_byte *val;
+ gdb_byte valbuf[4];
struct value *arg;
struct type *arg_type;
int len;
@@ -1274,7 +1274,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
else
{
- val = (char *) value_contents (arg);
+ val = value_contents (arg);
}
while (len > 0)
diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c
index e964064..667904e 100644
--- a/gdb/hppa-hpux-tdep.c
+++ b/gdb/hppa-hpux-tdep.c
@@ -1278,9 +1278,9 @@ hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
static void
hppa_hpux_supply_ss_narrow (struct regcache *regcache,
- int regnum, const char *save_state)
+ int regnum, const gdb_byte *save_state)
{
- const char *ss_narrow = save_state + HPPA_HPUX_SS_NARROW_OFFSET;
+ const gdb_byte *ss_narrow = save_state + HPPA_HPUX_SS_NARROW_OFFSET;
int i, offset = 0;
for (i = HPPA_R1_REGNUM; i < HPPA_FP0_REGNUM; i++)
@@ -1294,9 +1294,9 @@ hppa_hpux_supply_ss_narrow (struct regcache *regcache,
static void
hppa_hpux_supply_ss_fpblock (struct regcache *regcache,
- int regnum, const char *save_state)
+ int regnum, const gdb_byte *save_state)
{
- const char *ss_fpblock = save_state + HPPA_HPUX_SS_FPBLOCK_OFFSET;
+ const gdb_byte *ss_fpblock = save_state + HPPA_HPUX_SS_FPBLOCK_OFFSET;
int i, offset = 0;
/* FIXME: We view the floating-point state as 64 single-precision
@@ -1329,9 +1329,9 @@ hppa_hpux_supply_ss_fpblock (struct regcache *regcache,
static void
hppa_hpux_supply_ss_wide (struct regcache *regcache,
- int regnum, const char *save_state)
+ int regnum, const gdb_byte *save_state)
{
- const char *ss_wide = save_state + HPPA_HPUX_SS_WIDE_OFFSET;
+ const gdb_byte *ss_wide = save_state + HPPA_HPUX_SS_WIDE_OFFSET;
int i, offset = 8;
if (register_size (get_regcache_arch (regcache), HPPA_R1_REGNUM) == 4)
@@ -1353,8 +1353,8 @@ hppa_hpux_supply_save_state (const struct regset *regset,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- const char *proc_info = regs;
- const char *save_state = proc_info + 8;
+ const gdb_byte *proc_info = regs;
+ const gdb_byte *save_state = proc_info + 8;
ULONGEST flags;
flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET,
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index d09bf68..fe1b45b 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -725,7 +725,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct type *type = check_typedef (value_type (arg));
/* The corresponding parameter that is pushed onto the
stack, and [possibly] passed in a register. */
- char param_val[8];
+ gdb_byte param_val[8];
int param_len;
memset (param_val, 0, sizeof param_val);
if (TYPE_LENGTH (type) > 8)
@@ -928,7 +928,7 @@ hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
addr += 2 * 8)
{
ULONGEST opdaddr;
- char tmp[8];
+ gdb_byte tmp[8];
if (target_read_memory (addr, tmp, sizeof (tmp)))
break;
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 65bb103..48a00c3 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -298,7 +298,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
if (value_entirely_available (regval))
{
- const char *raw = value_contents (regval);
+ const gdb_byte *raw = value_contents (regval);
fputs_filtered ("0x", file);
for (i = 9; i >= 0; i--)
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 9797217..7d440e4 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -370,7 +370,7 @@ ia64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
bit ``from''. */
static long long
-extract_bit_field (const char *bundle, int from, int len)
+extract_bit_field (const gdb_byte *bundle, int from, int len)
{
long long result = 0LL;
int to = from + len;
@@ -406,7 +406,7 @@ extract_bit_field (const char *bundle, int from, int len)
/* Replace the specified bits in an instruction bundle. */
static void
-replace_bit_field (char *bundle, long long val, int from, int len)
+replace_bit_field (gdb_byte *bundle, long long val, int from, int len)
{
int to = from + len;
int from_byte = from / 8;
@@ -456,7 +456,7 @@ replace_bit_field (char *bundle, long long val, int from, int len)
and instruction bundle. */
static long long
-slotN_contents (char *bundle, int slotnum)
+slotN_contents (gdb_byte *bundle, int slotnum)
{
return extract_bit_field (bundle, 5+41*slotnum, 41);
}
@@ -464,7 +464,7 @@ slotN_contents (char *bundle, int slotnum)
/* Store an instruction in an instruction bundle. */
static void
-replace_slotN_contents (char *bundle, long long instr, int slotnum)
+replace_slotN_contents (gdb_byte *bundle, long long instr, int slotnum)
{
replace_bit_field (bundle, instr, 5+41*slotnum, 41);
}
@@ -511,7 +511,7 @@ static const enum instruction_type template_encoding_table[32][3] =
static CORE_ADDR
fetch_instruction (CORE_ADDR addr, instruction_type *it, long long *instr)
{
- char bundle[BUNDLE_LEN];
+ gdb_byte bundle[BUNDLE_LEN];
int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
long long template;
int val;
@@ -1165,7 +1165,7 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
else
{
- char nat_buf[8];
+ gdb_byte nat_buf[8];
nat_collection = read_memory_integer (nat_addr, 8, byte_order);
if (natN_val)
nat_collection |= natN_mask;
@@ -1224,7 +1224,7 @@ ia64_register_to_value (struct frame_info *frame, int regnum,
int *optimizedp, int *unavailablep)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- char in[MAX_REGISTER_SIZE];
+ gdb_byte in[MAX_REGISTER_SIZE];
/* Convert to TYPE. */
if (!get_frame_register_bytes (frame, regnum, 0,
@@ -1242,7 +1242,7 @@ ia64_value_to_register (struct frame_info *frame, int regnum,
struct type *valtype, const gdb_byte *in)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- char out[MAX_REGISTER_SIZE];
+ gdb_byte out[MAX_REGISTER_SIZE];
convert_typed_floating (in, valtype, out, ia64_ext_type (gdbarch));
put_frame_register (frame, regnum, out);
}
@@ -3228,7 +3228,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
float_elt_type = is_float_or_hfa_type (type);
if (float_elt_type != NULL)
{
- char from[MAX_REGISTER_SIZE];
+ gdb_byte from[MAX_REGISTER_SIZE];
int offset = 0;
int regnum = IA64_FR8_REGNUM;
int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3293,7 +3293,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache,
float_elt_type = is_float_or_hfa_type (type);
if (float_elt_type != NULL)
{
- char to[MAX_REGISTER_SIZE];
+ gdb_byte to[MAX_REGISTER_SIZE];
int offset = 0;
int regnum = IA64_FR8_REGNUM;
int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3783,7 +3783,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
&& TYPE_CODE (type) == TYPE_CODE_PTR
&& TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)
{
- char val_buf[8];
+ gdb_byte val_buf[8];
ULONGEST faddr = extract_unsigned_integer (value_contents (arg),
8, byte_order);
store_unsigned_integer (val_buf, 8, byte_order,
@@ -3807,7 +3807,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
argoffset = 0;
while (len > 0)
{
- char val_buf[8];
+ gdb_byte val_buf[8];
memset (val_buf, 0, 8);
if (!ia64_struct_type_p (type) && len < 8)
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 3a0267b..a147c94 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -2282,8 +2282,7 @@ m32c_return_value (struct gdbarch *gdbarch,
error (_("The return value is stored in memory at 'mem0', "
"but GDB cannot find\n"
" its address."));
- write_memory (SYMBOL_VALUE_ADDRESS (mem0),
- (char *) writebuf, valtype_len);
+ write_memory (SYMBOL_VALUE_ADDRESS (mem0), writebuf, valtype_len);
}
}
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 078be70..b3023ad 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -338,7 +338,7 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
if (regno == M68HC12_HARD_PC_REGNUM)
{
const int regsize = 4;
- char *tmp = alloca (regsize);
+ gdb_byte *tmp = alloca (regsize);
CORE_ADDR pc;
memcpy (tmp, buf, regsize);
@@ -363,7 +363,7 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
if (soft_regs[regno].name)
{
const int regsize = 2;
- char *tmp = alloca (regsize);
+ gdb_byte *tmp = alloca (regsize);
memcpy (tmp, buf, regsize);
target_write_memory (soft_regs[regno].addr, tmp, regsize);
}
@@ -1173,7 +1173,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argnum;
int first_stack_argnum;
struct type *type;
- char *val;
+ const gdb_byte *val;
gdb_byte buf[2];
first_stack_argnum = 0;
@@ -1209,12 +1209,12 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
if (TYPE_LENGTH (type) & 1)
{
- static char zero = 0;
+ static gdb_byte zero = 0;
sp--;
write_memory (sp, &zero, 1);
}
- val = (char*) value_contents (args[argnum]);
+ val = value_contents (args[argnum]);
sp -= TYPE_LENGTH (type);
write_memory (sp, val, TYPE_LENGTH (type));
}
@@ -1261,7 +1261,7 @@ m68hc11_register_type (struct gdbarch *gdbarch, int reg_nr)
static void
m68hc11_store_return_value (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
int len;
@@ -1274,7 +1274,7 @@ m68hc11_store_return_value (struct type *type, struct regcache *regcache,
{
regcache_raw_write_part (regcache, HARD_X_REGNUM, 4 - len,
len - 2, valbuf);
- regcache_raw_write (regcache, HARD_D_REGNUM, (char*) valbuf + (len - 2));
+ regcache_raw_write (regcache, HARD_D_REGNUM, valbuf + (len - 2));
}
else
error (_("return of value > 4 is not supported."));
diff --git a/gdb/mipsnbsd-tdep.c b/gdb/mipsnbsd-tdep.c
index 699e317..e9f36fd 100644
--- a/gdb/mipsnbsd-tdep.c
+++ b/gdb/mipsnbsd-tdep.c
@@ -262,7 +262,7 @@ mipsnbsd_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR jb_addr;
- char *buf;
+ gdb_byte *buf;
buf = alloca (NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch));
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 0609242..c31af8d 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -168,7 +168,7 @@ mn10300_use_struct_convention (struct type *type)
static void
mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
- struct regcache *regcache, const void *valbuf)
+ struct regcache *regcache, const gdb_byte *valbuf)
{
int len = TYPE_LENGTH (type);
int reg, regsz;
@@ -187,7 +187,7 @@ mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
regcache_raw_write (regcache, reg, valbuf);
gdb_assert (regsz == register_size (gdbarch, reg + 1));
regcache_raw_write_part (regcache, reg+1, 0,
- len - regsz, (char *) valbuf + regsz);
+ len - regsz, valbuf + regsz);
}
else
internal_error (__FILE__, __LINE__,
@@ -330,7 +330,7 @@ const static unsigned char *
mn10300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
int *bp_size)
{
- static char breakpoint[] = {0xff};
+ static gdb_byte breakpoint[] = {0xff};
*bp_size = 1;
return breakpoint;
}
@@ -1231,7 +1231,8 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
int len, arg_len;
int stack_offset = 0;
int argnum;
- char *val, valbuf[MAX_REGISTER_SIZE];
+ const gdb_byte *val;
+ gdb_byte valbuf[MAX_REGISTER_SIZE];
/* This should be a nop, but align the stack just in case something
went wrong. Stacks are four byte aligned on the mn10300. */
@@ -1280,7 +1281,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
else
{
arg_len = TYPE_LENGTH (value_type (*args));
- val = (char *) value_contents (*args);
+ val = value_contents (*args);
}
while (regs_used < 2 && arg_len > 0)
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 1676a9b..79d160b 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -498,7 +498,7 @@ moxie_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
/* Read an unsigned integer from the inferior, and adjust
endianess. */
static ULONGEST
-moxie_process_readu (CORE_ADDR addr, char *buf,
+moxie_process_readu (CORE_ADDR addr, gdb_byte *buf,
int length, enum bfd_endian byte_order)
{
if (target_read_memory (addr, buf, length))
@@ -766,8 +766,7 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
break;
case 0x1f: /* sta.b */
{
- tmpu32 = moxie_process_readu (addr+2, (char *) buf,
- 4, byte_order);
+ tmpu32 = moxie_process_readu (addr+2, buf, 4, byte_order);
if (record_full_arch_list_add_mem (tmpu32, 1))
return -1;
}
@@ -793,8 +792,7 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
break;
case 0x24: /* sta.s */
{
- tmpu32 = moxie_process_readu (addr+2, (char *) buf,
- 4, byte_order);
+ tmpu32 = moxie_process_readu (addr+2, buf, 4, byte_order);
if (record_full_arch_list_add_mem (tmpu32, 2))
return -1;
}
@@ -825,8 +823,7 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
/* We currently implement support for libgloss'
system calls. */
- int inum = moxie_process_readu (addr+2, (char *) buf,
- 4, byte_order);
+ int inum = moxie_process_readu (addr+2, buf, 4, byte_order);
switch (inum)
{
@@ -855,8 +852,7 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
MOXIE_FP_REGNUM, (gdb_byte *) & tmpu32);
tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
4, byte_order);
- length = moxie_process_readu (tmpu32+20, (char *) buf,
- 4, byte_order);
+ length = moxie_process_readu (tmpu32+20, buf, 4, byte_order);
if (record_full_arch_list_add_mem (ptr, length))
return -1;
diff --git a/gdb/ppc-ravenscar-thread.c b/gdb/ppc-ravenscar-thread.c
index 1993fce..790d970 100644
--- a/gdb/ppc-ravenscar-thread.c
+++ b/gdb/ppc-ravenscar-thread.c
@@ -121,9 +121,9 @@ supply_register_at_address (struct regcache *regcache, int regnum,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
- char *buf;
+ gdb_byte *buf;
- buf = (char *) alloca (buf_size);
+ buf = alloca (buf_size);
read_memory (register_addr, buf, buf_size);
regcache_raw_supply (regcache, regnum, buf);
}
@@ -189,7 +189,7 @@ ppc_ravenscar_generic_store_registers
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
- char buf [buf_size];
+ gdb_byte buf[buf_size];
ULONGEST register_address;
if (register_in_thread_descriptor_p (reg_info, regnum))
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index ae01760..0a3100d 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -155,7 +155,7 @@ get_running_thread_id (void)
const struct minimal_symbol *object_msym = get_running_thread_msymbol ();
int object_size;
int buf_size;
- char *buf;
+ gdb_byte *buf;
CORE_ADDR object_addr;
struct type *builtin_type_void_data_ptr =
builtin_type (target_gdbarch ())->builtin_data_ptr;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 7ac6322..2f910e6 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -933,7 +933,7 @@ m32r_fetch_register (struct target_ops *ops,
}
else
{
- char buffer[MAX_REGISTER_SIZE];
+ gdb_byte buffer[MAX_REGISTER_SIZE];
regid = get_reg_id (regno);
send_one_arg_cmd (SDI_READ_CPU_REG, regid);
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index bc36a00..85002ec 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2151,7 +2151,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
int i;
CORE_ADDR addr;
int count;
- char *buffer;
+ gdb_byte *buffer;
int status;
/* PMON targets do not cope well with 64 bit addresses. Mask the
diff --git a/gdb/remote.c b/gdb/remote.c
index de075c8..39ce116 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8491,7 +8491,7 @@ compare_sections_command (char *args, int from_tty)
{
asection *s;
struct cleanup *old_chain;
- char *sectdata;
+ gdb_byte *sectdata;
const char *sectname;
bfd_size_type size;
bfd_vma lma;
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 46257ba..784b912 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -835,7 +835,7 @@ score7_malloc_and_get_memblock (CORE_ADDR addr, CORE_ADDR size)
}
static void
-score7_free_memblock (char *memblock)
+score7_free_memblock (gdb_byte *memblock)
{
xfree (memblock);
}
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 0bd0179..53de7a2 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -908,22 +908,22 @@ sh_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
to R7. */
/* Helper function to justify value in register according to endianess. */
-static char *
+static const gdb_byte *
sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len)
{
- static char valbuf[4];
+ static gdb_byte valbuf[4];
memset (valbuf, 0, sizeof (valbuf));
if (len < 4)
{
/* value gets right-justified in the register or stack word. */
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
- memcpy (valbuf + (4 - len), (char *) value_contents (val), len);
+ memcpy (valbuf + (4 - len), value_contents (val), len);
else
- memcpy (valbuf, (char *) value_contents (val), len);
+ memcpy (valbuf, value_contents (val), len);
return valbuf;
}
- return (char *) value_contents (val);
+ return value_contents (val);
}
/* Helper function to eval number of bytes to allocate on stack. */
@@ -1068,7 +1068,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
struct type *func_type = value_type (function);
struct type *type;
CORE_ADDR regval;
- char *val;
+ const gdb_byte *val;
int len, reg_size = 0;
int pass_on_stack = 0;
int treat_as_flt;
@@ -1209,7 +1209,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
struct type *func_type = value_type (function);
struct type *type;
CORE_ADDR regval;
- char *val;
+ const gdb_byte *val;
int len, reg_size = 0;
int pass_on_stack = 0;
int last_reg_arg = INT_MAX;
@@ -1302,7 +1302,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
TYPE, and copy that, in virtual format, into VALBUF. */
static void
sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
- void *valbuf)
+ gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1321,7 +1321,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
{
int i, regnum = R0_REGNUM;
for (i = 0; i < len; i += 4)
- regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_read (regcache, regnum++, valbuf + i);
}
else
error (_("bad size for return value"));
@@ -1329,7 +1329,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
static void
sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
- void *valbuf)
+ gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (sh_treat_as_flt_p (type))
@@ -1339,9 +1339,9 @@ sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
for (i = 0; i < len; i += 4)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
regcache_raw_read (regcache, regnum++,
- (char *) valbuf + len - 4 - i);
+ valbuf + len - 4 - i);
else
- regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_read (regcache, regnum++, valbuf + i);
}
else
sh_extract_return_value_nofpu (type, regcache, valbuf);
@@ -1355,7 +1355,7 @@ sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
the result is stored in r0, left-justified. */
static void
sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1371,13 +1371,13 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
{
int i, regnum = R0_REGNUM;
for (i = 0; i < len; i += 4)
- regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_write (regcache, regnum++, valbuf + i);
}
}
static void
sh_store_return_value_fpu (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (sh_treat_as_flt_p (type))
@@ -1387,9 +1387,9 @@ sh_store_return_value_fpu (struct type *type, struct regcache *regcache,
for (i = 0; i < len; i += 4)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
regcache_raw_write (regcache, regnum++,
- (char *) valbuf + len - 4 - i);
+ valbuf + len - 4 - i);
else
- regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_write (regcache, regnum++, valbuf + i);
}
else
sh_store_return_value_nofpu (type, regcache, valbuf);
@@ -1549,7 +1549,7 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
static void
sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
- struct type *type, char *from, char *to)
+ struct type *type, gdb_byte *from, gdb_byte *to)
{
if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE)
{
@@ -1572,7 +1572,7 @@ sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
static void
sh_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
- int regnum, const void *from, void *to)
+ int regnum, const gdb_byte *from, gdb_byte *to)
{
if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE)
{
@@ -1643,7 +1643,7 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
int base_regnum;
- char temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr == PSEUDO_BANK_REGNUM)
@@ -1682,7 +1682,7 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
int base_regnum, portion;
- char temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr == PSEUDO_BANK_REGNUM)
{
@@ -1718,7 +1718,7 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
regcache_raw_write (regcache, base_regnum + portion,
- ((char *) buffer
+ (buffer
+ register_size (gdbarch,
base_regnum) * portion));
}
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 8a81fcb..b640b1d 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -1067,8 +1067,8 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
int argnum;
struct type *type;
CORE_ADDR regval;
- char *val;
- char valbuf[8];
+ const gdb_byte *val;
+ gdb_byte valbuf[8];
int len;
int argreg_size;
int fp_args[12];
@@ -1113,22 +1113,21 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
/* value gets right-justified in the register or stack word. */
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
memcpy (valbuf + argreg_size - len,
- (char *) value_contents (args[argnum]), len);
+ value_contents (args[argnum]), len);
else
- memcpy (valbuf, (char *) value_contents (args[argnum]), len);
+ memcpy (valbuf, value_contents (args[argnum]), len);
val = valbuf;
}
else
- val = (char *) value_contents (args[argnum]);
+ val = value_contents (args[argnum]);
while (len > 0)
{
if (int_argreg > ARGLAST_REGNUM)
{
/* Must go on the stack. */
- write_memory (sp + stack_offset, (const bfd_byte *) val,
- argreg_size);
+ write_memory (sp + stack_offset, val, argreg_size);
stack_offset += 8;/*argreg_size;*/
}
/* NOTE WELL!!!!! This is not an "else if" clause!!!
@@ -1153,7 +1152,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
}
else
{
- val = (char *) value_contents (args[argnum]);
+ val = value_contents (args[argnum]);
if (len == 4)
{
/* Where is it going to be stored? */
@@ -1287,7 +1286,7 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache,
static void
sh64_store_return_value (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
gdb_byte buf[64]; /* more than enough... */
@@ -1299,9 +1298,9 @@ sh64_store_return_value (struct type *type, struct regcache *regcache,
for (i = 0; i < len; i += 4)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
regcache_raw_write (regcache, regnum++,
- (char *) valbuf + len - 4 - i);
+ valbuf + len - 4 - i);
else
- regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_write (regcache, regnum++, valbuf + i);
}
else
{
@@ -1449,7 +1448,7 @@ sh64_register_type (struct gdbarch *gdbarch, int reg_nr)
static void
sh64_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
- struct type *type, char *from, char *to)
+ struct type *type, gdb_byte *from, gdb_byte *to)
{
if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE)
{
@@ -1530,7 +1529,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int offset = 0;
- char temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr >= DR0_REGNUM
@@ -1706,7 +1705,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
- char temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
@@ -1721,7 +1720,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
for (portion = 0; portion < 2; portion++)
regcache_raw_write (regcache, base_regnum + portion,
(temp_buffer
- + register_size (gdbarch,
+ + register_size (gdbarch,
base_regnum) * portion));
}
@@ -1733,9 +1732,8 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
regcache_raw_write (regcache, base_regnum + portion,
- ((char *) buffer
- + register_size (gdbarch,
- base_regnum) * portion));
+ (buffer + register_size (gdbarch,
+ base_regnum) * portion));
}
else if (reg_nr >= FV0_REGNUM
@@ -1746,9 +1744,8 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
regcache_raw_write (regcache, base_regnum + portion,
- ((char *) buffer
- + register_size (gdbarch,
- base_regnum) * portion));
+ (buffer + register_size (gdbarch,
+ base_regnum) * portion));
}
/* sh compact general pseudo registers. 1-to-1 with a shmedia
@@ -1807,7 +1804,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
for (portion = 0; portion < 4; portion++)
{
regcache_raw_write (regcache, base_regnum + portion,
- ((char *) buffer
+ (buffer
+ register_size (gdbarch,
base_regnum) * portion));
}
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index b9a4be1..8c2307e 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -288,7 +288,7 @@ darwin_current_sos (void)
path_addr = extract_typed_address (buf + ptr_len, ptr_type);
/* Read Mach-O header from memory. */
- if (target_read_memory (load_addr, (char *) &hdr, sizeof (hdr) - 4))
+ if (target_read_memory (load_addr, (gdb_byte *) &hdr, sizeof (hdr) - 4))
break;
/* Discard wrong magic numbers. Shouldn't happen. */
hdr_val = extract_unsigned_integer
@@ -359,7 +359,7 @@ darwin_read_exec_load_addr (struct darwin_info *info)
load_addr = extract_typed_address (buf, ptr_type);
/* Read Mach-O header from memory. */
- if (target_read_memory (load_addr, (char *) &hdr, sizeof (hdr) - 4))
+ if (target_read_memory (load_addr, (gdb_byte *) &hdr, sizeof (hdr) - 4))
break;
/* Discard wrong magic numbers. Shouldn't happen. */
hdr_val = extract_unsigned_integer
diff --git a/gdb/solib-irix.c b/gdb/solib-irix.c
index af3e7d6..0dbbb1b 100644
--- a/gdb/solib-irix.c
+++ b/gdb/solib-irix.c
@@ -152,13 +152,13 @@ fetch_lm_info (CORE_ADDR addr)
with one of the other cases. (We don't want to incur a memory error
if we were to read a larger region that generates an error due to
being at the end of a page or the like.) */
- read_memory (addr, (char *) &buf, sizeof (buf.ol32));
+ read_memory (addr, (gdb_byte *) &buf, sizeof (buf.ol32));
if (extract_unsigned_integer (buf.magic.b, sizeof (buf.magic), byte_order)
!= 0xffffffff)
{
/* Use buf.ol32... */
- char obj_buf[432];
+ gdb_byte obj_buf[432];
CORE_ADDR obj_addr = extract_mips_address (&buf.ol32.data,
sizeof (buf.ol32.data),
byte_order);
@@ -182,7 +182,7 @@ fetch_lm_info (CORE_ADDR addr)
/* Read rest of buffer. */
read_memory (addr + sizeof (buf.ol32),
- ((char *) &buf) + sizeof (buf.ol32),
+ ((gdb_byte *) &buf) + sizeof (buf.ol32),
sizeof (buf.oi32) - sizeof (buf.ol32));
/* Fill in fields using buffer contents. */
@@ -209,7 +209,7 @@ fetch_lm_info (CORE_ADDR addr)
/* Read rest of buffer. */
read_memory (addr + sizeof (buf.ol32),
- ((char *) &buf) + sizeof (buf.ol32),
+ ((gdb_byte *) &buf) + sizeof (buf.ol32),
sizeof (buf.oi64) - sizeof (buf.ol32));
/* Fill in fields using buffer contents. */
@@ -455,7 +455,7 @@ irix_current_sos (void)
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / TARGET_CHAR_BIT;
CORE_ADDR lma;
- char addr_buf[8];
+ gdb_byte addr_buf[8];
struct so_list *head = 0;
struct so_list **link_ptr = &head;
int is_first = 1;
@@ -547,7 +547,7 @@ irix_open_symbol_file_object (void *from_ttyp)
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int addr_size = gdbarch_addr_bit (target_gdbarch ()) / TARGET_CHAR_BIT;
CORE_ADDR lma;
- char addr_buf[8];
+ gdb_byte addr_buf[8];
struct lm_info lm;
struct cleanup *cleanups;
int errcode;
diff --git a/gdb/solib-som.c b/gdb/solib-som.c
index 650e3df..f88b539 100644
--- a/gdb/solib-som.c
+++ b/gdb/solib-som.c
@@ -588,7 +588,7 @@ som_current_sos (void)
struct cleanup *old_chain;
int errcode;
struct dld_list dbuf;
- char tsdbuf[4];
+ gdb_byte tsdbuf[4];
new = (struct so_list *) xmalloc (sizeof (struct so_list));
old_chain = make_cleanup (xfree, new);
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
index 43a2069..d27514f 100644
--- a/gdb/sparc-ravenscar-thread.c
+++ b/gdb/sparc-ravenscar-thread.c
@@ -64,9 +64,9 @@ supply_register_at_address (struct regcache *regcache, int regnum,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
- char *buf;
+ gdb_byte *buf;
- buf = (char *) alloca (buf_size);
+ buf = alloca (buf_size);
read_memory (register_addr, buf, buf_size);
regcache_raw_supply (regcache, regnum, buf);
}
@@ -157,7 +157,7 @@ sparc_ravenscar_store_registers (struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
- char buf [buf_size];
+ gdb_byte buf[buf_size];
ULONGEST register_address;
if (register_in_thread_descriptor_p (regnum))
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 4365da1..32c8f1e 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1748,7 +1748,7 @@ spu_get_overlay_table (struct objfile *objfile)
unsigned ovly_table_size, ovly_buf_table_size;
struct spu_overlay_table *tbl;
struct obj_section *osect;
- char *ovly_table;
+ gdb_byte *ovly_table;
int i;
tbl = objfile_data (objfile, spu_overlay_data);
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index 4c44fb9..045fc73 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -323,7 +323,7 @@ tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
/* This is the implementation of gdbarch method breakpiont_from_pc. */
-static const unsigned char*
+static const gdb_byte *
tic6x_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
int *bp_size)
{
diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h
index a168403..5fe26ae 100644
--- a/gdb/tic6x-tdep.h
+++ b/gdb/tic6x-tdep.h
@@ -47,7 +47,7 @@ struct gdbarch_tdep
instruction. */
CORE_ADDR (*syscall_next_pc) (struct frame_info *frame);
- const char *breakpoint; /* Breakpoint instruction. */
+ const gdb_byte *breakpoint; /* Breakpoint instruction. */
int has_gp; /* Has general purpose registers A16 - A31 and B16 - B31. */
};
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4113999..b89ca22 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4921,7 +4921,7 @@ tfile_fetch_registers (struct target_ops *ops,
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int offset, regn, regsize, pc_regno;
- char *regs;
+ gdb_byte *regs;
/* An uninitialized reg size says we're not going to be
successful at getting register blocks. */
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 1a2ba1d..cb551ff 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -160,13 +160,13 @@ xstormy16_use_struct_convention (struct type *type)
static void
xstormy16_extract_return_value (struct type *type, struct regcache *regcache,
- void *valbuf)
+ gdb_byte *valbuf)
{
int len = TYPE_LENGTH (type);
int i, regnum = E_1ST_ARG_REGNUM;
for (i = 0; i < len; i += xstormy16_reg_size)
- regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_read (regcache, regnum++, valbuf + i);
}
/* Function: xstormy16_store_return_value
@@ -176,7 +176,7 @@ xstormy16_extract_return_value (struct type *type, struct regcache *regcache,
static void
xstormy16_store_return_value (struct type *type, struct regcache *regcache,
- const void *valbuf)
+ const gdb_byte *valbuf)
{
if (TYPE_LENGTH (type) == 1)
{
@@ -192,7 +192,7 @@ xstormy16_store_return_value (struct type *type, struct regcache *regcache,
int i, regnum = E_1ST_ARG_REGNUM;
for (i = 0; i < len; i += xstormy16_reg_size)
- regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+ regcache_raw_write (regcache, regnum++, valbuf + i);
}
}
@@ -278,7 +278,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
wordaligned. */
for (j = nargs - 1; j >= i; j--)
{
- char *val;
+ gdb_byte *val;
struct cleanup *back_to;
const gdb_byte *bytes = value_contents (args[j]);
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 3cdb27a..1eedee7 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1154,7 +1154,7 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc)
CORE_ADDR start_addr;
xtensa_isa isa;
xtensa_insnbuf ins, slot;
- char ibuf[XTENSA_ISA_BSZ];
+ gdb_byte ibuf[XTENSA_ISA_BSZ];
CORE_ADDR ia, bt, ba;
xtensa_format ifmt;
int ilen, islots, is;
@@ -2032,7 +2032,7 @@ call0_ret (CORE_ADDR start_pc, CORE_ADDR finish_pc)
#define RETURN_RET goto done
xtensa_isa isa;
xtensa_insnbuf ins, slot;
- char ibuf[XTENSA_ISA_BSZ];
+ gdb_byte ibuf[XTENSA_ISA_BSZ];
CORE_ADDR ia, bt, ba;
xtensa_format ifmt;
int ilen, islots, is;
@@ -2390,7 +2390,7 @@ call0_analyze_prologue (struct gdbarch *gdbarch,
CORE_ADDR ia; /* Current insn address in prologue. */
CORE_ADDR ba = 0; /* Current address at base of insn buffer. */
CORE_ADDR bt; /* Current address at top+1 of insn buffer. */
- char ibuf[XTENSA_ISA_BSZ];/* Instruction buffer for decoding prologue. */
+ gdb_byte ibuf[XTENSA_ISA_BSZ];/* Instruction buffer for decoding prologue. */
xtensa_isa isa; /* libisa ISA handle. */
xtensa_insnbuf ins, slot; /* libisa handle to decoded insn, slot. */
xtensa_format ifmt; /* libisa instruction format. */
@@ -2805,7 +2805,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb)
{
xtensa_isa isa;
xtensa_insnbuf ins, slot;
- char ibuf[XTENSA_ISA_BSZ];
+ gdb_byte ibuf[XTENSA_ISA_BSZ];
CORE_ADDR ia, bt, ba;
xtensa_format ifmt;
int ilen, islots, is;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 04/26] alpha-tdep.c/mips-tdep.c: "set heuristic-fence-post" is signed/zinteger.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
2013-04-11 23:00 ` [PATCH 02/26] -Wpointer-sign: gdb_byte -> char Pedro Alves
2013-04-11 23:00 ` [PATCH 01/26] -Wpointer-sign: char -> gdb_byte Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 05/26] mep-tdep.c: Wrong signness for instruction buffer Pedro Alves
` (25 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/alpha-tdep.c | 4 ++--
gdb/mips-tdep.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index e394605..7696b42 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -1032,7 +1032,7 @@ static const struct frame_unwind alpha_sigtramp_frame_unwind = {
/* Heuristic_proc_start may hunt through the text section for a long
time across a 2400 baud serial line. Allows the user to limit this
search. */
-static unsigned int heuristic_fence_post = 0;
+static int heuristic_fence_post = 0;
/* Attempt to locate the start of the function containing PC. We assume that
the previous function ends with an about_to_return insn. Not foolproof by
@@ -1059,7 +1059,7 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
if (func)
return func;
- if (heuristic_fence_post == UINT_MAX
+ if (heuristic_fence_post == -1
|| fence < tdep->vm_min_address)
fence = tdep->vm_min_address;
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 9d9451c..8e5d5d2 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -787,7 +787,7 @@ static const signed char mips_reg3_to_reg[8] = { 16, 17, 2, 3, 4, 5, 6, 7 };
time across a 2400 baud serial line. Allows the user to limit this
search. */
-static unsigned int heuristic_fence_post = 0;
+static int heuristic_fence_post = 0;
/* Number of bytes of storage in the actual machine representation for
register N. NOTE: This defines the pseudo register type so need to
@@ -4021,7 +4021,7 @@ heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
if (start_pc == 0)
return 0;
- if (heuristic_fence_post == UINT_MAX || fence < VM_MIN_ADDRESS)
+ if (heuristic_fence_post == -1 || fence < VM_MIN_ADDRESS)
fence = VM_MIN_ADDRESS;
instlen = mips_pc_is_mips (pc) ? MIPS_INSN32_SIZE : MIPS_INSN16_SIZE;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 05/26] mep-tdep.c: Wrong signness for instruction buffer.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (2 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 04/26] alpha-tdep.c/mips-tdep.c: "set heuristic-fence-post" is signed/zinteger Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 07/26] ppc-linux-tdep.c: Wrong signness for buffer holding instructions Pedro Alves
` (24 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
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 *.
---
gdb/mep-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 3d91773..7c5f992 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -1424,7 +1424,7 @@ mep_pc_in_vliw_section (CORE_ADDR pc)
anyway. */
static CORE_ADDR
-mep_get_insn (struct gdbarch *gdbarch, CORE_ADDR pc, long *insn)
+mep_get_insn (struct gdbarch *gdbarch, CORE_ADDR pc, unsigned long *insn)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int pc_in_vliw_section;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 07/26] ppc-linux-tdep.c: Wrong signness for buffer holding instructions.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (3 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 05/26] mep-tdep.c: Wrong signness for instruction buffer Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 03/26] cris-tdep.c: Use unsigned variable for unsigned command Pedro Alves
` (23 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
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[].
---
gdb/ppc-linux-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 6895562..25b6c0b 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -355,7 +355,7 @@ powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc)
static CORE_ADDR
ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
- int insnbuf[POWERPC32_PLT_STUB_LEN];
+ unsigned int insnbuf[POWERPC32_PLT_STUB_LEN];
struct gdbarch *gdbarch = get_frame_arch (frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 03/26] cris-tdep.c: Use unsigned variable for unsigned command.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (4 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 07/26] ppc-linux-tdep.c: Wrong signness for buffer holding instructions Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 08/26] -Wpointer-sign: s390-tdep.c Pedro Alves
` (22 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
"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.
---
gdb/cris-tdep.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 2662513..03041e4 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -144,7 +144,7 @@ extern const struct cris_spec_reg cris_spec_regs[];
/* CRIS version, set via the user command 'set cris-version'. Affects
register names and sizes. */
-static int usr_cmd_cris_version;
+static unsigned int usr_cmd_cris_version;
/* Indicates whether to trust the above variable. */
static int usr_cmd_cris_version_valid = 0;
@@ -167,7 +167,7 @@ static int usr_cmd_cris_dwarf2_cfi = 1;
/* CRIS architecture specific information. */
struct gdbarch_tdep
{
- int cris_version;
+ unsigned int cris_version;
const char *cris_mode;
int cris_dwarf2_cfi;
};
@@ -1439,7 +1439,7 @@ cris_spec_reg_applicable (struct gdbarch *gdbarch,
struct cris_spec_reg spec_reg)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- int version = tdep->cris_version;
+ unsigned int version = tdep->cris_version;
switch (spec_reg.applicable_version)
{
@@ -4013,7 +4013,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch *gdbarch;
struct gdbarch_tdep *tdep;
- int cris_version;
+ unsigned int cris_version;
if (usr_cmd_cris_version_valid)
{
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 08/26] -Wpointer-sign: s390-tdep.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (5 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 03/26] cris-tdep.c: Use unsigned variable for unsigned command Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 10/26] -Wpointer-sign: xtensa-tdep.c Pedro Alves
` (21 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
-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 *.
---
gdb/s390-tdep.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 50f8877..641bc80 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -964,7 +964,7 @@ is_rre (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2)
static int
is_rs (bfd_byte *insn, int op,
- unsigned int *r1, unsigned int *r3, unsigned int *d2, unsigned int *b2)
+ unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
{
if (insn[0] == op)
{
@@ -981,7 +981,7 @@ is_rs (bfd_byte *insn, int op,
static int
is_rsy (bfd_byte *insn, int op1, int op2,
- unsigned int *r1, unsigned int *r3, unsigned int *d2, unsigned int *b2)
+ unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
{
if (insn[0] == op1
&& insn[5] == op2)
@@ -1036,7 +1036,7 @@ is_rie (bfd_byte *insn, int op1, int op2,
static int
is_rx (bfd_byte *insn, int op,
- unsigned int *r1, unsigned int *d2, unsigned int *x2, unsigned int *b2)
+ unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
{
if (insn[0] == op)
{
@@ -1053,7 +1053,7 @@ is_rx (bfd_byte *insn, int op,
static int
is_rxy (bfd_byte *insn, int op1, int op2,
- unsigned int *r1, unsigned int *d2, unsigned int *x2, unsigned int *b2)
+ unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
{
if (insn[0] == op1
&& insn[5] == op2)
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 10/26] -Wpointer-sign: xtensa-tdep.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (6 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 08/26] -Wpointer-sign: s390-tdep.c Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 06/26] mips-tdep.c: Wrong signness for local holding PC register Pedro Alves
` (20 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
../../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.
---
gdb/xtensa-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 1eedee7..d9b1a45 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -2814,7 +2814,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb)
int fail = 0;
void (*func) (struct gdbarch *, int, int, int, CORE_ADDR);
- int at, as, offset;
+ uint32_t at, as, offset;
/* WindowUnderflow12 = true, when inside _WindowUnderflow12. */
int WindowUnderflow12 = (current_pc & 0x1ff) >= 0x140;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 06/26] mips-tdep.c: Wrong signness for local holding PC register.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (7 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 10/26] -Wpointer-sign: xtensa-tdep.c Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:01 ` [PATCH 12/26] Cast result of obstack_base to gdb_byte * in a couple spots Pedro Alves
` (19 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/mips-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 8e5d5d2..245ffd6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -1245,7 +1245,7 @@ static CORE_ADDR
mips_read_pc (struct regcache *regcache)
{
int regnum = gdbarch_pc_regnum (get_regcache_arch (regcache));
- ULONGEST pc;
+ LONGEST pc;
regcache_cooked_read_signed (regcache, regnum, &pc);
if (is_compact_addr (pc))
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 12/26] Cast result of obstack_base to gdb_byte * in a couple spots.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (8 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 06/26] mips-tdep.c: Wrong signness for local holding PC register Pedro Alves
@ 2013-04-11 23:01 ` Pedro Alves
2013-04-11 23:02 ` [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer Pedro Alves
` (18 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:01 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/c-lang.c | 2 +-
gdb/linux-tdep.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 1c1d60b..46a6c73 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -658,7 +658,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
if (obstack_object_size (&output) != TYPE_LENGTH (type))
error (_("Could not convert character "
"constant to target character set"));
- value = unpack_long (type, obstack_base (&output));
+ value = unpack_long (type, (gdb_byte *) obstack_base (&output));
result = value_from_longest (type, value);
}
else
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 9623d19..bfb6404 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -993,8 +993,8 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
if (mapping_data.file_count != 0)
{
/* Write the count to the obstack. */
- pack_long (obstack_base (&data_obstack), long_type,
- mapping_data.file_count);
+ pack_long ((gdb_byte *) obstack_base (&data_obstack),
+ long_type, mapping_data.file_count);
/* Copy the filenames to the data obstack. */
obstack_grow (&data_obstack, obstack_base (&filename_obstack),
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (9 preceding siblings ...)
2013-04-11 23:01 ` [PATCH 12/26] Cast result of obstack_base to gdb_byte * in a couple spots Pedro Alves
@ 2013-04-11 23:02 ` Pedro Alves
2013-04-12 14:55 ` Pedro Alves
2013-04-11 23:02 ` [PATCH 11/26] -Wpointer-sign: alpha-tdep.c Pedro Alves
` (17 subsequent siblings)
28 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:02 UTC (permalink / raw)
To: gdb-patches
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/ser-base.c | 11 ++++++-----
gdb/ser-base.h | 2 +-
gdb/ser-go32.c | 13 +++++++------
gdb/serial.c | 16 +++++++++-------
gdb/serial.h | 6 +++---
5 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index c602650..e471247 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -440,18 +440,19 @@ ser_base_readchar (struct serial *scb, int timeout)
}
int
-ser_base_write (struct serial *scb, const char *str, int len)
+ser_base_write (struct serial *scb, const void *buf, size_t count)
{
+ const char *ucbuf = buf;
int cc;
- while (len > 0)
+ while (count > 0)
{
- cc = scb->ops->write_prim (scb, str, len);
+ cc = scb->ops->write_prim (scb, ucbuf, count);
if (cc < 0)
return 1;
- len -= cc;
- str += cc;
+ count -= cc;
+ ucbuf += cc;
}
return 0;
}
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 175bf20..e5fe9e1 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -45,7 +45,7 @@ extern int ser_base_setbaudrate (struct serial *scb, int rate);
extern int ser_base_setstopbits (struct serial *scb, int rate);
extern int ser_base_drain_output (struct serial *scb);
-extern int ser_base_write (struct serial *scb, const char *str, int len);
+extern int ser_base_write (struct serial *scb, const void *buf, size_t count);
extern void ser_base_async (struct serial *scb, int async_p);
extern int ser_base_readchar (struct serial *scb, int timeout);
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 7d76720..76a2f4f 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -230,7 +230,7 @@ static int dos_open (struct serial *scb, const char *name);
static void dos_raw (struct serial *scb);
static int dos_readchar (struct serial *scb, int timeout);
static int dos_setbaudrate (struct serial *scb, int rate);
-static int dos_write (struct serial *scb, const char *str, int len);
+static int dos_write (struct serial *scb, const void *buf, int count);
static void dos_close (struct serial *scb);
static serial_ttystate dos_get_tty_state (struct serial *scb);
static int dos_set_tty_state (struct serial *scb, serial_ttystate state);
@@ -787,26 +787,27 @@ dos_setstopbits (struct serial *scb, int num)
}
static int
-dos_write (struct serial *scb, const char *str, int len)
+dos_write (struct serial *scb, const void *buf, int count)
{
volatile struct dos_ttystate *port = &ports[scb->fd];
int fifosize = port->fifo ? 16 : 1;
long then;
int cnt;
+ const char *str = buf;
- while (len > 0)
+ while (count > 0)
{
/* Send the data, fifosize bytes at a time. */
- cnt = fifosize > len ? len : fifosize;
+ cnt = fifosize > count ? count : fifosize;
port->txbusy = 1;
/* Francisco Pastor <fpastor.etra-id@etra.es> says OUTSB messes
up the communications with UARTs with FIFOs. */
#ifdef UART_FIFO_WORKS
outportsb (port->base + com_data, str, cnt);
str += cnt;
- len -= cnt;
+ count -= cnt;
#else
- for ( ; cnt > 0; cnt--, len--)
+ for ( ; cnt > 0; cnt--, count--)
outportb (port->base + com_data, *str++);
#endif
#ifdef DOS_STATS
diff --git a/gdb/serial.c b/gdb/serial.c
index 3202b0f..ee3f1ea 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -398,14 +398,15 @@ serial_readchar (struct serial *scb, int timeout)
}
int
-serial_write (struct serial *scb, const char *str, int len)
+serial_write (struct serial *scb, const void *buf, size_t count)
{
if (serial_logfp != NULL)
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
- serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0);
+ for (c = 0; c < count; c++)
+ serial_logchar (serial_logfp, 'w', str[c] & 0xff, 0);
/* Make sure that the log file is as up-to-date as possible,
in case we are getting ready to dump core or something. */
@@ -413,9 +414,10 @@ serial_write (struct serial *scb, const char *str, int len)
}
if (serial_debug_p (scb))
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
+ for (c = 0; c < count; c++)
{
fprintf_unfiltered (gdb_stdlog, "[");
serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0);
@@ -424,7 +426,7 @@ serial_write (struct serial *scb, const char *str, int len)
gdb_flush (gdb_stdlog);
}
- return (scb->ops->write (scb, str, len));
+ return (scb->ops->write (scb, buf, count));
}
void
diff --git a/gdb/serial.h b/gdb/serial.h
index a91c8b8..7a97e28 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -104,10 +104,10 @@ enum serial_rc {
extern int serial_readchar (struct serial *scb, int timeout);
-/* Write LEN chars from STRING to the port SCB. Returns 0 for
+/* Write COUNT bytes from BUF to the port SCB. Returns 0 for
success, non-zero for failure. */
-extern int serial_write (struct serial *scb, const char *str, int len);
+extern int serial_write (struct serial *scb, const void *buf, size_t count);
/* Write a printf style string onto the serial port. */
@@ -256,7 +256,7 @@ struct serial_ops
void (*close) (struct serial *);
int (*fdopen) (struct serial *, int fd);
int (*readchar) (struct serial *, int timeout);
- int (*write) (struct serial *, const char *str, int len);
+ int (*write) (struct serial *, const void *buf, size_t count);
/* Discard pending output */
int (*flush_output) (struct serial *);
/* Discard pending input */
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer.
2013-04-11 23:02 ` [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer Pedro Alves
@ 2013-04-12 14:55 ` Pedro Alves
2013-04-19 14:23 ` Pedro Alves
0 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 14:55 UTC (permalink / raw)
To: gdb-patches
On 04/12/2013 12:00 AM, Pedro Alves wrote:
> +static int dos_write (struct serial *scb, const void *buf, int count);
> static int
> -dos_write (struct serial *scb, const char *str, int len)
> +dos_write (struct serial *scb, const void *buf, int count)
> {
Bah. Re-reading this with a fresher head, I notice I failed to
change int -> size_t here. This results in a little cascade of
updates to other variables (mainly to avoid signed/unsigned comparisons).
I've merged this into the patch:
diff --git i/gdb/ser-go32.c w/gdb/ser-go32.c
index 76a2f4f..9b321df 100644
--- i/gdb/ser-go32.c
+++ w/gdb/ser-go32.c
@@ -148,7 +148,7 @@ typedef unsigned long u_long;
#define NCNT 20
static int intrcnt;
-static int cnts[NCNT];
+static size_t cnts[NCNT];
static char *cntnames[NCNT] =
{
/* h/w interrupt counts. */
@@ -230,7 +230,7 @@ static int dos_open (struct serial *scb, const char *name);
static void dos_raw (struct serial *scb);
static int dos_readchar (struct serial *scb, int timeout);
static int dos_setbaudrate (struct serial *scb, int rate);
-static int dos_write (struct serial *scb, const void *buf, int count);
+static int dos_write (struct serial *scb, const void *buf, size_t count);
static void dos_close (struct serial *scb);
static serial_ttystate dos_get_tty_state (struct serial *scb);
static int dos_set_tty_state (struct serial *scb, serial_ttystate state);
@@ -787,12 +787,12 @@ dos_setstopbits (struct serial *scb, int num)
}
static int
-dos_write (struct serial *scb, const void *buf, int count)
+dos_write (struct serial *scb, const void *buf, size_t count)
{
volatile struct dos_ttystate *port = &ports[scb->fd];
- int fifosize = port->fifo ? 16 : 1;
+ size_t fifosize = port->fifo ? 16 : 1;
long then;
- int cnt;
+ size_t cnt;
const char *str = buf;
while (count > 0)
@@ -905,7 +905,7 @@ dos_info (char *arg, int from_tty)
printf_filtered ("\nTotal interrupts: %d\n", intrcnt);
for (i = 0; i < NCNT; i++)
if (cnts[i])
- printf_filtered ("%s:\t%d\n", cntnames[i], cnts[i]);
+ printf_filtered ("%s:\t%lu\n", cntnames[i], (unsigned long) cnts[i]);
#endif
}
New version of full patch follows. I've also updated the github branch.
---------------
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-12 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 (cnts): Change type to size_t.
(dos_write): Change prototype -- take 'void *'
buffer and size_t size. Adjust.
(dos_info): Print elements of 'cnts' as unsigned long.
* 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/ser-base.c | 9 +++++----
gdb/ser-base.h | 2 +-
gdb/ser-go32.c | 21 +++++++++++----------
gdb/serial.c | 16 +++++++++-------
gdb/serial.h | 6 +++---
5 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index c602650..52c5726 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -440,17 +440,18 @@ ser_base_readchar (struct serial *scb, int timeout)
}
int
-ser_base_write (struct serial *scb, const char *str, int len)
+ser_base_write (struct serial *scb, const void *buf, size_t count)
{
+ const char *str = buf;
int cc;
- while (len > 0)
+ while (count > 0)
{
- cc = scb->ops->write_prim (scb, str, len);
+ cc = scb->ops->write_prim (scb, str, count);
if (cc < 0)
return 1;
- len -= cc;
+ count -= cc;
str += cc;
}
return 0;
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 175bf20..e5fe9e1 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -45,7 +45,7 @@ extern int ser_base_setbaudrate (struct serial *scb, int rate);
extern int ser_base_setstopbits (struct serial *scb, int rate);
extern int ser_base_drain_output (struct serial *scb);
-extern int ser_base_write (struct serial *scb, const char *str, int len);
+extern int ser_base_write (struct serial *scb, const void *buf, size_t count);
extern void ser_base_async (struct serial *scb, int async_p);
extern int ser_base_readchar (struct serial *scb, int timeout);
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 7d76720..9b321df 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -148,7 +148,7 @@ typedef unsigned long u_long;
#define NCNT 20
static int intrcnt;
-static int cnts[NCNT];
+static size_t cnts[NCNT];
static char *cntnames[NCNT] =
{
/* h/w interrupt counts. */
@@ -230,7 +230,7 @@ static int dos_open (struct serial *scb, const char *name);
static void dos_raw (struct serial *scb);
static int dos_readchar (struct serial *scb, int timeout);
static int dos_setbaudrate (struct serial *scb, int rate);
-static int dos_write (struct serial *scb, const char *str, int len);
+static int dos_write (struct serial *scb, const void *buf, size_t count);
static void dos_close (struct serial *scb);
static serial_ttystate dos_get_tty_state (struct serial *scb);
static int dos_set_tty_state (struct serial *scb, serial_ttystate state);
@@ -787,26 +787,27 @@ dos_setstopbits (struct serial *scb, int num)
}
static int
-dos_write (struct serial *scb, const char *str, int len)
+dos_write (struct serial *scb, const void *buf, size_t count)
{
volatile struct dos_ttystate *port = &ports[scb->fd];
- int fifosize = port->fifo ? 16 : 1;
+ size_t fifosize = port->fifo ? 16 : 1;
long then;
- int cnt;
+ size_t cnt;
+ const char *str = buf;
- while (len > 0)
+ while (count > 0)
{
/* Send the data, fifosize bytes at a time. */
- cnt = fifosize > len ? len : fifosize;
+ cnt = fifosize > count ? count : fifosize;
port->txbusy = 1;
/* Francisco Pastor <fpastor.etra-id@etra.es> says OUTSB messes
up the communications with UARTs with FIFOs. */
#ifdef UART_FIFO_WORKS
outportsb (port->base + com_data, str, cnt);
str += cnt;
- len -= cnt;
+ count -= cnt;
#else
- for ( ; cnt > 0; cnt--, len--)
+ for ( ; cnt > 0; cnt--, count--)
outportb (port->base + com_data, *str++);
#endif
#ifdef DOS_STATS
@@ -904,7 +905,7 @@ dos_info (char *arg, int from_tty)
printf_filtered ("\nTotal interrupts: %d\n", intrcnt);
for (i = 0; i < NCNT; i++)
if (cnts[i])
- printf_filtered ("%s:\t%d\n", cntnames[i], cnts[i]);
+ printf_filtered ("%s:\t%lu\n", cntnames[i], (unsigned long) cnts[i]);
#endif
}
diff --git a/gdb/serial.c b/gdb/serial.c
index 3202b0f..ee3f1ea 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -398,14 +398,15 @@ serial_readchar (struct serial *scb, int timeout)
}
int
-serial_write (struct serial *scb, const char *str, int len)
+serial_write (struct serial *scb, const void *buf, size_t count)
{
if (serial_logfp != NULL)
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
- serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0);
+ for (c = 0; c < count; c++)
+ serial_logchar (serial_logfp, 'w', str[c] & 0xff, 0);
/* Make sure that the log file is as up-to-date as possible,
in case we are getting ready to dump core or something. */
@@ -413,9 +414,10 @@ serial_write (struct serial *scb, const char *str, int len)
}
if (serial_debug_p (scb))
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
+ for (c = 0; c < count; c++)
{
fprintf_unfiltered (gdb_stdlog, "[");
serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0);
@@ -424,7 +426,7 @@ serial_write (struct serial *scb, const char *str, int len)
gdb_flush (gdb_stdlog);
}
- return (scb->ops->write (scb, str, len));
+ return (scb->ops->write (scb, buf, count));
}
void
diff --git a/gdb/serial.h b/gdb/serial.h
index a91c8b8..7a97e28 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -104,10 +104,10 @@ enum serial_rc {
extern int serial_readchar (struct serial *scb, int timeout);
-/* Write LEN chars from STRING to the port SCB. Returns 0 for
+/* Write COUNT bytes from BUF to the port SCB. Returns 0 for
success, non-zero for failure. */
-extern int serial_write (struct serial *scb, const char *str, int len);
+extern int serial_write (struct serial *scb, const void *buf, size_t count);
/* Write a printf style string onto the serial port. */
@@ -256,7 +256,7 @@ struct serial_ops
void (*close) (struct serial *);
int (*fdopen) (struct serial *, int fd);
int (*readchar) (struct serial *, int timeout);
- int (*write) (struct serial *, const char *str, int len);
+ int (*write) (struct serial *, const void *buf, size_t count);
/* Discard pending output */
int (*flush_output) (struct serial *);
/* Discard pending input */
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer.
2013-04-12 14:55 ` Pedro Alves
@ 2013-04-19 14:23 ` Pedro Alves
2013-04-19 14:28 ` Eli Zaretskii
0 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-19 14:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Eli, this patch touches ser-go32.c. Is it OK?
Most recent version here:
http://sourceware.org/ml/gdb-patches/2013-04/msg00364.html
I've now installed a cross djgpp toolchain (gcc 4.7.2) on my Fedora 17
machine (*), and verified this causes no build regressions. I stumbled
on a couple unrelated preexisting issues I had to hack around, but GDB
built. Moreover, djgpp is -Wpointer-sign clean too with the whole
series applied.
(*) - ftp://ftp.delorie.com/pub/djgpp/rpms/
--
Pedro Alves
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer.
2013-04-19 14:23 ` Pedro Alves
@ 2013-04-19 14:28 ` Eli Zaretskii
2013-04-19 14:28 ` Pedro Alves
0 siblings, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2013-04-19 14:28 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> Date: Thu, 18 Apr 2013 12:09:17 +0100
> From: Pedro Alves <palves@redhat.com>
> CC: gdb-patches@sourceware.org
>
> Eli, this patch touches ser-go32.c. Is it OK?
>
> Most recent version here:
>
> http://sourceware.org/ml/gdb-patches/2013-04/msg00364.html
Oops, sorry. I've seen this at the time, but didn't realize I needed
to approve it.
Yes, OK, please go ahead.
> I've now installed a cross djgpp toolchain (gcc 4.7.2) on my Fedora 17
> machine (*), and verified this causes no build regressions. I stumbled
> on a couple unrelated preexisting issues I had to hack around, but GDB
> built. Moreover, djgpp is -Wpointer-sign clean too with the whole
> series applied.
Thanks.
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 11/26] -Wpointer-sign: alpha-tdep.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (10 preceding siblings ...)
2013-04-11 23:02 ` [PATCH 13/26] serial_write: change prototype to take a void-pointer buffer Pedro Alves
@ 2013-04-11 23:02 ` Pedro Alves
2013-04-11 23:20 ` [PATCH 14/26] gdb_byte for binary buffer, char for string: remote.c, tracepoint.c Pedro Alves
` (16 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:02 UTC (permalink / raw)
To: gdb-patches
../../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'.
---
gdb/alpha-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 7696b42..a8b90b9 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -517,7 +517,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
break;
case 32:
- regcache_cooked_read_signed (regcache, ALPHA_V0_REGNUM, &l);
+ regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
read_memory (l, valbuf, 32);
break;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 14/26] gdb_byte for binary buffer, char for string: remote.c, tracepoint.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (11 preceding siblings ...)
2013-04-11 23:02 ` [PATCH 11/26] -Wpointer-sign: alpha-tdep.c Pedro Alves
@ 2013-04-11 23:20 ` Pedro Alves
2013-04-11 23:23 ` [PATCH 15/26] gdb_byte for binary buffer, char for string: common/agent.c Pedro Alves
` (15 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:20 UTC (permalink / raw)
To: gdb-patches
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/remote.c | 29 +++++++++++++++--------------
gdb/tracepoint.c | 17 +++++++++--------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 39ce116..1c3af57 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6744,8 +6744,8 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
/* Binary mode. Send target system values byte by byte, in
increasing byte addresses. Only escape certain critical
characters. */
- payload_length = remote_escape_output (myaddr, todo, p, &nr_bytes,
- payload_size);
+ payload_length = remote_escape_output (myaddr, todo, (gdb_byte *) p,
+ &nr_bytes, payload_size);
/* If not all TODO bytes fit, then we'll need another packet. Make
a second try to keep the end of the packet aligned. Don't do
@@ -6758,7 +6758,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
- memaddr);
if (new_nr_bytes != nr_bytes)
payload_length = remote_escape_output (myaddr, new_nr_bytes,
- p, &nr_bytes,
+ (gdb_byte *) p, &nr_bytes,
payload_size);
}
@@ -8576,7 +8576,7 @@ remote_write_qxfer (struct target_ops *ops, const char *object_name,
/* Escape as much data as fits into rs->buf. */
buf_len = remote_escape_output
- (writebuf, len, (rs->buf + i), &max_size, max_size);
+ (writebuf, len, (gdb_byte *) rs->buf + i, &max_size, max_size);
if (putpkt_binary (rs->buf, i + buf_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
@@ -8655,7 +8655,8 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
error (_("Remote qXfer reply contained no data."));
/* Got some data. */
- i = remote_unescape_input (rs->buf + 1, packet_len - 1, readbuf, n);
+ i = remote_unescape_input ((gdb_byte *) rs->buf + 1,
+ packet_len - 1, readbuf, n);
/* 'l' is an EOF marker, possibly including a final block of data,
or possibly empty. If we have the final block of a non-empty
@@ -8936,7 +8937,7 @@ remote_search_memory (struct target_ops* ops,
/* Escape as much data as fits into rs->buf. */
escaped_pattern_len =
- remote_escape_output (pattern, pattern_len, (rs->buf + i),
+ remote_escape_output (pattern, pattern_len, (gdb_byte *) rs->buf + i,
&used_pattern_len, max_size);
/* Bail if the pattern is too large. */
@@ -9710,7 +9711,7 @@ remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
remote_buffer_add_int (&p, &left, offset);
remote_buffer_add_string (&p, &left, ",");
- p += remote_escape_output (write_buf, len, p, &out_len,
+ p += remote_escape_output (write_buf, len, (gdb_byte *) p, &out_len,
get_remote_packet_size () - (p - rs->buf));
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_pwrite,
@@ -9749,7 +9750,7 @@ remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
if (ret < 0)
return ret;
- read_len = remote_unescape_input (attachment, attachment_len,
+ read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
read_buf, len);
if (read_len != ret)
error (_("Read returned %d, but %d bytes."), ret, (int) read_len);
@@ -9823,8 +9824,8 @@ remote_hostio_readlink (const char *filename, int *remote_errno)
ret = xmalloc (len + 1);
- read_len = remote_unescape_input (attachment, attachment_len,
- ret, len);
+ read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
+ (gdb_byte *) ret, len);
if (read_len != len)
error (_("Readlink returned %d, but %d bytes."), len, read_len);
@@ -9952,7 +9953,7 @@ remote_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
pos = 0;
while (nbytes > pos)
{
- bytes = remote_hostio_pread (fd, (char *)buf + pos, nbytes - pos,
+ bytes = remote_hostio_pread (fd, (gdb_byte *) buf + pos, nbytes - pos,
offset + pos, &remote_errno);
if (bytes == 0)
/* Success, but no bytes, means end-of-file. */
@@ -11135,21 +11136,21 @@ remote_set_trace_notes (char *user, char *notes, char *stop_notes)
if (user)
{
buf += xsnprintf (buf, endbuf - buf, "user:");
- nbytes = bin2hex (user, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) user, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}
if (notes)
{
buf += xsnprintf (buf, endbuf - buf, "notes:");
- nbytes = bin2hex (notes, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) notes, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}
if (stop_notes)
{
buf += xsnprintf (buf, endbuf - buf, "tstop:");
- nbytes = bin2hex (stop_notes, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) stop_notes, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index b89ca22..212fe59 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3000,7 +3000,7 @@ encode_source_string (int tpnum, ULONGEST addr,
srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
- bin2hex (src, buf + strlen (buf), 0);
+ bin2hex ((gdb_byte *) src, buf + strlen (buf), 0);
return -1;
}
@@ -3190,7 +3190,7 @@ tfile_write_uploaded_tp (struct trace_file_writer *self,
= (struct tfile_trace_file_writer *) self;
int a;
char *act;
- gdb_byte buf[MAX_TRACE_UPLOAD];
+ char buf[MAX_TRACE_UPLOAD];
fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
@@ -3322,6 +3322,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
ULONGEST offset = 0;
gdb_byte buf[MAX_TRACE_UPLOAD];
+#define MAX_TRACE_UPLOAD 2000
int written;
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
@@ -4175,7 +4176,7 @@ tfile_open (char *filename, int from_tty)
int scratch_chan;
char header[TRACE_HEADER_SIZE];
char linebuf[1000]; /* Should be max remote packet size or so. */
- char byte;
+ gdb_byte byte;
int bytes, i;
struct trace_status *ts;
struct uploaded_tp *uploaded_tps = NULL;
@@ -4387,7 +4388,7 @@ Status line: '%s'\n"), p, line);
else if (p2 != p1)
{
ts->stop_desc = xmalloc (strlen (line));
- end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
ts->stop_desc[end] = '\0';
}
else
@@ -4407,7 +4408,7 @@ Status line: '%s'\n"), p, line);
if (p2 != p1)
{
ts->stop_desc = xmalloc ((p2 - p1) / 2 + 1);
- end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
ts->stop_desc[end] = '\0';
}
else
@@ -4461,7 +4462,7 @@ Status line: '%s'\n"), p, line);
{
++p1;
ts->user_name = xmalloc (strlen (p) / 2);
- end = hex2bin (p1, ts->user_name, (p3 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->user_name, (p3 - p1) / 2);
ts->user_name[end] = '\0';
p = p3;
}
@@ -4469,7 +4470,7 @@ Status line: '%s'\n"), p, line);
{
++p1;
ts->notes = xmalloc (strlen (p) / 2);
- end = hex2bin (p1, ts->notes, (p3 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->notes, (p3 - p1) / 2);
ts->notes[end] = '\0';
p = p3;
}
@@ -4865,7 +4866,7 @@ traceframe_walk_blocks (walk_blocks_callback_func callback,
unsigned short mlen;
char block_type;
- tfile_read (&block_type, 1);
+ tfile_read ((gdb_byte *) &block_type, 1);
++pos;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 15/26] gdb_byte for binary buffer, char for string: common/agent.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (12 preceding siblings ...)
2013-04-11 23:20 ` [PATCH 14/26] gdb_byte for binary buffer, char for string: remote.c, tracepoint.c Pedro Alves
@ 2013-04-11 23:23 ` Pedro Alves
2013-04-12 2:30 ` [PATCH 16/26] -Wpointer-sign: remote-mips.c Pedro Alves
` (14 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-11 23:23 UTC (permalink / raw)
To: gdb-patches
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 *.
---
gdb/common/agent.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
index 632310d..f7bedc2 100644
--- a/gdb/common/agent.c
+++ b/gdb/common/agent.c
@@ -218,7 +218,8 @@ agent_run_command (int pid, const char *cmd, int len)
int ret = write_inferior_memory (ipa_sym_addrs.addr_cmd_buf,
(const unsigned char *) cmd, len);
#else
- int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf, cmd, len);
+ int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
+ (gdb_byte *) cmd, len);
#endif
if (ret != 0)
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 16/26] -Wpointer-sign: remote-mips.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (13 preceding siblings ...)
2013-04-11 23:23 ` [PATCH 15/26] gdb_byte for binary buffer, char for string: common/agent.c Pedro Alves
@ 2013-04-12 2:30 ` Pedro Alves
2013-04-12 2:32 ` [PATCH 17/26] -Wpointer-sign: python/ Pedro Alves
` (13 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 2:30 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/remote-mips.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 85002ec..3b65b59 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -63,7 +63,7 @@ static int mips_receive_trailer (unsigned char *trlr, int *pgarbage,
int *pch, int timeout);
static int mips_cksum (const unsigned char *hdr,
- const unsigned char *data, int len);
+ const char *data, int len);
static void mips_send_packet (const char *s, int get_ack);
@@ -108,12 +108,12 @@ static void mips_files_info (struct target_ops *ignore);
static void mips_mourn_inferior (struct target_ops *ops);
-static int pmon_makeb64 (unsigned long v, char *p, int n, int *chksum);
+static int pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum);
-static int pmon_zeroset (int recsize, char **buff, int *amount,
+static int pmon_zeroset (int recsize, char **buff, unsigned int *amount,
unsigned int *chksum);
-static int pmon_checkset (int recsize, char **buff, int *value);
+static int pmon_checkset (int recsize, char **buff, unsigned int *value);
static void pmon_make_fastrec (char **outbuf, unsigned char *inbuf,
int *inptr, int inamount, int *recsize,
@@ -824,12 +824,13 @@ mips_receive_trailer (unsigned char *trlr, int *pgarbage,
}
/* Get the checksum of a packet. HDR points to the packet header.
- DATA points to the packet data. LEN is the length of DATA. */
+ DATASTR points to the packet data. LEN is the length of DATASTR. */
static int
-mips_cksum (const unsigned char *hdr, const unsigned char *data, int len)
+mips_cksum (const unsigned char *hdr, const char *datastr, int len)
{
const unsigned char *p;
+ const unsigned char *data = (const unsigned char *) datastr;
int c;
int cksum;
@@ -872,7 +873,7 @@ mips_send_packet (const char *s, int get_ack)
memcpy (packet + HDR_LENGTH, s, len);
- cksum = mips_cksum (packet, packet + HDR_LENGTH, len);
+ cksum = mips_cksum (packet, (char *) packet + HDR_LENGTH, len);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
packet[HDR_LENGTH + len + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
@@ -976,8 +977,7 @@ mips_send_packet (const char *s, int get_ack)
/* If the checksum does not match the trailer checksum, this
is a bad packet; ignore it. */
- if (mips_cksum (hdr, (unsigned char *) NULL, 0)
- != TRLR_GET_CKSUM (trlr))
+ if (mips_cksum (hdr, NULL, 0) != TRLR_GET_CKSUM (trlr))
continue;
if (remote_debug > 0)
@@ -1142,7 +1142,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
- cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
+ cksum = mips_cksum (ack, NULL, 0);
ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@@ -1183,7 +1183,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
- cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
+ cksum = mips_cksum (ack, NULL, 0);
ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@@ -2781,7 +2781,8 @@ mips_load_srec (char *args)
{
bfd *abfd;
asection *s;
- char *buffer, srec[1024];
+ char srec[1024];
+ bfd_byte *buffer;
unsigned int i;
unsigned int srec_frame = 200;
int reclen;
@@ -2974,7 +2975,7 @@ static char encoding[] =
characters written into the buffer. */
static int
-pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
+pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum)
{
int count = (n / 6);
@@ -3022,7 +3023,8 @@ pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
escape sequence into the data stream. */
static int
-pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
+pmon_zeroset (int recsize, char **buff,
+ unsigned int *amount, unsigned int *chksum)
{
int count;
@@ -3048,7 +3050,7 @@ pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
the record elements added by this call. */
static int
-pmon_checkset (int recsize, char **buff, int *value)
+pmon_checkset (int recsize, char **buff, unsigned int *value)
{
int count;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 17/26] -Wpointer-sign: python/.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (14 preceding siblings ...)
2013-04-12 2:30 ` [PATCH 16/26] -Wpointer-sign: remote-mips.c Pedro Alves
@ 2013-04-12 2:32 ` Pedro Alves
2013-04-12 20:56 ` Tom Tromey
2013-04-12 6:55 ` [PATCH 18/26] -Wpointer-sign: bookmarks Pedro Alves
` (12 subsequent siblings)
28 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 2:32 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/python/py-inferior.c | 2 +-
gdb/python/py-prettyprint.c | 10 +++++-----
gdb/python/py-value.c | 3 ++-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 9c84904..4af7131 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -513,7 +513,7 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
error = 1;
break;
}
- write_memory_with_notification (addr, buffer, length);
+ write_memory_with_notification (addr, (gdb_byte *) buffer, length);
}
#ifdef IS_PY3K
PyBuffer_Release (&pybuf);
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index dbf6c22..b50e757 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -343,13 +343,13 @@ print_string_repr (PyObject *printer, const char *hint,
string = python_string_to_target_python_string (py_str);
if (string)
{
- gdb_byte *output;
+ char *output;
long length;
struct type *type;
make_cleanup_py_decref (string);
#ifdef IS_PY3K
- output = (gdb_byte *) PyBytes_AS_STRING (string);
+ output = PyBytes_AS_STRING (string);
length = PyBytes_GET_SIZE (string);
#else
output = PyString_AsString (string);
@@ -358,8 +358,8 @@ print_string_repr (PyObject *printer, const char *hint,
type = builtin_type (gdbarch)->builtin_char;
if (hint && !strcmp (hint, "string"))
- LA_PRINT_STRING (stream, type, output, length, NULL,
- 0, options);
+ LA_PRINT_STRING (stream, type, (gdb_byte *) output,
+ length, NULL, 0, options);
else
fputs_filtered (output, stream);
}
@@ -634,7 +634,7 @@ print_children (PyObject *printer, const char *hint,
}
else if (gdbpy_is_string (py_v))
{
- gdb_byte *output;
+ char *output;
output = python_string_to_host_string (py_v);
if (!output)
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 11cc038..2cbb0cb 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -421,7 +421,8 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
GDB_PY_HANDLE_EXCEPTION (except);
encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding;
- unicode = PyUnicode_Decode (buffer, length * TYPE_LENGTH (char_type),
+ unicode = PyUnicode_Decode ((const char *) buffer,
+ length * TYPE_LENGTH (char_type),
encoding, errors);
xfree (buffer);
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 18/26] -Wpointer-sign: bookmarks.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (15 preceding siblings ...)
2013-04-12 2:32 ` [PATCH 17/26] -Wpointer-sign: python/ Pedro Alves
@ 2013-04-12 6:55 ` Pedro Alves
2013-04-12 8:58 ` [PATCH 19/26] -Wpointer-sign: coff-pe-read.c: treat strings in PE/COFF data as char * Pedro Alves
` (11 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 6:55 UTC (permalink / raw)
To: gdb-patches
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 *.
---
gdb/record-full.c | 10 ++++++----
gdb/reverse.c | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 03d287d..aa3ad85 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1844,7 +1844,7 @@ record_full_can_execute_reverse (void)
static gdb_byte *
record_full_get_bookmark (char *args, int from_tty)
{
- gdb_byte *ret = NULL;
+ char *ret = NULL;
/* Return stringified form of instruction count. */
if (record_full_list && record_full_list->type == record_full_end)
@@ -1859,14 +1859,16 @@ record_full_get_bookmark (char *args, int from_tty)
fprintf_unfiltered (gdb_stdlog,
"record_full_get_bookmark returns NULL\n");
}
- return ret;
+ return (gdb_byte *) ret;
}
/* "to_goto_bookmark" method for process record and prec over core. */
static void
-record_full_goto_bookmark (gdb_byte *bookmark, int from_tty)
+record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty)
{
+ char *bookmark = (char *) raw_bookmark;
+
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
"record_full_goto_bookmark receives %s\n", bookmark);
@@ -1883,7 +1885,7 @@ record_full_goto_bookmark (gdb_byte *bookmark, int from_tty)
/* Pass along to cmd_record_full_goto. */
}
- cmd_record_goto ((char *) bookmark, from_tty);
+ cmd_record_goto (bookmark, from_tty);
return;
}
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 171c53c..c0d7058 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -259,7 +259,7 @@ goto_bookmark_command (char *args, int from_tty)
|| strncmp (args, "end", strlen ("end")) == 0)
{
/* Special case. Give target opportunity to handle. */
- target_goto_bookmark (args, from_tty);
+ target_goto_bookmark ((gdb_byte *) args, from_tty);
return;
}
@@ -268,7 +268,7 @@ goto_bookmark_command (char *args, int from_tty)
/* Special case -- quoted string. Pass on to target. */
if (args[strlen (args) - 1] != args[0])
error (_("Unbalanced quotes: %s"), args);
- target_goto_bookmark (args, from_tty);
+ target_goto_bookmark ((gdb_byte *) args, from_tty);
return;
}
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 19/26] -Wpointer-sign: coff-pe-read.c: treat strings in PE/COFF data as char *.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (16 preceding siblings ...)
2013-04-12 6:55 ` [PATCH 18/26] -Wpointer-sign: bookmarks Pedro Alves
@ 2013-04-12 8:58 ` Pedro Alves
2013-04-12 9:06 ` [PATCH 20/26] -Wpointer-sign: xcoffread.c Pedro Alves
` (10 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 8:58 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/coff-pe-read.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 8961c78..91ee3f6 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -505,7 +505,7 @@ read_pe_exported_syms (struct objfile *objfile)
exp_funcbase = pe_as32 (expdata + 28);
/* Use internal dll name instead of full pathname. */
- dll_name = pe_as32 (expdata + 12) + erva;
+ dll_name = (char *) (pe_as32 (expdata + 12) + erva);
pe_sections_info.nb_sections = otherix;
pe_sections_info.sections = section_data;
@@ -579,9 +579,10 @@ read_pe_exported_syms (struct objfile *objfile)
if ((func_rva >= section_data[sectix].rva_start)
&& (func_rva < section_data[sectix].rva_end))
{
+ char *sym_name = (char *) (erva + name_rva);
+
section_found = 1;
- add_pe_exported_sym (erva + name_rva,
- func_rva, ordinal,
+ add_pe_exported_sym (sym_name, func_rva, ordinal,
section_data + sectix, dll_name, objfile);
++nbnormal;
break;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 20/26] -Wpointer-sign: xcoffread.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (17 preceding siblings ...)
2013-04-12 8:58 ` [PATCH 19/26] -Wpointer-sign: coff-pe-read.c: treat strings in PE/COFF data as char * Pedro Alves
@ 2013-04-12 9:06 ` Pedro Alves
2013-04-12 9:32 ` [PATCH 21/26] -Wpointer-sign: dwarf2read.c Pedro Alves
` (9 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 9:06 UTC (permalink / raw)
To: gdb-patches
../../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 *'.
---
gdb/xcoffread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 6013551..2b5f9b7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2979,7 +2979,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
}
}
}
- info->debugsec = debugsec;
+ info->debugsec = (char *) debugsec;
}
}
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 21/26] -Wpointer-sign: dwarf2read.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (18 preceding siblings ...)
2013-04-12 9:06 ` [PATCH 20/26] -Wpointer-sign: xcoffread.c Pedro Alves
@ 2013-04-12 9:32 ` Pedro Alves
2013-04-12 21:01 ` Tom Tromey
2013-04-12 9:54 ` [PATCH 22/26] -Wpointer-sign: dwarf2-frame.c: Pass unsigned variable to safe_read_uleb128 Pedro Alves
` (8 subsequent siblings)
28 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 9:32 UTC (permalink / raw)
To: gdb-patches
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 *'.
---
gdb/dwarf2read.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 25dcfc9..3ed00cc 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2093,7 +2093,7 @@ dwarf2_get_dwz_file (void)
bfd_errmsg (bfd_get_error ()));
cleanup = make_cleanup (xfree, data);
- filename = data;
+ filename = (const char *) data;
if (!IS_ABSOLUTE_PATH (filename))
{
char *abs = gdb_realpath (dwarf2_per_objfile->objfile->name);
@@ -2754,7 +2754,7 @@ to use the section anyway."),
/ (2 * sizeof (offset_type)));
++i;
- map->constant_pool = addr + MAYBE_SWAP (metadata[i]);
+ map->constant_pool = (char *) (addr + MAYBE_SWAP (metadata[i]));
return 1;
}
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 21/26] -Wpointer-sign: dwarf2read.c.
2013-04-12 9:32 ` [PATCH 21/26] -Wpointer-sign: dwarf2read.c Pedro Alves
@ 2013-04-12 21:01 ` Tom Tromey
0 siblings, 0 replies; 39+ messages in thread
From: Tom Tromey @ 2013-04-12 21:01 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> This fixes the remaining issues necessary to make the DWARF reader
Pedro> -Wpointer-sign clean. The 'filename' bit should be obvious.
Pedro> 'constant_pool' holds the contents of an obstack, which are 'char *'.
Pedro> gdb_byte would work too, but it'd need more casts elsewhere, so I just
Pedro> chose the minimal approach. Any way would be fine with me.
I think this is fine.
Tom
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 22/26] -Wpointer-sign: dwarf2-frame.c: Pass unsigned variable to safe_read_uleb128.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (19 preceding siblings ...)
2013-04-12 9:32 ` [PATCH 21/26] -Wpointer-sign: dwarf2read.c Pedro Alves
@ 2013-04-12 9:54 ` Pedro Alves
2013-04-12 10:01 ` [PATCH 23/26] -Wpointer-sign: ada-lang.c, ada-tasks.c Pedro Alves
` (7 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 9:54 UTC (permalink / raw)
To: gdb-patches
The 'bytes_read' change should be obvious. As for the other hunk,
we're passing the address of the signed 'offset' to safe_read_uleb128,
which expects unsigned. Fix it by passing the address of the unsigned
'utmp' instead, like already done on other spots in the file.
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (execute_cfa_program): Make 'bytes_read' local
unsigned. Pass 'tmp' to safe_read_uleb128 instead of the signed
'offset', and adjust.
---
gdb/dwarf2-frame.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index ec4edfa..9ec0d2f 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -410,7 +410,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
CORE_ADDR pc, struct dwarf2_frame_state *fs)
{
int eh_frame_p = fde->eh_frame_p;
- int bytes_read;
+ unsigned int bytes_read;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
while (insn_ptr < insn_end && fs->pc <= pc)
@@ -672,8 +672,8 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"),
case DW_CFA_GNU_negative_offset_extended:
insn_ptr = safe_read_uleb128 (insn_ptr, insn_end, ®);
reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
- insn_ptr = safe_read_uleb128 (insn_ptr, insn_end, &offset);
- offset *= fs->data_align;
+ insn_ptr = safe_read_uleb128 (insn_ptr, insn_end, &utmp);
+ offset = utmp * fs->data_align;
dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = -offset;
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 23/26] -Wpointer-sign: ada-lang.c, ada-tasks.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (20 preceding siblings ...)
2013-04-12 9:54 ` [PATCH 22/26] -Wpointer-sign: dwarf2-frame.c: Pass unsigned variable to safe_read_uleb128 Pedro Alves
@ 2013-04-12 10:01 ` Pedro Alves
2013-04-12 10:11 ` [PATCH 24/26] -Wpointer-sign: cp-valprint.c Pedro Alves
` (6 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 10:01 UTC (permalink / raw)
To: gdb-patches
We're reading strings using the target memory access routines, which
work with raw bytes, so we need a couple casts.
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* ada-lang.c (print_it_exception): Add cast to gdb_byte *.
* ada-tasks.c (read_fat_string_value): Likewise.
---
gdb/ada-lang.c | 3 ++-
gdb/ada-tasks.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4d07d4d..fdfc0b4 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11532,7 +11532,8 @@ print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
if (addr != 0)
{
- read_memory (addr, exception_name, sizeof (exception_name) - 1);
+ read_memory (addr, (gdb_byte *) exception_name,
+ sizeof (exception_name) - 1);
exception_name [sizeof (exception_name) - 1] = '\0';
}
else
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index b0835f6..c5c7491 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -433,7 +433,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
/* Extract LEN characters from the fat string. */
array_val = value_ind (value_field (val, array_fieldno));
- read_memory (value_address (array_val), dest, len);
+ read_memory (value_address (array_val), (gdb_byte *) dest, len);
/* Add the NUL character to close the string. */
dest[len] = '\0';
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 24/26] -Wpointer-sign: cp-valprint.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (21 preceding siblings ...)
2013-04-12 10:01 ` [PATCH 23/26] -Wpointer-sign: ada-lang.c, ada-tasks.c Pedro Alves
@ 2013-04-12 10:11 ` Pedro Alves
2013-04-12 10:18 ` [PATCH 25/26] -Wpointer-sign: ctf.c Pedro Alves
` (5 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 10:11 UTC (permalink / raw)
To: gdb-patches
Fix:
../../src/gdb/cp-valprint.c: In function âcp_print_class_memberâ:
../../src/gdb/cp-valprint.c:793:3: error: pointer targets in passing argument 2 of âcp_find_class_memberâ differ in signedness [-Werror=pointer-sign]
../../src/gdb/cp-valprint.c:721:1: note: expected âint *â but argument is of type âunsigned int *â
'fieldno' is used throughout as 'int', so just follow the trend.
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* cp-valprint.c (cp_print_class_member): Change type of 'fieldno'
local to int.
---
gdb/cp-valprint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 9a8b4d3..0871848 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -768,7 +768,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type,
print it. */
struct type *domain = TYPE_DOMAIN_TYPE (type);
LONGEST val;
- unsigned int fieldno;
+ int fieldno;
val = extract_signed_integer (valaddr,
TYPE_LENGTH (type),
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 25/26] -Wpointer-sign: ctf.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (22 preceding siblings ...)
2013-04-12 10:11 ` [PATCH 24/26] -Wpointer-sign: cp-valprint.c Pedro Alves
@ 2013-04-12 10:18 ` Pedro Alves
2013-04-12 10:39 ` [PATCH 26/26] -Wpointer-sign: record.c Pedro Alves
` (4 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 10:18 UTC (permalink / raw)
To: gdb-patches
ctf_save_write's second parameter is gdb_byte *, and all these
arguments are 'char *'. Since this function is ultimately just
writing host bytes to a local file with fwrite, an alternative would
be to change ctf_save_write to take a 'void *' instead of 'gdb_byte
*', thus removing the need for any cast (we have more calls with casts
than without).
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* ctf.c (ctf_write_uploaded_tsv, ctf_write_uploaded_tp): Add casts
to 'gdb_byte *'.
---
gdb/ctf.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 0985784..ce0a318 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -528,7 +528,8 @@ ctf_write_uploaded_tsv (struct trace_file_writer *self,
/* name */
if (tsv->name != NULL)
- ctf_save_write (&writer->tcs, tsv->name, strlen (tsv->name));
+ ctf_save_write (&writer->tcs, (gdb_byte *) tsv->name,
+ strlen (tsv->name));
ctf_save_write (&writer->tcs, &zero, 1);
}
@@ -580,30 +581,30 @@ ctf_write_uploaded_tp (struct trace_file_writer *self,
/* condition */
if (tp->cond != NULL)
- ctf_save_write (&writer->tcs, tp->cond, strlen (tp->cond));
+ ctf_save_write (&writer->tcs, (gdb_byte *) tp->cond, strlen (tp->cond));
ctf_save_write (&writer->tcs, &zero, 1);
/* actions */
u32 = VEC_length (char_ptr, tp->actions);
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
for (a = 0; VEC_iterate (char_ptr, tp->actions, a, act); ++a)
- ctf_save_write (&writer->tcs, act, strlen (act) + 1);
+ ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
/* step_actions */
u32 = VEC_length (char_ptr, tp->step_actions);
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
for (a = 0; VEC_iterate (char_ptr, tp->step_actions, a, act); ++a)
- ctf_save_write (&writer->tcs, act, strlen (act) + 1);
+ ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
/* at_string */
if (tp->at_string != NULL)
- ctf_save_write (&writer->tcs, tp->at_string,
+ ctf_save_write (&writer->tcs, (gdb_byte *) tp->at_string,
strlen (tp->at_string));
ctf_save_write (&writer->tcs, &zero, 1);
/* cond_string */
if (tp->cond_string != NULL)
- ctf_save_write (&writer->tcs, tp->cond_string,
+ ctf_save_write (&writer->tcs, (gdb_byte *) tp->cond_string,
strlen (tp->cond_string));
ctf_save_write (&writer->tcs, &zero, 1);
@@ -611,7 +612,7 @@ ctf_write_uploaded_tp (struct trace_file_writer *self,
u32 = VEC_length (char_ptr, tp->cmd_strings);
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
for (a = 0; VEC_iterate (char_ptr, tp->cmd_strings, a, act); ++a)
- ctf_save_write (&writer->tcs, act, strlen (act) + 1);
+ ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
}
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 26/26] -Wpointer-sign: record.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (23 preceding siblings ...)
2013-04-12 10:18 ` [PATCH 25/26] -Wpointer-sign: ctf.c Pedro Alves
@ 2013-04-12 10:39 ` Pedro Alves
2013-04-12 11:34 ` [PATCH 09/26] -Wpointer-sign: aarch64-tdep.c Pedro Alves
` (3 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 10:39 UTC (permalink / raw)
To: gdb-patches
../../src/gdb/record.c: In function âset_record_insn_history_sizeâ:
../../src/gdb/record.c:670:5: error: pointer targets in passing argument 2 of âvalidate_history_sizeâ differ in signedness [-Werror=pointer-sign]
../../src/gdb/record.c:646:1: note: expected âint *â but argument is of type âunsigned int *â
../../src/gdb/record.c: In function âset_record_call_history_sizeâ:
../../src/gdb/record.c:682:5: error: pointer targets in passing argument 2 of âvalidate_history_sizeâ differ in signedness [-Werror=pointer-sign]
../../src/gdb/record.c:646:1: note: expected âint *â but argument is of type âunsigned int *â
Here's the obvious fix.
gdb/
2013-04-11 Pedro Alves <palves@redhat.com>
* record.c (validate_history_size): Make parameter 'setting'
unsigned.
---
gdb/record.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/record.c b/gdb/record.c
index 0a7f0a1..76d9fd2 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -643,7 +643,7 @@ cmd_record_call_history (char *arg, int from_tty)
is the real setting the command allows changing. */
static void
-validate_history_size (unsigned int *command_var, int *setting)
+validate_history_size (unsigned int *command_var, unsigned int *setting)
{
if (*command_var != UINT_MAX && *command_var > INT_MAX)
{
^ permalink raw reply [flat|nested] 39+ messages in thread* [PATCH 09/26] -Wpointer-sign: aarch64-tdep.c.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (24 preceding siblings ...)
2013-04-12 10:39 ` [PATCH 26/26] -Wpointer-sign: record.c Pedro Alves
@ 2013-04-12 11:34 ` Pedro Alves
2013-04-12 14:39 ` [PATCH 00/26] Make GDB -Wpointer-sign clean Yao Qi
` (2 subsequent siblings)
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-12 11:34 UTC (permalink / raw)
To: gdb-patches
../../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'.
---
gdb/aarch64-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 2a889fa..9a01352 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -683,7 +683,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch,
int op_is_sub;
int32_t imm;
unsigned cond;
- unsigned is64;
+ int is64;
unsigned is_link;
unsigned op;
unsigned bit;
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 00/26] Make GDB -Wpointer-sign clean.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (25 preceding siblings ...)
2013-04-12 11:34 ` [PATCH 09/26] -Wpointer-sign: aarch64-tdep.c Pedro Alves
@ 2013-04-12 14:39 ` Yao Qi
2013-04-12 21:44 ` Tom Tromey
2013-04-19 18:17 ` [COMMIT] " Pedro Alves
28 siblings, 0 replies; 39+ messages in thread
From: Yao Qi @ 2013-04-12 14:39 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 04/12/2013 06:58 AM, Pedro Alves wrote:
> The main idea came out as reviewing a new port a few months ago, and
> pointing out for the Nth time to use gdb_byte[] instead of char[].
> The bad uses were of course coming in through copy/paste, so at the
> time I grepped and fixed all I found. Later, I noticed that
gdb_byte and char is misused probably because we don't have guidelines
on using them. People have to reference how they are used somewhere
else. After reading related patches recently, I have some in my mind,
and please complete them.
- Use gdb_byte for the raw data of target either from the inferior or
from the BFD.
- Use 'char *' for string, such as file name and path name.
We need to document them somewhere, for example gdb internals, IMO.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 00/26] Make GDB -Wpointer-sign clean.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (26 preceding siblings ...)
2013-04-12 14:39 ` [PATCH 00/26] Make GDB -Wpointer-sign clean Yao Qi
@ 2013-04-12 21:44 ` Tom Tromey
2013-04-19 14:13 ` Pedro Alves
2013-04-19 18:17 ` [COMMIT] " Pedro Alves
28 siblings, 1 reply; 39+ messages in thread
From: Tom Tromey @ 2013-04-12 21:44 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> This makes GDB -Wpointer-sign clean on x86_64 GNU/Linux,
Pedro> --enable-targets=all. Once this is in, and perhaps a couple hosts
Pedro> more are clean too (mingw and i386 GNU/Linux at least; haven't tried
Pedro> those), I'll propose enabling the switch by default.
Thanks. I think the sooner it is enabled, the better.
Enabling reduces the chances for bit-rot, and fixing up any build
problems looks very easy.
Pedro> I'm hoping this sort of split makes review easy and allows quick
Pedro> turnaround as consequence.
I skimmed through all the patches and read ones more deeply where I know
the code well. It all looks good to me.
thanks,
Tom
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 00/26] Make GDB -Wpointer-sign clean.
2013-04-12 21:44 ` Tom Tromey
@ 2013-04-19 14:13 ` Pedro Alves
0 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-19 14:13 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 04/12/2013 04:45 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> This makes GDB -Wpointer-sign clean on x86_64 GNU/Linux,
> Pedro> --enable-targets=all. Once this is in, and perhaps a couple hosts
> Pedro> more are clean too (mingw and i386 GNU/Linux at least; haven't tried
> Pedro> those), I'll propose enabling the switch by default.
>
> Thanks. I think the sooner it is enabled, the better.
> Enabling reduces the chances for bit-rot, and fixing up any build
> problems looks very easy.
Indeed.
> Pedro> I'm hoping this sort of split makes review easy and allows quick
> Pedro> turnaround as consequence.
>
> I skimmed through all the patches and read ones more deeply where I know
> the code well. It all looks good to me.
Thanks. Unless I hear further comments, I'll check this in soon.
--
Pedro Alves
^ permalink raw reply [flat|nested] 39+ messages in thread
* [COMMIT] Re: [PATCH 00/26] Make GDB -Wpointer-sign clean.
2013-04-11 23:00 [PATCH 00/26] Make GDB -Wpointer-sign clean Pedro Alves
` (27 preceding siblings ...)
2013-04-12 21:44 ` Tom Tromey
@ 2013-04-19 18:17 ` Pedro Alves
28 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2013-04-19 18:17 UTC (permalink / raw)
To: gdb-patches
FYI, I've checked this series in now.
Thanks,
--
Pedro Alves
^ permalink raw reply [flat|nested] 39+ messages in thread