gdb 附加到进程而不停止 [英] gdb attach to a process without stop

查看:16
本文介绍了gdb 附加到进程而不停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我使用 gdb 附加到一个进程时,它都会停止目标程序,我需要输入 'cont' 让它离开.有没有办法在不停止进程的情况下附加到进程?如果进程停止一段时间后行为会有所不同,这会使事情变得更容易.

解决方案

你不能让它不停.但是,您可以立即继续...创建一个简单的批处理脚本,该脚本将附加到特定进程并在附加后立即继续执行:

gdb attach $1 -x <(echo "cont")

<块引用>

./附加PID

Everytime I attach to a process using gdb, it will stop the target program, and I need to type 'cont' to let it go. Is there a way to attach to a process without stopping it? This makes things easier if the process will behave differently if it stops for a while.

解决方案

You can't make it not stop. You can however instantly continue... Create a simple batch script which will attach to a specific process and instantly continuing execution after attaching:

gdb attach $1 -x <(echo "cont")

./attach PID

这篇关于gdb 附加到进程而不停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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