Testing for bpf_probe_read should not include parenethes when walking
the tree, since the inner operation will have already been rewritten.
Fixes: #289
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
needs_probe_ = false;
return false;
}
+ bool VisitParenExpr(ParenExpr *E) {
+ return false;
+ }
bool VisitDeclRefExpr(DeclRefExpr *E) {
if (ptregs_.find(E->getDecl()) != ptregs_.end())
needs_probe_ = true;
return 0;
}""", debug=4)
+ def test_unop_probe_read(self):
+ text = """
+#include <linux/blkdev.h>
+int trace_entry(struct pt_regs *ctx, struct request *req) {
+ if (!(req->bio->bi_rw & 1))
+ return 1;
+ if (((req->bio->bi_rw)))
+ return 1;
+ return 0;
+}
+"""
+ b = BPF(text=text)
+ fn = b.load_func("trace_entry", BPF.KPROBE)
+
if __name__ == "__main__":
main()