[DTrace-devel] [PATCH 05/19] Add flag to dt_pid_create_probes()
Kris Van Hees
kris.van.hees at oracle.com
Wed Sep 18 20:33:47 UTC 2024
On Thu, Aug 29, 2024 at 01:25:44AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> The function dt_pid_create_probes() creates both pid and usdt probes.
> Once the dtrace session has started, however, we only need to watch
> for new usdt probes. So add a usdt_only argument to the function.
It would be better I think to create two functions, one for trying to match pid
probes, and one for trying to match USDT probes, and to call those two functions
from dt_pid_create_probes(). And then, after tracing has started, only the one
dealing with USDT probes needs to be called.
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
> libdtrace/dt_cc.c | 2 +-
> libdtrace/dt_pid.c | 4 ++--
> libdtrace/dt_pid.h | 3 +--
> 3 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> index e66d76fb..cfd4d3d1 100644
> --- a/libdtrace/dt_cc.c
> +++ b/libdtrace/dt_cc.c
> @@ -282,7 +282,7 @@ dt_setcontext(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)
> isdigit(pdp->prv[strlen(pdp->prv) - 1]) &&
> ((pvp = dt_provider_lookup(dtp, pdp->prv)) == NULL ||
> pvp->pv_flags & DT_PROVIDER_PID) &&
> - dt_pid_create_probes((dtrace_probedesc_t *)pdp, dtp, yypcb) != 0) {
> + dt_pid_create_probes((dtrace_probedesc_t *)pdp, dtp, yypcb, 0) != 0) {
> longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
> }
>
> diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
> index 996543b1..3f3453af 100644
> --- a/libdtrace/dt_pid.c
> +++ b/libdtrace/dt_pid.c
> @@ -1095,7 +1095,7 @@ dt_pid_get_pid(const dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb,
> }
>
> int
> -dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
> +dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb, int usdt_only)
> {
> char provname[DTRACE_PROVNAMELEN];
> dt_proc_t *dpr;
> @@ -1109,7 +1109,7 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
>
> snprintf(provname, sizeof(provname), "pid%d", (int)pid);
>
> - if (gmatch(provname, pdp->prv) != 0) {
> + if ((usdt_only == 0) && gmatch(provname, pdp->prv) != 0) {
> if (dt_proc_grab_lock(dtp, pid, DTRACE_PROC_WAITING) < 0) {
> dt_pid_error(dtp, pcb, NULL, D_PROC_GRAB,
> "failed to grab process %d", (int)pid);
> diff --git a/libdtrace/dt_pid.h b/libdtrace/dt_pid.h
> index 497c7751..dc200f4d 100644
> --- a/libdtrace/dt_pid.h
> +++ b/libdtrace/dt_pid.h
> @@ -16,8 +16,7 @@
> extern "C" {
> #endif
>
> -extern int dt_pid_create_probes(dtrace_probedesc_t *, dtrace_hdl_t *,
> - dt_pcb_t *);
> +extern int dt_pid_create_probes(dtrace_probedesc_t *, dtrace_hdl_t *, dt_pcb_t *, int);
> extern int dt_pid_create_probes_module(dtrace_hdl_t *, dt_proc_t *);
> extern pid_t dt_pid_get_pid(const dtrace_probedesc_t *, dtrace_hdl_t *, dt_pcb_t *,
> dt_proc_t *);
> --
> 2.43.5
>
More information about the DTrace-devel
mailing list