Commit 3381c792 authored by 4ast's avatar 4ast

Merge pull request #123 from iovisor/bblanco_dev

Fix recursive loop in parsing pointer to self struct
parents 0d7245dc dfcdf0a0
...@@ -64,7 +64,10 @@ bool BMapDeclVisitor::VisitRecordDecl(RecordDecl *D) { ...@@ -64,7 +64,10 @@ bool BMapDeclVisitor::VisitRecordDecl(RecordDecl *D) {
result_ += "\", ["; result_ += "\", [";
for (auto F : D->getDefinition()->fields()) { for (auto F : D->getDefinition()->fields()) {
result_ += "["; result_ += "[";
TraverseDecl(F); if (F->getType()->isPointerType())
result_ += "\"unsigned long long\"";
else
TraverseDecl(F);
if (F->isBitField()) if (F->isBitField())
result_ += ", " + to_string(F->getBitWidthValue(C)); result_ += ", " + to_string(F->getBitWidthValue(C));
result_ += "], "; result_ += "], ";
......
...@@ -65,5 +65,26 @@ int foo(void *ctx) { ...@@ -65,5 +65,26 @@ int foo(void *ctx) {
self.assertEqual(l.s.a, 5) self.assertEqual(l.s.a, 5)
self.assertEqual(l.s.b, 6) 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__": if __name__ == "__main__":
main() main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment