Skip to content

Commit

Permalink
c/profile: Short circuit on errors
Browse files Browse the repository at this point in the history
Report proper errors when symbolization fails and bail out early.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o authored and anakryiko committed Jul 24, 2024
1 parent ceb0dc3 commit 00c99c0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/c/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ static void show_stack_trace(__u64 *stack, int stack_sz, pid_t pid)
result = blaze_symbolize_kernel_abs_addrs(symbolizer, &src, (const uintptr_t *)stack, stack_sz);
}

if (result == NULL) {
printf(" failed to symbolize addresses: %s\n", blaze_err_str(blaze_err_last()));
return;
}

for (i = 0; i < stack_sz; i++) {
if (!result || result->cnt <= i || result->syms[i].name == NULL) {
Expand Down

0 comments on commit 00c99c0

Please sign in to comment.