Skip to content

Commit

Permalink
Traces external pointers in parenthesized expressions
Browse files Browse the repository at this point in the history
Partially reverts 80667b7, "Fix unary operator handling of probe
reads with parens", keeping the test case. With 4c6ecb4,
"Restrict rewrite of unary operators to dereference operator," only
dereferences are rewritten, removing the need for the previous fix.

Reverting 80667b7 allows bcc to rewrite more dereferences, as
highlighted in the new test case.
  • Loading branch information
pchaigno authored and drzaeus77 committed Sep 29, 2017
1 parent a135d89 commit c5ca2a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ class ProbeChecker : public RecursiveASTVisitor<ProbeChecker> {
}
return false;
}
bool VisitParenExpr(ParenExpr *E) {
return false;
}
bool VisitDeclRefExpr(DeclRefExpr *E) {
if (ptregs_.find(E->getDecl()) != ptregs_.end())
needs_probe_ = true;
Expand Down
11 changes: 11 additions & 0 deletions tests/python/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ def test_unop_probe_read(self):
return 1;
return 0;
}
"""
b = BPF(text=text)
fn = b.load_func("trace_entry", BPF.KPROBE)

def test_paren_probe_read(self):
text = """
#include <net/inet_sock.h>
int trace_entry(struct pt_regs *ctx, struct sock *sk) {
u16 sport = ((struct inet_sock *)sk)->inet_sport;
return sport;
}
"""
b = BPF(text=text)
fn = b.load_func("trace_entry", BPF.KPROBE)
Expand Down

0 comments on commit c5ca2a6

Please sign in to comment.