aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-tdep.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-03-13 16:45:11 +0000
committerPedro Alves <palves@redhat.com>2013-03-13 16:45:11 +0000
commita0bcdaa75e9fbabdf4e1654e4aba5237c8360989 (patch)
treeaf562ef27c4f00da7434b6dc60d6f82e53f45da6 /gdb/i386-tdep.c
parent8ddb196517f30b5e304663e428f345daf030230b (diff)
downloadgdb-a0bcdaa75e9fbabdf4e1654e4aba5237c8360989.zip
gdb-a0bcdaa75e9fbabdf4e1654e4aba5237c8360989.tar.gz
gdb-a0bcdaa75e9fbabdf4e1654e4aba5237c8360989.tar.bz2
More invalid pointer to pointer conversions.
As a follow up to: http://sourceware.org/ml/gdb-patches/2013-03/msg00449.html In a nutshell, casts between 'char **' <-> 'unsigned char **' and 'char **' <-> 'const char **' are invalid. I grepped for "\*\*) &" and found these. There's another one in demangle.c, but I've split fixing that one to a separate patch. I think the ada_decode_symbol change is perhaps the one that could be surprising. The function's description has this comment, which makes things much clearer: The GSYMBOL parameter is "mutable" in the C++ sense: logically const, but nevertheless modified to a semantically equivalent form when a decoded name is cached in it. */ const char * ada_decode_symbol (const struct general_symbol_info *gsymbol) With that out of the way, I think the patch ends up being pretty obvious. Tested on x86_64 Fedora 17. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_decode_symbol): Cast away constness of GSYMBOL rather than casting 'const char * const *' to 'const char **'. * ada-lex.l (processInt): Make "trailer" local const. Remove 'const char **' cast. * arm-linux-tdep.c (arm_stap_parse_special_token): Add 'char *' locals, and use those as strtol output pointer, instead than doing invalid casts to from 'const char **' to 'char **'. (_initialize_demangle): Remove cast. * i386-tdep.c (i386_stap_parse_special_token): : Add 'char *' locals, and use those as strtol output pointer, instead than doing invalid casts to from 'const char **' to 'char **'. * solib-dsbt.c (dsbt_get_initial_loadmaps): Remove 'gdb_byte**' casts. * stap-probe.c (stap_parse_register_operand) (stap_parse_single_operand): Likewise.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r--gdb/i386-tdep.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 61ccc3e..e76dcbe 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3494,6 +3494,7 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
char *regname;
int len;
struct stoken str;
+ char *endp;
got_minus[0] = 0;
if (*s == '+')
@@ -3504,7 +3505,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
got_minus[0] = 1;
}
- displacements[0] = strtol (s, (char **) &s, 10);
+ displacements[0] = strtol (s, &endp, 10);
+ s = endp;
if (*s != '+' && *s != '-')
{
@@ -3521,7 +3523,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
got_minus[1] = 1;
}
- displacements[1] = strtol (s, (char **) &s, 10);
+ displacements[1] = strtol (s, &endp, 10);
+ s = endp;
if (*s != '+' && *s != '-')
{
@@ -3538,7 +3541,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
got_minus[2] = 1;
}
- displacements[2] = strtol (s, (char **) &s, 10);
+ displacements[2] = strtol (s, &endp, 10);
+ s = endp;
if (*s != '(' || s[1] != '%')
break;
@@ -3628,7 +3632,12 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
break;
if (isdigit (*s))
- offset = strtol (s, (char **) &s, 10);
+ {
+ char *endp;
+
+ offset = strtol (s, &endp, 10);
+ s = endp;
+ }
if (*s != '(' || s[1] != '%')
break;
@@ -3675,6 +3684,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
if (*s == ',')
{
+ char *endp;
+
++s;
if (*s == '+')
++s;
@@ -3684,7 +3695,8 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
size_minus = 1;
}
- size = strtol (s, (char **) &s, 10);
+ size = strtol (s, &endp, 10);
+ s = endp;
if (*s != ')')
break;