Re: [PATCH v5] tracing/eprobes: Allow use of BTF names to dereference pointers

From: Steven Rostedt

Date: Wed May 20 2026 - 22:56:26 EST


On Thu, 21 May 2026 10:58:04 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:

> On Wed, 20 May 2026 12:48:32 -0400
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > On Wed, 20 May 2026 15:20:21 +0900
> > Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:
> >
> > > > > > @@ -515,6 +542,10 @@ static void clear_btf_context(struct traceprobe_parse_context *ctx)
> > > > > > ctx->params = NULL;
> > > > > > ctx->nr_params = 0;
> > > > > > }
> > > > > > + if (ctx->struct_btf) {
> > > > > > + btf_put(ctx->struct_btf);
> > > > > > + ctx->last_struct = NULL;
> > > > >
> > > > > [Severity: Low]
> > > > > Should ctx->struct_btf be explicitly set to NULL after btf_put() drops
> > > > > the reference?
> > > >
> > > > I'm thinking of dropping it in the '(' switch case.
> > >
> > > Can you consider making the '(' switch case part as a helper
> > > function because it depends on CONFIG_DEBUG_INFO_BTF?
> >
> > Should we just encapsulate that entire case statement with:
> >
> > #ifdef CONFIG_DEBUG_INFO_BTF
> > [..]
> > #endif
>
> Yeah that is possible, and I rather like to make it a separate
> function for simplifying switch-case block for readability.
>

Hmm, but as a separate function, you mean something like this?

case '(':
ret = handle_typecast(...);
break;

And have;

#ifdef CONFIG_DEBUG_INFO_BTF
static int handle_typecast(...)
{
[ do the real work here ]
}
#else
static int handle_typecast(...)
{
trace_probe_log_err(ctx->offset, NOSUP_BTFARG);
return -EOPNOTSUPP;
}
#endif

?

-- Steve