Skip to content

Commit

Permalink
correct error reporting on python text compilation
Browse files Browse the repository at this point in the history
The exception raised in the BPF class constructor assumed
that the "src_file" argument was used to pass eBPF code -
this is not the case for many of the tools scripts, which
tend to use "text".

Signed-off-by: Nathan Scott <[email protected]>
  • Loading branch information
natoscott committed Jan 15, 2018
1 parent 3763380 commit d10c642
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 @@ -287,6 +287,8 @@ def __init__(self, src_file="", hdr_file="", text=None, cb=None, debug=0,
if text:
self.module = lib.bpf_module_create_c_from_string(text.encode("ascii"),
self.debug, cflags_array, len(cflags_array))
if not self.module:
raise Exception("Failed to compile BPF text:\n%s" % text)
else:
src_file = BPF._find_file(src_file)
hdr_file = BPF._find_file(hdr_file)
Expand All @@ -296,9 +298,8 @@ def __init__(self, src_file="", hdr_file="", text=None, cb=None, debug=0,
else:
self.module = lib.bpf_module_create_c(src_file.encode("ascii"),
self.debug, cflags_array, len(cflags_array))

if not self.module:
raise Exception("Failed to compile BPF module %s" % src_file)
if not self.module:
raise Exception("Failed to compile BPF module %s" % src_file)

for usdt_context in usdt_contexts:
usdt_context.attach_uprobes(self)
Expand Down

0 comments on commit d10c642

Please sign in to comment.