public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 2/4] provider, cg: add reject_clasue() callback
@ 2025-07-15  5:48 Kris Van Hees
  2025-07-15 10:35 ` Nick Alcock
  2025-07-15 18:34 ` [DTrace-devel] " Eugene Loh
  0 siblings, 2 replies; 5+ messages in thread
From: Kris Van Hees @ 2025-07-15  5:48 UTC (permalink / raw)
  To: dtrace, dtrace-devel

Future providers will require functionality to determine whether a
clause for one of its probes needs to be rejected for some reason.

Since the callback is invoked during trampoline creation, rejection
must result in a compilation error.  The callback is responsible for
this.  If it returns, the clause is accepted.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 libdtrace/dt_cg.c       | 22 ++++++++++++++++------
 libdtrace/dt_provider.h |  2 ++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index d80b0a55..738597ed 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -855,16 +855,26 @@ dt_cg_tramp_map_args(dt_pcb_t *pcb, dt_argdesc_t *args, size_t nargs)
 }
 
 typedef struct {
-	dt_irlist_t	*dlp;
-	dt_activity_t	act;
-	uint_t		lbl_exit;
+	const dt_probe_t	*prp;
+	dt_irlist_t		*dlp;
+	dt_activity_t		act;
+	uint_t			lbl_exit;
 } dt_clause_arg_t;
 
 static int
 dt_cg_call_clause(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp, dt_clause_arg_t *arg)
 {
-	dt_irlist_t	*dlp = arg->dlp;
-	dt_ident_t	*idp = sdp->dtsd_clause;
+	const dt_probe_t	*prp = arg->prp;
+	dt_irlist_t		*dlp = arg->dlp;
+	dt_ident_t		*idp = sdp->dtsd_clause;
+
+	/*
+	 * Ensure the clause is valid for the probe.  Call the reject_clause()
+	 * hook if defined, otherwise apply default checks.  Rejection of the
+	 * clause must be reported as a compilation error.
+	 */
+	if (prp->prov->impl->reject_clause != NULL)
+		prp->prov->impl->reject_clause(prp, sdp->dtsd_clauseflags);
 
 	/*
 	 *	if (*dctx.act != act)	// ldw %r0, [%r9 + DCTX_ACT]
@@ -895,7 +905,7 @@ void
 dt_cg_tramp_call_clauses(dt_pcb_t *pcb, const dt_probe_t *prp, dt_activity_t act)
 {
 	dt_irlist_t	*dlp = &pcb->pcb_ir;
-	dt_clause_arg_t	arg = { dlp, act, pcb->pcb_exitlbl };
+	dt_clause_arg_t	arg = { prp, dlp, act, pcb->pcb_exitlbl };
 
 	dt_probe_stmt_iter(pcb->pcb_hdl, prp, (dt_stmt_f *)dt_cg_call_clause, &arg);
 }
diff --git a/libdtrace/dt_provider.h b/libdtrace/dt_provider.h
index 2a3bba80..a7263f5d 100644
--- a/libdtrace/dt_provider.h
+++ b/libdtrace/dt_provider.h
@@ -52,6 +52,8 @@ typedef struct dt_provimpl {
 		       const pid_probespec_t *psp);
 	void (*enable)(dtrace_hdl_t *dtp,	/* enable the given probe */
 		       struct dt_probe *prp);
+	void (*reject_clause)(const struct dt_probe *prp, int clsflags);
+						/* check clause flags */
 	int (*trampoline)(dt_pcb_t *pcb,	/* generate BPF trampoline */
 			   uint_t exitlbl);
 	int (*load_prog)(dtrace_hdl_t *dtp, const struct dt_probe *prp,
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/4] provider, cg: add reject_clasue() callback
  2025-07-15  5:48 [PATCH 2/4] provider, cg: add reject_clasue() callback Kris Van Hees
