Skip to content

Commit

Permalink
fix uprobe examples to read correct argument
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg committed Jul 25, 2016
1 parent 239e863 commit eb1b70d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/tracing/strlen_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
BPF_HASH(counts, struct key_t);
int count(struct pt_regs *ctx) {
if (!PT_REGS_PARM2(ctx))
if (!PT_REGS_PARM1(ctx))
return 0;
struct key_t key = {};
u64 zero = 0, *val;
bpf_probe_read(&key.c, sizeof(key.c), (void *)PT_REGS_PARM2(ctx));
bpf_probe_read(&key.c, sizeof(key.c), (void *)PT_REGS_PARM1(ctx));
val = counts.lookup_or_init(&key, &zero);
(*val)++;
return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/tracing/strlen_snoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
bpf_text = """
#include <uapi/linux/ptrace.h>
int printarg(struct pt_regs *ctx) {
if (!PT_REGS_PARM2(ctx))
if (!PT_REGS_PARM1(ctx))
return 0;
u32 pid = bpf_get_current_pid_tgid();
if (pid != PID)
return 0;
char str[80] = {};
bpf_probe_read(&str, sizeof(str), (void *)PT_REGS_PARM2(ctx));
bpf_probe_read(&str, sizeof(str), (void *)PT_REGS_PARM1(ctx));
bpf_trace_printk("%s\\n", &str);
return 0;
Expand Down

0 comments on commit eb1b70d

Please sign in to comment.