From c5ca2a67666d2c0e9e5d90d9efeb0d2338f7865b Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sun, 6 Aug 2017 15:39:10 +0200 Subject: [PATCH] Traces external pointers in parenthesized expressions Partially reverts 80667b7b0ade, "Fix unary operator handling of probe reads with parens", keeping the test case. With 4c6ecb46ea8e, "Restrict rewrite of unary operators to dereference operator," only dereferences are rewritten, removing the need for the previous fix. Reverting 80667b7b0ade allows bcc to rewrite more dereferences, as highlighted in the new test case. --- src/cc/frontends/clang/b_frontend_action.cc | 3 --- tests/python/test_clang.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc index 40af8d2be374..76bee5ae7f87 100644 --- a/src/cc/frontends/clang/b_frontend_action.cc +++ b/src/cc/frontends/clang/b_frontend_action.cc @@ -83,9 +83,6 @@ class ProbeChecker : public RecursiveASTVisitor { } return false; } - bool VisitParenExpr(ParenExpr *E) { - return false; - } bool VisitDeclRefExpr(DeclRefExpr *E) { if (ptregs_.find(E->getDecl()) != ptregs_.end()) needs_probe_ = true; diff --git a/tests/python/test_clang.py b/tests/python/test_clang.py index 70ff1b8a7366..27f36c29cc76 100755 --- a/tests/python/test_clang.py +++ b/tests/python/test_clang.py @@ -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 +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)