【发布时间】:2017-01-17 00:43:53
【问题描述】:
我正在尝试使用 LLDB + python,以便更好地将 json 字符串打印到文件中。对于给定的 std::string 变量(称为缓冲区),我在 python 断点脚本中尝试了以下操作,以便漂亮地打印到文件 - 均未成功:
json.dump(frame.FindVariable("buffer"), handle, indent=4)
# ^^^^ error that SBValue* is not serializable
json.dump(frame.FindVariable("buffer").GetValue(), handle, indent=4)
# ^^^^ emits null
json.dump(frame.EvaluateExpression("buffer.c_str()"), handle, indent=4)
# ^^^^ error that SBValue* is not serializable
json.dump(frame.EvaluateExpression("buffer.c_str()").GetValue(), handle, indent=4)
# ^^^^ prints an address...not useful
json.dump(frame.EvaluateExpression("buffer.c_str()").GetData(), handle, indent=4)
# ^^^^ error that SBValue* is not serializable
有谁知道什么魔法酱可以让我将 std::string 帧变量转换为 python 字符串以传递给 json.dump() ?
【问题讨论】:
-
我发现
>>> print(reg.description)得到了对象的描述,而我从>>> print(reg.value)得到的只是一个指针。您知道这一点,但我是为最终出现在此 SO 页面上的其他人写的。参考:lldb.llvm.org/python_reference/lldb.SBValue-class.html