Add a dt_provider_discover() function
PATCH v4 2/19 Add a dt_provider_discover() function
From: Eugene Loh <[email protected]>
It is possible for new providers and probes to appear after dtrace_go(). Add a function that can be called for such discovery, on a per-provider basis. Each provider that supports such discovery needs to provide:
*) a function discover() that performs discovery on behalf of the provider
*) a function add_probe() that adds a particular (discovered) probe
To support looping over providers, move dt_providers[] from dt_open.c to dt_provider.c and extern it in dt_provider.h.
--- libdtrace/dt_bpf.c | 4 +++ libdtrace/dt_open.c | 22 +--------------- libdtrace/dt_provider.c | 57 +++++++++++++++++++++++++++++++++++++++++ libdtrace/dt_provider.h | 6 +++++ libdtrace/dt_work.c | 3 +++ 5 files changed, 71 insertions(+), 21 deletions(-)
libdtrace/dt_bpf.c +4 -0
@@ -1275,6 +1275,10 @@ dt_bpf_load_progs(dtrace_hdl_t *dtp, uint_t cflags)int fd;int rc =-1 ; +/* Handle probes discovered after compilation. */ +if (prp->prov->impl->add_probe) + prp->prov->impl->add_probe (dtp, prp); + dp = prp->difo;if (dp ==NULL )continue ;
libdtrace/dt_open.c +1 -21
@@ -61,26 +61,6 @@ const dt_version_t _dtrace_versions[] = { 0 }; -/* -* List of provider modules that register providers and probes. A single -* provider module may create multiple providers. -*/ -static const dt_provimpl_t *dt_providers[] = { - &dt_dtrace,/* list dt_dtrace first */ - &dt_cpc, - &dt_fbt_fprobe, - &dt_io, - &dt_ip, - &dt_lockstat, - &dt_proc, - &dt_profile, - &dt_rawtp, - &dt_sched, - &dt_sdt, - &dt_syscall, - &dt_uprobe, -}; -/* * Table of global identifiers. This is used to populate the global identifier * hash when a new dtrace client open occurs. For more info see dt_ident.h.
@@ -1210,7 +1190,7 @@ dtrace_init(dtrace_hdl_t *dtp)* known providers. */ dt_probe_init (dtp); -for (i =0 ; i <ARRAY_SIZE (dt_providers); i++) { +for (i =0 ; dt_providers[i]; i++) {int n; n = dt_providers[i]->populate (dtp);
libdtrace/dt_provider.c +57 -0
70 lines not on this page · raw message
libdtrace/dt_provider.h +6 -0
@@ -62,6 +62,9 @@ typedef struct dt_provimpl {int (*probe_info)(dtrace_hdl_t *dtp,/* get probe info */ const struct dt_probe *prp,int *argcp,dt_argdesc_t **argvp); +int (*discover)(dtrace_hdl_t *dtp);/* discover new probes */ +int (*add_probe)(dtrace_hdl_t *dtp,/* add a new probe */ +struct dt_probe *prp);void (*detach)(dtrace_hdl_t *dtp,/* probe cleanup */ const struct dt_probe *prb); void (*probe_destroy)(dtrace_hdl_t *dtp, /* free probe data */
@@ -86,6 +89,8 @@ extern dt_provimpl_t dt_sdt;extern dt_provimpl_t dt_syscall;extern dt_provimpl_t dt_uprobe; +extern const dt_provimpl_t *dt_providers[]; + typedef struct dt_provider { dt_list_t pv_list; /* list forward/back pointers */ struct dt_hentry he; /* htab links */
@@ -110,6 +115,7 @@ extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *, const dt_provimpl_t *, const dtrace_pattr_t *, void *);extern int dt_provider_xref (dtrace_hdl_t *,dt_provider_t *,id_t ); +extern int dt_provider_discover (dtrace_hdl_t *dtp); #ifdef __cplusplus }
libdtrace/dt_work.c +3 -0
@@ -362,6 +362,9 @@ dtrace_work(dtrace_hdl_t *dtp, FILE *fp, dtrace_consume_probe_f *pfunc,dtrace_workstatus_t rval;int gen; +if (dt_provider_discover (dtp) <0 ) +return DTRACE_WORKSTATUS_ERROR ; +switch (dtrace_status (dtp)) {case DTRACE_STATUS_EXITED :case DTRACE_STATUS_STOPPED :
Signature · 1 line
2.43.5
PATCH v7 7/19 Create the BPF usdt_names and usdt_prids maps
From: Eugene Loh <[email protected]>
As USDT processes come and go, the set of overlying probes for an underlying probe will change. Hence, we will move to a scheme in which an underlying probe program will walk all possible clauses that any of its possible overlying probes might call, for each overlying probe only executing the clauses that apply, using a bitmask.
In this patch, we create and update the BPF "usdt_prids" map. This is a hash map, where:
*) the key (size: dtp->dt_usdt_pridsmap_ksz) comprises
- the PID of the firing process
- the PRID of the underlying probe
*) the value (size: dtp->dt_usdt_pridsmap_vsz) comprises
- the PRID over the overlying USDT probe
- a bit mask indicating which clauses should be called
As USDT processes start up, we also add new overlying USDT probes, whose name elements must be retrievable by prid for the built-in variables probeprov, probemod, probefunc, and probename. While those strings are currently in the BPF "strtab" map, that monolithic table cannot safely be updated by the consumer while the kernel might be reading the map. Therefore, we introduce a new variable, dtp->dt_nprobes, that records the number of probes at the time of dtrace_go(). For a prid < dtp->nprobes, get_bvar() uses the existing scheme to retrieve probe name elements. For newer prids, necessarily USDT probes, use the new BPF "usdt_names" map instead.
The number of new USDT probes that can be accommodated at any one time is set by the new "nusdtprobes" option.
The size of the bit mask limits the number of clauses, currently 64, an underlying probe might call. This is relatively easy to extend; nevertheless, that work is left for a future patch.
We also want to be able to add new underlying probes, even after dtrace_go() has finished. Therefore, make dt_bpf_load_prog() callable outside of dt_bpf.c and call dt_construct(), dt_link(), dt_bpf_load_prog(), and attach() to add any new underlying probes.
--- bpf/get_bvar.c | 72 ++++--- include/dtrace/options_defines.h | 4 +- libdtrace/dt_bpf.c | 38 +++- libdtrace/dt_bpf.h | 4 + libdtrace/dt_bpf_maps.h | 9 + libdtrace/dt_cc.c | 3 + libdtrace/dt_dlibs.c | 3 + libdtrace/dt_impl.h | 5 +- libdtrace/dt_open.c | 8 + libdtrace/dt_options.c | 1 + libdtrace/dt_prov_uprobe.c | 336 ++++++++++++++++++++++++++++++- libdtrace/dt_provider.c | 1 + libdtrace/dt_provider.h | 1 + 13 files changed, 455 insertions(+), 30 deletions(-)
bpf/get_bvar.c +47 -25
@@ -22,6 +22,7 @@extern struct bpf_map_def cpuinfo;extern struct bpf_map_def probes;extern struct bpf_map_def state; +extern struct bpf_map_def usdt_names;extern uint64_t PC ;extern uint64_t STBSZ ;
@@ -29,6 +30,7 @@ extern uint64_t STKSIZ;extern uint64_t BOOTTM ;extern uint64_t STACK_OFF ;extern uint64_t STACK_SKIP ; +extern uint64_t NPROBES ;#define error (dctx, fault, illval) \ ({ \
@@ -122,32 +124,52 @@ noinline uint64_t dt_get_bvar(const dt_dctx_t *dctx, uint32_t id, uint32_t idx)case DIF_VAR_PROBEMOD :case DIF_VAR_PROBEFUNC :case DIF_VAR_PROBENAME : { -uint32_t key; -dt_bpf_probe_t *pinfo; -uint64_t off; - - key = mst->prid; - pinfo =bpf_map_lookup_elem (&probes, &key); -if (pinfo ==NULL ) -return (uint64_t )dctx->strtab; - -switch (id) { -case DIF_VAR_PROBEPROV : - off = pinfo->prv; -break ; -case DIF_VAR_PROBEMOD : - off = pinfo->mod; -break ; -case DIF_VAR_PROBEFUNC : - off = pinfo->fun; -break ; -case DIF_VAR_PROBENAME : - off = pinfo->prb; +uint32_t key = mst->prid; + +if (key < ((uint64_t )&NPROBES )) { +dt_bpf_probe_t *pinfo; +uint64_t off; + + pinfo =bpf_map_lookup_elem (&probes, &key); +if (pinfo ==NULL ) +return (uint64_t )dctx->strtab; + +switch (id) { +case DIF_VAR_PROBEPROV : + off = pinfo->prv; +break ; +case DIF_VAR_PROBEMOD : + off = pinfo->mod; +break ; +case DIF_VAR_PROBEFUNC : + off = pinfo->fun; +break ; +case DIF_VAR_PROBENAME : + off = pinfo->prb; + } +if (off > (uint64_t )&STBSZ ) +return (uint64_t )dctx->strtab; + +return (uint64_t )(dctx->strtab + off); + }else { +char *s; + + s =bpf_map_lookup_elem (&usdt_names, &key); +if (s ==NULL ) +return (uint64_t )dctx->strtab; + +switch (id) { +case DIF_VAR_PROBENAME : + s +=DTRACE_FUNCNAMELEN ; +case DIF_VAR_PROBEFUNC : + s +=DTRACE_MODNAMELEN ; +case DIF_VAR_PROBEMOD : + s +=DTRACE_PROVNAMELEN ; +case DIF_VAR_PROBEPROV : + } + +return (uint64_t )s; } -if (off > (uint64_t )&STBSZ ) -return (uint64_t )dctx->strtab; - -return (uint64_t )(dctx->strtab + off); }case DIF_VAR_PID : {uint64_t val =bpf_get_current_pid_tgid ();
include/dtrace/options_defines.h +3 -1
@@ -63,7 +63,9 @@#define DTRACEOPT_SCRATCHSIZE 33/* max scratch size permitted */ #define DTRACEOPT_LOCKMEM 34/* max locked memory */ #define DTRACEOPT_PRINTSIZE 35/* max # bytes printed by print() action */ -#define DTRACEOPT_MAX 36/* number of options */ +#define DTRACEOPT_NUSDTPROBES 36/* max number of (added) USDT probes */ + +#define DTRACEOPT_MAX 37/* number of options */ #define DTRACEOPT_UNSET (dtrace_optval_t)-2/* unset option */
libdtrace/dt_bpf.c +37 -1
@@ -940,6 +940,41 @@ gmap_create_probes(dtrace_hdl_t *dtp)return 0 ; } +/* +* Create the 'usdt_names' and 'usdt_prids' BPF maps. +* +* 'usdt_names': a global hash map indexed by PRID and whose value has probe +* name elements at fixed offsets within the value. This map +* is used for get_bvar() to look up probe name elements for +* any prid that was created after dtrace_go(). +* +* 'usdt_prids': a global hash map indexed by (pid, underlying probe ID). +* The value is a probe ID for the overlying USDT probe and +* a bit mask indicating which clauses to execute for this pid. +* +* For a given (pid, PRID) key, there can be at most one +* overlying USDT probe. +*/ +static int +gmap_create_usdt (dtrace_hdl_t *dtp) +{ +size_t nusdtprobes = dtp->dt_options[DTRACEOPT_NUSDTPROBES ]; + + dtp->dt_usdt_namesmap_fd =create_gmap (dtp,"usdt_names" ,BPF_MAP_TYPE_HASH , +sizeof (dtrace_id_t),DTRACE_FULLNAMELEN , nusdtprobes); +if (dtp->dt_usdt_namesmap_fd ==-1 ) +return -1 ; + + dtp->dt_usdt_pridsmap_fd =create_gmap (dtp,"usdt_prids" ,BPF_MAP_TYPE_HASH , +sizeof (usdt_prids_map_key_t),sizeof (usdt_prids_map_val_t), nusdtprobes); +if (dtp->dt_usdt_pridsmap_fd ==-1 ) +return -1 ; + + dtp->dt_nprobes = dtp->dt_probe_id; + +return 0 ; +} +/* * Create the 'gvars' BPF map. *
@@ -1045,6 +1080,7 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp) CREATE_MAP(scratchmem) CREATE_MAP(strtab) CREATE_MAP(probes) + CREATE_MAP(usdt) CREATE_MAP(gvars) CREATE_MAP(lvars) CREATE_MAP(dvars)
@@ -1093,7 +1129,7 @@ dt_bpf_reloc_prog(dtrace_hdl_t *dtp, const dtrace_difo_t *dp)* * Note that DTrace generates BPF programs that are licensed under the GPL. */ -static int +int dt_bpf_load_prog (dtrace_hdl_t *dtp,const dt_probe_t *prp,const dtrace_difo_t *dp,uint_t cflags) {
libdtrace/dt_bpf.h +4 -0
@@ -14,6 +14,7 @@#include <dtrace/difo.h> #include <dt_btf.h> #include <dt_impl.h> +#include <dt_probe.h> struct dtrace_hdl ;
@@ -54,6 +55,7 @@ extern "C" {#define DT_CONST_ZERO_OFF 20#define DT_CONST_STACK_OFF 21#define DT_CONST_STACK_SKIP 22 +#define DT_CONST_NPROBES 23#define DT_BPF_LOG_SIZE_DEFAULT (UINT32_MAX >> 8)#define DT_BPF_LOG_SIZE_SMALL 4096
@@ -88,6 +90,8 @@ extern int dt_bpf_prog_load(struct dtrace_hdl *, const struct dt_probe *prp, size_t sz);extern int dt_bpf_raw_tracepoint_open (const void *tp,int fd);extern int dt_bpf_make_progs (struct dtrace_hdl *,uint_t ); +extern int dt_bpf_load_prog (dtrace_hdl_t *dtp,const dt_probe_t *prp, +const dtrace_difo_t *dp,uint_t cflags);extern int dt_bpf_load_progs (struct dtrace_hdl *,uint_t );extern void dt_bpf_init (struct dtrace_hdl *dtp);
libdtrace/dt_bpf_maps.h +9 -0
@@ -42,6 +42,15 @@ struct dt_bpf_cpuinfo {uint64_t lockstat_stime;/* lockstat: spin time */ }; +typedef struct usdt_prids_map_key { +int pid;/* should be pid_t, unistd.h? */ +uint32_t uprid;/* should be dtrace_id_t, sys/dtrace_types.h */ +}usdt_prids_map_key_t ; +typedef struct usdt_prids_map_val { +uint32_t prid;/* should be dtrace_id_t, sys/dtrace_types.h */ +long long mask; +}usdt_prids_map_val_t ; + #ifdef __cplusplus }#endif
libdtrace/dt_cc.c +3 -0
@@ -1064,6 +1064,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp, nrp->dofr_data =sizeof (uint64_t ) * dtp->dt_options[DTRACEOPT_MAXFRAMES ];continue ; +case DT_CONST_NPROBES : + nrp->dofr_data = dtp->dt_nprobes; +continue ;case DT_CONST_BOOTTM :if (boottime ==0 &&get_boottime ())return -1 ;
libdtrace/dt_dlibs.c +3 -0
@@ -71,6 +71,8 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL (state,DT_IDENT_PTR ),DT_BPF_SYMBOL (strtab,DT_IDENT_PTR ),DT_BPF_SYMBOL (tuples,DT_IDENT_PTR ), +DT_BPF_SYMBOL (usdt_names,DT_IDENT_PTR ), +DT_BPF_SYMBOL (usdt_prids,DT_IDENT_PTR ),/* BPF internal identifiers */ DT_BPF_SYMBOL_ID(PRID, DT_IDENT_SCALAR, DT_CONST_PRID),
@@ -95,6 +97,7 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL_ID (ZERO_OFF ,DT_IDENT_SCALAR ,DT_CONST_ZERO_OFF ),DT_BPF_SYMBOL_ID (STACK_OFF ,DT_IDENT_SCALAR ,DT_CONST_STACK_OFF ),DT_BPF_SYMBOL_ID (STACK_SKIP ,DT_IDENT_SCALAR ,DT_CONST_STACK_SKIP ), +DT_BPF_SYMBOL_ID (NPROBES ,DT_IDENT_SCALAR ,DT_CONST_NPROBES ),/* End-of-list marker */ { NULL, }
libdtrace/dt_impl.h +4 -1
@@ -319,7 +319,8 @@ struct dtrace_hdl {*/ struct dt_probe **dt_probes;/* array of probes */ size_t dt_probes_sz;/* size of array of probes */ -uint32_t dt_probe_id;/* next available probe id */ +dtrace_id_t dt_probe_id;/* next available probe id */ +dtrace_id_t dt_nprobes;/* number of probes, at dtrace_go() */ struct dt_probe *dt_error;/* ERROR probe */
@@ -389,6 +390,8 @@ struct dtrace_hdl {int dt_aggmap_fd;/* file descriptor for the 'aggs' BPF map */ int dt_genmap_fd;/* file descriptor for the 'agggen' BPF map */ int dt_cpumap_fd;/* file descriptor for the 'cpuinfo' BPF map */ +int dt_usdt_pridsmap_fd;/* file descriptor for the 'usdt_prids' BPF map */ +int dt_usdt_namesmap_fd;/* file descriptor for the 'usdt_names' BPF map */ dtrace_handle_err_f *dt_errhdlr;/* error handler, if any */ void *dt_errarg;/* error handler argument */ dtrace_handle_drop_f *dt_drophdlr;/* drop handler, if any */
libdtrace/dt_open.c +8 -0
@@ -797,6 +797,14 @@ dt_vopen(int version, int flags, int *errp, dtp->dt_options[DTRACEOPT_SWITCHRATE ] =0 ; dtp->dt_options[DTRACEOPT_AGGRATE ] =0 ; +/* +* Set the default maximum number of (added) USDT probes. +*/ + dtp->dt_options[DTRACEOPT_NUSDTPROBES ] =256 ; + +/* +* Pre-processor. +*/ dtp->dt_cpp_argv[0 ] = (char *)strbasename (dtp->dt_cpp_path); snprintf(isadef, sizeof(isadef), "-D__SUNW_D_%u",
libdtrace/dt_options.c +1 -0
@@ -1137,6 +1137,7 @@ static const dt_option_t _dtrace_rtoptions[] = { { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE }, { "lockmem", dt_opt_lockmem, DTRACEOPT_LOCKMEM }, { "maxframes", dt_opt_runtime, DTRACEOPT_MAXFRAMES }, + { "nusdtprobes", dt_opt_runtime, DTRACEOPT_NUSDTPROBES }, { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC }, { "pcapsize", dt_opt_pcapsize, DTRACEOPT_PCAPSIZE }, { "scratchsize", dt_opt_scratchsize, DTRACEOPT_SCRATCHSIZE },
libdtrace/dt_prov_uprobe.c +334 -2
373 lines not on this page · raw message
libdtrace/dt_provider.c +1 -0
@@ -41,6 +41,7 @@ const dt_provimpl_t *dt_providers[] = { &dt_sdt, &dt_syscall, &dt_uprobe, + &dt_usdt, NULL };
libdtrace/dt_provider.h +1 -0
@@ -88,6 +88,7 @@ extern dt_provimpl_t dt_sched;extern dt_provimpl_t dt_sdt;extern dt_provimpl_t dt_syscall;extern dt_provimpl_t dt_uprobe; +extern dt_provimpl_t dt_usdt;extern const dt_provimpl_t *dt_providers[];
Signature · 1 line
2.43.5
Quoted 125 lines · On Mon, Oct 28, 2024 at 01:18:35AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
It is possible for new providers and probes to appear after
dtrace_go(). Add a function that can be called for such discovery, on a per-provider basis. Each provider that supports such discovery needs to provide:*) a function
discover()that performs discovery on behalf of the provider*) a function
add_probe()that adds a particular (discovered) probeTo support looping over providers, move dt_providers[] from
dt_open.ctodt_provider.cand extern it indt_provider.h.Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_bpf.c | 4 +++ libdtrace/dt_open.c | 22 +--------------- libdtrace/dt_provider.c | 57 +++++++++++++++++++++++++++++++++++++++++ libdtrace/dt_provider.h | 6 +++++ libdtrace/dt_work.c | 3 +++ 5 files changed, 71 insertions(+), 21 deletions(-)libdtrace/dt_bpf.c +4
-0@@ -1275,6 +1275,10 @@ dt_bpf_load_progs(dtrace_hdl_t *dtp, uint_t cflags)int fd;int rc =-1 ; +/* Handle probes discovered after compilation. */ +if (prp->prov->impl->add_probe) + prp->prov->impl->add_probe (dtp, prp); + dp = prp->difo;if (dp ==NULL )continue ;libdtrace/dt_open.c +1
-21@@ -61,26 +61,6 @@ const dt_version_t _dtrace_versions[] = { 0 }; -/* -* List of provider modules that register providers and probes. A single -* provider module may create multiple providers. -*/ -static const dt_provimpl_t *dt_providers[] = { - &dt_dtrace,/* list dt_dtrace first */ - &dt_cpc, - &dt_fbt_fprobe, - &dt_io, - &dt_ip, - &dt_lockstat, - &dt_proc, - &dt_profile, - &dt_rawtp, - &dt_sched, - &dt_sdt, - &dt_syscall, - &dt_uprobe, -}; -/* * Table of global identifiers. This is used to populate the global identifier * hash when a new dtrace client open occurs. For more info see dt_ident.h. @@ -1210,7 +1190,7 @@ dtrace_init(dtrace_hdl_t *dtp)* known providers. */ dt_probe_init (dtp); -for (i =0 ; i <ARRAY_SIZE (dt_providers); i++) { +for (i =0 ; dt_providers[i]; i++) {int n; n = dt_providers[i]->populate (dtp);libdtrace/dt_provider.c +29
-0@@ -18,10 +18,32 @@#include <port.h> #include <dt_provider.h> +#include <dt_probe.h> #include <dt_module.h> #include <dt_string.h> #include <dt_list.h> +/* +* List of provider modules that register providers and probes. A single +* provider module may create multiple providers. +*/ +const dt_provimpl_t *dt_providers[] = { + &dt_dtrace,/* list dt_dtrace first */ + &dt_cpc, + &dt_fbt_fprobe, + &dt_io, + &dt_ip, + &dt_lockstat, + &dt_proc, + &dt_profile, + &dt_rawtp, + &dt_sched, + &dt_sdt, + &dt_syscall, + &dt_uprobe, +NULL +}; +static uint32_t dt_provider_hval (const dt_provider_t *pvp) {@@ -149,3 +171,38 @@ dt_provider_xref(dtrace_hdl_t *dtp, dt_provider_t *pvp, id_t id)BT_SET (pvp->pv_xrefs, id);return 0 ; } + +int +dt_provider_discover (dtrace_hdl_t *dtp) +{ +int i, prid = dtp->dt_probe_id; + +/* Discover new probes. */
libdtrace/dt_provider.c dt_provider_xref(dtrace_hdl_t *dtp, dt_provider_t *pvp, id_t id) · line 190
Quoted 10 lines
libdtrace/dt_provider.c +10
-0+for (i =0 ; dt_providers[i]; i++) { +int n; + +if (dt_providers[i]->discover ==NULL ) +continue ; + + n = dt_providers[i]->discover (dtp); +if (n <0 ) +return -1 ;/* errno is already set */ + }
My apologies for not seeing this sooner, but can't this simply be:
for (i = 0; dt_providers[i]; i++) {
if (dt_providers[i]->discover && dt_providers[i]->discover(dtp) < 0)
return -1; /* errno is already set */
}Quoted 66 lines
libdtrace/dt_provider.c +18
-0+ +/* Add them. */ +for ( ; prid < dtp->dt_probe_id; prid++) { +dt_probe_t *prp = dtp->dt_probes[prid]; +int rc; + +dt_probe_enable (dtp, prp); + +if (prp->prov->impl->add_probe ==NULL ) +continue ; + + rc = prp->prov->impl->add_probe (dtp, prp); +if (rc <0 ) +return rc; + } + +return 0 ; +}libdtrace/dt_provider.h +6
-0@@ -62,6 +62,9 @@ typedef struct dt_provimpl {int (*probe_info)(dtrace_hdl_t *dtp,/* get probe info */ const struct dt_probe *prp,int *argcp,dt_argdesc_t **argvp); +int (*discover)(dtrace_hdl_t *dtp);/* discover new probes */ +int (*add_probe)(dtrace_hdl_t *dtp,/* add a new probe */ +struct dt_probe *prp);void (*detach)(dtrace_hdl_t *dtp,/* probe cleanup */ const struct dt_probe *prb); void (*probe_destroy)(dtrace_hdl_t *dtp, /* free probe data */@@ -86,6 +89,8 @@ extern dt_provimpl_t dt_sdt;extern dt_provimpl_t dt_syscall;extern dt_provimpl_t dt_uprobe; +extern const dt_provimpl_t *dt_providers[]; + typedef struct dt_provider { dt_list_t pv_list; /* list forward/back pointers */ struct dt_hentry he; /* htab links */@@ -110,6 +115,7 @@ extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *, const dt_provimpl_t *, const dtrace_pattr_t *, void *);extern int dt_provider_xref (dtrace_hdl_t *,dt_provider_t *,id_t ); +extern int dt_provider_discover (dtrace_hdl_t *dtp); #ifdef __cplusplus }libdtrace/dt_work.c +3
-0@@ -362,6 +362,9 @@ dtrace_work(dtrace_hdl_t *dtp, FILE *fp, dtrace_consume_probe_f *pfunc,dtrace_workstatus_t rval;int gen; +if (dt_provider_discover (dtp) <0 ) +return DTRACE_WORKSTATUS_ERROR ; +switch (dtrace_status (dtp)) {case DTRACE_STATUS_EXITED :case DTRACE_STATUS_STOPPED :Signature · 1 line
2.43.5