远程调试 Gogland 暂停

huangapple go评论96阅读模式
英文:

Remote debug Gogland halting

问题

我需要帮助解决在Gogland中使用Delve进行远程调试的问题。

我尝试使用Gogland(1.0 EAP)和dlv链接(https://github.com/derekparker/delve/)在远程服务器上调试我的应用程序。

首先,启动远程主机上的dlv(从控制台输出):

$ dlv debug --headless --listen=:2345 --log --api-version=2
API server listening at: [::]:2345

然后,在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

IDE调试不起作用(挂起)。如果我不使用断点,应用程序会像平常一样启动和运行(RUN)。

我认为这行代码是问题的原因:

2017/07/20 17:26:45 debugger.go:493: halting

为什么会出现这个问题?也许我的实用程序结构很复杂(主包分为几个文件,当然还有外部插件包等),或者其他原因?

但是(最有趣的是!),如果您不通过IDE而是通过控制台连接到远程服务器,那么调试在简单示例和我的实用程序的情况下都可以工作:

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

输出:

$ 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应用程序的远程调试工具。

附注:我尝试在Atom.io和VS Code中进行远程调试
在Atom中,仅本地调试与dlv一起工作。

在VS Code中,本地调试通过dlv +远程调试器工作,但断点不起作用!也就是说,VS Code也不是一个选择。
配置VS Code(launch.json)

{
"version": "0.2.0",
"configurations": [
{
"name": "REMOTE",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "{workspaceRoot}",
"port": 2345,
"host": "REMOTE_HOST_NAME",
"program": "${workspaceRoot}", //"${fileDirname}",
"env": {},
"args": ["--v", "--console"],
"showLog": true
}
]
}

英文:

I need help with Remote debugging in Gogland with Delve.

I try to debug my app on remote server with IDE Goglang (1.0 EAP) and dlv link: https://github.com/derekparker/delve/

Install and try remote debug simple program:

package main

import "fmt"

func main() {
    fmt.Println("hello world")
    for i:=uint(0); i< 10; i++{
        fmt.Println(i)
    }
}

Firstly, start dlv on remote host (output from console):

$ dlv debug --headless --listen=:2345 --log --api-version=2
API server listening at: [::]:2345

Then, start remote debug in IDE:

Out from remote host console:

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

Everything works as I expected (breakpoint, F7, F8 and etc.)

Then i try to debug My APP:

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 start

Output:

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

IDE debug does not work (hangs up). If I don't use breakpoints app start and run like a usual (RUN).

I think this line is the reason for my problem:

2017/07/20 17:26:45 debugger.go:493: halting

Why does it arise ?? Maybe I have a complicated utility structure (the main package is divided into several files, of course there are external plug-in packages, etc.) or something else?

BUT (! the most interesting !) is that if you join a remote server not through the IDE, but through the console, then debugging works on a simple example and in the case of 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

Output:

$ 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

Those. There is a suspicion of an error in the IDE, or I'm doing something wrong :).

I also try debug with dlv exec (already build app) and other command.

Thanks for the time given to the question, I really hope for help.

P.S. I will also be glad to know what else you can use for remote debugging for GO app.

P.P.S. I tried to make remote debugging in Atom.io and in VS code
In Atom, work only locale debug with dlv.

In VS code the local debugger works through dlv + remote debugger works, but breakpoints doesn't work !!! Those. VS Code is also not an option.
Configuring VS Code (launch.json)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "REMOTE",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath": "{workspaceRoot}",
            "port": 2345,
            "host": "REMOTE_HOST_NAME",
            "program":  "${workspaceRoot}", //"${fileDirname}",
            "env": {},
            "args": ["--v", "--console"],
            "showLog": true
        }
    ]
}

答案1

得分: 1

问题是基于IDE的。在版本中解决:
构建:EAP 12,172.3757.46
发布日期:2017年8月11日

英文:

Problem was IDE based. Solved in version:
Build: EAP 12, 172.3757.46
Released: Aug 11, 2017

huangapple
  • 本文由 发表于 2017年7月21日 20:59:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/45238337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定