我使用Babeltrace python3绑定来读取包含debug_info的lttng ust trace。当我从shell中运行Babeltrace我看到在输出中DEBUG_INFO:如何使用babeltrace python绑定从lttng ctf trace获取debug_info?
[13:28:29.998652878] (+0.000000321) hsm-dev lttng_ust_cyg_profile:func_exit: { cpu_id = 1 }, { ip = 0x4008E5, debug_info = { bin = "[email protected]", func = "foo+0" }, vpid = 28208, vtid = 28211 }, { addr = 0x4008E5, call_site = 0x400957 }
从python绑定,我可以得到其他事件字段(CPU_ID,IP,地址,call_site ...),但我得到键错误试图访问debug_info,bin或func。
import babeltrace
collection = babeltrace.TraceCollection()
collection.add_traces_recursive('lttng-traces/a.out-20170624-132829/', 'ctf')
for e in collection.events:
if e.name == 'lttng_ust_cyg_profile:func_entry':
print(e['addr'])
print(e['func'])
Traceback (most recent call last):
File "fields.py", line 9, in <module>
print(e['func'])
File "/usr/lib/python3/dist-packages/babeltrace.py", line 865, in __getitem__
raise KeyError(field_name)
KeyError: 'func'
有没有办法从Python获取这些字段?
我使用的是Babeltrace 1.5.2
顺便提一下,您应该将问题的标题作为问题重新引用。 – eepp