Skip to content

Commit

Permalink
python: Fix kprobe quota test breakage, add uprobes
Browse files Browse the repository at this point in the history
As part of the funccount work, the kprobe quota test doesn't fail
early when adding multiple kprobes at once (with `event_re`), but
rather only when the 1000th probe is being added. Revert to the old
behavior, which fixes the `test_probe_quota` test. Add similar test
for uprobes, `test_uprobe_quota`, which tests the recently-added
uprobe regex support.
  • Loading branch information
goldshtn committed Oct 19, 2016
1 parent ff3b9f3 commit 367234a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ def attach_kprobe(self, event="", fn_name="", event_re="",

# allow the caller to glob multiple functions together
if event_re:
for line in BPF.get_kprobe_functions(event_re):
matches = BPF.get_kprobe_functions(event_re)
self._check_probe_quota(len(matches))
for line in matches:
try:
self.attach_kprobe(event=line, fn_name=fn_name, pid=pid,
cpu=cpu, group_fd=group_fd)
Expand Down Expand Up @@ -672,7 +674,9 @@ def attach_uprobe(self, name="", sym="", sym_re="", addr=None,
name = str(name)

if sym_re:
for sym_addr in BPF.get_user_adddresses(name, sym_re):
addresses = BPF.get_user_addresses(name, sym_re)
self._check_probe_quota(len(addresses))
for sym_addr in addresses:
self.attach_uprobe(name=name, addr=sym_addr,
fn_name=fn_name, pid=pid, cpu=cpu,
group_fd=group_fd)
Expand Down
4 changes: 4 additions & 0 deletions tests/python/test_probe_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def test_probe_quota(self):
with self.assertRaises(Exception):
self.b.attach_kprobe(event_re=".*", fn_name="count")

def test_uprobe_quota(self):
with self.assertRaises(Exception):
self.b.attach_uprobe(name="c", sym_re=".*", fn_name="count")

def tearDown(self):
self.b.cleanup()

Expand Down

0 comments on commit 367234a

Please sign in to comment.