[DTrace-devel] [PATCH v2 15/17] bpf: don't throw away CTF errors when setting task offsets

Eugene Loh eugene.loh at oracle.com
Wed Mar 23 20:33:54 UTC 2022


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 3/14/22 5:30 PM, Nick Alcock wrote:
> The first type lookup done after translators are parsed is the set done
> to look up task offsets.  If something is wrong with the CTF and the
> translators are missing, these lookups are likely to fail -- but
> since we don't set dt_ctferr, the actual error is discarded and
> the only thing reported to the user is "unknown CTF error".
> Not even CTF debugging helps.
>
> Fix trivial.

"The fix is trivial."  Or better yet, just omit that assessment: the 
short patch speaks for itself.

> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>   libdtrace/dt_bpf.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
> index 159737a139f5..92317697c45d 100644
> --- a/libdtrace/dt_bpf.c
> +++ b/libdtrace/dt_bpf.c
> @@ -146,21 +146,25 @@ set_task_offsets(dtrace_hdl_t *dtp)
>   
>   	type = ctf_lookup_by_name(cfp, "struct task_struct");
>   	if (type == CTF_ERR)
> -		return -1;
> +		goto err;
>   
>   	if (ctf_member_info(cfp, type, "real_parent", &ctm) == CTF_ERR)
> -		return -1;
> +		goto err;
>   	dt_state_set_offparent(dtp, ctm.ctm_offset / NBBY);
>   
>   	if (ctf_member_info(cfp, type, "tgid", &ctm) == CTF_ERR)
> -		return -1;
> +		goto err;
>   	dt_state_set_offtgid(dtp, ctm.ctm_offset / NBBY);
>   
>   	if (ctf_member_info(cfp, type, "comm", &ctm) == CTF_ERR)
> -		return -1;
> +		goto err;
>   	dt_state_set_offcomm(dtp, ctm.ctm_offset / NBBY);
>   
>   	return 0;
> +
> +err:
> +	dtp->dt_ctferr = ctf_errno(dtp->dt_shared_ctf);
> +	return -1;
>   }
>   
>   static void



More information about the DTrace-devel mailing list