30#include "gdbsupport/gdb_regex.h"
39#include "gdbsupport/gdb_optional.h"
47 bool is_linespec (
const char **linespecp)
const override;
50 void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
71 const char *objfile_namestr,
74 std::vector<symtab_and_line> *result)
84 objfile_namestr) != 0)
87 const std::vector<std::unique_ptr<probe>> &probes
90 for (
auto &p : probes)
95 if (provider != NULL && p->get_provider () != provider)
98 if (p->get_name () !=
name)
102 sal.
pc = p->get_relocated_address (
objfile);
105 sal.
pspace = search_pspace;
109 result->push_back (std::move (sal));
116std::vector<symtab_and_line>
122 char *objfile_namestr = NULL, *provider = NULL, *
name, *p;
123 const char *arg_start, *cs;
131 error (_(
"'%s' is not a probe linespec"), arg_start);
134 arg = skip_spaces (arg);
136 error (_(
"argument to `%s' missing"), arg_start);
138 arg_end = skip_to_space (arg);
141 std::string copy (arg, arg_end - arg);
145 p = strchr (arg,
':');
156 p = strchr (hold,
':');
167 objfile_namestr = arg;
174 error (_(
"no probe name specified"));
175 if (provider && *provider ==
'\0')
176 error (_(
"invalid provider name"));
177 if (objfile_namestr && *objfile_namestr ==
'\0')
178 error (_(
"invalid objfile name"));
180 std::vector<symtab_and_line> result;
181 if (search_pspace != NULL)
184 provider,
name, &result);
190 provider,
name, &result);
195 throw_error (NOT_FOUND_ERROR,
196 _(
"No probe matching objfile=`%s', provider=`%s', name=`%s'"),
197 objfile_namestr ? objfile_namestr : _(
"<any>"),
198 provider ? provider : _(
"<any>"),
204 std::string canon (arg_start, arg_end - arg_start);
219 std::vector<probe *> result;
224 const std::vector<std::unique_ptr<probe>> &probes
226 for (
auto &p : probes)
228 if (p->get_provider () != provider)
231 if (p->get_name () !=
name)
234 result.push_back (p.get ());
257 const std::vector<std::unique_ptr<probe>> &probes
259 for (
auto &p : probes)
260 if (p->get_relocated_address (
objfile) == pc)
263 result.
prob = p.get ();
278static std::vector<bound_probe>
282 std::vector<bound_probe> result;
283 gdb::optional<compiled_regex> obj_pat, prov_pat, probe_pat;
285 if (!provider.empty ())
286 prov_pat.emplace (provider.c_str (), REG_NOSUB,
287 _(
"Invalid provider regexp"));
288 if (!probe_name.empty ())
289 probe_pat.emplace (probe_name.c_str (), REG_NOSUB,
290 _(
"Invalid probe regexp"));
291 if (!objname.empty ())
292 obj_pat.emplace (objname.c_str (), REG_NOSUB,
293 _(
"Invalid object file regexp"));
306 const std::vector<std::unique_ptr<probe>> &probes
309 for (
auto &p : probes)
315 && prov_pat->exec (p->get_provider ().c_str (), 0, NULL, 0) != 0)
319 && probe_pat->exec (p->get_name ().c_str (), 0, NULL, 0) != 0)
322 result.emplace_back (p.get (),
objfile);
359 gdb_assert (spops != NULL);
361 std::vector<struct info_probe_column> headings
366 size_t size_max = strlen (column.print_name);
376 std::vector<const char *> probe_fields
379 gdb_assert (probe_fields.size () == headings.size ());
381 for (
const char *val : probe_fields)
389 size_max = std::max (strlen (val), size_max);
394 column.field_name, column.print_name);
404 std::vector<struct info_probe_column> headings
419 gdb_assert (
probe != NULL);
420 std::vector<struct info_probe_column> headings
422 std::vector<const char *> values
425 gdb_assert (headings.size () == values.size ());
427 for (
int ix = 0; ix < headings.size (); ++ix)
430 const char *val = values[ix];
467 std::string *probe_name, std::string *objname)
469 *probe_name = *objname =
"";
472 if (!provider->empty ())
475 if (!probe_name->empty ())
486 std::string provider, probe_name, objname;
488 int ui_out_extra_fields = 0;
490 size_t size_name = strlen (
"Name");
491 size_t size_objname = strlen (
"Object");
492 size_t size_provider = strlen (
"Provider");
493 size_t size_type = strlen (
"Type");
498 std::vector<bound_probe> probes
524 5 + ui_out_extra_fields,
525 probes.size (),
"StaticProbes");
538 size_type = std::max (strlen (probe_type), size_type);
539 size_name = std::max (
probe.prob->
get_name ().size (), size_name);
598 any_found = !probes.empty ();
618 std::string provider, probe_name, objname;
622 std::vector<bound_probe> probes
642 current_uiout->message (_(
"Probe %s:%s cannot be enabled.\n"),
653 std::string provider, probe_name, objname;
657 std::vector<bound_probe> probes
677 current_uiout->message (_(
"Probe %s:%s cannot be disabled.\n"),
708 if (ops->is_linespec (linespecp))
719 const char *s = *linespecp;
720 const char *
const *csp;
722 for (csp = keywords; *csp; csp++)
727 if (strncmp (s,
keyword, len) == 0 && isspace (s[len]))
729 *linespecp += len + 1;
742 static const char *
const keywords[] = {
"-p",
"-probe", NULL };
766std::vector<struct info_probe_column>
769 return std::vector<struct info_probe_column> ();
779 if (info_probes_cmdlist == NULL)
782Show available static probes.\n\
783Usage: info probes [all|TYPE [ARGS]]\n\
784TYPE specifies the type of the probe, and can be one of the following:\n\
786If you specify TYPE, there may be additional arguments needed by the\n\
788If you do not specify any argument, or specify `all', then the command\n\
789will show information about all types of probes."),
790 &info_probes_cmdlist, 0, &
infolist);
792 return &info_probes_cmdlist;
806 int sel = (int) (uintptr_t) data;
811 gdb_assert (sel >= -1);
814 if (pc_probe.
prob == NULL)
815 error (_(
"No probe at PC %s"), core_addr_to_string (pc));
822 error (_(
"Invalid probe argument %d -- probe has %u arguments available"),
835 CORE_ADDR pc =
expr->scope;
836 int sel = (int) (uintptr_t) data;
841 gdb_assert (sel >= -1);
844 if (pc_probe.
prob == NULL)
845 error (_(
"No probe at PC %s"), core_addr_to_string (pc));
857 gdb_assert (sel >= 0);
859 error (_(
"Invalid probe argument %d -- probe has %d arguments available"),
881 (
void *) (uintptr_t) -1);
883 (
void *) (uintptr_t) 0);
885 (
void *) (uintptr_t) 1);
887 (
void *) (uintptr_t) 2);
889 (
void *) (uintptr_t) 3);
891 (
void *) (uintptr_t) 4);
893 (
void *) (uintptr_t) 5);
895 (
void *) (uintptr_t) 6);
897 (
void *) (uintptr_t) 7);
899 (
void *) (uintptr_t) 8);
901 (
void *) (uintptr_t) 9);
903 (
void *) (uintptr_t) 10);
905 (
void *) (uintptr_t) 11);
909Show information about all type of probes."),
914Usage: enable probes [PROVIDER [NAME [OBJECT]]]\n\
915Each argument is a regular expression, used to select probes.\n\
916PROVIDER matches probe provider names.\n\
917NAME matches the probe names.\n\
918OBJECT matches the executable or shared library name.\n\
919If you do not specify any argument then the command will enable\n\
920all defined probes."),
925Usage: disable probes [PROVIDER [NAME [OBJECT]]]\n\
926Each argument is a regular expression, used to select probes.\n\
927PROVIDER matches probe provider names.\n\
928NAME matches the probe names.\n\
929OBJECT matches the executable or shared library name.\n\
930If you do not specify any argument then the command will disable\n\
931all defined probes."),
struct gdbarch * get_current_arch(void)
void ax_const_l(struct agent_expr *x, LONGEST l)
void get_probes(std::vector< std::unique_ptr< probe > > *probesp, struct objfile *objfile) const override
bool is_linespec(const char **linespecp) const override
const char * type_name() const override
std::vector< struct info_probe_column > gen_info_probes_table_header() const override
virtual struct value * evaluate_argument(unsigned n, frame_info_ptr frame)=0
virtual std::vector< const char * > gen_info_probes_table_values() const
virtual const static_probe_ops * get_static_ops() const =0
virtual CORE_ADDR get_relocated_address(struct objfile *objfile)=0
virtual void compile_to_ax(struct agent_expr *aexpr, struct axs_value *axs_value, unsigned n)=0
const std::string & get_name() const
virtual unsigned get_argument_count(struct gdbarch *gdbarch)=0
const std::string & get_provider() const
CORE_ADDR get_address() const
struct gdbarch * get_gdbarch() const
virtual std::vector< struct info_probe_column > gen_info_probes_table_header() const =0
virtual bool can_enable() const
virtual const char * type_name() const =0
struct cmd_list_element * infolist
struct cmd_list_element * disablelist
struct cmd_list_element * enablelist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
std::string extract_arg(const char **arg)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
frame_info_ptr get_selected_frame(const char *message)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
location_spec_up new_probe_location_spec(std::string &&probe)
const char * objfile_name(const struct objfile *objfile)
const struct static_probe_ops * probe_linespec_to_static_ops(const char **linespecp)
static void gen_ui_out_table_header_info(const std::vector< bound_probe > &probes, const static_probe_ops *spops)
static void info_probes_command(const char *arg, int from_tty)
static void print_ui_out_info(probe *probe)
void info_probes_for_spops(const char *arg, int from_tty, const static_probe_ops *spops)
static void parse_probe_linespec(const char *str, std::string *provider, std::string *probe_name, std::string *objname)
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)
static bool exists_probe_with_spops(const std::vector< bound_probe > &probes, const static_probe_ops *spops)
int probe_is_linespec_by_keyword(const char **linespecp, const char *const *keywords)
std::vector< const static_probe_ops * > all_static_probe_ops
static void print_ui_out_not_applicables(const static_probe_ops *spops)
static int get_number_extra_fields(const static_probe_ops *spops)
std::vector< probe * > find_probes_in_objfile(struct objfile *objfile, const char *provider, const char *name)
std::vector< symtab_and_line > parse_probes(const location_spec *locspec, struct program_space *search_pspace, struct linespec_result *canonical)
static struct value * compute_probe_arg(struct gdbarch *arch, struct internalvar *ivar, void *data)
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)
static const struct internalvar_funcs probe_funcs
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)
struct cmd_list_element ** info_probes_cmdlist_get(void)
static bool compare_probes(const bound_probe &a, const bound_probe &b)
struct value * probe_safe_evaluate_at_pc(frame_info_ptr frame, unsigned n)
struct bound_probe find_probe_by_pc(CORE_ADDR pc)
static void enable_probes_command(const char *arg, int from_tty)
struct program_space * current_program_space
std::vector< struct program_space * > program_spaces
struct type * builtin_int
enum location_spec_type type() const
const char * to_string() const
const struct sym_fns * sf
objfiles_range objfiles()
const struct sym_probe_fns * sym_probe_fns
const std::vector< std::unique_ptr< probe > > &(* sym_get_probes)(struct objfile *)
struct obj_section * section
struct program_space * pspace
struct obj_section * find_pc_overlay(CORE_ADDR pc)
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
struct value * value_from_longest(struct type *type, LONGEST num)