Skip to content

Commit

Permalink
cc: Use PID to detach uprobes
Browse files Browse the repository at this point in the history
We need the PID when detaching uprobes to resolve library names
to the same path as when attaching
  • Loading branch information
pchaigno committed Dec 27, 2016
1 parent bc4d868 commit 492d5ef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,15 @@ def attach_uprobe(self, name="", sym="", sym_re="", addr=None,
self._add_uprobe(ev_name, res)
return self

def detach_uprobe(self, name="", sym="", addr=None):
"""detach_uprobe(name="", sym="", addr=None)
def detach_uprobe(self, name="", sym="", addr=None, pid=-1):
"""detach_uprobe(name="", sym="", addr=None, pid=-1)
Stop running a bpf function that is attached to symbol 'sym' in library
or binary 'name'.
"""

name = str(name)
(path, addr) = BPF._check_path_symbol(name, sym, addr, -1)
(path, addr) = BPF._check_path_symbol(name, sym, addr, pid)
ev_name = "p_%s_0x%x" % (self._probe_repl.sub("_", path), addr)
if ev_name not in self.open_uprobes:
raise Exception("Uprobe %s is not attached" % event)
Expand Down Expand Up @@ -822,15 +822,15 @@ def attach_uretprobe(self, name="", sym="", sym_re="", addr=None,
self._add_uprobe(ev_name, res)
return self

def detach_uretprobe(self, name="", sym="", addr=None):
"""detach_uretprobe(name="", sym="", addr=None)
def detach_uretprobe(self, name="", sym="", addr=None, pid=-1):
"""detach_uretprobe(name="", sym="", addr=None, pid=-1)
Stop running a bpf function that is attached to symbol 'sym' in library
or binary 'name'.
"""

name = str(name)
(path, addr) = BPF._check_path_symbol(name, sym, addr, -1)
(path, addr) = BPF._check_path_symbol(name, sym, addr, pid)
ev_name = "r_%s_0x%x" % (self._probe_repl.sub("_", path), addr)
if ev_name not in self.open_uprobes:
raise Exception("Kretprobe %s is not attached" % event)
Expand Down

0 comments on commit 492d5ef

Please sign in to comment.