dongshi4773 2017-07-21 12:59
浏览 47
已采纳

远程调试Gogland暂停

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条回答 默认 最新

  • drmticpet66231422 2017-10-23 11:04
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?