Skip to content

Commit

Permalink
Merge pull request iovisor#123 from iovisor/bblanco_dev
Browse files Browse the repository at this point in the history
Fix recursive loop in parsing pointer to self struct
  • Loading branch information
4ast committed Aug 11, 2015
2 parents 0d7245d + dfcdf0a commit 3381c79
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ bool BMapDeclVisitor::VisitRecordDecl(RecordDecl *D) {
result_ += "\", [";
for (auto F : D->getDefinition()->fields()) {
result_ += "[";
TraverseDecl(F);
if (F->getType()->isPointerType())
result_ += "\"unsigned long long\"";
else
TraverseDecl(F);
if (F->isBitField())
result_ += ", " + to_string(F->getBitWidthValue(C));
result_ += "], ";
Expand Down
21 changes: 21 additions & 0 deletions tests/cc/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,26 @@ def test_sscanf(self):
self.assertEqual(l.s.a, 5)
self.assertEqual(l.s.b, 6)

def test_iosnoop(self):
text = """
#include <linux/blkdev.h>
#include <uapi/linux/ptrace.h>
struct key_t {
struct request *req;
};
BPF_TABLE("hash", struct key_t, u64, start, 1024);
int do_request(struct pt_regs *ctx, struct request *req) {
struct key_t key = {};
bpf_trace_printk("traced start %d\\n", req->__data_len);
return 0;
}
"""
b = BPF(text=text, debug=0)
fn = b.load_func("do_request", BPF.KPROBE)

if __name__ == "__main__":
main()

0 comments on commit 3381c79

Please sign in to comment.