Debugging 远程调试和停止
我需要帮助在Gogland与Delve进行远程调试 我尝试使用IDE Goglang(1.0 EAP)和dlv链接在远程服务器上调试我的应用程序: 安装并尝试远程调试简单程序:Debugging 远程调试和停止,debugging,go,remote-debugging,delve,goland,Debugging,Go,Remote Debugging,Delve,Goland,我需要帮助在Gogland与Delve进行远程调试 我尝试使用IDE Goglang(1.0 EAP)和dlv链接在远程服务器上调试我的应用程序: 安装并尝试远程调试简单程序: package main import "fmt" func main() { fmt.Println("hello world") for i:=uint(0); i< 10; i++{ fmt.Println(i) } } 然后,在IDE中启动远程调试: 从远程主机
package main
import "fmt"
func main() {
fmt.Println("hello world")
for i:=uint(0); i< 10; i++{
fmt.Println(i)
}
}
然后,在IDE中启动远程调试:
从远程主机控制台输出:
2017/07/20 17:23:24 debugger.go:504: continuing
2017/07/20 17:23:24 debugger.go:493: halting
2017/07/20 17:23:24 debugger.go:347: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x47bb52, File:"/....../hello/hello.go", Line:6, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:23:24 debugger.go:504: continuing
2017/07/20 17:23:28 debugger.go:516: nexting
hello world
2017/07/20 17:23:28 debugger.go:516: nexting
2017/07/20 17:23:29 debugger.go:516: nexting
0
2017/07/20 17:23:29 debugger.go:516: nexting
02017/07/20 17:23:29 debugger.go:516: nexting
2017/07/20 17:23:29 debugger.go:516: nexting
1
2017/07/20 17:23:29 debugger.go:516: nexting
12017/07/20 17:23:30 debugger.go:516: nexting
2017/07/20 17:23:30 debugger.go:516: nexting
2
2017/07/20 17:23:30 debugger.go:516: nexting
42017/07/20 17:23:30 debugger.go:516: nexting
2017/07/20 17:23:30 debugger.go:516: nexting
3
2017/07/20 17:23:30 debugger.go:516: nexting
92017/07/20 17:23:31 debugger.go:516: nexting
2017/07/20 17:23:31 debugger.go:516: nexting
4
2017/07/20 17:23:31 debugger.go:516: nexting
162017/07/20 17:23:31 debugger.go:516: nexting
2017/07/20 17:23:31 debugger.go:516: nexting
5
2017/07/20 17:23:32 debugger.go:516: nexting
252017/07/20 17:23:32 debugger.go:516: nexting
2017/07/20 17:23:32 debugger.go:516: nexting
6
2017/07/20 17:23:32 debugger.go:516: nexting
362017/07/20 17:23:32 debugger.go:516: nexting
2017/07/20 17:23:32 debugger.go:516: nexting
7
2017/07/20 17:23:33 debugger.go:516: nexting
492017/07/20 17:23:33 debugger.go:516: nexting
2017/07/20 17:23:33 debugger.go:516: nexting
8
2017/07/20 17:23:34 debugger.go:516: nexting
642017/07/20 17:23:34 debugger.go:516: nexting
2017/07/20 17:23:34 debugger.go:516: nexting
9
2017/07/20 17:23:34 debugger.go:516: nexting
812017/07/20 17:23:34 debugger.go:516: nexting
2017/07/20 17:23:35 debugger.go:516: nexting
2017/07/20 17:23:35 debugger.go:516: nexting
一切都按照我的预期进行(断点、F7、F8等)
然后我尝试调试我的应用程序:
dlv debug --headless --listen=:2345 --log --api-version=2 -- --v --console
2017/07/20 17:26:51 debugger.go:97: launching process with args: [/home/...../debug --v --console]
API server listening at: [::]:2345
IDE启动
输出:
2017/07/20 17:26:55 debugger.go:493: halting
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x687a73, File:"/home/..........go", Line:136, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:2, Name:"", Addr:0x6869b2, File:"/home/..........go", Line:66, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:504: continuing
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:3, Name:"", Addr:0x687d33, File:"/home/........go", Line:143, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:504: continuing
2017/07/20 17:26:57 debugger.go:516: nexting
$ dlv debug --headless --listen=:2345 --log --api-version=2 -- --v --console
2017/07/20 17:37:37 debugger.go:97: launching process with args: [/home/*****************/debug --v --console]
API server listening at: [::]:2345
2017/07/20 17:38:27 debugger.go:347: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x687a86, File:"/home/*******************.go", Line:137, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:38:35 debugger.go:504: continuing
2017/07/20 17:38:39 debugger.go:516: nexting
IDE调试不工作(挂起)。如果我不使用断点,应用程序启动并像平常一样运行(运行)
我认为这一行是我的问题的原因:
2017/07/20 17:26:45调试器。转到:493:停止
它为什么会出现??也许我有一个复杂的实用程序结构(主程序包被分成几个文件,当然还有外部插件程序包等等)或者其他什么
但是(!最有趣的!)是,如果您不是通过IDE而是通过控制台加入远程服务器,那么调试可以在一个简单的示例中工作,在my utility的情况下:
dlv connect HOSTNAME:2345
Type 'help' for list of commands.
(dlv) b ********.go:137
Breakpoint 1 set at 0x687a86 for main.main() /home/*************.go:137
(dlv) c
> main.main() /home/***************************.go:137 (hits goroutine(1):1 total:1) (PC: 0x687a86)
(dlv) n
输出:
2017/07/20 17:26:55 debugger.go:493: halting
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x687a73, File:"/home/..........go", Line:136, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:2, Name:"", Addr:0x6869b2, File:"/home/..........go", Line:66, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:504: continuing
2017/07/20 17:26:55 debugger.go:347: created breakpoint: &api.Breakpoint{ID:3, Name:"", Addr:0x687d33, File:"/home/........go", Line:143, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:26:55 debugger.go:504: continuing
2017/07/20 17:26:57 debugger.go:516: nexting
$ dlv debug --headless --listen=:2345 --log --api-version=2 -- --v --console
2017/07/20 17:37:37 debugger.go:97: launching process with args: [/home/*****************/debug --v --console]
API server listening at: [::]:2345
2017/07/20 17:38:27 debugger.go:347: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x687a86, File:"/home/*******************.go", Line:137, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/07/20 17:38:35 debugger.go:504: continuing
2017/07/20 17:38:39 debugger.go:516: nexting
那些。怀疑IDE中有错误,或者我做错了什么:)
我还尝试使用dlv exec(已构建应用程序)和其他命令进行调试
谢谢你花时间回答这个问题,我真的希望能得到帮助
另外,我也很高兴知道您还可以使用什么进行GO应用程序的远程调试
p.p.S.我试图在Atom.io和VS代码中进行远程调试
在Atom中,仅使用dlv进行区域设置调试
在VS代码中,本地调试器通过dlv+远程调试器工作,但断点不工作!!!那些VS代码也不是一个选项。
配置VS代码(launch.json)
问题是基于IDE的。已在版本中解决: 内部版本:EAP12172.3757.46
发布日期:2017年8月11日问题是基于IDE的。已在版本中解决: 内部版本:EAP12172.3757.46
发布日期:2017年8月11日对于Gogland,请添加“#com.goide.dlv.DlvVm”(不带引号)以帮助调试日志设置。。。然后尝试调试应用程序并在此处添加日志。您可以通过帮助找到日志|在中显示日志。。。请参阅idea.log。或者,您可以在tracker:上打开问题并上载日志there@dlsniper,来自IDE的日志文件:据我所知,delve只是存在过程,仅此而已。您是否正在运行最新的围棋(1.8.3)?被调试进程的主机是什么?如何构建/启动已调试的应用程序?我不明白这个简单的应用程序是否有效?如果有,如果没有,你能从IDE发布完整的日志吗?如果实际的应用程序不起作用,可能还有其他原因,但是没有一种方法可以在示例中重现它,我对此无能为力。遗憾的是,这些问题不适合在StackOverflow上解决。简单的应用程序可以工作(远程调试)。但是我的应用程序不工作,停止时没有任何错误消息。嗯,可能是IDE、调试器或Go中的错误。如果没有办法复制它,我就没有任何神奇的方法来理解它。我问了你很多问题,你一个也没回答。想象一下,你必须理解这个问题,我们的角色就会颠倒过来。如何确定问题?对于Gogland,请添加“#com.goide.dlv.DlvVm”(不带引号)以帮助调试日志设置。。。然后尝试调试应用程序并在此处添加日志。您可以通过帮助找到日志|在中显示日志。。。请参阅idea.log。或者,您可以在tracker:上打开问题并上载日志there@dlsniper,来自IDE的日志文件:据我所知,delve只是存在过程,仅此而已。您是否正在运行最新的围棋(1.8.3)?被调试进程的主机是什么?如何构建/启动已调试的应用程序?我不明白这个简单的应用程序是否有效?如果有,如果没有,你能从IDE发布完整的日志吗?如果实际的应用程序不起作用,可能还有其他原因,但是没有一种方法可以在示例中重现它,我对此无能为力。遗憾的是,这些问题不适合在StackOverflow上解决。简单的应用程序可以工作(远程调试)。但是我的应用程序不工作,停止时没有任何错误消息。嗯,可能是IDE、调试器或Go中的错误。如果没有办法复制它,我就没有任何神奇的方法来理解它。我问了你很多问题,你一个也没回答。想象一下,你必须理解这个问题,我们的角色就会颠倒过来。您将如何确定问题?