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

查看:19
本文介绍了如何强制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)

附:开始命令在这里对我不起作用(应该是评论,但我没有足够的代表)

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

推荐答案

获取程序入口点地址,并在该地址处插入断点.

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天全站免登陆