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

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置