Skip to content

Commit

Permalink
Fix error message capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
marctc committed Jul 16, 2024
1 parent 9b7d4ca commit ea1709f
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bpf/go_nethttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,16 @@ int uprobe_errorReturn(struct pt_regs *ctx) {
}

// Read the error message
void *msg_ptr = (void *)PT_REGS_RC(ctx);
bpf_probe_read_str(&event->err_msg, sizeof(event->err_msg), msg_ptr);
// GO_PARAM1(ctx) is the pointer to the error message
// GO_PARAM2(ctx) is the length of the error message
void *msg_ptr = GO_PARAM1(ctx);
u64 len = (u64)GO_PARAM2(ctx);
u64 max_size = sizeof(event->err_msg);
u64 size = max_size < len ? max_size : len;
bpf_probe_read(&event->err_msg, size, msg_ptr);
if (size < max_size) {
((char *)event->err_msg)[size] = 0;
}
bpf_dbg_printk("error msg %llx, %s", msg_ptr, event->err_msg);

// Write event
Expand Down
1 change: 1 addition & 0 deletions bpf/go_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define GO_STR_H

#include "utils.h"
#include "bpf_dbg.h"

static __always_inline int read_go_str_n(char *name, void *base_ptr, u64 len, void *field, u64 max_size) {
u64 size = max_size < len ? max_size : len;
Expand Down
Binary file modified pkg/internal/ebpf/grpc/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/grpc/bpf_tp_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_debug_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_tp_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_tp_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_tp_debug_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/ebpf/nethttp/bpf_tp_debug_bpfel_x86.o
Binary file not shown.

0 comments on commit ea1709f

Please sign in to comment.