英文:
Golang delve, how do you start the debugger and have the application that you are debugging start?
问题
我正在尝试设置一个无头的 delve 调试器,可以远程连接。我无法找到一种不会暂停我正在调试的应用程序的调试服务器启动方法。我一直在使用dlv attach --headless=true --listen=:2345 attach 32
,但这会暂停进程。或者,我可以使用dlv --headless=true --listen=:2345 exec app
,如果这样可以运行应用程序二进制文件的话。我不知道 init
文件是否可以做到这样的事情?我找不到关于它的任何文档说明。
英文:
I am trying to setup a headless delve debugger that I can attach to remotely.
I am unable to find a way to launch a debugging server that doesn't pause the application I am debugging.
I have been using dlv attach --headless=true --listen=:2345 attach 32
but this pauses the process.
Alternatively I could use dlv --headless=true --listen=:2345 exec app
if this allowed the app binary to run.
I don't know if the init
file can do something like this? I cannot find any documentation on what that actually is.
答案1
得分: 5
如果你考虑一下深入问题145,那可能是一个功能,而不是一个错误:
> 我无法看到在没有暂停的情况下启动实际调试会话的价值,除非你仅仅依赖于提供一个init
文件(用于加载断点/跟踪点),然后希望立即继续执行,这可以通过在init
文件的末尾编写一个继续命令来实现。
>
> 你已经可以使用trace
子命令设置跟踪点,而不必无限期地停止程序。
话虽如此,从Delve 1.3.0(2019年8月,2年后)开始:
go-delve/delve问题245已经通过PR 1585得到解决
> ## cmd/dlv
: 添加--continue
以在启动/附加时继续进程
>
> 为attach
、debug
、exec
和trace
添加--continue
选项,以在启动时发出continue
命令。
>
> 这个功能的主要用例是启动一个无头的 delve 服务器(例如在容器中)
英文:
If you consider delve issue 145, that might be a feature, not a bug:
> 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 the init
file.
>
> You can already set tracepoints without stopping the program indefinitely with the trace
subcommand, which takes a pid flag.
That being said, with Delve 1.3.0 (August 2019, 2 years later):
go-delve/delve issue 245 is resolved by PR 1585
> ## cmd/dlv
: add --continue
to continue process on launch/attach
>
> Add --continue
option for attach
, debug
, exec
, and trace
, to issue a continue
on start.
>
> The main use case for this feature would be to start a headless delve server (for example within a container)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论