29 #include "filenames.h" 46 #define STAP_BASE_SECTION_NAME ".stapsdt.base" 106 bool is_linespec (
const char **linespecp)
const override;
109 void get_probes (std::vector<probe *> *probesp,
130 :
probe (std::move (name_), std::move (provider_), address_, arch_),
151 unsigned n)
override;
181 _(
"Probe '%s' apparently does not have arguments, but \n" 182 "GDB is requesting its argument number %u anyway. " 183 "This should not happen. Please report this bug."),
188 _(
"Probe '%s' has %d arguments, but GDB is requesting\n" 189 "argument %u. This should not happen. Please\n" 285 case BINOP_LOGICAL_OR:
288 case BINOP_LOGICAL_AND:
301 case BINOP_BITWISE_IOR:
302 case BINOP_BITWISE_AND:
303 case BINOP_BITWISE_XOR:
304 case UNOP_LOGICAL_NOT:
378 op = BINOP_BITWISE_IOR;
382 op = BINOP_LOGICAL_OR;
387 op = BINOP_BITWISE_AND;
391 op = BINOP_LOGICAL_AND;
396 op = BINOP_BITWISE_XOR;
400 op = UNOP_LOGICAL_NOT;
417 error (
_(
"Invalid opcode in expression `%s' for SystemTap" 430 const char *probe_name)
465 error (
_(
"Undefined bitness for probe '%s'."), probe_name);
481 const char **r,
const char *
const *prefixes)
483 const char *
const *p;
485 if (prefixes == NULL)
493 for (p = prefixes; *p != NULL; ++p)
494 if (strncasecmp (s, *p, strlen (*p)) == 0)
543 const char *
const *p;
555 for (p = t; *p != NULL; ++p)
557 size_t len = strlen (*p);
559 if ((len == 0 && isdigit (*s))
560 || (len > 0 && strncasecmp (s, *p, len) == 0))
588 const char **r,
const char *
const *suffixes)
590 const char *
const *p;
593 if (suffixes == NULL)
601 for (p = suffixes; *p != NULL; ++p)
602 if (strncasecmp (s, *p, strlen (*p)) == 0)
680 int disp_p = 0, indirect_p = 0;
690 int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
692 int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 0;
693 const char *reg_prefix;
694 const char *reg_ind_prefix;
695 const char *reg_suffix;
696 const char *reg_ind_suffix;
712 if (isdigit (*p->
arg))
719 displacement = strtol (p->
arg, &endp, 10);
735 p->
arg += strlen (reg_ind_prefix);
738 if (disp_p && !indirect_p)
739 error (
_(
"Invalid register displacement syntax on expression `%s'."),
744 p->
arg += strlen (reg_prefix);
751 while (isalnum (*p->
arg))
754 len = p->
arg - start;
756 regname = (
char *) alloca (len + gdb_reg_prefix_len + gdb_reg_suffix_len + 1);
761 if (gdb_reg_prefix && isdigit (*start))
763 strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
764 strncpy (regname + gdb_reg_prefix_len, start, len);
767 strncpy (regname + gdb_reg_prefix_len + len,
768 gdb_reg_suffix, gdb_reg_suffix_len);
770 len += gdb_reg_prefix_len + gdb_reg_suffix_len;
773 strncpy (regname, start, len);
779 error (
_(
"Invalid register name `%s' on expression `%s'."),
803 p->
arg += strlen (reg_suffix);
805 error (
_(
"Missing register name suffix on expression `%s'."),
813 p->
arg += strlen (reg_ind_suffix);
815 error (
_(
"Missing indirection suffix on expression `%s'."),
839 const char *int_prefix = NULL;
852 if (*p->
arg ==
'-' || *p->
arg ==
'~' || *p->
arg ==
'+')
856 const char *tmp = p->
arg;
874 while (isdigit (*tmp))
891 error (
_(
"Invalid operator `%c' for register displacement " 892 "on expression `%s'."), c, p->
saved_arg);
908 else if (isdigit (*p->
arg))
911 const char *tmp = p->
arg;
917 number = strtol (tmp, &endp, 10);
930 const char *int_suffix;
942 p->
arg += strlen (int_suffix);
944 error (
_(
"Invalid constant suffix on expression `%s'."),
950 error (
_(
"Unknown numeric token on expression `%s'."),
958 const char *int_suffix;
960 p->
arg += strlen (int_prefix);
961 number = strtol (p->
arg, &endp, 10);
970 p->
arg += strlen (int_suffix);
972 error (
_(
"Invalid constant suffix on expression `%s'."),
979 error (
_(
"Operator `%c' not recognized on expression `%s'."),
994 if (*p->
arg ==
'-' || *p->
arg ==
'~' || *p->
arg ==
'+' 998 else if (*p->
arg ==
'(')
1011 error (
_(
"Missign close-paren on expression `%s'."),
1055 while (*p->
arg !=
'\0' && *p->
arg !=
')' && !isspace (*p->
arg))
1057 const char *tmp_exp_buf;
1062 error (
_(
"Invalid operator `%c' on expression `%s'."), *p->
arg,
1069 tmp_exp_buf = p->
arg;
1073 if (cur_prec < prec)
1082 p->
arg = tmp_exp_buf;
1098 tmp_exp_buf = p->
arg;
1102 if (lookahead_prec <= prec)
1181 if (cur == NULL || *cur ==
'\0' || *cur ==
':')
1184 while (*cur !=
'\0')
1187 bool got_minus =
false;
1196 if ((cur[0] ==
'-' && isdigit (cur[1]) && cur[2] ==
'@')
1197 || (isdigit (cur[0]) && cur[1] ==
'@'))
1233 warning (
_(
"unrecognized bitness %s%c' for probe `%s'"),
1234 got_minus ?
"`-" :
"`", *cur,
1253 "before conversion to prefix form");
1260 m_parsed_args.emplace_back (bitness, atype, std::move (expr));
1298 static int have_warned_stap_incomplete = 0;
1300 if (!have_warned_stap_incomplete)
1303 "The SystemTap SDT probe support is not fully implemented on this target;\n" 1304 "you will not be able to inspect the arguments of the probes.\n" 1305 "Please report a bug against GDB requesting a port to this target."));
1306 have_warned_stap_incomplete = 1;
1394 pc = arg->
aexpr->elts;
1421 warning (
_(
"Could not read the value of a SystemTap semaphore."));
1438 warning (
_(
"Could not write the value of a SystemTap semaphore."));
1473 std::vector<const char *>
1476 const char *val = NULL;
1481 return std::vector<const char *> { val };
1500 std::vector<probe *> *probesp,
CORE_ADDR base)
1503 int size = bfd_get_arch_size (abfd) / 8;
1508 const char *provider = (
const char *) &el->data[3 *
size];
1509 const char *
name = ((
const char *)
1510 memchr (provider,
'\0',
1511 (
char *) el->data + el->size - provider));
1535 address += base - base_ref;
1537 sem_addr += base - base_ref;
1541 const char *probe_args = ((
const char*)
1543 (
char *) el->data + el->size -
name));
1545 if (probe_args != NULL)
1548 if (probe_args == NULL
1549 || (memchr (probe_args,
'\0', (
char *) el->data + el->size -
name)
1550 != el->data + el->size - 1))
1561 address,
gdbarch, sem_addr, probe_args);
1564 probesp->push_back (ret);
1573 asection **ret = (asection **) obj;
1575 if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
1587 asection *ret = NULL;
1594 "SystemTap section on objfile `%s'."),
1610 static const char *
const keywords[] = {
"-pstap",
"-probe-stap", NULL };
1627 struct sdt_note *iter;
1628 unsigned save_probesp_len = probesp->size ();
1636 if (elf_tdata (obfd)->sdt_note_head == NULL)
1650 for (iter = elf_tdata (obfd)->sdt_note_head;
1659 if (save_probesp_len == probesp->size ())
1679 std::vector<struct info_probe_column>
1687 return std::vector<struct info_probe_column> { stap_probe_column };
1705 _(
"Set SystemTap expression debugging."),
1706 _(
"Show SystemTap expression debugging."),
1707 _(
"When non-zero, the internal representation " 1708 "of SystemTap expressions will be printed."),
1715 Show information about SystemTap static probes.\n\ 1716 Usage: info probes stap [PROVIDER [NAME [OBJECT]]]\n\ 1717 Each argument is a regular expression, used to select probes.\n\ 1718 PROVIDER matches probe provider names.\n\ 1719 NAME matches the probe names.\n\ 1720 OBJECT matches the executable or shared library name."),
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)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
static expression_up stap_parse_argument(const char **arg, struct type *atype, struct gdbarch *gdbarch)
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)
bool is_linespec(const char **linespecp) const override
unsigned get_argument_count(struct frame_info *frame) override
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
gdb::unique_xmalloc_ptr< expression > expression_up
std::vector< struct info_probe_column > gen_info_probes_table_header() const override
static void info_probes_stap_command(const char *arg, int from_tty)
CORE_ADDR get_relocated_address(struct objfile *objfile) override
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)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void internal_error(const char *file, int line, const char *fmt,...)
const struct language_defn * language_def(enum language lang)
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
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
CORE_ADDR get_address() const
const static_probe_ops * get_static_ops() const override
const char * type_name() const override
char * skip_spaces(char *chp)
void info_probes_for_spops(const char *arg, int from_tty, const static_probe_ops *spops)
void parse_arguments(struct gdbarch *gdbarch)
int gdbarch_stap_is_single_operand_p(struct gdbarch *gdbarch)
std::vector< const char * > gen_info_probes_table_values() const override
static void show_stapexpressiondebug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct type * builtin_int32
static void stap_parse_argument_conditionally(struct stap_parse_info *p)
void get_probes(std::vector< probe *> *probesp, struct objfile *objfile) const override
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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
void dump_raw_expression(struct expression *exp, struct ui_file *stream, const char *note)
const char * gdbarch_stap_gdb_register_prefix(struct gdbarch *gdbarch)
void dump_prefix_expression(struct expression *exp, struct ui_file *stream)
enum stap_arg_bitness bitness
int prefixify_expression(struct expression *expr)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
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 std::string & get_name() const
const char *const * gdbarch_stap_integer_suffixes(struct gdbarch *gdbarch)
struct type * builtin_int16
void set_semaphore(struct objfile *objfile, struct gdbarch *gdbarch) override
const char *const * gdbarch_stap_register_suffixes(struct gdbarch *gdbarch)
#define SECT_OFF_DATA(objfile)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
#define ANOFFSET(secoff, whichone)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
stap_probe_arg(enum stap_arg_bitness bitness_, struct type *atype_, expression_up &&aexpr_)
void clear_semaphore(struct objfile *objfile, struct gdbarch *gdbarch) override
const char * m_unparsed_args_text
struct type * builtin_uint32
#define complaint(COMPLAINTS, FMT,...)
int gdbarch_stap_is_single_operand(struct gdbarch *gdbarch, const char *s)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
static CORE_ADDR relocate_address(CORE_ADDR address, struct objfile *objfile)
struct cmd_list_element * setdebuglist
std::vector< struct stap_probe_arg > m_parsed_args
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)
void gen_expr(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value)
struct type * builtin_unsigned_short
static void handle_stap_probe(struct objfile *objfile, struct sdt_note *el, std::vector< probe *> *probesp, CORE_ADDR base)
std::vector< const static_probe_ops * > all_static_probe_ops
void write_exp_elt_opcode(struct parser_state *ps, enum exp_opcode expelt)
struct value * evaluate_argument(unsigned n, struct frame_info *frame) override
#define STAP_BASE_SECTION_NAME
const char * gdbarch_stap_gdb_register_suffix(struct gdbarch *gdbarch)
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)
struct type * builtin_data_ptr
struct complaints * symfile_complaints
static int stap_is_operator(const char *op)
static struct type * stap_get_expected_argument_type(struct gdbarch *gdbarch, enum stap_arg_bitness b, const char *probe_name)
stap_probe(std::string &&name_, std::string &&provider_, CORE_ADDR address_, struct gdbarch *arch_, CORE_ADDR sem_addr, const char *args_text)
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)
const stap_static_probe_ops stap_static_probe_ops
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)
unsigned long long ULONGEST
static unsigned int stap_expression_debug
struct type * builtin_int64
struct cmd_list_element * showdebuglist
void compile_to_ax(struct agent_expr *aexpr, struct axs_value *axs_value, unsigned n) override
#define TYPE_LENGTH(thistype)
const char *const * gdbarch_stap_register_indirection_suffixes(struct gdbarch *gdbarch)
struct section_offsets * section_offsets
struct type * builtin_uint64
struct type * builtin_int8
static int stap_generic_check_suffix(struct gdbarch *gdbarch, const char *s, const char **r, const char *const *suffixes)
bool can_evaluate_arguments() const override
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)
struct stap_probe_arg * get_arg_by_number(unsigned n, struct gdbarch *gdbarch)
struct gdbarch * get_gdbarch() const
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)