程序执行开始后如何强制gdb停止? [英] how to force gdb to stop right after the start of program execution?

查看:2289
本文介绍了程序执行开始后如何强制gdb停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在每个功能上设置断点,使任何意义上的程序退出,然后再到达任何一个。有没有办法使程序从一开始就以分步模式运行,所以我可以看到发生了什么?

I've tried to set breakpoint on every function that makes any sense but program exit before reaching any of those. Is there a way to make program run in step-by-step mode from the start so I can see what's going on?

我试图调试/ usr / bin / id如果重要(我们有自定义插件,它的行为不正确)

I'm trying to debug /usr/bin/id if it's important (we have custom plugin for it and it's misbehaved)

PS开始命令对我来说不起作用(它应该是一个注释,但是我没有足够的代码)

P.S. Start command doesn't work for me here(it should be a comment, but I don't have enough rep for it)

推荐答案

p>获取程序入口点地址,并在该地址插入一个断点。

Get the program entry point address and insert a breakpoint at that address.

这样做的一个方法是做信息文件,给出例如入口点: 0x4045a4。然后做break * 0x4045a4。运行程序后,它将立即停止。

One way to do this is to do info files which gives you for example "Entry point: 0x4045a4". Then do "break *0x4045a4". After run-ning program, it will immediately stop.

从这里可以使用单步执行指令(如step或stepi)继续。

From here on you can use single stepping instructions (like step or stepi) to proceed.

您没有告诉您正在尝试调试哪个系统。如果代码在只读内存中,则可能需要使用硬件断点(hbreak)(如果该系统支持)。

You did not tell what system you are trying to debug. If code is in read-only memory you may need to use hardware breakpoints (hbreak) if they are supported by that system.

这篇关于程序执行开始后如何强制gdb停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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