英文:
How to set breakpoint in Delve with an init-command
问题
在GDB中,有一个--init-command
标志,我可以定义一个命令,比如b dbConnection
,它会在运行项目后自动应用。它在dbConnection
函数上设置断点。
我在Delve中寻找类似的功能,但是我找不到。
整个想法是,不是先运行dlv命令,然后告诉它我的函数在哪里,并在那里设置断点,而是在运行dlv之前,将函数名作为初始化命令,比如break pkg/db/connection.go:dbConnection
。我可以运行fzf命令轻松找到文件,然后将其传递给dlv的初始化命令,以在那里设置断点。
英文:
In GDB, there is a flag --init-command
which I can define a command like b dbConnection
and it will be applied automatically after running the project. It sets the breakpoint on the dbConnection
function.
I was looking for the same in Delve but I couldn't find it.
The whole idea is instead of running dlv command and then telling where is my function and set the breakpoint there, I wanna give the function name before running dlv as init command like break pkg/db/connection.go:dbConnection
. I can run fzf command to find the file easily and then I'll pass it to the dlv init command to set the breakpoint there.
答案1
得分: 1
这是答案的链接:https://github.com/go-delve/delve/discussions/3189
标志是 --init
。例如:
dlv debug --init <(echo b main.main)
英文:
Here is the answer https://github.com/go-delve/delve/discussions/3189
The flag is --init
. For example:
dlv debug --init <(echo b main.main)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论