douzi9430 2017-05-18 05:01
浏览 374
已采纳

调试go应用程序不会在断点处停止

I have latest IntelliJ Ultimate EAP and latest Gogland and the problem occurs on both under MacOS Sierra.

I'm trying to debug a go application by creating a debug profile for Go Application and the Run Kind is configured to Package, which contains the package name of the current project.

under Go tool arguments I have -ldflags="-linkmode internal" configured.

When I start a debug session while having some breakpoints, it would run but not stop at these breakpoints.

what am I missing?

thanks

update

ok I was able to reproduce the issue with the following project:

test1.go contains:

package main

const Numb uint64 = 5

test2.go contains:

package main

import "fmt"

func main() {
    fmt.Println(Numb);
}

I Created a Go Application run/debug configuration with the following parameters:

Run kind: package
Package: github.com/kfirufk/test
Working Directory: /usr/local/Cellar/go/1.8.1/src/github.com/kfirufk/test/

when I choose a breakpoint on test2.go line 6 (the first and only line of code in the main function) and I start a debug session, I see the following output:

"/Users/ufk/Library/Application Support/IntelliJIdea2017.1/Go/lib/dlv/mac/dlv" --listen=localhost:53111 --headless=true exec /private/var/folders/cn/n7rwdd_95_l54s3zdnbxvw040000gn/T/Unnamedgo --
GOROOT=/usr/local/Cellar/go/1.8.1/libexec
GOPATH=/usr/local/opt/go
/usr/local/Cellar/go/1.8.1/libexec/bin/go build -o /private/var/folders/cn/n7rwdd_95_l54s3zdnbxvw040000gn/T/Unnamedgo -gcflags "-N -l" github.com/kfirufk/test
API server listening at: 127.0.0.1:53111
5

I get the program's output properly but Intellij did not stop in the required breakpoint.

the problem is reproduced on Intellij 2017.1.3 with Go Lang Plugin 0.171.1928 on MacOS Sierra 10.12.4.

update

trying to play with intellij's delve to try to understand better what's going on:

/Users/ufk/Library/Application\ Support/IntelliJIdea2017.1/intellij-go/lib/dlv/mac/dlv exec ./test

then I executed:

(dlv) step

and received:

Command failed: could not find FDE for PC 0x78bc000

did I fail to understand how to use delve or is something doesn't work properly here ?

update

yeap.. with continue the debugger works properly with both versions of delve (installed from homebrew and the intellij's version). but still intellij works the same, doesn't stop at breakpoints. i create a breakpoint at test2.go at the line when I print the variable.

any ideas ?

  • 写回答

3条回答 默认 最新

  • douchuanghan1344 2017-05-28 22:56
    关注

    Ok.. I finally got it. I got mixed up with the GOROOT structure and GOPATH structure and I placed my project in GOROOT instead of GOPATH.

    this is what I did to resolve the issue

    I completely deleted go with brew uninstall --force go, then reinstalled go with the following environment variables:

    export GOPATH=$HOME/golang
    export GOROOT=/usr/local/opt/go/libexec
    export PATH=$PATH:$GOPATH/bin
    export PATH=$PATH:$GOROOT/bin
    

    then I placed my project at ~/golang/src/github.com/kfirufk/windy-server

    and I was finally able to properly debug go applications.

    thank you all for assisting me! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?