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"),
699 gdb::optional<compiled_regex> &re_prov
701 gdb::optional<compiled_regex> &re_name
703 gdb::optional<compiled_regex> &re_obj
708 || re_prov->exec (provider, 0, NULL, 0) == 0)
710 || re_name->exec (
name, 0, NULL, 0) == 0)
726 std::string ignore_provider, ignore_probe_name, ignore_objname;
728 bool verbose_p =
false;
731 const char *idx = arg;
734 if (strcmp (s.c_str (),
"-reset") == 0)
737 error (_(
"-reset: no arguments allowed"));
744 if (strcmp (s.c_str (),
"-verbose") == 0
745 || strcmp (s.c_str (),
"-v") == 0)
758 gdb::optional<compiled_regex> &re_prov
760 gdb::optional<compiled_regex> &re_name
762 gdb::optional<compiled_regex> &re_obj
767 if (!ignore_provider.empty ())
768 re_prov.emplace (ignore_provider.c_str (), REG_NOSUB,
769 _(
"Invalid provider regexp"));
770 if (!ignore_probe_name.empty ())
771 re_name.emplace (ignore_probe_name.c_str (), REG_NOSUB,
772 _(
"Invalid probe regexp"));
773 if (!ignore_objname.empty ())
774 re_obj.emplace (ignore_objname.c_str (), REG_NOSUB,
775 _(
"Invalid object file regexp"));
811 if (ops->is_linespec (linespecp))
822 const char *s = *linespecp;
823 const char *
const *csp;
825 for (csp = keywords; *csp; csp++)
830 if (strncmp (s,
keyword, len) == 0 && isspace (s[len]))
832 *linespecp += len + 1;
845 static const char *
const keywords[] = {
"-p",
"-probe", NULL };
869std::vector<struct info_probe_column>
872 return std::vector<struct info_probe_column> ();
882 if (info_probes_cmdlist == NULL)
885Show available static probes.\n\
886Usage: info probes [all|TYPE [ARGS]]\n\
887TYPE specifies the type of the probe, and can be one of the following:\n\
889If you specify TYPE, there may be additional arguments needed by the\n\
891If you do not specify any argument, or specify `all', then the command\n\
892will show information about all types of probes."),
893 &info_probes_cmdlist, 0, &
infolist);
895 return &info_probes_cmdlist;
909 int sel = (int) (uintptr_t) data;
914 gdb_assert (sel >= -1);
917 if (pc_probe.
prob == NULL)
918 error (_(
"No probe at PC %s"), core_addr_to_string (pc));
925 error (_(
"Invalid probe argument %d -- probe has %u arguments available"),
938 CORE_ADDR pc =
expr->scope;
939 int sel = (int) (uintptr_t) data;
944 gdb_assert (sel >= -1);
947 if (pc_probe.
prob == NULL)
948 error (_(
"No probe at PC %s"), core_addr_to_string (pc));
960 gdb_assert (sel >= 0);
962 error (_(
"Invalid probe argument %d -- probe has %d arguments available"),
984 (
void *) (uintptr_t) -1);
986 (
void *) (uintptr_t) 0);
988 (
void *) (uintptr_t) 1);
990 (
void *) (uintptr_t) 2);
992 (
void *) (uintptr_t) 3);
994 (
void *) (uintptr_t) 4);
996 (
void *) (uintptr_t) 5);
998 (
void *) (uintptr_t) 6);
1000 (
void *) (uintptr_t) 7);
1002 (
void *) (uintptr_t) 8);
1004 (
void *) (uintptr_t) 9);
1006 (
void *) (uintptr_t) 10);
1008 (
void *) (uintptr_t) 11);
1012Show information about all type of probes."),
1017Usage: enable probes [PROVIDER [NAME [OBJECT]]]\n\
1018Each argument is a regular expression, used to select probes.\n\
1019PROVIDER matches probe provider names.\n\
1020NAME matches the probe names.\n\
1021OBJECT matches the executable or shared library name.\n\
1022If you do not specify any argument then the command will enable\n\
1023all defined probes."),
1028Usage: disable probes [PROVIDER [NAME [OBJECT]]]\n\
1029Each argument is a regular expression, used to select probes.\n\
1030PROVIDER matches probe provider names.\n\
1031NAME matches the probe names.\n\
1032OBJECT matches the executable or shared library name.\n\
1033If you do not specify any argument then the command will disable\n\
1034all defined probes."),
1039Usage: maintenance ignore-probes [-v|-verbose] [PROVIDER [NAME [OBJECT]]]\n\
1040 maintenance ignore-probes -reset\n\
1041Each argument is a regular expression, used to select probes.\n\
1042PROVIDER matches probe provider names.\n\
1043NAME matches the probe names.\n\
1044OBJECT matches the executable or shared library name.\n\
1045If you do not specify any argument then the command will ignore\n\
1046all defined probes. To reset the ignore-probes filter, use the -reset form.\n\
1047Only supported for SystemTap 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 * maintenancelist
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)
const struct builtin_type * builtin_type(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 gdb::optional< compiled_regex > ignore_probes_prov_pat[2]
static gdb::optional< compiled_regex > ignore_probes_name_pat[2]
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 gdb::optional< compiled_regex > ignore_probes_obj_pat[2]
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 bool ignore_probes_verbose_p
static bool ignore_probes_p
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 bool ignore_probes_idx
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)
static void ignore_probes_command(const char *arg, int from_tty)
struct cmd_list_element ** info_probes_cmdlist_get(void)
bool ignore_probe_p(const char *provider, const char *name, const char *objfile_name, const char *type)
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 gdbarch * arch() const
struct type * type() const
struct obj_section * find_pc_overlay(CORE_ADDR pc)
void gdb_printf(struct ui_file *stream, const char *format,...)
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)