btf_encoder: detect BTF encoding errors and exit

Don't silently swallow BTF encoding errors and continue onto next CU. If
any of CU fails to properly encode BTF, exit with an error message.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Andrii Nakryiko 2020-09-29 21:27:33 -07:00 committed by Arnaldo Carvalho de Melo
parent c35b7fa52c
commit 7bc2dd07d5
1 changed files with 5 additions and 2 deletions

View File

@ -2379,8 +2379,11 @@ static enum load_steal_kind pahole_stealer(struct cu *cu,
goto filter_it;
if (btf_encode) {
cu__encode_btf(cu, global_verbose, btf_encode_force,
skip_encoding_btf_vars);
if (cu__encode_btf(cu, global_verbose, btf_encode_force,
skip_encoding_btf_vars)) {
fprintf(stderr, "Encountered error while encoding BTF.\n");
exit(1);
}
return LSK__KEEPIT;
}