29 #include "filenames.h"
46 #define STAP_BASE_SECTION_NAME ".stapsdt.base"
50 extern const struct probe_ops stap_probe_ops;
184 case BINOP_LOGICAL_OR:
187 case BINOP_LOGICAL_AND:
200 case BINOP_BITWISE_IOR:
201 case BINOP_BITWISE_AND:
202 case BINOP_BITWISE_XOR:
203 case UNOP_LOGICAL_NOT:
277 op = BINOP_BITWISE_IOR;
281 op = BINOP_LOGICAL_OR;
286 op = BINOP_BITWISE_AND;
290 op = BINOP_LOGICAL_AND;
295 op = BINOP_BITWISE_XOR;
299 op = UNOP_LOGICAL_NOT;
317 _(
"Invalid opcode in expression `%s' for SystemTap"
365 _(
"Undefined bitness for probe."));
381 const char **r,
const char *
const *prefixes)
383 const char *
const *p;
385 if (prefixes == NULL)
393 for (p = prefixes; *p != NULL; ++p)
394 if (strncasecmp (s, *p, strlen (*p)) == 0)
443 const char *
const *p;
455 for (p = t; *p != NULL; ++p)
457 size_t len = strlen (*p);
459 if ((len == 0 && isdigit (*s))
460 || (len > 0 && strncasecmp (s, *p, len) == 0))
488 const char **r,
const char *
const *suffixes)
490 const char *
const *p;
493 if (suffixes == NULL)
501 for (p = suffixes; *p != NULL; ++p)
502 if (strncasecmp (s, *p, strlen (*p)) == 0)
580 int disp_p = 0, indirect_p = 0;
590 int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
592 int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 0;
593 const char *reg_prefix;
594 const char *reg_ind_prefix;
595 const char *reg_suffix;
596 const char *reg_ind_suffix;
612 if (isdigit (*p->
arg))
619 displacement = strtol (p->
arg, &endp, 10);
635 p->
arg += strlen (reg_ind_prefix);
638 if (disp_p && !indirect_p)
639 error (
_(
"Invalid register displacement syntax on expression `%s'."),
644 p->
arg += strlen (reg_prefix);
651 while (isalnum (*p->
arg))
654 len = p->
arg - start;
656 regname = alloca (len + gdb_reg_prefix_len + gdb_reg_suffix_len + 1);
661 if (gdb_reg_prefix && isdigit (*start))
663 strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
664 strncpy (regname + gdb_reg_prefix_len, start, len);
667 strncpy (regname + gdb_reg_prefix_len + len,
668 gdb_reg_suffix, gdb_reg_suffix_len);
670 len += gdb_reg_prefix_len + gdb_reg_suffix_len;
673 strncpy (regname, start, len);
679 error (
_(
"Invalid register name `%s' on expression `%s'."),
703 p->
arg += strlen (reg_suffix);
705 error (
_(
"Missing register name suffix on expression `%s'."),
713 p->
arg += strlen (reg_ind_suffix);
715 error (
_(
"Missing indirection suffix on expression `%s'."),
739 const char *int_prefix = NULL;
752 if (*p->
arg ==
'-' || *p->
arg ==
'~' || *p->
arg ==
'+')
756 const char *tmp = p->
arg;
774 while (isdigit (*tmp))
791 error (
_(
"Invalid operator `%c' for register displacement "
792 "on expression `%s'."), c, p->
saved_arg);
808 else if (isdigit (*p->
arg))
811 const char *tmp = p->
arg;
817 number = strtol (tmp, &endp, 10);
830 const char *int_suffix;
842 p->
arg += strlen (int_suffix);
844 error (
_(
"Invalid constant suffix on expression `%s'."),
850 error (
_(
"Unknown numeric token on expression `%s'."),
858 const char *int_suffix;
860 p->
arg += strlen (int_prefix);
861 number = strtol (p->
arg, &endp, 10);
870 p->
arg += strlen (int_suffix);
872 error (
_(
"Invalid constant suffix on expression `%s'."),
879 error (
_(
"Operator `%c' not recognized on expression `%s'."),
894 if (*p->
arg ==
'-' || *p->
arg ==
'~' || *p->
arg ==
'+'
898 else if (*p->
arg ==
'(')
911 error (
_(
"Missign close-paren on expression `%s'."),
955 while (*p->
arg !=
'\0' && *p->
arg !=
')' && !isspace (*p->
arg))
957 const char *tmp_exp_buf;
962 error (
_(
"Invalid operator `%c' on expression `%s'."), *p->
arg,
969 tmp_exp_buf = p->
arg;
982 p->
arg = tmp_exp_buf;
998 tmp_exp_buf = p->
arg;
1002 if (lookahead_prec <= prec)
1103 probe->
args_u.vec = NULL;
1105 if (cur == NULL || *cur ==
'\0' || *cur ==
':')
1108 while (*cur !=
'\0')
1115 memset (&arg, 0,
sizeof (arg));
1124 if ((cur[0] ==
'-' && isdigit (cur[1]) && cur[2] ==
'@')
1125 || (isdigit (cur[0]) && cur[1] ==
'@'))
1161 warning (
_(
"unrecognized bitness %s%c' for probe `%s'"),
1162 got_minus ?
"`-" :
"`", *cur, probe->
p.
name);
1179 if (stap_expression_debug)
1181 "before conversion to prefix form");
1185 if (stap_expression_debug)
1224 static int have_warned_stap_incomplete = 0;
1226 if (!have_warned_stap_incomplete)
1229 "The SystemTap SDT probe support is not fully implemented on this target;\n"
1230 "you will not be able to inspect the arguments of the probes.\n"
1231 "Please report a bug against GDB requesting a port to this target."));
1232 have_warned_stap_incomplete = 1;
1236 probe->
args_u.vec = NULL;
1307 static struct value *
1387 warning (
_(
"Could not read the value of a SystemTap semaphore."));
1404 warning (
_(
"Could not write the value of a SystemTap semaphore."));
1462 bfd *abfd = objfile->
obfd;
1463 int size = bfd_get_arch_size (abfd) / 8;
1467 const char *probe_args = NULL;
1472 ret->
p.
arch = gdbarch;
1475 ret->
p.
provider = (
char *) &el->data[3 * size];
1477 (
char *) el->data + el->size - ret->
p.
provider);
1479 if (ret->
p.
name == NULL)
1507 probe_args = memchr (ret->
p.
name,
'\0',
1508 (
char *) el->data + el->size - ret->
p.
name);
1510 if (probe_args != NULL)
1513 if (probe_args == NULL
1514 || (memchr (probe_args,
'\0', (
char *) el->data + el->size - ret->
p.
name)
1515 != el->data + el->size - 1))
1538 asection **ret = obj;
1540 if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
1552 asection *ret = NULL;
1559 "SystemTap section on objfile `%s'."),
1580 bfd *obfd = objfile->
obfd;
1582 struct sdt_note *iter;
1591 if (elf_tdata (obfd)->sdt_note_head == NULL)
1605 for (iter = elf_tdata (obfd)->sdt_note_head;
1636 static const char *
const keywords[] = {
"-pstap",
"-probe-stap", NULL };
1658 const char *val = NULL;
1662 gdbarch = probe->
p.
arch;
1707 &stap_expression_debug,
1708 _(
"Set SystemTap expression debugging."),
1709 _(
"Show SystemTap expression debugging."),
1710 _(
"When non-zero, the internal representation "
1711 "of SystemTap expressions will be printed."),
1718 Show information about SystemTap static probes.\n\
1719 Usage: info probes stap [PROVIDER [NAME [OBJECT]]]\n\
1720 Each argument is a regular expression, used to select probes.\n\
1721 PROVIDER matches probe provider names.\n\
1722 NAME matches the probe names.\n\
1723 OBJECT matches the executable or shared library name."),
struct expression * aexpr
static int stap_is_integer_prefix(struct gdbarch *gdbarch, const char *s, const char **r)
static void stap_modify_semaphore(CORE_ADDR address, int set, struct gdbarch *gdbarch)
union exp_element elts[1]
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
static CORE_ADDR stap_get_probe_address(struct probe *probe, struct objfile *objfile)
void initialize_expout(struct parser_state *ps, size_t initial_size, const struct language_defn *lang, struct gdbarch *gdbarch)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
static int stap_is_register_prefix(struct gdbarch *gdbarch, const char *s, const char **r)
static enum exp_opcode stap_get_opcode(const char **s)
static int stap_check_register_suffix(struct gdbarch *gdbarch, const char *s, const char **r)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct obstack storage_obstack
static struct type * stap_get_expected_argument_type(struct gdbarch *gdbarch, enum stap_arg_bitness b)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
struct objfile * separate_debug_objfile_backlink
static int get_stap_base_address(bfd *obfd, bfd_vma *base)
void warning(const char *fmt,...)
static int stap_is_generic_prefix(struct gdbarch *gdbarch, const char *s, const char **r, const char *const *prefixes)
static void stap_clear_semaphore(struct probe *probe_generic, struct objfile *objfile, struct gdbarch *gdbarch)
DEF_VEC_O(stap_probe_arg_s)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void internal_error(const char *file, int line, const char *fmt,...)
void dump_raw_expression(struct expression *exp, struct ui_file *stream, char *note)
const struct language_defn * language_def(enum language lang)
static void handle_stap_probe(struct objfile *objfile, struct sdt_note *el, VEC(probe_p)**probesp, CORE_ADDR base)
static int stap_check_register_indirection_suffix(struct gdbarch *gdbarch, const char *s, const char **r)
struct type * builtin_uint8
struct cmd_list_element ** info_probes_cmdlist_get(void)
struct type * builtin_uint16
static void stap_probe_destroy(struct probe *probe_generic)
static struct value * stap_evaluate_probe_argument(struct probe *probe_generic, unsigned n, struct frame_info *frame)
int can_evaluate_probe_arguments(struct probe *probe)
#define VEC_safe_push(T, V, O)
int gdbarch_stap_is_single_operand_p(struct gdbarch *gdbarch)
static void show_stapexpressiondebug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct objfile_per_bfd_storage * per_bfd
struct type * builtin_int32
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
static void stap_parse_argument_conditionally(struct stap_parse_info *p)
static void info_probes_stap_command(char *arg, int from_tty)
struct parser_state pstate
int probe_is_linespec_by_keyword(const char **linespecp, const char *const *keywords)
const char *const * gdbarch_stap_register_prefixes(struct gdbarch *gdbarch)
void write_exp_elt_longcst(struct parser_state *ps, LONGEST expelt)
#define VEC_iterate(T, V, I, P)
const struct probe_ops stap_probe_ops
const char * gdbarch_stap_gdb_register_prefix(struct gdbarch *gdbarch)
static int stap_can_evaluate_probe_arguments(struct probe *probe_generic)
void dump_prefix_expression(struct expression *exp, struct ui_file *stream)
enum stap_arg_bitness bitness
static void stap_gen_info_probes_table_header(VEC(info_probe_column_s)**heads)
int prefixify_expression(struct expression *expr)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
const char * const_char_ptr
const char * skip_spaces_const(const char *chp)
static void stap_parse_single_operand(struct stap_parse_info *p)
int gdbarch_stap_parse_special_token(struct gdbarch *gdbarch, struct stap_parse_info *p)
const char *const * gdbarch_stap_integer_suffixes(struct gdbarch *gdbarch)
static void stap_get_probes(VEC(probe_p)**probesp, struct objfile *objfile)
struct type * builtin_int16
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
const char *const * gdbarch_stap_register_suffixes(struct gdbarch *gdbarch)
#define SECT_OFF_DATA(objfile)
void free_current_contents(void *ptr)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void complaint(struct complaints **complaints, const char *fmt,...)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
#define ANOFFSET(secoff, whichone)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
#define VEC_index(T, V, I)
struct type * builtin_uint32
int gdbarch_stap_is_single_operand(struct gdbarch *gdbarch, const char *s)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
struct expression * expout
struct cmd_list_element * setdebuglist
int user_reg_map_name_to_regnum(struct gdbarch *gdbarch, const char *name, int len)
const char * objfile_name(const struct objfile *objfile)
static void get_stap_base_address_1(bfd *abfd, asection *sect, void *obj)
struct ui_file * gdb_stdlog
static void stap_parse_probe_arguments(struct stap_probe *probe, struct gdbarch *gdbarch)
void gen_expr(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value)
struct type * builtin_unsigned_short
void write_exp_elt_opcode(struct parser_state *ps, enum exp_opcode expelt)
union stap_probe::@155 args_u
#define STAP_BASE_SECTION_NAME
const char * gdbarch_stap_gdb_register_suffix(struct gdbarch *gdbarch)
void discard_cleanups(struct cleanup *old_chain)
static void stap_parse_argument_1(struct stap_parse_info *p, int has_lhs, enum stap_operand_prec prec)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static void stap_parse_register_operand(struct stap_parse_info *p)
static void stap_compile_to_ax(struct probe *probe_generic, struct agent_expr *expr, struct axs_value *value, unsigned n)
struct type * builtin_data_ptr
struct complaints * symfile_complaints
static int stap_is_operator(const char *op)
const char *const * gdbarch_stap_integer_prefixes(struct gdbarch *gdbarch)
const char *const * gdbarch_stap_register_indirection_prefixes(struct gdbarch *gdbarch)
void _initialize_stap_probe(void)
void info_probes_for_ops(const char *arg, int from_tty, const struct probe_ops *pops)
void require_rvalue(struct agent_expr *ax, struct axs_value *value)
struct value * evaluate_subexp_standard(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
static int stap_is_register_indirection_prefix(struct gdbarch *gdbarch, const char *s, const char **r)
const char * print_core_address(struct gdbarch *gdbarch, CORE_ADDR address)
const struct probe_ops * pops
static unsigned stap_get_probe_argument_count(struct probe *probe_generic, struct frame_info *frame)
unsigned long long ULONGEST
static unsigned int stap_expression_debug
struct type * builtin_int64
struct cmd_list_element * showdebuglist
#define TYPE_LENGTH(thistype)
const char *const * gdbarch_stap_register_indirection_suffixes(struct gdbarch *gdbarch)
static struct expression * stap_parse_argument(const char **arg, struct type *atype, struct gdbarch *gdbarch)
struct section_offsets * section_offsets
struct type * builtin_uint64
void reallocate_expout(struct parser_state *ps)
static void stap_set_semaphore(struct probe *probe_generic, struct objfile *objfile, struct gdbarch *gdbarch)
struct type * builtin_int8
static int stap_generic_check_suffix(struct gdbarch *gdbarch, const char *s, const char **r, const char *const *suffixes)
static struct stap_probe_arg * stap_get_arg(struct stap_probe *probe, unsigned n, struct gdbarch *gdbarch)
void write_exp_string(struct parser_state *ps, struct stoken str)
static enum stap_operand_prec stap_get_operator_prec(enum exp_opcode op)
void write_exp_elt_type(struct parser_state *ps, struct type *expelt)
void error(const char *fmt,...)
struct type * lookup_pointer_type(struct type *type)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
int gdbarch_stap_parse_special_token_p(struct gdbarch *gdbarch)
static int stap_check_integer_suffix(struct gdbarch *gdbarch, const char *s, const char **r)
static const char * stap_type_name(struct probe *probe)
static void stap_gen_info_probes_table_values(struct probe *probe_generic, VEC(const_char_ptr)**ret)
static int stap_probe_is_linespec(const char **linespecp)
const ULONGEST const LONGEST len