简体   繁体   English

评估表达式 LLDB Python C++ 类型格式化程序

[英]Evaluate Expression LLDB Python C++ Type Formatter

I'm trying to make an lldb custom type formatter for a variant type, but I can't seem to call a query member function on the value to format.我正在尝试为变体类型制作 lldb 自定义类型格式化程序,但我似乎无法在要格式化的值上调用查询成员 function。 I have a size_t member called typeIndex, that can be gotten by calling index().我有一个名为 typeIndex 的 size_t 成员,可以通过调用 index() 获得。 I can get the value by getting it directly through the get child member with name, but I can't seem to call the index() function which directly returns that value.我可以通过直接通过带有名称的 get 子成员获取该值,但我似乎无法调用直接返回该值的 index() function。 What do I have to do to call a function on the type being formatted?我该怎么做才能在格式化的类型上调用 function?

def format_variant(valobj, internal_dict):
    a = valobj.GetChildMemberWithName("typeIndex").GetValueAsUnsigned()
    b = valobj.EvaluateExpression(".index()").GetValueAsUnsigned()
    
    print(a)
    print(b)

b always results in no value, a is fine. b 总是没有值,a 很好。

You want to eval "index()" instead of ".index()"您想评估“index()”而不是“.index()”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM