从核心文件恢复程序状态

发布于 2024-08-15 13:56:51 字数 247 浏览 2 评论 0原文

在任何情况下,是否有可能将程序的状态恢复到生成核心文件期间的状态?

我问的原因是,为了利用 gdb 执行函数等的能力,您需要有一个正在运行的实例。当然应该可以生成同一可执行文件的模拟进程,并将状态设置为核心的内容?

如果不是,对于最初让我想要这样做的情况,有什么替代方案呢?在这种情况下,核心的回溯导致了一个库函数,我想复制该函数调用的输入,但其中一个输入是复杂的对象,可以轻松地通过运行中的函数调用将其序列化为字符串。实例但在核心转储中并非如此。

Is it possible, under any circumstances, to restore the state of a program to what it was during the generation of a core file?

The reason I ask is that in order to take advantage of gdb's ability to execute functions and so forth you need to have a running instance. Surely it should be possible to produce a mock process of the same executable with the state set to be the contents of the core?

If not what alternatives are there for the sort of situation that made me want to do this in the first place? In this case the back-trace of the core led to a library function and I wanted to replicate the inputs to this function call but one of the inputs is was complex object which could easily be serialized to a string with a function call in a running instance but not so in a core dump.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

娇妻 2024-08-22 13:56:51

理论上可以完全按照您想要的方式进行操作,但是(AFAICT)GDB 中尚不支持此操作(尚未)。

最好的选择是使用 GDB-7.0 并使用其嵌入式 python 脚本来重新实现序列化功能。

It is theoretically possible to do exactly what you want, but (AFAICT) there is no support for this in GDB (yet).

Your best bet is to use GDB-7.0 and use its embedded python scripting to re-implement the serialization function.

星軌x 2024-08-22 13:56:51

这就是核心文件的作用吗?如果您使用原始可执行文件和核心文件加载 gdb

gdb myprogram.exe -c mycorefile

那么它将转到崩溃的位置。您可以使用所有常规检查功能来查看变量、查看堆栈跟踪等。

或者我误解了你的问题?

That's what a core file does already? If you load gdb with the original executable and the core file

gdb myprogram.exe -c mycorefile

Then it'll go to the point at where it crashed. You can use all the normal inspection functionality to view the variables, see the stack trace and so on.

Or have I misunderstood your question?

心如狂蝶 2024-08-22 13:56:51

如果它对某人有用,
我已经实现了一个 Python 模块来做到这一点:调用核心文件中的函数(通过模拟 CPU)。

它称为 EmuCore
我已成功地将它用于非常复杂的函数,示例序列化 GStreamer 管道图。

请注意,它仍然有重要的限制,例如:

  • 仅限 x64 Linux,
  • 该函数无法调用操作系统(例如读取文件)
  • 函数参数不能为浮点数

有关更多信息,请参阅自述文件。

In case it's useful to someone,
I've implemented a Python module to do just that: call functions in a core file (by emulating the CPU).

It's called EmuCore.
I've successfully used it on very complex functions, example serializing a GStreamer pipeline graph.

Note that it still has important limitations such as:

  • only x64 Linux
  • the function can't call the OS (to e.g. read files)
  • function arguments can't be floats

See README for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文