public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-stap-on-linespec: Fixing lots and lots and lots of bugs in the branch.
@ 2011-12-21 22:09 sergiodj
0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-12-21 22:09 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-stap-on-linespec has been updated
via 9f45c41cdf03da49a2fffb73a91907e160b89a34 (commit)
from bbf5dc3e23fe19c5434a7a59dcc23b31515d2ea2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 9f45c41cdf03da49a2fffb73a91907e160b89a34
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Wed Dec 21 20:04:17 2011 -0200
Fixing lots and lots and lots of bugs in the branch.
I should have made a separate commit for each fix, but I will try to
summarize them here:
- Implement the conversion of SystemTap probes' arguments to `struct
expression';
- Implement the evaluation of those arguments using GDB's own evaluation
mechanism (evaluate_subexp_standard);
- Increment the testcase `stap-probe.exp' (I will continue to increment
the testcases since the tracepoint feature is not covered yet);
- Implement the AX generation using GDB's own mechanism (gen_expr);
- Re-designed gdbarch's methods in order to reflect the new evaluation
mechanism;
- Implemented `skip_spaces_const' (probably not the right place for
it...);
- Minor bugfixes found during the work;
I think that covers almost everything.
-----------------------------------------------------------------------
Summary of changes:
gdb/amd64-linux-tdep.c | 12 +-
gdb/arm-linux-tdep.c | 154 ++--
gdb/ax-gdb.c | 8 +-
gdb/ax-gdb.h | 5 +
gdb/breakpoint.c | 4 +-
gdb/cli/cli-utils.c | 12 +
gdb/cli/cli-utils.h | 4 +
gdb/elfread.c | 8 +-
gdb/gdbarch.c | 37 +-
gdb/gdbarch.h | 40 +-
gdb/gdbarch.sh | 33 +-
gdb/i386-linux-tdep.c | 12 +-
gdb/i386-tdep.c | 683 +++++--------
gdb/i386-tdep.h | 18 +-
gdb/parse.c | 45 +-
gdb/parser-defs.h | 18 +
gdb/ppc-linux-tdep.c | 500 +---------
gdb/remote.c | 2 +-
gdb/s390-tdep.c | 462 +--------
gdb/stap-probe.c | 1844 ++++++++++++---------------------
gdb/stap-probe.h | 103 +--
gdb/symfile.h | 8 +-
gdb/testsuite/gdb.base/stap-probe.c | 53 +-
gdb/testsuite/gdb.base/stap-probe.exp | 129 +++-
gdb/tracepoint.c | 4 +-
25 files changed, 1339 insertions(+), 2859 deletions(-)
First 500 lines of diff:
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 0e504e0..3be7f25 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1365,20 +1365,12 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* SystemTap variables and functions. */
set_gdbarch_stap_integer_prefix (gdbarch, "$");
- set_gdbarch_stap_integer_sufix (gdbarch, NULL);
set_gdbarch_stap_register_prefix (gdbarch, "%");
- set_gdbarch_stap_register_sufix (gdbarch, NULL);
set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
set_gdbarch_stap_register_indirection_sufix (gdbarch, ")");
set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
-#if 0
- set_gdbarch_stap_parse_arg (gdbarch, i386_stap_parse_arg);
- set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
- set_gdbarch_stap_evaluate_single_operand (gdbarch,
- i386_stap_evaluate_single_operand);
- set_gdbarch_stap_fetch_register_value (gdbarch,
- i386_stap_fetch_register_value);
-#endif
+ set_gdbarch_stap_parse_special_token (gdbarch,
+ i386_stap_parse_special_token);
/* Initialize the amd64_linux_record_tdep. */
/* These values are the size of the type that will be used in a system
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 382d503..cb5f3c1 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -46,6 +46,8 @@
#include "cli/cli-utils.h"
#include "stap-probe.h"
+#include "parser-defs.h"
+#include "user-regs.h"
#include <ctype.h>
#include "gdb_string.h"
@@ -1062,98 +1064,111 @@ arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
|| isalpha (*s)); /* Register value. */
}
-static int
-arm_stap_parse_special_token (struct gdbarch *gdbarch, const char **token)
-{
- char *s = (char *) *token;
-
- /* The special tokens parsed here are:
+/* This routine is used to parse a special token in ARM's assembly.
- - register displacement, in the form of [rR, #N]. */
- if (*s == '[')
- {
- ++s;
- if (!isalnum (*s))
- return 0;
+ The special tokens parsed by it are:
- while (isalnum (*s))
- ++s;
+ - Register displacement (e.g, [fp, #-8])
- if (*s++ != ',')
- return 0;
+ It returns one if the special token has been parsed successfully,
+ or zero if the current token is not considered special. */
- s = skip_spaces (s);
+static int
+arm_stap_parse_special_token (struct gdbarch *gdbarch,
+ struct stap_parse_info *p)
+{
+ if (*p->arg == '[')
+ {
+ /* Temporary holder for lookahead. */
+ const char *tmp = p->arg;
+ /* Used to save the register name. */
+ const char *start;
+ char *regname;
+ int len, offset;
+ int got_minus = 0;
+ long displacement;
+ struct stoken str;
- if (*s++ != '#')
- return 0;
+ ++tmp;
+ start = tmp;
- if (*s == '-')
- ++s;
+ /* Register name. */
+ while (isalnum (*tmp))
+ ++tmp;
- if (!isdigit (*s))
+ if (*tmp != ',')
return 0;
- while (isdigit (*s))
- ++s;
+ len = tmp - start;
+ regname = alloca (len + 2);
- if (*s++ != ']')
- return 0;
- }
- else
- return 0;
+ offset = 0;
+ if (isdigit (*start))
+ {
+ /* If we are dealing with a register whose name begins with a
+ digit, it means we should prefix the name with the letter
+ `r', because GDB expects this name pattern. Otherwise (e.g.,
+ we are dealing with the register `fp'), we don't need to
+ add such a prefix. */
+ regname[0] = 'r';
+ offset = 1;
+ }
- *token = s;
+ strncpy (regname + offset, start, len);
+ len += offset;
+ regname[len] = '\0';
- return 1;
-}
+ if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
+ error (_("Invalid register name `%s' on expression `%s'."),
+ regname, p->saved_arg);
-static struct value *
-arm_stap_evaluate_special_token (struct gdbarch *gdbarch,
- struct stap_evaluation_info *eval_info)
-{
- struct value *ret = NULL;
+ ++tmp;
+ tmp = skip_spaces_const (tmp);
+ if (*tmp++ != '#')
+ return 0;
- if (*eval_info->exp_buf == '[')
- {
- char *tmp = eval_info->exp_buf;
- char *comma;
- int number;
+ if (*tmp == '-')
+ {
+ ++tmp;
+ got_minus = 1;
+ }
- ++tmp;
- while (*tmp && *tmp != ',')
- ++tmp;
+ displacement = strtol (tmp, (char **) &tmp, 10);
- if (*tmp == '\0')
- return NULL;
+ /* Skipping last `]'. */
+ if (*tmp++ != ']')
+ return 0;
- /* We have to make this hack here because otherwise
- `stap_fetch_reg_value' would get confused due to the odd format
- of the displacement line. */
- *tmp = ']';
- comma = tmp;
+ /* The displacement. */
+ write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (displacement);
+ write_exp_elt_opcode (OP_LONG);
+ if (got_minus)
+ write_exp_elt_opcode (UNOP_NEG);
- ++tmp;
- tmp = skip_spaces (tmp);
- if (*tmp++ != '#')
- return NULL;
+ /* The register name. */
+ write_exp_elt_opcode (OP_REGISTER);
+ str.ptr = regname;
+ str.length = len;
+ write_exp_string (str);
+ write_exp_elt_opcode (OP_REGISTER);
- number = strtol (tmp, &tmp, 0);
+ write_exp_elt_opcode (BINOP_ADD);
- /* Skipping last `]'. */
- ++tmp;
+ /* Casting to the expected type. */
+ write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_type (lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (UNOP_CAST);
- ret = stap_fetch_reg_value (eval_info,
- value_from_longest (builtin_type (gdbarch)->builtin_int,
- number));
+ write_exp_elt_opcode (UNOP_IND);
- eval_info->exp_buf = tmp;
- /* Restoring the original char. */
- *comma = ',';
+ p->arg = tmp;
}
else
- return NULL;
+ return 0;
- return ret;
+ return 1;
}
static void
@@ -1257,18 +1272,13 @@ arm_linux_init_abi (struct gdbarch_info info,
/* SystemTap functions. */
set_gdbarch_stap_integer_prefix (gdbarch, "#");
- set_gdbarch_stap_integer_sufix (gdbarch, NULL);
set_gdbarch_stap_register_prefix (gdbarch, "r");
- 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, arm_stap_is_single_operand);
set_gdbarch_stap_parse_special_token (gdbarch,
arm_stap_parse_special_token);
- set_gdbarch_stap_evaluate_special_token (gdbarch,
- arm_stap_evaluate_special_token);
tdep->syscall_next_pc = arm_linux_syscall_next_pc;
}
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 648b06c..e1b0f85 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -95,8 +95,6 @@ static void gen_int_literal (struct agent_expr *ax,
struct axs_value *value,
LONGEST k, struct type *type);
-
-static void require_rvalue (struct agent_expr *ax, struct axs_value *value);
static void gen_usual_unary (struct expression *exp, struct agent_expr *ax,
struct axs_value *value);
static int type_wider_than (struct type *type1, struct type *type2);
@@ -157,8 +155,6 @@ static void gen_repeat (struct expression *exp, union exp_element **pc,
static void gen_sizeof (struct expression *exp, union exp_element **pc,
struct agent_expr *ax, struct axs_value *value,
struct type *size_type);
-static void gen_expr (struct expression *exp, union exp_element **pc,
- struct agent_expr *ax, struct axs_value *value);
static void gen_expr_binop_rest (struct expression *exp,
enum exp_opcode op, union exp_element **pc,
struct agent_expr *ax,
@@ -789,7 +785,7 @@ gen_int_literal (struct agent_expr *ax, struct axs_value *value, LONGEST k,
/* Take what's on the top of the stack (as described by VALUE), and
try to make an rvalue out of it. Signal an error if we can't do
that. */
-static void
+void
require_rvalue (struct agent_expr *ax, struct axs_value *value)
{
/* Only deal with scalars, structs and such may be too large
@@ -1807,7 +1803,7 @@ gen_sizeof (struct expression *exp, union exp_element **pc,
/* XXX: i18n */
/* A gen_expr function written by a Gen-X'er guy.
Append code for the subexpression of EXPR starting at *POS_P to AX. */
-static void
+void
gen_expr (struct expression *exp, union exp_element **pc,
struct agent_expr *ax, struct axs_value *value)
{
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 951ec1f..6cdcda2 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -111,6 +111,11 @@ extern struct agent_expr *gen_trace_for_return_address (CORE_ADDR,
extern struct agent_expr *gen_eval_for_expr (CORE_ADDR, struct expression *);
+extern void gen_expr (struct expression *exp, union exp_element **pc,
+ struct agent_expr *ax, struct axs_value *value);
+
+extern void require_rvalue (struct agent_expr *ax, struct axs_value *value);
+
extern int trace_kludge;
extern int trace_string_kludge;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index aeb131f..3679a29 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2367,7 +2367,7 @@ create_longjmp_master_breakpoint (void)
if (bp_objfile_data->longjmp_probes != NULL)
{
int i;
- const struct stap_probe *probe;
+ struct stap_probe *probe;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
for (i = 0;
@@ -2510,7 +2510,7 @@ create_exception_master_breakpoint (void)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
int i;
- const struct stap_probe *probe;
+ struct stap_probe *probe;
for (i = 0;
VEC_iterate (stap_probe_p,
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index dd2824f..cd5fab5 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -223,6 +223,18 @@ skip_spaces (char *chp)
return chp;
}
+/* A const-correct version of the above. */
+
+const char *
+skip_spaces_const (const char *chp)
+{
+ if (chp == NULL)
+ return NULL;
+ while (*chp && isspace (*chp))
+ chp++;
+ return chp;
+}
+
/* See documentation in cli-utils.h. */
char *
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index ed1a63e..6581151 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -94,6 +94,10 @@ extern int number_is_in_list (char *list, int number);
extern char *skip_spaces (char *inp);
+/* A const-correct version of the above. */
+
+extern const char *skip_spaces_const (const char *inp);
+
/* Skip leading non-whitespace characters in INP, returning an updated
pointer. If INP is NULL, return NULL. */
diff --git a/gdb/elfread.c b/gdb/elfread.c
index a983449..d5247aa 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1688,7 +1688,7 @@ get_base_address (bfd *obfd)
/* Implementation of `sym_get_probes', as documented in symfile.h. */
-static const struct stap_probe *
+static struct stap_probe *
elf_get_probes (struct objfile *objfile, int *num_probes)
{
struct stap_probe *ret = NULL;
@@ -1755,7 +1755,7 @@ elf_get_probes (struct objfile *objfile, int *num_probes)
static int
elf_get_probe_argument_count (struct objfile *objfile,
- const struct stap_probe *probe)
+ struct stap_probe *probe)
{
const char *pargs = probe->args;
@@ -1771,7 +1771,7 @@ elf_get_probe_argument_count (struct objfile *objfile,
static struct value *
elf_evaluate_probe_argument (struct objfile *objfile,
- const struct stap_probe *probe,
+ struct stap_probe *probe,
struct frame_info *frame,
int n)
{
@@ -1782,7 +1782,7 @@ elf_evaluate_probe_argument (struct objfile *objfile,
static void
elf_compile_to_ax (struct objfile *objfile,
- const struct stap_probe *probe,
+ struct stap_probe *probe,
struct agent_expr *expr,
struct axs_value *value,
int n)
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index fd77872..ec1ef46 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -273,7 +273,6 @@ struct gdbarch
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;
int has_global_solist;
int has_global_breakpoints;
gdbarch_has_shared_address_space_ftype *has_shared_address_space;
@@ -439,7 +438,6 @@ struct gdbarch startup_gdbarch =
0, /* stap_gdb_register_sufix */
0, /* stap_is_single_operand */
0, /* stap_parse_special_token */
- 0, /* stap_evaluate_special_token */
0, /* has_global_solist */
0, /* has_global_breakpoints */
default_has_shared_address_space, /* has_shared_address_space */
@@ -739,7 +737,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* 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. */
/* Skip verify of has_global_solist, invalid_p == 0 */
/* Skip verify of has_global_breakpoints, invalid_p == 0 */
/* Skip verify of has_shared_address_space, invalid_p == 0 */
@@ -1273,12 +1270,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: stabs_argument_has_addr = <%s>\n",
host_address_to_string (gdbarch->stabs_argument_has_addr));
fprintf_unfiltered (file,
- "gdbarch_dump: gdbarch_stap_evaluate_special_token_p() = %d\n",
- gdbarch_stap_evaluate_special_token_p (gdbarch));
- fprintf_unfiltered (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,
@@ -4002,13 +3993,13 @@ gdbarch_stap_parse_special_token_p (struct gdbarch *gdbarch)
}
int
-gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, const char **token)
+gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->stap_parse_special_token != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_parse_special_token called\n");
- return gdbarch->stap_parse_special_token (gdbarch, token);
+ return gdbarch->stap_parse_special_token (gdbarch, p);
}
void
@@ -4019,30 +4010,6 @@ set_gdbarch_stap_parse_special_token (struct gdbarch *gdbarch,
}
int
-gdbarch_stap_evaluate_special_token_p (struct gdbarch *gdbarch)
-{
- gdb_assert (gdbarch != NULL);
- return gdbarch->stap_evaluate_special_token != NULL;
-}
-
-struct value *
-gdbarch_stap_evaluate_special_token (struct gdbarch *gdbarch, struct stap_evaluation_info *eval_info)
-{
- gdb_assert (gdbarch != NULL);
- gdb_assert (gdbarch->stap_evaluate_special_token != NULL);
- if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_evaluate_special_token called\n");
- return gdbarch->stap_evaluate_special_token (gdbarch, eval_info);
-}
-
-void
-set_gdbarch_stap_evaluate_special_token (struct gdbarch *gdbarch,
- gdbarch_stap_evaluate_special_token_ftype stap_evaluate_special_token)
-{
- gdbarch->stap_evaluate_special_token = stap_evaluate_special_token;
-}
-
-int
gdbarch_has_global_solist (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 5e4b518..1aa42ef 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -55,7 +55,7 @@ struct core_regset_section;
struct syscall;
struct agent_expr;
struct axs_value;
-struct stap_evaluation_info;
+struct stap_parse_info;
/* The architecture associated with the connection to the target.
@@ -1070,41 +1070,19 @@ extern void set_gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, gdbarch
it means that it will not be able to recognize and parse this odd syntax.
Therefore, we should add a special case function that will handle this token.
- This function should return 1 if the parsing was successful, or zero
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-12-21 22:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 22:09 [SCM] archer-tromey-stap-on-linespec: Fixing lots and lots and lots of bugs in the branch 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).