+2019-04-04 Tom Tromey <tom@tromey.com>
+
+ * gdbarch.h, gdbarch.c: Rebuild.
+ * gdbarch.sh (dtrace_parse_probe_argument): Change type.
+ * stap-probe.h:
+ (struct stap_parse_info): Replace "parser_state" with
+ "expr_builder".
+ * parser-defs.h (struct expr_builder): Rename from "parser_state".
+ (parser_state): New class.
+ * parse.c (expr_builder): Rename.
+ (expr_builder::release): Rename.
+ (write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
+ (write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
+ (write_exp_elt_longcst, write_exp_elt_floatcst)
+ (write_exp_elt_type, write_exp_elt_intern, write_exp_string)
+ (write_exp_string_vector, write_exp_bitstring)
+ (write_exp_msymbol, mark_struct_expression)
+ (write_dollar_variable)
+ (insert_type_address_space, increase_expout_size): Replace
+ "parser_state" with "expr_builder".
+ * dtrace-probe.c: Replace "parser_state" with "expr_builder".
+ * amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace
+ "parser_state" with "expr_builder".
+
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y: Replace "parse_language" with method call.
static void
amd64_dtrace_parse_probe_argument (struct gdbarch *gdbarch,
- struct parser_state *pstate,
+ struct expr_builder *builder,
int narg)
{
struct stoken str;
int regno = arg_reg_map[narg];
const char *regname = user_reg_map_regnum_to_name (gdbarch, regno);
- write_exp_elt_opcode (pstate, OP_REGISTER);
+ write_exp_elt_opcode (builder, OP_REGISTER);
str.ptr = regname;
str.length = strlen (regname);
- write_exp_string (pstate, str);
- write_exp_elt_opcode (pstate, OP_REGISTER);
+ write_exp_string (builder, str);
+ write_exp_elt_opcode (builder, OP_REGISTER);
}
else
{
const char *regname = user_reg_map_regnum_to_name (gdbarch, AMD64_RSP_REGNUM);
/* Displacement. */
- write_exp_elt_opcode (pstate, OP_LONG);
- write_exp_elt_type (pstate, builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (pstate, narg - 6);
- write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_opcode (builder, OP_LONG);
+ write_exp_elt_type (builder, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (builder, narg - 6);
+ write_exp_elt_opcode (builder, OP_LONG);
/* Register: SP. */
- write_exp_elt_opcode (pstate, OP_REGISTER);
+ write_exp_elt_opcode (builder, OP_REGISTER);
str.ptr = regname;
str.length = strlen (regname);
- write_exp_string (pstate, str);
- write_exp_elt_opcode (pstate, OP_REGISTER);
+ write_exp_string (builder, str);
+ write_exp_elt_opcode (builder, OP_REGISTER);
- write_exp_elt_opcode (pstate, BINOP_ADD);
+ write_exp_elt_opcode (builder, BINOP_ADD);
/* Cast to long. */
- write_exp_elt_opcode (pstate, UNOP_CAST);
- write_exp_elt_type (pstate,
+ write_exp_elt_opcode (builder, UNOP_CAST);
+ write_exp_elt_type (builder,
lookup_pointer_type (builtin_type (gdbarch)->builtin_long));
- write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_opcode (builder, UNOP_CAST);
- write_exp_elt_opcode (pstate, UNOP_IND);
+ write_exp_elt_opcode (builder, UNOP_IND);
}
}
value of the argument when executed at the PC of the probe. */
for (dtrace_probe_arg &arg : m_args)
{
- /* Initialize the expression buffer in the parser state. The
- language does not matter, since we are using our own
- parser. */
- parser_state pstate (current_language, gdbarch);
+ /* Initialize the expression builder. The language does not
+ matter, since we are using our own parser. */
+ expr_builder builder (current_language, gdbarch);
/* The argument value, which is ABI dependent and casted to
`long int'. */
- gdbarch_dtrace_parse_probe_argument (gdbarch, &pstate, argc);
+ gdbarch_dtrace_parse_probe_argument (gdbarch, &builder, argc);
/* Casting to the expected type, but only if the type was
recognized at probe load time. Otherwise the argument will
be evaluated as the long integer passed to the probe. */
if (arg.type != NULL)
{
- write_exp_elt_opcode (&pstate, UNOP_CAST);
- write_exp_elt_type (&pstate, arg.type);
- write_exp_elt_opcode (&pstate, UNOP_CAST);
+ write_exp_elt_opcode (&builder, UNOP_CAST);
+ write_exp_elt_type (&builder, arg.type);
+ write_exp_elt_opcode (&builder, UNOP_CAST);
}
- arg.expr = pstate.release ();
+ arg.expr = builder.release ();
prefixify_expression (arg.expr.get ());
++argc;
}
}
void
-gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, struct parser_state *pstate, int narg)
+gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, struct expr_builder *builder, int narg)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->dtrace_parse_probe_argument != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_dtrace_parse_probe_argument called\n");
- gdbarch->dtrace_parse_probe_argument (gdbarch, pstate, narg);
+ gdbarch->dtrace_parse_probe_argument (gdbarch, builder, narg);
}
void
struct agent_expr;
struct axs_value;
struct stap_parse_info;
-struct parser_state;
+struct expr_builder;
struct ravenscar_arch_ops;
struct mem_range;
struct syscalls_info;
extern int gdbarch_dtrace_parse_probe_argument_p (struct gdbarch *gdbarch);
-typedef void (gdbarch_dtrace_parse_probe_argument_ftype) (struct gdbarch *gdbarch, struct parser_state *pstate, int narg);
-extern void gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, struct parser_state *pstate, int narg);
+typedef void (gdbarch_dtrace_parse_probe_argument_ftype) (struct gdbarch *gdbarch, struct expr_builder *builder, int narg);
+extern void gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, struct expr_builder *builder, int narg);
extern void set_gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, gdbarch_dtrace_parse_probe_argument_ftype *dtrace_parse_probe_argument);
/* True if the given ADDR does not contain the instruction sequence
# The expression to compute the NARTGth+1 argument to a DTrace USDT probe.
# NARG must be >= 0.
-M;void;dtrace_parse_probe_argument;struct parser_state *pstate, int narg;pstate, narg
+M;void;dtrace_parse_probe_argument;struct expr_builder *builder, int narg;builder, narg
# True if the given ADDR does not contain the instruction sequence
# corresponding to a disabled DTrace is-enabled probe.
struct agent_expr;
struct axs_value;
struct stap_parse_info;
-struct parser_state;
+struct expr_builder;
struct ravenscar_arch_ops;
struct mem_range;
struct syscalls_info;
int, int *,
innermost_block_tracker_types);
-static void increase_expout_size (struct parser_state *ps, size_t lenelt);
+static void increase_expout_size (struct expr_builder *ps, size_t lenelt);
/* Documented at it's declaration. */
/* See definition in parser-defs.h. */
-parser_state::parser_state (const struct language_defn *lang,
+expr_builder::expr_builder (const struct language_defn *lang,
struct gdbarch *gdbarch)
: expout_size (10),
expout (XNEWVAR (expression,
}
expression_up
-parser_state::release ()
+expr_builder::release ()
{
/* Record the actual number of expression elements, and then
reallocate the expression memory so that we free up any
a register through here. */
static void
-write_exp_elt (struct parser_state *ps, const union exp_element *expelt)
+write_exp_elt (struct expr_builder *ps, const union exp_element *expelt)
{
if (ps->expout_ptr >= ps->expout_size)
{
}
void
-write_exp_elt_opcode (struct parser_state *ps, enum exp_opcode expelt)
+write_exp_elt_opcode (struct expr_builder *ps, enum exp_opcode expelt)
{
union exp_element tmp;
}
void
-write_exp_elt_sym (struct parser_state *ps, struct symbol *expelt)
+write_exp_elt_sym (struct expr_builder *ps, struct symbol *expelt)
{
union exp_element tmp;
}
void
-write_exp_elt_msym (struct parser_state *ps, minimal_symbol *expelt)
+write_exp_elt_msym (struct expr_builder *ps, minimal_symbol *expelt)
{
union exp_element tmp;
}
void
-write_exp_elt_block (struct parser_state *ps, const struct block *b)
+write_exp_elt_block (struct expr_builder *ps, const struct block *b)
{
union exp_element tmp;
}
void
-write_exp_elt_objfile (struct parser_state *ps, struct objfile *objfile)
+write_exp_elt_objfile (struct expr_builder *ps, struct objfile *objfile)
{
union exp_element tmp;
}
void
-write_exp_elt_longcst (struct parser_state *ps, LONGEST expelt)
+write_exp_elt_longcst (struct expr_builder *ps, LONGEST expelt)
{
union exp_element tmp;
}
void
-write_exp_elt_floatcst (struct parser_state *ps, const gdb_byte expelt[16])
+write_exp_elt_floatcst (struct expr_builder *ps, const gdb_byte expelt[16])
{
union exp_element tmp;
int index;
}
void
-write_exp_elt_type (struct parser_state *ps, struct type *expelt)
+write_exp_elt_type (struct expr_builder *ps, struct type *expelt)
{
union exp_element tmp;
}
void
-write_exp_elt_intern (struct parser_state *ps, struct internalvar *expelt)
+write_exp_elt_intern (struct expr_builder *ps, struct internalvar *expelt)
{
union exp_element tmp;
void
-write_exp_string (struct parser_state *ps, struct stoken str)
+write_exp_string (struct expr_builder *ps, struct stoken str)
{
int len = str.length;
size_t lenelt;
long constant, followed by the contents of the string. */
void
-write_exp_string_vector (struct parser_state *ps, int type,
+write_exp_string_vector (struct expr_builder *ps, int type,
struct stoken_vector *vec)
{
int i, len;
either end of the bitstring. */
void
-write_exp_bitstring (struct parser_state *ps, struct stoken str)
+write_exp_bitstring (struct expr_builder *ps, struct stoken str)
{
int bits = str.length; /* length in bits */
int len = (bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
the expression. */
void
-write_exp_msymbol (struct parser_state *ps,
+write_exp_msymbol (struct expr_builder *ps,
struct bound_minimal_symbol bound_msym)
{
write_exp_elt_opcode (ps, OP_VAR_MSYM_VALUE);
expression. This is used when completing on field names. */
void
-mark_struct_expression (struct parser_state *ps)
+mark_struct_expression (struct expr_builder *ps)
{
gdb_assert (parse_completion
&& expout_tag_completion_type == TYPE_CODE_UNDEF);
value in the value history, I.e. $$1 */
void
-write_dollar_variable (struct parser_state *ps, struct stoken str)
+write_dollar_variable (struct expr_builder *ps, struct stoken str)
{
struct block_symbol sym;
struct bound_minimal_symbol msym;
item. */
void
-insert_type_address_space (struct parser_state *pstate, char *string)
+insert_type_address_space (struct expr_builder *pstate, char *string)
{
union type_stack_elt element;
int slot;
there is enough room for the elements. */
static void
-increase_expout_size (struct parser_state *ps, size_t lenelt)
+increase_expout_size (struct expr_builder *ps, size_t lenelt)
{
if ((ps->expout_ptr + lenelt) >= ps->expout_size)
{
extern int parser_debug;
-struct parser_state
+/* A class that can be used to build a "struct expression". */
+
+struct expr_builder
{
/* Constructor. LANG is the language used to parse the expression.
And GDBARCH is the gdbarch to use during parsing. */
- parser_state (const struct language_defn *lang,
+ expr_builder (const struct language_defn *lang,
struct gdbarch *gdbarch);
- DISABLE_COPY_AND_ASSIGN (parser_state);
+ DISABLE_COPY_AND_ASSIGN (expr_builder);
/* Resize the allocated expression to the correct size, and return
it as an expression_up -- passing ownership to the caller. */
size_t expout_ptr;
};
+/* An instance of this type is instantiated during expression parsing,
+ and passed to the appropriate parser. It holds both inputs to the
+ parser, and result. */
+
+struct parser_state : public expr_builder
+{
+ /* Constructor. LANG is the language used to parse the expression.
+ And GDBARCH is the gdbarch to use during parsing. */
+
+ parser_state (const struct language_defn *lang,
+ struct gdbarch *gdbarch)
+ : expr_builder (lang, gdbarch)
+ {
+ }
+
+ DISABLE_COPY_AND_ASSIGN (parser_state);
+};
+
/* If this is nonzero, this block is used as the lexical context
for symbol names. */
extern int prefixify_expression (struct expression *expr);
-extern void write_exp_elt_opcode (struct parser_state *, enum exp_opcode);
+extern void write_exp_elt_opcode (struct expr_builder *, enum exp_opcode);
-extern void write_exp_elt_sym (struct parser_state *, struct symbol *);
+extern void write_exp_elt_sym (struct expr_builder *, struct symbol *);
-extern void write_exp_elt_longcst (struct parser_state *, LONGEST);
+extern void write_exp_elt_longcst (struct expr_builder *, LONGEST);
-extern void write_exp_elt_floatcst (struct parser_state *, const gdb_byte *);
+extern void write_exp_elt_floatcst (struct expr_builder *, const gdb_byte *);
-extern void write_exp_elt_type (struct parser_state *, struct type *);
+extern void write_exp_elt_type (struct expr_builder *, struct type *);
-extern void write_exp_elt_intern (struct parser_state *, struct internalvar *);
+extern void write_exp_elt_intern (struct expr_builder *, struct internalvar *);
-extern void write_exp_string (struct parser_state *, struct stoken);
+extern void write_exp_string (struct expr_builder *, struct stoken);
-void write_exp_string_vector (struct parser_state *, int type,
+void write_exp_string_vector (struct expr_builder *, int type,
struct stoken_vector *vec);
-extern void write_exp_bitstring (struct parser_state *, struct stoken);
+extern void write_exp_bitstring (struct expr_builder *, struct stoken);
-extern void write_exp_elt_block (struct parser_state *, const struct block *);
+extern void write_exp_elt_block (struct expr_builder *, const struct block *);
-extern void write_exp_elt_objfile (struct parser_state *,
+extern void write_exp_elt_objfile (struct expr_builder *,
struct objfile *objfile);
-extern void write_exp_msymbol (struct parser_state *,
+extern void write_exp_msymbol (struct expr_builder *,
struct bound_minimal_symbol);
-extern void write_dollar_variable (struct parser_state *, struct stoken str);
+extern void write_dollar_variable (struct expr_builder *, struct stoken str);
-extern void mark_struct_expression (struct parser_state *);
+extern void mark_struct_expression (struct expr_builder *);
extern const char *find_template_name_end (const char *);
extern void push_type_int (int);
-extern void insert_type_address_space (struct parser_state *, char *);
+extern void insert_type_address_space (struct expr_builder *, char *);
extern enum type_pieces pop_type (void);
#if !defined (STAP_PROBE_H)
#define STAP_PROBE_H 1
-/* For `struct parser_state'. */
#include "parser-defs.h"
/* Structure which holds information about the parsing process of one probe's
const char *arg;
/* The parser state to be used when generating the expression. */
- struct parser_state pstate;
+ struct expr_builder pstate;
/* A pointer to the full chain of arguments. This is useful for printing
error messages. The parser functions should not modify this argument