41# define SHT_SUNW_dof 0x6ffffff4
81 bool is_linespec (
const char **linespecp)
const override;
84 void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
111 dtrace_probe (std::string &&name_, std::string &&provider_, CORE_ADDR address_,
113 std::vector<struct dtrace_probe_arg> &&args_,
114 std::vector<struct dtrace_probe_enabler> &&enablers_)
115 :
probe (
std::move (name_),
std::move (provider_), address_, arch_),
137 unsigned n)
override;
166 std::vector<struct dtrace_probe_arg>
m_args;
352#define DOF_UINT(dof, field) \
353 extract_unsigned_integer ((gdb_byte *) &(field), \
355 (((dof)->dofh_ident[DTRACE_DOF_ID_ENCODING] \
356 == DTRACE_DOF_ENCODE_MSB) \
357 ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE))
363#define DTRACE_DOF_PTR(dof, offset) (&((char *) (dof))[(offset)])
369#define DTRACE_DOF_SECT(dof, idx) \
370 ((struct dtrace_dof_sect *) \
371 DTRACE_DOF_PTR ((dof), \
372 DOF_UINT ((dof), (dof)->dofh_secoff) \
373 + ((idx) * DOF_UINT ((dof), (dof)->dofh_secsize))))
383 std::vector<std::unique_ptr<probe>> *probesp,
387 char *strtab,
char *offtab,
char *eofftab,
388 char *argtab, uint64_t strtab_size)
390 int i, j, num_probes, num_enablers;
435 std::vector<struct dtrace_probe_enabler> enablers;
437 for (i = 0; i < num_enablers; i++)
440 uint32_t enabler_offset
441 = ((uint32_t *) eofftab)[
DOF_UINT (dof,
probe->dofpr_enoffidx) + i];
445 enablers.push_back (enabler);
448 for (i = 0; i < num_probes; i++)
450 uint32_t probe_offset
451 = ((uint32_t *) offtab)[
DOF_UINT (dof,
probe->dofpr_offidx) + i];
454 const char *probe_provider
468 std::vector<struct dtrace_probe_arg> args;
470 for (j = 0; j < probe_argc; j++)
476 std::string type_str (p);
479 while (*p++ !=
'\0' && p - strtab < strtab_size)
492 catch (
const gdb_exception_error &ex)
496 if (
expr != NULL &&
expr->first_opcode () == OP_TYPE)
497 type =
expr->evaluate_type ()->type ();
499 args.emplace_back (
type, std::move (type_str), std::move (
expr));
502 std::vector<struct dtrace_probe_enabler> enablers_copy = enablers;
504 std::string (probe_provider),
507 std::move (enablers_copy));
510 probesp->emplace_back (ret);
521 std::vector<std::unique_ptr<probe>> *probesp,
535 goto invalid_dof_data;
541 goto invalid_dof_data;
583 goto invalid_dof_data;
589 goto invalid_dof_data;
593 for (i = 0; i < num_probes; i++)
602 provider, strtab, offtab, eofftab, argtab,
610 complaint (_(
"skipping section '%s' which does not contain valid DOF data."),
639 if (arg.type != NULL)
640 op = expr::make_operation<expr::unop_cast_operation> (std::move (op),
658 internal_error (_(
"Probe '%s' has %d arguments, but GDB is requesting\n"
659 "argument %u. This should not happen. Please\n"
717 return arg->
expr->evaluate (arg->
type);
745std::vector<const char *>
748 const char *val = NULL;
759 return std::vector<const char *> { val };
772 error (_(
"No inferior running"));
796 error (_(
"No inferior running"));
805 error (_(
"Probe %s:%s cannot be disabled: no enablers."),
820 static const char *
const keywords[] = {
"-pdtrace",
"-probe-dtrace", NULL };
829 (std::vector<std::unique_ptr<probe>> *probesp,
833 asection *sect = NULL;
842 for (sect = abfd->sections; sect != NULL; sect = sect->next)
844 if (elf_section_data (sect)->this_hdr.sh_type ==
SHT_SUNW_dof)
850 if (bfd_malloc_and_get_section (abfd, sect, &dof) && dof != NULL)
854 complaint (_(
"could not obtain the contents of"
855 "section '%s' in objfile `%s'."),
856 bfd_section_name (sect), bfd_get_filename (abfd));
873std::vector<struct info_probe_column>
879 dtrace_probe_column.
print_name = _(
"Enabled");
881 return std::vector<struct info_probe_column> { dtrace_probe_column };
900Show information about DTrace static probes.\n\
901Usage: info probes dtrace [PROVIDER [NAME [OBJECT]]]\n\
902Each argument is a regular expression, used to select probes.\n\
903PROVIDER matches probe provider names.\n\
904NAME matches the probe names.\n\
905OBJECT matches the executable or shared library name."),
void require_rvalue(struct agent_expr *ax, struct axs_value *value)
dtrace_probe(std::string &&name_, std::string &&provider_, CORE_ADDR address_, struct gdbarch *arch_, std::vector< struct dtrace_probe_arg > &&args_, std::vector< struct dtrace_probe_enabler > &&enablers_)
unsigned get_argument_count(struct gdbarch *gdbarch) override
const static_probe_ops * get_static_ops() const override
std::vector< struct dtrace_probe_arg > m_args
CORE_ADDR get_relocated_address(struct objfile *objfile) override
bool can_evaluate_arguments() const override
std::vector< struct dtrace_probe_enabler > m_enablers
std::vector< const char * > gen_info_probes_table_values() const override
struct value * evaluate_argument(unsigned n, frame_info_ptr frame) override
struct dtrace_probe_arg * get_arg_by_number(unsigned n, struct gdbarch *gdbarch)
void build_arg_exprs(struct gdbarch *gdbarch)
void compile_to_ax(struct agent_expr *aexpr, struct axs_value *axs_value, unsigned n) override
bool can_enable() const override
void get_probes(std::vector< std::unique_ptr< probe > > *probesp, struct objfile *objfile) const override
bool is_linespec(const char **linespecp) const override
std::vector< struct info_probe_column > gen_info_probes_table_header() const override
const char * type_name() const override
const std::string & get_name() const
const std::string & get_provider() const
CORE_ADDR get_address() const
struct gdbarch * get_gdbarch() const
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
#define complaint(FMT,...)
static void dtrace_process_dof_probe(struct objfile *objfile, struct gdbarch *gdbarch, std::vector< std::unique_ptr< probe > > *probesp, struct dtrace_dof_hdr *dof, struct dtrace_dof_probe *probe, struct dtrace_dof_provider *provider, char *strtab, char *offtab, char *eofftab, char *argtab, uint64_t strtab_size)
#define DTRACE_DOF_SECT(dof, idx)
@ DTRACE_DOF_SECT_TYPE_ECBDESC
@ DTRACE_DOF_SECT_TYPE_PROVIDER
@ DTRACE_DOF_SECT_TYPE_PRENOFFS
@ DTRACE_DOF_SECT_TYPE_PROFFS
@ DTRACE_DOF_SECT_TYPE_STRTAB
@ DTRACE_DOF_SECT_TYPE_NONE
@ DTRACE_DOF_SECT_TYPE_PRARGS
@ DTRACE_DOF_SECT_TYPE_PROBES
const dtrace_static_probe_ops dtrace_static_probe_ops
static void info_probes_dtrace_command(const char *arg, int from_tty)
static void dtrace_process_dof(asection *sect, struct objfile *objfile, std::vector< std::unique_ptr< probe > > *probesp, struct dtrace_dof_hdr *dof)
#define DTRACE_DOF_PTR(dof, offset)
void _initialize_dtrace_probe()
#define DOF_UINT(dof, field)
std::unique_ptr< expression > expression_up
expression_up parse_expression_with_language(const char *string, enum language lang)
void gdbarch_dtrace_enable_probe(struct gdbarch *gdbarch, CORE_ADDR addr)
bool gdbarch_dtrace_parse_probe_argument_p(struct gdbarch *gdbarch)
bool gdbarch_dtrace_enable_probe_p(struct gdbarch *gdbarch)
expr::operation_up gdbarch_dtrace_parse_probe_argument(struct gdbarch *gdbarch, int narg)
bool gdbarch_dtrace_probe_is_enabled_p(struct gdbarch *gdbarch)
int gdbarch_dtrace_probe_is_enabled(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdbarch_dtrace_disable_probe(struct gdbarch *gdbarch, CORE_ADDR addr)
bool gdbarch_dtrace_disable_probe_p(struct gdbarch *gdbarch)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
const struct language_defn * current_language
std::unique_ptr< operation > operation_up
void info_probes_for_spops(const char *arg, int from_tty, 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
struct cmd_list_element ** info_probes_cmdlist_get(void)
struct type * builtin_long
dtrace_probe_arg(struct type *type_, std::string &&type_str_, expression_up &&expr_)
void set_operation(expr::operation_up &&op)
ATTRIBUTE_UNUSED_RESULT expression_up release()
struct objfile * separate_debug_objfile_backlink
struct gdbarch * arch() const
CORE_ADDR text_section_offset() const
struct type * type() const