28 #include "filenames.h" 47 bool is_linespec (
const char **linespecp)
const override;
50 void get_probes (std::vector<probe *> *probesp,
71 const char *objfile_namestr,
74 std::vector<symtab_and_line> *result)
86 objfile_namestr) != 0)
89 const std::vector<probe *> &probes
92 for (
probe *p : probes)
97 if (provider != NULL && p->get_provider () != provider)
100 if (p->get_name () !=
name)
104 sal.
pc = p->get_relocated_address (
objfile);
107 sal.
pspace = search_pspace;
111 result->push_back (std::move (sal));
118 std::vector<symtab_and_line>
124 char *objfile_namestr = NULL, *provider = NULL, *
name, *p;
125 const char *arg_start, *cs;
133 error (
_(
"'%s' is not a probe linespec"), arg_start);
138 error (
_(
"argument to `%s' missing"), arg_start);
147 p = strchr (arg,
':');
158 p = strchr (hold,
':');
169 objfile_namestr = arg;
176 error (
_(
"no probe name specified"));
177 if (provider && *provider ==
'\0')
178 error (
_(
"invalid provider name"));
179 if (objfile_namestr && *objfile_namestr ==
'\0')
180 error (
_(
"invalid objfile name"));
182 std::vector<symtab_and_line> result;
183 if (search_pspace != NULL)
186 provider,
name, &result);
194 provider,
name, &result);
200 _(
"No probe matching objfile=`%s', provider=`%s', name=`%s'"),
201 objfile_namestr ? objfile_namestr :
_(
"<any>"),
202 provider ? provider :
_(
"<any>"),
208 std::string canon (arg_start, arg_end - arg_start);
223 std::vector<probe *> result;
228 const std::vector<probe *> &probes
230 for (
probe *p : probes)
232 if (p->get_provider () != provider)
235 if (p->get_name () !=
name)
238 result.push_back (p);
262 const std::vector<probe *> &probes
264 for (
probe *p : probes)
265 if (p->get_relocated_address (
objfile) == pc)
283 static std::vector<bound_probe>
288 std::vector<bound_probe> result;
291 if (!provider.empty ())
292 prov_pat.
emplace (provider.c_str (), REG_NOSUB,
293 _(
"Invalid provider regexp"));
294 if (!probe_name.empty ())
295 probe_pat.
emplace (probe_name.c_str (), REG_NOSUB,
296 _(
"Invalid probe regexp"));
297 if (!objname.empty ())
298 obj_pat.
emplace (objname.c_str (), REG_NOSUB,
299 _(
"Invalid object file regexp"));
312 const std::vector<probe *> &probes
315 for (
probe *p : probes)
321 && prov_pat->
exec (p->get_provider ().c_str (), 0, NULL, 0) != 0)
325 && probe_pat->
exec (p->get_name ().c_str (), 0, NULL, 0) != 0)
328 result.emplace_back (p,
objfile);
367 std::vector<struct info_probe_column> headings
372 size_t size_max = strlen (column.print_name);
382 std::vector<const char *> probe_fields
385 gdb_assert (probe_fields.size () == headings.size ());
387 for (
const char *val : probe_fields)
395 size_max = std::max (strlen (val), size_max);
400 column.field_name, column.print_name);
410 std::vector<struct info_probe_column> headings
426 std::vector<struct info_probe_column> headings
428 std::vector<const char *> values
431 gdb_assert (headings.size () == values.size ());
433 for (
int ix = 0; ix < headings.size (); ++ix)
436 const char *val = values[ix];
475 *probe_name = *objname =
"";
478 if (!provider->empty ())
481 if (!probe_name->empty ())
494 int ui_out_extra_fields = 0;
496 size_t size_name = strlen (
"Name");
497 size_t size_objname = strlen (
"Object");
498 size_t size_provider = strlen (
"Provider");
499 size_t size_type = strlen (
"Type");
504 std::vector<bound_probe> probes
530 5 + ui_out_extra_fields,
531 probes.size (),
"StaticProbes");
544 size_type = std::max (strlen (probe_type), size_type);
545 size_name = std::max (
probe.prob->
get_name ().size (), size_name);
605 any_found = !probes.empty ();
629 std::vector<bound_probe> probes
664 std::vector<bound_probe> probes
715 if (ops->is_linespec (linespecp))
726 const char *s = *linespecp;
727 const char *
const *csp;
729 for (csp = keywords; *csp; csp++)
734 if (strncmp (s,
keyword, len) == 0 && isspace (s[len]))
736 *linespecp += len + 1;
749 static const char *
const keywords[] = {
"-p",
"-probe", NULL };
773 std::vector<struct info_probe_column>
776 return std::vector<struct info_probe_column> ();
786 if (info_probes_cmdlist == NULL)
789 Show available static probes.\n\ 790 Usage: info probes [all|TYPE [ARGS]]\n\ 791 TYPE specifies the type of the probe, and can be one of the following:\n\ 793 If you specify TYPE, there may be additional arguments needed by the\n\ 795 If you do not specify any argument, or specify `all', then the command\n\ 796 will show information about all types of probes."),
797 &info_probes_cmdlist,
"info probes ",
800 return &info_probes_cmdlist;
808 static struct value *
814 int sel = (int) (uintptr_t) data;
822 if (pc_probe.
prob == NULL)
830 error (
_(
"Invalid probe argument %d -- probe has %u arguments available"),
844 int sel = (int) (uintptr_t) data;
853 if (pc_probe.
prob == NULL)
868 error (
_(
"Invalid probe argument %d -- probe has %d arguments available"),
890 (
void *) (uintptr_t) -1);
892 (
void *) (uintptr_t) 0);
894 (
void *) (uintptr_t) 1);
896 (
void *) (uintptr_t) 2);
898 (
void *) (uintptr_t) 3);
900 (
void *) (uintptr_t) 4);
902 (
void *) (uintptr_t) 5);
904 (
void *) (uintptr_t) 6);
906 (
void *) (uintptr_t) 7);
908 (
void *) (uintptr_t) 8);
910 (
void *) (uintptr_t) 9);
912 (
void *) (uintptr_t) 10);
914 (
void *) (uintptr_t) 11);
918 Show information about all type of probes."),
923 Usage: enable probes [PROVIDER [NAME [OBJECT]]]\n\ 924 Each argument is a regular expression, used to select probes.\n\ 925 PROVIDER matches probe provider names.\n\ 926 NAME matches the probe names.\n\ 927 OBJECT matches the executable or shared library name.\n\ 928 If you do not specify any argument then the command will enable\n\ 929 all defined probes."),
934 Usage: disable probes [PROVIDER [NAME [OBJECT]]]\n\ 935 Each argument is a regular expression, used to select probes.\n\ 936 PROVIDER matches probe provider names.\n\ 937 NAME matches the probe names.\n\ 938 OBJECT matches the executable or shared library name.\n\ 939 If you do not specify any argument then the command will disable\n\ 940 all defined probes."),
static std::vector< bound_probe > collect_probes(const std::string &objname, const std::string &provider, const std::string &probe_name, const static_probe_ops *spops)
struct frame_info * get_selected_frame(const char *message)
virtual struct value * evaluate_argument(unsigned n, struct frame_info *frame)=0
CORE_ADDR get_frame_pc(struct frame_info *frame)
const struct static_probe_ops * probe_linespec_to_static_ops(const char **linespecp)
void _initialize_probe(void)
const char * get_probe_location(const struct event_location *location)
struct cmd_list_element * enablelist
static void info_probes_command(const char *arg, int from_tty)
std::string extract_arg(const char **arg)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
virtual std::vector< struct info_probe_column > gen_info_probes_table_header() const =0
struct cmd_list_element ** info_probes_cmdlist_get(void)
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
std::vector< struct info_probe_column > gen_info_probes_table_header() const override
struct obj_section * section
char * skip_spaces(char *chp)
void info_probes_for_spops(const char *arg, int from_tty, const static_probe_ops *spops)
event_location_up location
struct value * probe_safe_evaluate_at_pc(struct frame_info *frame, unsigned n)
static bool compare_probes(const bound_probe &a, const bound_probe &b)
const std::string & get_provider() const
static void disable_probes_command(const char *arg, int from_tty)
static void compile_probe_arg(struct internalvar *ivar, struct agent_expr *expr, struct axs_value *value, void *data)
void get_probes(std::vector< probe *> *probesp, struct objfile *objfile) const override
const char * type_name() const override
const struct sym_probe_fns * sym_probe_fns
struct obj_section * find_pc_overlay(CORE_ADDR pc)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
int probe_is_linespec_by_keyword(const char **linespecp, const char *const *keywords)
struct cmd_list_element * infolist
static bool exists_probe_with_spops(const std::vector< bound_probe > &probes, const static_probe_ops *spops)
const std::vector< probe * > &(* sym_get_probes)(struct objfile *)
static void print_ui_out_info(probe *probe)
static void parse_probes_in_pspace(const static_probe_ops *spops, struct program_space *search_pspace, const char *objfile_namestr, const char *provider, const char *name, std::vector< symtab_and_line > *result)
objfile(bfd *, const char *, objfile_flags)
static void print_ui_out_not_applicables(const static_probe_ops *spops)
static const struct internalvar_funcs probe_funcs
const std::string & get_name() const
const struct sym_fns * sf
std::vector< symtab_and_line > parse_probes(const struct event_location *location, struct program_space *search_pspace, struct linespec_result *canonical)
struct gdbarch * get_current_arch(void)
struct value * value_from_longest(struct type *type, LONGEST num)
virtual std::vector< const char * > gen_info_probes_table_values() const
const char * skip_to_space(const char *chp)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
static void gen_ui_out_table_header_info(const std::vector< bound_probe > &probes, const static_probe_ops *spops)
virtual CORE_ADDR get_relocated_address(struct objfile *objfile)=0
const any_static_probe_ops any_static_probe_ops
const char * objfile_name(const struct objfile *objfile)
virtual unsigned get_argument_count(struct frame_info *frame)=0
struct cmd_list_element * disablelist
event_location_up new_probe_location(const char *probe)
std::vector< const static_probe_ops * > all_static_probe_ops
bool is_linespec(const char **linespecp) const override
virtual bool can_enable() const
T & emplace(Args &&... args)
#define ALL_PSPACES(pspace)
struct program_space * pspace
virtual void compile_to_ax(struct agent_expr *aexpr, struct axs_value *axs_value, unsigned n)=0
virtual const char * type_name() const =0
struct bound_probe find_probe_by_pc(CORE_ADDR pc)
void ax_const_l(struct agent_expr *x, LONGEST l)
static void parse_probe_linespec(const char *str, std::string *provider, std::string *probe_name, std::string *objname)
std::vector< probe * > find_probes_in_objfile(struct objfile *objfile, const char *provider, const char *name)
const char * core_addr_to_string(const CORE_ADDR addr)
#define ALL_OBJFILES(obj)
static struct value * compute_probe_arg(struct gdbarch *arch, struct internalvar *ivar, void *data)
virtual const static_probe_ops * get_static_ops() const =0
#define ALL_PSPACE_OBJFILES(ss, obj)
static void enable_probes_command(const char *arg, int from_tty)
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
void error(const char *fmt,...)
static int get_number_extra_fields(const static_probe_ops *spops)
void throw_error(enum errors error, const char *fmt,...)
struct gdbarch * get_gdbarch() const
struct type * builtin_int
int exec(const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) const