Skip to content

Commit

Permalink
fix get_kprobe_functions
Browse files Browse the repository at this point in the history
Fix issue iovisor#1747.

In commit iovisor#1647, we excluded all symbols outside [_stext, _etext].
This is incorrect as it excluded module symbols as well.

This patch changed the algorithm to only skip symbols
in init sections [__init_begin, __init_end].

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song committed May 10, 2018
1 parent 0a43633 commit 0c27472
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,18 @@ def get_kprobe_functions(event_re):
blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
fns = []

found_stext = False
in_init_section = 0
with open("/proc/kallsyms", "rb") as avail_file:
for line in avail_file:
(_, t, fn) = line.rstrip().split()[:3]
if found_stext is False:
if fn == b'_stext':
found_stext = True
(t, fn) = line.rstrip().split()[1:3]
if in_init_section == 0:
if fn == b'__init_begin':
in_init_section = 1
continue
elif in_init_section == 1:
if fn == b'__init_end':
in_init_section = 2
continue

if fn == b'_etext':
break
if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \
and fn not in blacklist:
fns.append(fn)
Expand Down

0 comments on commit 0c27472

Please sign in to comment.