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

Nick Alcock nick.alcock at oracle.com
Mon Mar 14 21:30:23 UTC 2022


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.

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
-- 
2.35.1.261.g8402f930ba.dirty




More information about the DTrace-devel mailing list