mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-10 02:29:06 +08:00
libbpf: Append "..." in fixed up log if CO-RE spec is truncated
Detect CO-RE spec truncation and append "..." to make user aware that there was supposed to be more of the spec there. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220428041523.4089853-2-andrii@kernel.org
This commit is contained in:
committed by
Andrii Nakryiko
parent
97ab064bc0
commit
1a18c6f051
@@ -6962,7 +6962,7 @@ static void fixup_log_failed_core_relo(struct bpf_program *prog,
|
|||||||
const struct bpf_core_relo *relo;
|
const struct bpf_core_relo *relo;
|
||||||
struct bpf_core_spec spec;
|
struct bpf_core_spec spec;
|
||||||
char patch[512], spec_buf[256];
|
char patch[512], spec_buf[256];
|
||||||
int insn_idx, err;
|
int insn_idx, err, spec_len;
|
||||||
|
|
||||||
if (sscanf(line1, "%d: (%*d) call unknown#195896080\n", &insn_idx) != 1)
|
if (sscanf(line1, "%d: (%*d) call unknown#195896080\n", &insn_idx) != 1)
|
||||||
return;
|
return;
|
||||||
@@ -6975,11 +6975,11 @@ static void fixup_log_failed_core_relo(struct bpf_program *prog,
|
|||||||
if (err)
|
if (err)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bpf_core_format_spec(spec_buf, sizeof(spec_buf), &spec);
|
spec_len = bpf_core_format_spec(spec_buf, sizeof(spec_buf), &spec);
|
||||||
snprintf(patch, sizeof(patch),
|
snprintf(patch, sizeof(patch),
|
||||||
"%d: <invalid CO-RE relocation>\n"
|
"%d: <invalid CO-RE relocation>\n"
|
||||||
"failed to resolve CO-RE relocation %s\n",
|
"failed to resolve CO-RE relocation %s%s\n",
|
||||||
insn_idx, spec_buf);
|
insn_idx, spec_buf, spec_len >= sizeof(spec_buf) ? "..." : "");
|
||||||
|
|
||||||
patch_log(buf, buf_sz, log_sz, line1, line3 - line1, patch);
|
patch_log(buf, buf_sz, log_sz, line1, line3 - line1, patch);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user