保存并重新启动已暂停的gdb会话 [英] Saving and restarting a paused gdb session

查看:119
本文介绍了保存并重新启动已暂停的gdb会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是gdb可以监视正在运行的程序的完整状态。我可以保存在断点处暂停的gdb会话并在以后恢复该会话吗?在断点处,然后使用核心转储启动第二个gdb会话。



将核心文件保存在gdb中



这会导致以下错误。

 程序以信号SIGTRAP,跟踪/断点陷阱终止。 

因此将断点信息插入程序状态,很有趣。在第二次尝试中,我执行了相同的操作,但是这次我在第二次会话中添加了与第一次会话相同的断点。



获取gdb保存断点列表?



仍然出现相同的错误。



我可以保存并重新启动gdb会话吗?如果是这样,怎么办?



我认为这并不直接相关,但我也收到此警告。

 警告:核心文件可能与指定的可执行文件不匹配。 

gdb只是简单地指出这种事情是可能的,还是gdb认为这可能是在正在运行的会话?我相信产生核心转储的同一可执行文件正在gdb下运行。



编辑:对于其他任何人,这个问题:保存进程的内存以备后用吗?文章: http://blogs.msdn.com/ b / oldnewthing / archive / 2004/04/20 / 116749.aspx 这很有趣。链接的问题还建议将进程包装在VM中。

解决方案

我怀疑这种方法是否可行。保存核心文件时,程序已打开/创建的文件和任何其他资源(信号量,共享内存,串行端口,网络连接和许多其他东西)的句柄将丢失。您可以检查它,但不能继续。核心文件只是原始程序正在使用的所有内存的副本。程序终止时,其他所有内容都将丢失。换句话说,核心文件仅在以后检查时有用,但是您不能在核心文件调试会话中运行,步进或继续。只有看事物。而且,如果您无法执行,则断点也不会真正起作用...;)


My understanding is that gdb can monitor the complete state of a running program. Can I save a gdb session that is paused at a breakpoint and resume the session later?

My first attempt was simply generating a core dump in a first gdb session that was paused at a breakpoint and then using the core dump to start a second gdb session.

Saving core file in gdb

This resulted in the following error.

Program terminated with signal SIGTRAP, Trace/breakpoint trap.

So breakpoint information is inserted into the program state, interesting. On my second attempt I did the same but this time I added the same breakpoint to the second session as were in the first session.

Getting gdb to save a list of breakpoints?

Still, I get the same error.

Can I save and restart a gdb session? If so, how?

I don't think this is directly relevant but I'm also getting this warning.

warning: core file may not match specified executable file.

Is gdb simply stating that such a thing is possible in general or does gdb believe this may have happened in the running session? I'm confident that the same executable that produced the core dump is being run under gdb.

Edit: For anyone else who comes along, this question: Save a process' memory for later use? adds to Mats Petersson's answer and links to this article: http://blogs.msdn.com/b/oldnewthing/archive/2004/04/20/116749.aspx which is an interesting read. The linked question also has the suggestion of wrapping the process up in a VM.

解决方案

I doubt that will ever work. Handles for files and any other resources (semaphores, shared memory, serial ports, network connections and lots of other things) that the program has opened/created will be lost when you save the core-file. You can inspect it, but you can't "continue". A core-file is simply a copy of all the memory that original program was using. Anything else is "lost" when the program terminates. In other words, a core-file will only be useful to inspect things later on, but you can't run, step or continue in a core-file debug session. Only "look at things". And if you can't execute, breakpoints won't really work either... ;)

这篇关于保存并重新启动已暂停的gdb会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