Commit f631b0e0 authored by Rich Lane's avatar Rich Lane

add ebpf method to retrieve bytecode

This is useful if you want to use bcc as a compiler without running the
program.
parent 3daeee7d
......@@ -392,6 +392,17 @@ class BPF(object):
return fn
def ebpf(self, func_name):
"""
Return the eBPF bytecodes for the specified function as a string
"""
if lib.bpf_function_start(self.module, func_name.encode("ascii")) == None:
raise Exception("Unknown program %s" % func_name)
start, = lib.bpf_function_start(self.module, func_name.encode("ascii")),
size, = lib.bpf_function_size(self.module, func_name.encode("ascii")),
return ct.string_at(start, size)
str2ctype = {
u"_Bool": ct.c_bool,
u"char": ct.c_char,
......
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