Skip to content

Commit

Permalink
Merge pull request iovisor#290 from iovisor/bblanco_dev
Browse files Browse the repository at this point in the history
Fix unary operator handling of probe reads with parens
  • Loading branch information
drzaeus77 committed Nov 13, 2015
2 parents 66a33c8 + 80667b7 commit 782158b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class ProbeChecker : public RecursiveASTVisitor<ProbeChecker> {
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;
Expand Down
14 changes: 14 additions & 0 deletions tests/cc/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,19 @@ def test_probe_simple_assign(self):
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()

0 comments on commit 782158b

Please sign in to comment.