mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-28 12:33:36 +08:00
Bool-ify stap-probe.c and stap-related code on i386-tdep.c
This simple patch converts a bunch of "int"s to "bool" on stap-probe.c and on the stap-related code present on i386-tdep.c. Pushed as obvious (+ I'm the maintainer of this code). gdb/ChangeLog: 2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com> * i386-tdep.c (i386_stap_parse_special_token_triplet): Change return type to 'bool'. Adjust comment. Use 'bool' when appropriate. (i386_stap_parse_special_token_three_arg_disp): Likewise. * stap-probe.c (stap_parse_argument_1): Likewise. (stap_is_operator): Likewise. (stap_is_generic_prefix): Likewise. (stap_is_register_prefix): Likewise. (stap_is_register_indirection_prefix): Likewise. (stap_is_integer_prefix): Likewise. (stap_generic_check_suffix): Likewise. (stap_check_integer_suffix): Likewise. (stap_check_register_suffix): Likewise. (stap_check_register_indirection_suffix): Likewise. (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_probe::get_argument_count): Likewise. (stap_is_operator): Likewise.
This commit is contained in:
parent
61c9c4212d
commit
af2d9beee9
@ -1,3 +1,25 @@
|
||||
2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
* i386-tdep.c (i386_stap_parse_special_token_triplet): Change
|
||||
return type to 'bool'. Adjust comment. Use 'bool' when
|
||||
appropriate.
|
||||
(i386_stap_parse_special_token_three_arg_disp): Likewise.
|
||||
* stap-probe.c (stap_parse_argument_1): Likewise.
|
||||
(stap_is_operator): Likewise.
|
||||
(stap_is_generic_prefix): Likewise.
|
||||
(stap_is_register_prefix): Likewise.
|
||||
(stap_is_register_indirection_prefix): Likewise.
|
||||
(stap_is_integer_prefix): Likewise.
|
||||
(stap_generic_check_suffix): Likewise.
|
||||
(stap_check_integer_suffix): Likewise.
|
||||
(stap_check_register_suffix): Likewise.
|
||||
(stap_check_register_indirection_suffix): Likewise.
|
||||
(stap_parse_register_operand): Likewise.
|
||||
(stap_parse_single_operand): Likewise.
|
||||
(stap_parse_argument_1): Likewise.
|
||||
(stap_probe::get_argument_count): Likewise.
|
||||
(stap_is_operator): Likewise.
|
||||
|
||||
2019-05-16 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* darwin-nat.c (thread_info_from_private_thread_info): Add struct
|
||||
|
@ -4033,10 +4033,10 @@ i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
|
||||
This function parses operands of the form `-8+3+1(%rbp)', which
|
||||
must be interpreted as `*(-8 + 3 - 1 + (void *) $eax)'.
|
||||
|
||||
Return 1 if the operand was parsed successfully, zero
|
||||
Return true if the operand was parsed successfully, false
|
||||
otherwise. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
struct stap_parse_info *p)
|
||||
{
|
||||
@ -4044,7 +4044,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
|
||||
if (isdigit (*s) || *s == '-' || *s == '+')
|
||||
{
|
||||
int got_minus[3];
|
||||
bool got_minus[3];
|
||||
int i;
|
||||
long displacements[3];
|
||||
const char *start;
|
||||
@ -4053,17 +4053,17 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
struct stoken str;
|
||||
char *endp;
|
||||
|
||||
got_minus[0] = 0;
|
||||
got_minus[0] = false;
|
||||
if (*s == '+')
|
||||
++s;
|
||||
else if (*s == '-')
|
||||
{
|
||||
++s;
|
||||
got_minus[0] = 1;
|
||||
got_minus[0] = true;
|
||||
}
|
||||
|
||||
if (!isdigit ((unsigned char) *s))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
displacements[0] = strtol (s, &endp, 10);
|
||||
s = endp;
|
||||
@ -4071,20 +4071,20 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
if (*s != '+' && *s != '-')
|
||||
{
|
||||
/* We are not dealing with a triplet. */
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
got_minus[1] = 0;
|
||||
got_minus[1] = false;
|
||||
if (*s == '+')
|
||||
++s;
|
||||
else
|
||||
{
|
||||
++s;
|
||||
got_minus[1] = 1;
|
||||
got_minus[1] = true;
|
||||
}
|
||||
|
||||
if (!isdigit ((unsigned char) *s))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
displacements[1] = strtol (s, &endp, 10);
|
||||
s = endp;
|
||||
@ -4092,26 +4092,26 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
if (*s != '+' && *s != '-')
|
||||
{
|
||||
/* We are not dealing with a triplet. */
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
got_minus[2] = 0;
|
||||
got_minus[2] = false;
|
||||
if (*s == '+')
|
||||
++s;
|
||||
else
|
||||
{
|
||||
++s;
|
||||
got_minus[2] = 1;
|
||||
got_minus[2] = true;
|
||||
}
|
||||
|
||||
if (!isdigit ((unsigned char) *s))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
displacements[2] = strtol (s, &endp, 10);
|
||||
s = endp;
|
||||
|
||||
if (*s != '(' || s[1] != '%')
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
s += 2;
|
||||
start = s;
|
||||
@ -4120,7 +4120,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
++s;
|
||||
|
||||
if (*s++ != ')')
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
len = s - start - 1;
|
||||
regname = (char *) alloca (len + 1);
|
||||
@ -4167,10 +4167,10 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
|
||||
p->arg = s;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Helper function for i386_stap_parse_special_token.
|
||||
@ -4179,10 +4179,10 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
||||
(register index * size) + offset', as represented in
|
||||
`(%rcx,%rax,8)', or `[OFFSET](BASE_REG,INDEX_REG[,SIZE])'.
|
||||
|
||||
Return 1 if the operand was parsed successfully, zero
|
||||
Return true if the operand was parsed successfully, false
|
||||
otherwise. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
struct stap_parse_info *p)
|
||||
{
|
||||
@ -4190,9 +4190,9 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
|
||||
if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+')
|
||||
{
|
||||
int offset_minus = 0;
|
||||
bool offset_minus = false;
|
||||
long offset = 0;
|
||||
int size_minus = 0;
|
||||
bool size_minus = false;
|
||||
long size = 0;
|
||||
const char *start;
|
||||
char *base;
|
||||
@ -4206,11 +4206,11 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
else if (*s == '-')
|
||||
{
|
||||
++s;
|
||||
offset_minus = 1;
|
||||
offset_minus = true;
|
||||
}
|
||||
|
||||
if (offset_minus && !isdigit (*s))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (isdigit (*s))
|
||||
{
|
||||
@ -4221,7 +4221,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
}
|
||||
|
||||
if (*s != '(' || s[1] != '%')
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
s += 2;
|
||||
start = s;
|
||||
@ -4230,7 +4230,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
++s;
|
||||
|
||||
if (*s != ',' || s[1] != '%')
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
len_base = s - start;
|
||||
base = (char *) alloca (len_base + 1);
|
||||
@ -4257,7 +4257,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
index, p->saved_arg);
|
||||
|
||||
if (*s != ',' && *s != ')')
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (*s == ',')
|
||||
{
|
||||
@ -4269,14 +4269,14 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
else if (*s == '-')
|
||||
{
|
||||
++s;
|
||||
size_minus = 1;
|
||||
size_minus = true;
|
||||
}
|
||||
|
||||
size = strtol (s, &endp, 10);
|
||||
s = endp;
|
||||
|
||||
if (*s != ')')
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
++s;
|
||||
@ -4330,10 +4330,10 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
||||
|
||||
p->arg = s;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Implementation of `gdbarch_stap_parse_special_token', as defined in
|
||||
|
@ -257,14 +257,14 @@ enum stap_operand_prec
|
||||
STAP_OPERAND_PREC_MUL
|
||||
};
|
||||
|
||||
static void stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
|
||||
static void stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
|
||||
enum stap_operand_prec prec);
|
||||
|
||||
static void stap_parse_argument_conditionally (struct stap_parse_info *p);
|
||||
|
||||
/* Returns 1 if *S is an operator, zero otherwise. */
|
||||
/* Returns true if *S is an operator, false otherwise. */
|
||||
|
||||
static int stap_is_operator (const char *op);
|
||||
static bool stap_is_operator (const char *op);
|
||||
|
||||
static void
|
||||
show_stapexpressiondebug (struct ui_file *file, int from_tty,
|
||||
@ -474,9 +474,9 @@ stap_get_expected_argument_type (struct gdbarch *gdbarch,
|
||||
|
||||
This function does a case-insensitive match.
|
||||
|
||||
Return 1 if any prefix has been found, zero otherwise. */
|
||||
Return true if any prefix has been found, false otherwise. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r, const char *const *prefixes)
|
||||
{
|
||||
@ -487,7 +487,7 @@ stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
if (r != NULL)
|
||||
*r = "";
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (p = prefixes; *p != NULL; ++p)
|
||||
@ -496,16 +496,16 @@ stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
if (r != NULL)
|
||||
*r = *p;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return 1 if S points to a register prefix, zero otherwise. For a
|
||||
description of the arguments, look at stap_is_generic_prefix. */
|
||||
/* Return true if S points to a register prefix, false otherwise. For
|
||||
a description of the arguments, look at stap_is_generic_prefix. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -514,11 +514,11 @@ stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
return stap_is_generic_prefix (gdbarch, s, r, t);
|
||||
}
|
||||
|
||||
/* Return 1 if S points to a register indirection prefix, zero
|
||||
/* Return true if S points to a register indirection prefix, false
|
||||
otherwise. For a description of the arguments, look at
|
||||
stap_is_generic_prefix. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -527,15 +527,15 @@ stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
return stap_is_generic_prefix (gdbarch, s, r, t);
|
||||
}
|
||||
|
||||
/* Return 1 if S points to an integer prefix, zero otherwise. For a
|
||||
description of the arguments, look at stap_is_generic_prefix.
|
||||
/* Return true if S points to an integer prefix, false otherwise. For
|
||||
a description of the arguments, look at stap_is_generic_prefix.
|
||||
|
||||
This function takes care of analyzing whether we are dealing with
|
||||
an expected integer prefix, or, if there is no integer prefix to be
|
||||
expected, whether we are dealing with a digit. It does a
|
||||
case-insensitive match. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -549,7 +549,7 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
if (r != NULL)
|
||||
*r = "";
|
||||
|
||||
return isdigit (*s);
|
||||
return isdigit (*s) > 0;
|
||||
}
|
||||
|
||||
for (p = t; *p != NULL; ++p)
|
||||
@ -567,35 +567,35 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
|
||||
if (r != NULL)
|
||||
*r = *p;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Helper function to check for a generic list of suffixes. If we are
|
||||
not expecting any suffixes, then it just returns 1. If we are
|
||||
expecting at least one suffix, then it returns 1 if a suffix has
|
||||
been found, zero otherwise. GDBARCH is the current gdbarch being
|
||||
expecting at least one suffix, then it returns true if a suffix has
|
||||
been found, false otherwise. GDBARCH is the current gdbarch being
|
||||
used. S is the expression being analyzed. If R is not NULL, it
|
||||
will be used to return the found suffix. SUFFIXES is the list of
|
||||
expected suffixes. This function does a case-insensitive
|
||||
match. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r, const char *const *suffixes)
|
||||
{
|
||||
const char *const *p;
|
||||
int found = 0;
|
||||
bool found = false;
|
||||
|
||||
if (suffixes == NULL)
|
||||
{
|
||||
if (r != NULL)
|
||||
*r = "";
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (p = suffixes; *p != NULL; ++p)
|
||||
@ -604,18 +604,18 @@ stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
if (r != NULL)
|
||||
*r = *p;
|
||||
|
||||
found = 1;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Return 1 if S points to an integer suffix, zero otherwise. For a
|
||||
description of the arguments, look at
|
||||
/* Return true if S points to an integer suffix, false otherwise. For
|
||||
a description of the arguments, look at
|
||||
stap_generic_check_suffix. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -624,11 +624,11 @@ stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
return stap_generic_check_suffix (gdbarch, s, r, p);
|
||||
}
|
||||
|
||||
/* Return 1 if S points to a register suffix, zero otherwise. For a
|
||||
description of the arguments, look at
|
||||
/* Return true if S points to a register suffix, false otherwise. For
|
||||
a description of the arguments, look at
|
||||
stap_generic_check_suffix. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -637,11 +637,11 @@ stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
return stap_generic_check_suffix (gdbarch, s, r, p);
|
||||
}
|
||||
|
||||
/* Return 1 if S points to a register indirection suffix, zero
|
||||
/* Return true if S points to a register indirection suffix, false
|
||||
otherwise. For a description of the arguments, look at
|
||||
stap_generic_check_suffix. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_check_register_indirection_suffix (struct gdbarch *gdbarch, const char *s,
|
||||
const char **r)
|
||||
{
|
||||
@ -674,10 +674,11 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
||||
{
|
||||
/* Simple flag to indicate whether we have seen a minus signal before
|
||||
certain number. */
|
||||
int got_minus = 0;
|
||||
bool got_minus = false;
|
||||
/* Flags to indicate whether this register access is being displaced and/or
|
||||
indirected. */
|
||||
int disp_p = 0, indirect_p = 0;
|
||||
bool disp_p = false;
|
||||
bool indirect_p = false;
|
||||
struct gdbarch *gdbarch = p->gdbarch;
|
||||
/* Needed to generate the register name as a part of an expression. */
|
||||
struct stoken str;
|
||||
@ -705,7 +706,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
||||
|
||||
if (*p->arg == '-')
|
||||
{
|
||||
got_minus = 1;
|
||||
got_minus = true;
|
||||
++p->arg;
|
||||
}
|
||||
|
||||
@ -715,7 +716,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
||||
long displacement;
|
||||
char *endp;
|
||||
|
||||
disp_p = 1;
|
||||
disp_p = true;
|
||||
displacement = strtol (p->arg, &endp, 10);
|
||||
p->arg = endp;
|
||||
|
||||
@ -731,7 +732,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
||||
/* Getting rid of register indirection prefix. */
|
||||
if (stap_is_register_indirection_prefix (gdbarch, p->arg, ®_ind_prefix))
|
||||
{
|
||||
indirect_p = 1;
|
||||
indirect_p = true;
|
||||
p->arg += strlen (reg_ind_prefix);
|
||||
}
|
||||
|
||||
@ -854,7 +855,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
|
||||
char c = *p->arg;
|
||||
/* We use this variable to do a lookahead. */
|
||||
const char *tmp = p->arg;
|
||||
int has_digit = 0;
|
||||
bool has_digit = false;
|
||||
|
||||
/* Skipping signal. */
|
||||
++tmp;
|
||||
@ -879,7 +880,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
|
||||
called below ('stap_parse_argument_conditionally' or
|
||||
'stap_parse_register_operand'). */
|
||||
++tmp;
|
||||
has_digit = 1;
|
||||
has_digit = true;
|
||||
}
|
||||
|
||||
if (has_digit && stap_is_register_indirection_prefix (gdbarch, tmp,
|
||||
@ -1023,7 +1024,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p)
|
||||
better understand what this function does. */
|
||||
|
||||
static void
|
||||
stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
|
||||
stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
|
||||
enum stap_operand_prec prec)
|
||||
{
|
||||
/* This is an operator-precedence parser.
|
||||
@ -1295,7 +1296,7 @@ stap_probe::get_argument_count (struct frame_info *frame)
|
||||
this->parse_arguments (gdbarch);
|
||||
else
|
||||
{
|
||||
static int have_warned_stap_incomplete = 0;
|
||||
static bool have_warned_stap_incomplete = false;
|
||||
|
||||
if (!have_warned_stap_incomplete)
|
||||
{
|
||||
@ -1303,7 +1304,7 @@ stap_probe::get_argument_count (struct frame_info *frame)
|
||||
"The SystemTap SDT probe support is not fully implemented on this target;\n"
|
||||
"you will not be able to inspect the arguments of the probes.\n"
|
||||
"Please report a bug against GDB requesting a port to this target."));
|
||||
have_warned_stap_incomplete = 1;
|
||||
have_warned_stap_incomplete = true;
|
||||
}
|
||||
|
||||
/* Marking the arguments as "already parsed". */
|
||||
@ -1315,13 +1316,13 @@ stap_probe::get_argument_count (struct frame_info *frame)
|
||||
return m_parsed_args.size ();
|
||||
}
|
||||
|
||||
/* Return 1 if OP is a valid operator inside a probe argument, or zero
|
||||
otherwise. */
|
||||
/* Return true if OP is a valid operator inside a probe argument, or
|
||||
false otherwise. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
stap_is_operator (const char *op)
|
||||
{
|
||||
int ret = 1;
|
||||
bool ret = true;
|
||||
|
||||
switch (*op)
|
||||
{
|
||||
@ -1340,12 +1341,12 @@ stap_is_operator (const char *op)
|
||||
|
||||
case '=':
|
||||
if (op[1] != '=')
|
||||
ret = 0;
|
||||
ret = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* We didn't find any operator. */
|
||||
ret = 0;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user