我寻找了与我类似的问题,但我发现的最接近的是 Continue debugging after SegFault in GDB
我的目标是从核心转储中调用 GDB 中的函数。我有一个 C++ 类型,其 operator<<
已定义,我想漂亮地打印这种类型,而不必在 python 中编写 pretty-print 。
从我到目前为止发现的情况来看,GDB 对待 coredump 的方式与常规劣等不同,后者具有主动执行功能,因此无法调用函数(正如 this answer 所证实的那样,它指出您不能使用继续进行核心转储)。
虽然我可以理解为什么默认情况下会出现这种情况,但可以修补 GDB 以将核心转储加载到内存中并将其作为正在运行的进程调用吗?如果程序由于 Seg.故障那么可以在GDB中加载核心后手动更改损坏的路径,甚至可能在之后继续执行程序。
最佳答案
Though I can see why that might be the case by default, could GDB be patched to load a coredump into memory and invoke it as a running process?
理论上,这是可能的。在实践中,您会发现这是一项重大任务,(可能)需要您至少几周甚至几个月的时间。
I would like to pretty print this type without having to write a pretty printer in python.
我可以向您保证,用 Python 编写一个 pretty-print 会减少很多工作。
If the program terminated due to a Seg. Fault then it is possible to manually alter the broken path after loading the core in GDB and potentially even continue executing the program after.
如果程序使用未在核心转储中捕获的任何操作系统级资源,则不会。所有套接字、文件、SysV IPC 等都将消失。 This answer同意。
关于linux - gdb coredump - 调用函数或继续执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62419146/