查看Python扩展中的数据GDB

发布于 2025-02-07 14:52:43 字数 803 浏览 1 评论 0原文

假设我有一个类:

class RawMessage(NamedTuple):
    data: Dict
    timestamp: float
    ...

这个词典中的键和值可能都是整数,但是我不想确定地说明这一点。

我另外,HVAE具有以下信息的核心转储文件(没有活动的过程!):

(gdb) py-locals
...
msg = <RawMessage at remote 0x7fc91ea90ee0>
...

我想查看消息中的内容,而不是获得内存地址。本质上,python中的print(msg.data)等效。但是,我有GDB而不是Python!

以下命令不起作用:

(gdb) py-print msg.data
'msg.data' not found
(gdb) set $rawmessage = (PyObject*)0x7fc91ea90ee0
(gdb) p $rawmessage->data
There is no member named data.
(gdb) py msg
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'msg' is not defined
Error while executing Python code.

我们有什么想法如何访问此信息?如果有一种方法可以运行简单的Python代码,则额外的信用!

Suppose I have a class:

class RawMessage(NamedTuple):
    data: Dict
    timestamp: float
    ...

The keys and values in this dictionary are probably all integers, but I don't want to state that with certainty.

I additionally hvae a core dump file with the following information (There is no active process!):

(gdb) py-locals
...
msg = <RawMessage at remote 0x7fc91ea90ee0>
...

I would like to see what's in the message instead of getting a memory address. Essentially the equivalent of print(msg.data) in python. However, I have GDB instead of python!

The following commands do not work:

(gdb) py-print msg.data
'msg.data' not found
(gdb) set $rawmessage = (PyObject*)0x7fc91ea90ee0
(gdb) p $rawmessage->data
There is no member named data.
(gdb) py msg
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'msg' is not defined
Error while executing Python code.

Do we have any ideas how to access this information? Extra credit if there's a way to run simple python code!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文