Commit dcf8cf98 authored by Mark Drayton's avatar Mark Drayton

python: handle null module in BPF.sym

Check to see if `module` is None before attempting to call `os.path.basename`
on it. Before:

```
>>> BPF.sym(0x400001, 12345, show_module=True)
Traceback (most recent call last):
..
AttributeError: 'NoneType' object has no attribute 'rfind'
```

After:

```
>>> BPF.sym(0x400001, 12345, show_module=True)
'[unknown]'
```
parent cb06c97f
...@@ -1002,7 +1002,8 @@ class BPF(object): ...@@ -1002,7 +1002,8 @@ class BPF(object):
offset = "+0x%x" % offset if show_offset and name is not None else "" offset = "+0x%x" % offset if show_offset and name is not None else ""
name = name or "[unknown]" name = name or "[unknown]"
name = name + offset name = name + offset
module = " [%s]" % os.path.basename(module) if show_module else "" module = " [%s]" % os.path.basename(module) \
if show_module and module is not None else ""
return name + module return name + module
@staticmethod @staticmethod
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment