服务启动时调试
我正在尝试调试服务。通常的过程是启动服务并将 gdb 附加到进程。但我想在服务仍在启动时调试代码。 gdb 需要一段时间来加载库,并且在我放置断点之前所需的代码已经执行。知道怎么做吗?谢谢!
I am trying to debug a service. The usual procedure is to start the service and attach gdb to the process. But I want to debug the code when the service is still starting up. It takes a while for gdb to load the libraries, and the required code has executed before I can put the breakpoints. Any idea how to do it? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的服务名为“myservice.exe”,
如果您可以进入实际运行代码的机器,那么我将执行以下操作:
这应该可以满足您的需求。
注意:如果您无法直接运行 gdb,请在开始时(在您要调试的部分之前)放置一个“睡眠”语句 1 分钟 - 这应该允许您在启动敏感代码之前进行连接。
Let's assume your service is called "myservice.exe"
If you can get on the box that the code is actually running on, then I would do the following:
This should get you what you want.
Note: if you can't run gdb directly, then put a "sleep" statement for 1 minute at the very start (before the part you want to debug) - that should allow you to connect before it starts the sensitive code.