argdist, trace: Support naked executable names in probes (#720)
authorSasha Goldshtein <goldshtn@gmail.com>
Tue, 4 Oct 2016 15:33:36 +0000 (18:33 +0300)
committer4ast <alexei.starovoitov@gmail.com>
Tue, 4 Oct 2016 15:33:36 +0000 (08:33 -0700)
Fixes the error message from `BPF._find_exe` which would
occur if argdist or trace had a naked executable name
not qualified with a path, such as:

```
trace 'r:bash:readline "%s", retval'
```

This is now supported again.

src/python/bcc/__init__.py
tools/argdist.py
tools/trace.py

index 35d293d..c0f95f1 100644 (file)
@@ -120,9 +120,9 @@ class BPF(object):
         return filename
 
     @staticmethod
-    def _find_exe(cls, bin_path):
+    def find_exe(bin_path):
         """
-        _find_exe(bin_path)
+        find_exe(bin_path)
 
         Traverses the PATH environment variable, looking for the first
         directory that contains an executable file named bin_path, and
index bc8aff3..12edded 100755 (executable)
@@ -379,7 +379,7 @@ int PROBENAME(struct pt_regs *ctx SIGNATURE)
         def _attach_u(self):
                 libpath = BPF.find_library(self.library)
                 if libpath is None:
-                        libpath = BPF._find_exe(self.library)
+                        libpath = BPF.find_exe(self.library)
                 if libpath is None or len(libpath) == 0:
                         self._bail("unable to find library %s" % self.library)
 
index 696ca61..ee41373 100755 (executable)
@@ -472,7 +472,7 @@ int %s(%s)
                 libpath = BPF.find_library(self.library)
                 if libpath is None:
                         # This might be an executable (e.g. 'bash')
-                        libpath = BPF._find_exe(self.library)
+                        libpath = BPF.find_exe(self.library)
                 if libpath is None or len(libpath) == 0:
                         self._bail("unable to find library %s" % self.library)