correct error reporting on python text compilation
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".
@@ -287,6 +287,8 @@ class BPF(object):
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)
@@ -296,7 +298,6 @@ class BPF(object):
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)
