public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-sergiodj-stap-patch-split: Implementing mechanism to add a prefix and a sufix in a register's name.
@ 2011-10-11 22:46 sergiodj
0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-10-11 22:46 UTC (permalink / raw)
To: archer-commits
The branch, archer-sergiodj-stap-patch-split has been updated
via 3553c1f3d695106c4b835396bd705d2fa3f71ce6 (commit)
from 62e2c58e8ec35b12b11da53e2e434f86f689f5f9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 3553c1f3d695106c4b835396bd705d2fa3f71ce6
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Tue Oct 11 19:44:59 2011 -0300
Implementing mechanism to add a prefix and a sufix in a register's name.
-----------------------------------------------------------------------
Summary of changes:
gdb/arm-linux-tdep.c | 2 +
gdb/gdbarch.c | 46 +++++++++++++++++++++++++++++++
gdb/gdbarch.h | 15 ++++++++++
gdb/gdbarch.sh | 11 +++++++
gdb/ppc-linux-tdep.c | 2 +
gdb/stap-probe.c | 74 ++++++++++++++++++++++++++++++++++++++++++-------
6 files changed, 139 insertions(+), 11 deletions(-)
First 500 lines of diff:
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index bdab71c..e3f09a9 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1262,6 +1262,8 @@ arm_linux_init_abi (struct gdbarch_info info,
set_gdbarch_stap_register_sufix (gdbarch, NULL);
set_gdbarch_stap_register_indirection_prefix (gdbarch, "[");
set_gdbarch_stap_register_indirection_sufix (gdbarch, "]");
+ set_gdbarch_stap_gdb_register_prefix (gdbarch, "r");
+ set_gdbarch_stap_gdb_register_prefix (gdbarch, NULL);
set_gdbarch_stap_is_single_operand (gdbarch, arm_stap_is_single_operand);
set_gdbarch_stap_parse_special_token (gdbarch,
arm_stap_parse_special_token);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 3971301..e097288 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -268,6 +268,8 @@ struct gdbarch
const char * stap_register_sufix;
const char * stap_register_indirection_prefix;
const char * stap_register_indirection_sufix;
+ const char * stap_gdb_register_prefix;
+ const char * stap_gdb_register_sufix;
gdbarch_stap_is_single_operand_ftype *stap_is_single_operand;
gdbarch_stap_parse_special_token_ftype *stap_parse_special_token;
gdbarch_stap_evaluate_special_token_ftype *stap_evaluate_special_token;
@@ -430,6 +432,8 @@ struct gdbarch startup_gdbarch =
0, /* stap_register_sufix */
0, /* stap_register_indirection_prefix */
0, /* stap_register_indirection_sufix */
+ 0, /* stap_gdb_register_prefix */
+ 0, /* stap_gdb_register_sufix */
0, /* stap_is_single_operand */
0, /* stap_parse_special_token */
0, /* stap_evaluate_special_token */
@@ -724,6 +728,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of stap_register_sufix, invalid_p == 0 */
/* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */
/* Skip verify of stap_register_indirection_sufix, invalid_p == 0 */
+ /* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */
+ /* Skip verify of stap_gdb_register_sufix, invalid_p == 0 */
/* Skip verify of stap_is_single_operand, has predicate. */
/* Skip verify of stap_parse_special_token, has predicate. */
/* Skip verify of stap_evaluate_special_token, has predicate. */
@@ -1259,6 +1265,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: stap_evaluate_special_token = <%s>\n",
host_address_to_string (gdbarch->stap_evaluate_special_token));
fprintf_unfiltered (file,
+ "gdbarch_dump: stap_gdb_register_prefix = %s\n",
+ gdbarch->stap_gdb_register_prefix);
+ fprintf_unfiltered (file,
+ "gdbarch_dump: stap_gdb_register_sufix = %s\n",
+ gdbarch->stap_gdb_register_sufix);
+ fprintf_unfiltered (file,
"gdbarch_dump: stap_integer_prefix = %s\n",
gdbarch->stap_integer_prefix);
fprintf_unfiltered (file,
@@ -3893,6 +3905,40 @@ set_gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch,
gdbarch->stap_register_indirection_sufix = stap_register_indirection_sufix;
}
+const char *
+gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_gdb_register_prefix called\n");
+ return gdbarch->stap_gdb_register_prefix;
+}
+
+void
+set_gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch,
+ const char * stap_gdb_register_prefix)
+{
+ gdbarch->stap_gdb_register_prefix = stap_gdb_register_prefix;
+}
+
+const char *
+gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Skip verify of stap_gdb_register_sufix, invalid_p == 0 */
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_gdb_register_sufix called\n");
+ return gdbarch->stap_gdb_register_sufix;
+}
+
+void
+set_gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch,
+ const char * stap_gdb_register_sufix)
+{
+ gdbarch->stap_gdb_register_sufix = stap_gdb_register_sufix;
+}
+
int
gdbarch_stap_is_single_operand_p (struct gdbarch *gdbarch)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index c369d5b..5fb2550 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1014,6 +1014,21 @@ extern void set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarc
extern const char * gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_register_indirection_sufix (struct gdbarch *gdbarch, const char * stap_register_indirection_sufix);
+/* Prefix used to name a register using GDB's nomenclature.
+
+ For example, on PPC a register is represented by a number in the assembly
+ language (e.g., `10' is the 10th general-purpose register). However,
+ inside GDB this same register has an `r' appended to its name, so the 10th
+ register would be represented as `r10' internally. */
+
+extern const char * gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch);
+extern void set_gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch, const char * stap_gdb_register_prefix);
+
+/* Sufix used to name a register using GDB's nomenclature. */
+
+extern const char * gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch);
+extern void set_gdbarch_stap_gdb_register_sufix (struct gdbarch *gdbarch, const char * stap_gdb_register_sufix);
+
/* Check if S is a single operand.
Single operands can be:
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 5a1806c..13c4ecb 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -830,6 +830,17 @@ v:const char *:stap_register_indirection_prefix:::0:0::0:gdbarch->stap_register_
# displacement, e.g., \`4\(\%eax\)\' on x86.
v:const char *:stap_register_indirection_sufix:::0:0::0:gdbarch->stap_register_indirection_sufix
+# Prefix used to name a register using GDB's nomenclature.
+#
+# For example, on PPC a register is represented by a number in the assembly
+# language (e.g., \`10\' is the 10th general-purpose register). However,
+# inside GDB this same register has an \`r\' appended to its name, so the 10th
+# register would be represented as \`r10\' internally.
+v:const char *:stap_gdb_register_prefix:::0:0::0:gdbarch->stap_gdb_register_prefix
+
+# Sufix used to name a register using GDB's nomenclature.
+v:const char *:stap_gdb_register_sufix:::0:0::0:gdbarch->stap_gdb_register_sufix
+
# Check if S is a single operand.
#
# Single operands can be:
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 764c345..109c97c 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -2006,6 +2006,8 @@ ppc_linux_init_abi (struct gdbarch_info info,
set_gdbarch_stap_register_sufix (gdbarch, NULL);
set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
set_gdbarch_stap_register_indirection_sufix (gdbarch, ")");
+ set_gdbarch_stap_gdb_register_prefix (gdbarch, "r");
+ set_gdbarch_stap_gdb_register_sufix (gdbarch, NULL);
set_gdbarch_stap_is_single_operand (gdbarch, ppc_stap_is_single_operand);
set_gdbarch_stap_parse_special_token (gdbarch,
ppc_stap_parse_special_token);
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 5861f3e..9ff2d4b 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -360,6 +360,50 @@ stap_free_args_info (void *args_info_ptr)
xfree (a);
}
+/* Helper function that removes whitespaces from the probe's argument
+ string. This function xfree's the space pointed by *ARG if needed,
+ and updates the pointer to the new string without spaces. */
+
+static void
+stap_remove_arg_whitespaces (char **arg)
+{
+ char *p = *arg;
+ char *new, *tmp;
+ size_t size = strlen (p);
+ int i = 0, n_spaces = 0;
+
+ tmp = p;
+ while (*p)
+ {
+ if (isspace (*p))
+ ++n_spaces;
+
+ ++p;
+ }
+
+ if (!n_spaces)
+ /* No space to remove. */
+ return;
+
+ p = tmp;
+ new = xmalloc (size - n_spaces + 1);
+
+ while (*p)
+ {
+ if (isspace (*p))
+ {
+ ++p;
+ continue;
+ }
+
+ new[i++] = *p++;
+ }
+ new[i] = '\0';
+
+ xfree (*arg);
+ *arg = new;
+}
+
/* Function which parses an argument string from PROBE, correctly splitting
the arguments and storing their information in properly ways. This function
only separates the arguments, but does not evaluate them.
@@ -480,6 +524,7 @@ stap_parse_probe_arguments (struct stap_probe *probe)
case PARSE_ARG:
{
const char *start = cur;
+ char *tmp_arg_str;
if (!stap_parse_arg (&cur, probe->gdbarch))
{
@@ -494,6 +539,9 @@ stap_parse_probe_arguments (struct stap_probe *probe)
args_info->arg[current_arg].arg_str
= savestring (start, cur - start);
+ /* Removing the argument's whitespaces. */
+ stap_remove_arg_whitespaces (&args_info->arg[current_arg].arg_str);
+
++args_info->n_args;
/* Start it over again. */
cur = skip_spaces ((char *) cur);
@@ -815,15 +863,19 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch);
const char *reg_ind_prefix
= gdbarch_stap_register_indirection_prefix (gdbarch);
+ const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0;
int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0;
+ int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
/* Sufixes for the parser. */
const char *reg_sufix = gdbarch_stap_register_sufix (gdbarch);
const char *reg_ind_sufix
= gdbarch_stap_register_indirection_sufix (gdbarch);
+ const char *gdb_reg_sufix = gdbarch_stap_gdb_register_sufix (gdbarch);
int reg_sufix_len = reg_sufix ? strlen (reg_sufix) : 0;
int reg_ind_sufix_len = reg_ind_sufix ? strlen (reg_ind_sufix) : 0;
+ int gdb_reg_sufix_len = gdb_reg_sufix ? strlen (gdb_reg_sufix) : 0;
if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
/* If we are compiling, we cannot return NULL because that would
@@ -882,19 +934,19 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
eval_info->exp_buf += reg_ind_sufix_len;
}
- regname = alloca (len + 2);
+ regname = alloca (len + gdb_reg_prefix_len + gdb_reg_sufix_len + 1);
+ regname[0] = '\0';
- /* For PPC we have to insert a leading `r' before the register name,
- so (unfortunately) we need to do this "hard coded if" here. */
- if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_powerpc)
- {
- ++len;
- regname[0] = 'r';
- strncpy (regname + 1, start, len);
- }
- else
- strncpy (regname, start, len);
+ if (gdb_reg_prefix)
+ strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
+
+ strncpy (regname + gdb_reg_prefix_len, start, len);
+
+ if (gdb_reg_sufix)
+ strncpy (regname + gdb_reg_prefix_len + len,
+ gdb_reg_sufix, gdb_reg_sufix_len);
+ len += gdb_reg_prefix_len + gdb_reg_sufix_len;
regname[len] = '\0';
regnum = user_reg_map_name_to_regnum (get_frame_arch (frame), regname, len);
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-11 22:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-11 22:46 [SCM] archer-sergiodj-stap-patch-split: Implementing mechanism to add a prefix and a sufix in a register's name sergiodj
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).