Skip to content

Commit

Permalink
bpf: don't throw away CTF errors when doing relocations
Browse files Browse the repository at this point in the history
The first type lookup done after translators are parsed is the set done
to relocate CTF-related offsets.  If something is wrong with the CTF and
the translators are missing, these lookups are likely to fail -- but
since most of these lookups 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.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Jul 27, 2022
1 parent 905a1b6 commit 4bfeea9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions libdtrace/dt_cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,10 +2380,10 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
ctf_file_t *cfp = dtp->dt_shared_ctf;
ctf_id_t type = ctf_lookup_by_name(cfp, "struct task_struct");
ctf_membinfo_t ctm;
int rc;
int rc = 0;

if (type == CTF_ERR)
return -1;
goto err_ctf;

switch (idp->di_id) {
case DT_CONST_TASK_PID:
Expand All @@ -2400,7 +2400,7 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
break;
}
if (rc == CTF_ERR)
return -1;
goto err_ctf;
nrp->dofr_data = ctm.ctm_offset / NBBY;
continue;
}
Expand All @@ -2411,11 +2411,12 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
ctf_id_t rc = CTF_ERR;

if (type == CTF_ERR)
return -1;
goto err_ctf;

rc = ctf_member_info(cfp, type, "owner", &ctm);
if (rc == CTF_ERR)
return -1;
goto err_ctf;

nrp->dofr_data = ctm.ctm_offset / NBBY;
continue;
}
Expand All @@ -2437,18 +2438,18 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,

type = ctf_lookup_by_name(cfp, "rwlock_t");
if (type == CTF_ERR)
return -1;
goto err_ctf;
rc = ctf_member_info(cfp, type, "raw_lock", &ctm);
if (rc == CTF_ERR)
return -1;
goto err_ctf;
total_offset = ctm.ctm_offset / NBBY;

type = ctf_lookup_by_name(cfp, "arch_rwlock_t");
if (type == CTF_ERR)
return -1;
goto err_ctf;
rc = ctf_member_info(cfp, type, "cnts", &ctm);
if (rc == CTF_ERR)
return -1;
goto err_ctf;
total_offset += ctm.ctm_offset / NBBY;

nrp->dofr_data = total_offset;
Expand Down Expand Up @@ -2497,6 +2498,10 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
}

return pc;

err_ctf:
dtp->dt_ctferr = ctf_errno(dtp->dt_shared_ctf);
return -1;
}

static void
Expand Down

0 comments on commit 4bfeea9

Please sign in to comment.