我正在尝试设置一个可以远程连接的 headless Delve 调试器。
我无法找到一种方法来启动不会暂停我正在调试的应用程序的调试服务器。
我一直在使用 dlv attach --headless=true --listen=:2345 attach 32
但这会暂停进程。
或者我可以使用 dlv --headless=true --listen=:2345 exec app
如果这允许应用程序二进制文件运行。
不知道init
文件能不能做这样的事情?我找不到关于它到底是什么的任何文档。
最佳答案
如果你考虑delve issue 145 ,这可能是一个特性,而不是一个错误:
I can't see the value of starting an actual debug session without pausing unless you're simply relying on providing an
init
file (to load breakpoints / tracepoints) and then want to immediately continue execution, which you could do by writing a continue command at the end of theinit
file.You can already set tracepoints without stopping the program indefinitely with the
trace
subcommand, which takes a pid flag.
也就是说,Delve 1.3.0 (2019 年 8 月,2 年后):
go-delve/delve issue 245由 PR 1585 解决
cmd/dlv
: add--continue
to continue process on launch/attachAdd
--continue
option forattach
,debug
,exec
, andtrace
, to issue acontinue
on start.The main use case for this feature would be to start a headless delve server (for example within a container)
关于debugging - Golang delve,如何启动调试器并启动正在调试的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45856590/