Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Oct 2, 2023
1 parent ff6322e commit 77e35ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
5 changes: 0 additions & 5 deletions GPL/Events/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

const volatile int consumer_pid = 0;

#if BPF_DEBUG_TRACE == 0
#undef bpf_printk
#define bpf_printk(fmt, ...)
#endif

// Compiler barrier, used to prevent compile-time insns reordering and optimizations.
#define barrier() asm volatile("" ::: "memory")

Expand Down
1 change: 1 addition & 0 deletions GPL/Events/Process/Probe.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ static int tty_write__enter(struct kiocb *iocb, struct iov_iter *from)
}

const struct iovec *iov;
bpf_printk("hello %d", FIELD_OFFSET(iov_iter, __iov));
if (FIELD_OFFSET(iov_iter, __iov) > 0) {
iov = (struct iovec *)from + FIELD_OFFSET(iov_iter, __iov);
} else {
Expand Down
11 changes: 4 additions & 7 deletions non-GPL/Events/Lib/EbpfEvents.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ static int resolve_btf_field_off_recur(struct btf *btf,

for (int i = 0; i < btf_vlen(t); i++, m++) {
const char *name = btf__name_by_offset(btf, m->name_off);
printf("field off: %s @ %d+%d", name, base_off, m->offset);
if (name == NULL)
continue;
if (strcmp(name, field) == 0) {
printf("[OK] %s @ %d+%d", name, base_off, m->offset);
if (strcmp(name, field) == 0)
return base_off + m->offset;
}

const struct btf_type *m_type = btf__type_by_id(btf, m->type);
if (!btf_is_struct(m_type) && !btf_is_union(m_type))
Expand All @@ -89,7 +86,6 @@ static int resolve_btf_field_off_recur(struct btf *btf,
return ret;
}

printf("not found: %d+%d", base_off, m->offset);
return -1;
}

Expand Down Expand Up @@ -273,8 +269,9 @@ static int probe_fill_relos(struct btf *btf, struct EventProbe_bpf *obj)
}
err = err ?: FILL_FUNC_RET_IDX(obj, btf, vfs_rename);

if (BTF_FIELD_EXISTS(btf, iov_iter, __iov))
err = err ?: FILL_FIELD_OFFSET(obj, btf, iov_iter, __iov);
FILL_FIELD_OFFSET(obj, btf, iov_iter, __iov);
// if (BTF_FIELD_EXISTS(btf, iov_iter, __iov))
// err = err ?: FILL_FIELD_OFFSET(obj, btf, iov_iter, __iov);

return err;
}
Expand Down

0 comments on commit 77e35ea

Please sign in to comment.