Skip to content

Commit

Permalink
Merge pull request #16 from parca-dev/coredump-fix
Browse files Browse the repository at this point in the history
Fix coredump compilation
  • Loading branch information
gnurizen authored Oct 15, 2024
2 parents 433e6e3 + e5655f6 commit 63655fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions support/ebpf/interpreter_dispatcher.ebpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ bool get_go_custom_labels(struct pt_regs *ctx, UnwindState *state, void *offsets
DEBUG_PRINT("failed to read custom label: value too long");
continue;
}

#ifdef TESTING_COREDUMP
if (val_len > CUSTOM_LABEL_MAX_VAL_LEN)
res = bpf_probe_read(lbl->val.val_bytes, val_len, map_value->values[i].str);
else
res = -1;
#else
// The following assembly statement is equivalent to:
// if (val_len > CUSTOM_LABEL_MAX_VAL_LEN)
// res = bpf_probe_read(lbl->val, val_len, map_value->values[i].str);
Expand Down Expand Up @@ -353,6 +360,7 @@ bool get_go_custom_labels(struct pt_regs *ctx, UnwindState *state, void *offsets
// all r0-r5 are clobbered since we make a function call.
: "r0", "r1", "r2", "r3", "r4", "r5", "memory"
);
#endif
// clang-format on
if (res) {
DEBUG_PRINT("failed to read value for custom label: %ld", res);
Expand Down
7 changes: 7 additions & 0 deletions support/ebpf/opaquify.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef OPTI_OPAQUIFY_H
#define OPTI_OPAQUIFY_H

#ifndef TESTING_COREDUMP
#include "bpfdefs.h"
// Hack to thwart the verifier's detection of variable bounds.
//
Expand Down Expand Up @@ -54,6 +55,12 @@ u64 opaquify64(u64 val, u64 seed) {
);
return val;
}
#else
static inline __attribute__((__always_inline__))
u64 opaquify64(u64 val, u64 seed) {
return val;
}
#endif


#endif
1 change: 1 addition & 0 deletions tools/coredump/ebpfcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main
#include <stdarg.h>
#include <setjmp.h>
#include "../../support/ebpf/types.h"
#include "../../support/ebpf/opaquify.h"
struct cgo_ctx {
jmp_buf jmpbuf;
Expand Down

0 comments on commit 63655fc

Please sign in to comment.