@ 2025-07-15 10:35 ` Nick Alcock
  2025-07-15 15:10   ` Kris Van Hees
  2025-07-15 18:34 ` [DTrace-devel] " Eugene Loh
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Alcock @ 2025-07-15 10:35 UTC (permalink / raw)
  To: Kris Van Hees; +Cc: dtrace, dtrace-devel

On 15 Jul 2025, Kris Van Hees spake thusly:

> Future providers will require functionality to determine whether a
> clause for one of its probes needs to be rejected for some reason.
> 
> Since the callback is invoked during trampoline creation, rejection
> must result in a compilation error.  The callback is responsible for
> this.  If it returns, the clause is accepted.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>

Reviewed-by: Nick Alcock <nick.alcock@oracle.com>

modulo the comment nit below.

> +	/*
> +	 * Ensure the clause is valid for the probe.  Call the reject_clause()
> +	 * hook if defined, otherwise apply default checks.  Rejection of the
> +	 * clause must be reported as a compilation error.
> +	 */
> +	if (prp->prov->impl->reject_clause != NULL)
> +		prp->prov->impl->reject_clause(prp, sdp->dtsd_clauseflags);

This change applies default checks *and* the reject_clause() checks, if
any, not one or the other.

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/4] provider, cg: add reject_clasue() callback
  2025-07-15 10:35 ` Nick Alcock
@ 2025-07-15 15:10   ` Kris Van Hees
  2025-07-16 10:53     ` Nick Alcock
  0 siblings, 1 reply; 5+ messages in thread
From: Kris Van Hees @ 2025-07-15 15:10 UTC (permalink / raw)
  To: Nick Alcock; +Cc: Kris Van Hees, dtrace, dtrace-devel

On Tue, Jul 15, 2025 at 11:35:23AM +0100, Nick Alcock wrote:
> On 15 Jul 2025, Kris Van Hees spake thusly:
> 
> > Future providers will require functionality to determine whether a
> > clause for one of its probes needs to be rejected for some reason.
> > 
> > Since the callback is invoked during trampoline creation, rejection
> > must result in a compilation error.  The callback is responsible for
> > this.  If it returns, the clause is accepted.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> 
> Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
> 
> modulo the comment nit below.
> 
> > +	/*
> > +	 * Ensure the clause is valid for the probe.  Call the reject_clause()
> > +	 * hook if defined, otherwise apply default checks.  Rejection of the
> > +	 * clause must be reported as a compilation error.
> > +	 */
> > +	if (prp->prov->impl->reject_clause != NULL)
> > +		prp->prov->impl->reject_clause(prp, sdp->dtsd_clauseflags);
> 
> This change applies default checks *and* the reject_clause() checks, if
> any, not one or the other.

Well, actually, the comment needs updating because with this patch there is
no default yet.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [DTrace-devel] [PATCH 2/4] provider, cg: add reject_clasue() callback
  2025-07-15  5:48 [PATCH 2/4] provider, cg: add reject_clasue() callback Kris Van Hees
  2025-07-15 10:35 ` Nick Alcock
@ 2025-07-15 18:34 ` Eugene Loh
  1 sibling, 0 replies; 5+ messages in thread
From: Eugene Loh @ 2025-07-15 18:34 UTC (permalink / raw)
  To: Kris Van Hees, dtrace, dtrace-devel

and the clasue typo in the subject line

On 7/15/25 01:48, Kris Van Hees via DTrace-devel wrote:
> Future providers will require functionality to determine whether a
> clause for one of its probes needs to be rejected for some reason.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/4] provider, cg: add reject_clasue() callback
  2025-07-15 15:10   ` Kris Van Hees
@ 2025-07-16 10:53     ` Nick Alcock
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Alcock @ 2025-07-16 10:53 UTC (permalink / raw)
  To: Kris Van Hees; +Cc: Nick Alcock, dtrace, dtrace-devel

On 15 Jul 2025, Kris Van Hees outgrape:

> On Tue, Jul 15, 2025 at 11:35:23AM +0100, Nick Alcock wrote:
>> > +	/*
>> > +	 * Ensure the clause is valid for the probe.  Call the reject_clause()
>> > +	 * hook if defined, otherwise apply default checks.  Rejection of the
>> > +	 * clause must be reported as a compilation error.
>> > +	 */
>> > +	if (prp->prov->impl->reject_clause != NULL)
>> > +		prp->prov->impl->reject_clause(prp, sdp->dtsd_clauseflags);
>> 
>> This change applies default checks *and* the reject_clause() checks, if
>> any, not one or the other.
>
> Well, actually, the comment needs updating because with this patch there is
> no default yet.

Yeah, you might as well fix what confused me :)

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-16 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15  5:48 [PATCH 2/4] provider, cg: add reject_clasue() callback Kris Van Hees
2025-07-15 10:35 ` Nick Alcock
2025-07-15 15:10   ` Kris Van Hees
2025-07-16 10:53     ` Nick Alcock
2025-07-15 18:34 ` [DTrace-devel] " Eugene Loh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox