aboutsummaryrefslogtreecommitdiff
path: root/gdb/arm-linux-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:38 -0700
commit4c5e7a930a46ddd6844eb7aede3ef60df535bc33 (patch)
tree360c0598047c43c52d5b770a869cfa3efe847f3a /gdb/arm-linux-tdep.c
parent482ddd69c5f026aac98932be2fa8ac985b37d5be (diff)
downloadfsf-binutils-gdb-4c5e7a930a46ddd6844eb7aede3ef60df535bc33.zip
fsf-binutils-gdb-4c5e7a930a46ddd6844eb7aede3ef60df535bc33.tar.gz
fsf-binutils-gdb-4c5e7a930a46ddd6844eb7aede3ef60df535bc33.tar.bz2
Convert stap probes to create operations
This changes the stap probe code to create operations, rather than exp_elements. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * stap-probe.c (binop_maker_ftype): New typedef. (stap_maker_map): New global. (stap_make_binop): New function. (stap_parse_register_operand): Return operation_up. (stap_parse_single_operand, stap_parse_argument_conditionally) (stap_parse_argument_1): Likewise. (stap_parse_argument): Create operations. (stap_probe::parse_arguments): Update. (_initialize_stap_probe): Initialize stap_maker_map. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Change return type. * i386-tdep.h (i386_stap_parse_special_token): Change return type. * i386-tdep.c (i386_stap_parse_special_token_triplet) (i386_stap_parse_special_token_three_arg_disp) (i386_stap_parse_special_token): Change return type. * gdbarch.sh (stap_parse_special_token): Change return type. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * arm-linux-tdep.c (arm_stap_parse_special_token): Change return type. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Change return type.
Diffstat (limited to 'gdb/arm-linux-tdep.c')
-rw-r--r--gdb/arm-linux-tdep.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 20cae5b..773a933 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -32,6 +32,7 @@
#include "breakpoint.h"
#include "auxv.h"
#include "xml-syscall.h"
+#include "expop.h"
#include "aarch32-tdep.h"
#include "arch/arm.h"
@@ -1146,7 +1147,7 @@ arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
It returns one if the special token has been parsed successfully,
or zero if the current token is not considered special. */
-static int
+static expr::operation_up
arm_stap_parse_special_token (struct gdbarch *gdbarch,
struct stap_parse_info *p)
{
@@ -1161,7 +1162,6 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
int len, offset;
int got_minus = 0;
long displacement;
- struct stoken str;
++tmp;
start = tmp;
@@ -1171,7 +1171,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
++tmp;
if (*tmp != ',')
- return 0;
+ return {};
len = tmp - start;
regname = (char *) alloca (len + 2);
@@ -1212,38 +1212,33 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
/* Skipping last `]'. */
if (*tmp++ != ']')
- return 0;
+ return {};
+ p->arg = tmp;
+
+ using namespace expr;
/* The displacement. */
- write_exp_elt_opcode (&p->pstate, OP_LONG);
- write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (&p->pstate, displacement);
- write_exp_elt_opcode (&p->pstate, OP_LONG);
+ struct type *long_type = builtin_type (gdbarch)->builtin_long;
if (got_minus)
- write_exp_elt_opcode (&p->pstate, UNOP_NEG);
+ displacement = -displacement;
+ operation_up disp = make_operation<long_const_operation> (long_type,
+ displacement);
/* The register name. */
- write_exp_elt_opcode (&p->pstate, OP_REGISTER);
- str.ptr = regname;
- str.length = len;
- write_exp_string (&p->pstate, str);
- write_exp_elt_opcode (&p->pstate, OP_REGISTER);
+ operation_up reg
+ = make_operation<register_operation> (regname);
- write_exp_elt_opcode (&p->pstate, BINOP_ADD);
+ operation_up sum
+ = make_operation<add_operation> (std::move (reg), std::move (disp));
/* Casting to the expected type. */
- write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (&p->pstate, UNOP_CAST);
-
- write_exp_elt_opcode (&p->pstate, UNOP_IND);
-
- p->arg = tmp;
+ struct type *arg_ptr_type = lookup_pointer_type (p->arg_type);
+ sum = make_operation<unop_cast_operation> (std::move (sum),
+ arg_ptr_type);
+ return make_operation<unop_ind_operation> (std::move (sum));
}
- else
- return 0;
- return 1;
+ return {};
}
/* ARM process record-replay constructs: syscall, signal etc. */