LLDB API:如何调用存储在SBValue中的对象的方法
LLDB API : How to call a method of object stored in SBValue
>我有一个类型为 sc_time 的值,它有方法
inline double sc_time::to_double() const
我可以从调试器调用此方法以获取返回值吗?可能吗?
// lldb::SBValue cur_time
cout << "IsInScope: " << cur_time.IsInScope() << endl;
cout << "Name: " << cur_time.GetName() << endl;
cout << "Type Name: " << cur_time.GetType().GetName() << endl;
返回
IsInScope: 1
Name: m_curr_time
Type Name: sc_core::sc_time
我试过了
cur_time.CreateValueFromExpression("retval", "to_double()")
cur_time.CreateValueFromExpression("retval", "m_curr_time.to_double()")
cur_time.CreateValueFromExpression("retval", "this->to_double()")
没有一个工作
class sc_time
{
public:
double to_double() const { return 123.456; // mock }
};
在~/.lldbinit
中加载配置文件:
command script import ~/.lldbcfg/print_sc_time.py
用于打印sc_time类实例的配置文件: $HOME/.lldbcfg/print_sc_time.py
:
def print_sc_time(valobj, internal_dict):
res = str(valobj.EvaluateExpression("to_double()").GetValue())
return res
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('type summary add -P sc_time -F {:s}.print_sc_time'.format(__name__))
相关文章:
- 将字符串存储在c++中的稳定内存中
- std::原子加载和存储都需要吗
- C++:将控制台输出存储在宏中更好吗
- 使用QProcess执行命令,并将结果存储在QStringList中
- 访问存储在向量C++中的结构的多态成员
- 如何从存储在std::映射中的std::集中删除元素
- 存储模板类型以强制转换回派生<T>
- 类型总是使用其大小存储在内存中吗
- 当字符串存储在变量中时,如何将字符串转换为wchar_t
- 使用无符号字符数组有效存储内存
- 如何在cpp.中使用协议缓冲区存储大缓冲区/数组(char/int)
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 带结构的二维矢量:如何存储元素
- 添加存储在向量中的大整数的函数出现问题
- 从文件中读取多个字节,并将它们存储在C++中进行比较
- 在std::vector上存储带有模板的类实例
- 谷歌测试中的期望值存储在哪里
- 为什么C中的通用链表中存储的数据已损坏
- 在c++中获取两个大int,并将它们存储在数组中
- LLDB API:如何调用存储在SBValue中的对象的方法