Skip to content

Commit

Permalink
Merge pull request iovisor#1021 from markdrayton/sym-mod-fix
Browse files Browse the repository at this point in the history
python: handle null module in BPF.sym
  • Loading branch information
4ast committed Mar 4, 2017
2 parents c924193 + dcf8cf9 commit bdbc472
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,20 +995,21 @@ def sym(addr, pid, show_module=False, show_offset=False):
returned. When show_module is True, the module name is also included.
When show_offset is True, the instruction offset as a hexadecimal
number is also included in the string.
A pid of less than zero will access the kernel symbol cache.
Example output when both show_module and show_offset are True:
"start_thread+0x202 [libpthread-2.24.so]"
Example output when both show_module and show_offset are False:
"start_thread"
"""
name, offset, module = BPF._sym_cache(pid).resolve(addr)
offset = "+0x%x" % offset if show_offset and name is not None else ""
name = name or "[unknown]"
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

@staticmethod
Expand Down

0 comments on commit bdbc472

Please sign in to comment.