mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 09:14:14 +08:00
Make stap-probe.c:stap_parse_register_operand's "regname" an std::string
This patch simplifies the code of stap-probe.c:stap_parse_register_operand by making "regname" an std::string. No functionality change. I'm this code's maintainer, so I'm pushing this as it's a fairly trivial patch. gdb/ChangeLog: 2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com> * stap-probe.c (stap_parse_register_operand): Make "regname" an "std::string", simplifying the algorithm.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
|
* stap-probe.c (stap_parse_register_operand): Make "regname" an
|
||||||
|
"std::string", simplifying the algorithm.
|
||||||
|
|
||||||
2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com>
|
2019-05-16 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
* stap-probe.c (handle_stap_probe): Fix complaint formatting.
|
* stap-probe.c (handle_stap_probe): Fix complaint formatting.
|
||||||
|
@ -687,12 +687,8 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
|||||||
/* Variables used to extract the register name from the probe's
|
/* Variables used to extract the register name from the probe's
|
||||||
argument. */
|
argument. */
|
||||||
const char *start;
|
const char *start;
|
||||||
char *regname;
|
|
||||||
int len;
|
|
||||||
const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
|
const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
|
||||||
int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
|
|
||||||
const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
|
const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
|
||||||
int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 0;
|
|
||||||
const char *reg_prefix;
|
const char *reg_prefix;
|
||||||
const char *reg_ind_prefix;
|
const char *reg_ind_prefix;
|
||||||
const char *reg_suffix;
|
const char *reg_suffix;
|
||||||
@ -753,37 +749,29 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
|||||||
while (isalnum (*p->arg))
|
while (isalnum (*p->arg))
|
||||||
++p->arg;
|
++p->arg;
|
||||||
|
|
||||||
len = p->arg - start;
|
std::string regname (start, p->arg - start);
|
||||||
|
|
||||||
regname = (char *) alloca (len + gdb_reg_prefix_len + gdb_reg_suffix_len + 1);
|
|
||||||
regname[0] = '\0';
|
|
||||||
|
|
||||||
/* We only add the GDB's register prefix/suffix if we are dealing with
|
/* We only add the GDB's register prefix/suffix if we are dealing with
|
||||||
a numeric register. */
|
a numeric register. */
|
||||||
if (gdb_reg_prefix && isdigit (*start))
|
if (isdigit (*start))
|
||||||
{
|
{
|
||||||
strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
|
if (gdb_reg_prefix != NULL)
|
||||||
strncpy (regname + gdb_reg_prefix_len, start, len);
|
regname = gdb_reg_prefix + regname;
|
||||||
|
|
||||||
if (gdb_reg_suffix)
|
if (gdb_reg_suffix != NULL)
|
||||||
strncpy (regname + gdb_reg_prefix_len + len,
|
regname += gdb_reg_suffix;
|
||||||
gdb_reg_suffix, gdb_reg_suffix_len);
|
|
||||||
|
|
||||||
len += gdb_reg_prefix_len + gdb_reg_suffix_len;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
strncpy (regname, start, len);
|
|
||||||
|
|
||||||
regname[len] = '\0';
|
|
||||||
|
|
||||||
/* Is this a valid register name? */
|
/* Is this a valid register name? */
|
||||||
if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
|
if (user_reg_map_name_to_regnum (gdbarch,
|
||||||
|
regname.c_str (),
|
||||||
|
regname.size ()) == -1)
|
||||||
error (_("Invalid register name `%s' on expression `%s'."),
|
error (_("Invalid register name `%s' on expression `%s'."),
|
||||||
regname, p->saved_arg);
|
regname.c_str (), p->saved_arg);
|
||||||
|
|
||||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||||
str.ptr = regname;
|
str.ptr = regname.c_str ();
|
||||||
str.length = len;
|
str.length = regname.size ();
|
||||||
write_exp_string (&p->pstate, str);
|
write_exp_string (&p->pstate, str);
|
||||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user