2017-07-27 35 views
0

我使用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

+0

顺便提一下,您应该将问题的标题作为问题重新引用。 – eepp

回答

2

还没有。在构建适当的处理图并运行它之后,使用Babeltrace 2 Python绑定是可能的,但是这个主要的修订从截止到这个日期(前期)还没有发布。

在Babeltrace 1中存在对调试信息的攻击,其中text输出在打印时“输入”虚拟域,但在此之前它们不可用,所以这就是为什么例如无法访问e['func']的原因。

现在最好的办法是创建一个babeltrace CLI子进程,并且一次输出一行,使用正则表达式来查找所需的字段。丑陋,但这就是今天可用的。