Skip to content

Commit

Permalink
Move find_mapping's log to its callsite
Browse files Browse the repository at this point in the history
In the unwinder process we want to log if we can't find a mapping,
but in the tracers, we are just checking to see whether we should
send the event or not. Logging there is not really necessary and it
adds lots of noise.
  • Loading branch information
javierhonduco committed Apr 23, 2024
1 parent ab2dd8d commit c5b8525
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
11 changes: 9 additions & 2 deletions src/bpf/profiler.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,16 @@ int dwarf_unwind(struct bpf_perf_event_data *ctx) {
LOG("\tcurrent bp: %llx", unwind_state->bp);

mapping_t *mapping = find_mapping(per_process_id, unwind_state->ip);

if (mapping == NULL) {
// find_mapping bumps the counters already.
// request_refresh_process_info?
LOG("[error] no mapping found for pc %llx", unwind_state->ip);
bump_unwind_error_mapping_not_found();
return 1;
}

if (unwind_state->ip < mapping->begin || unwind_state->ip >= mapping->end) {
LOG("[error] pc %llx not contained within begin: %llx end: %llx", unwind_state->ip, mapping->begin, mapping->end);
bump_unwind_error_mapping_does_not_contain_pc();
return 1;
}

Expand Down
16 changes: 1 addition & 15 deletions src/bpf/shared_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@ static __always_inline mapping_t* find_mapping(int per_process_id, u64 pc) {
key.pid = __builtin_bswap32((u32) per_process_id);
key.data = __builtin_bswap64(pc);

mapping_t *mapping = bpf_map_lookup_elem(&exec_mappings, &key);

if (mapping == NULL) {
LOG("[error] no mapping found for pc %llx", pc);
bump_unwind_error_mapping_not_found();
return NULL;
}

if (pc < mapping->begin || pc >= mapping->end) {
LOG("[error] pc %llx not contained within begin: %llx end: %llx", pc, mapping->begin, mapping->end);
bump_unwind_error_mapping_does_not_contain_pc();
return NULL;
}

return mapping;
return bpf_map_lookup_elem(&exec_mappings, &key);
}

static __always_inline bool process_is_known(int per_process_id) {
Expand Down

0 comments on commit c5b8525

Please sign in to comment.