aboutsummaryrefslogtreecommitdiff
path: root/gdb/stap-probe.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/stap-probe.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/stap-probe.c')
-rw-r--r--gdb/stap-probe.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 9b67304..1079e3b 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -422,9 +422,11 @@ stap_parse_register_operand (struct stap_parse_info *p)
{
/* The value of the displacement. */
long displacement;
+ char *endp;
disp_p = 1;
- displacement = strtol (p->arg, (char **) &p->arg, 10);
+ displacement = strtol (p->arg, &endp, 10);
+ p->arg = endp;
/* Generating the expression for the displacement. */
write_exp_elt_opcode (OP_LONG);
@@ -598,7 +600,12 @@ stap_parse_single_operand (struct stap_parse_info *p)
tmp = skip_spaces_const (tmp);
if (isdigit (*tmp))
- number = strtol (tmp, (char **) &tmp, 10);
+ {
+ char *endp;
+
+ number = strtol (tmp, &endp, 10);
+ tmp = endp;
+ }
if (!reg_ind_prefix
|| strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
@@ -627,11 +634,13 @@ stap_parse_single_operand (struct stap_parse_info *p)
{
/* A temporary variable, needed for lookahead. */
const char *tmp = p->arg;
+ char *endp;
long number;
/* We can be dealing with a numeric constant (if `const_prefix' is
NULL), or with a register displacement. */
- number = strtol (tmp, (char **) &tmp, 10);
+ number = strtol (tmp, &endp, 10);
+ tmp = endp;
if (p->inside_paren_p)
tmp = skip_spaces_const (tmp);
@@ -667,9 +676,11 @@ stap_parse_single_operand (struct stap_parse_info *p)
{
/* We are dealing with a numeric constant. */
long number;
+ char *endp;
p->arg += const_prefix_len;
- number = strtol (p->arg, (char **) &p->arg, 10);
+ number = strtol (p->arg, &endp, 10);
+ p->arg = endp;
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);