如何使用GoClipse调试Go程序? [英] How to debug Go programs using GoClipse?

查看:191
本文介绍了如何使用GoClipse调试Go程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OS X Mavericks上使用Go(go1.3 darwin / amd6)和GoClipse 0.8 ...

Am using Go (go1.3 darwin/amd6) and GoClipse 0.8 on OS X Mavericks...

在调试器(设置断点后)遇到问题,所以我打扫了Stack Overflow和Internet的其余部分,发现我需要安装gdb。

Was having trouble running the Debugger (after setting breakpoints) so I scoured Stack Overflow and also the rest of the Internet and discovered that I needed to install gdb.

遵循以下说明(到T)(通过安装gdb HomeBrew):

Followed the following instructions (to a T) (by installing gdb via HomeBrew):

http://ntraft.com/installing-gdb-on-os-x-mavericks/

现在,当我放置一个断点并运行我的程序通过Eclipse的调试器,它逐步通过汇编代码而不是Go代码:

Now, when I place a breakpoint and Run my go program through Eclipse's debugger, it steps through assembly code instead of Go code:

例如

已设置断点我的go程序中的这一行:

A breakpoint was set that this line inside my go program:

responses := [] *HttpResponse{}

当我运行调试器时,它打开了一个名为:

When I ran the debugger, it opened up a file called:

rt0_darwin_amd64的文件。 s

rt0_darwin_amd64.s

及其代码行等等是:

MOVQ    $_rt0_go(SB), AX

当我尝试跳过我的代码,它通过这些程序集文件继续这样做...

And when I tried to "Step Over" my code, it kept doing so through these assembly files...

我不知道程序集(不要以为我有时间去学习它)...有没有一个简单的方法来调试Go程序使用Eclipse调试器?

I don't know assembly (and don't think I have the time to learn it)... Is there a simple way of debugging Go program using the Eclipse debugger?

推荐答案

当Go程序停止时,调试视图显示什么? (调试视图是什么显示您的堆栈跟踪)。它是否显示类似于以下的堆栈跟踪:

What does the Debug view display when your Go program stops? (The Debug view is what shows your stack trace). Does it display a stack trace similar to this:

Thread [1] 0 (Suspended : Breakpoint)   
    main() at rt0_windows_amd64.s:15 0x42a400   
    KERNEL32!BaseThreadInitThunk() at 0x773259ed    
    0x0 

(注意:对于OSX,在rt0_darwin_amd64.s 中将是 main())

(note: for OSX, it would be main() at rt0_darwin_amd64.s)

如果是,这里正在发生什么:启动程序时,程序启动时会自动停止在主功能上。但这不是Go的主要内容,而是一个内部运行时的main函数,它的代码用C编写,并且没有可用的源,这就是为什么你看到汇编程序)。
这可以通过启动配置选项中的第一个选项进行控制,如下所示:

If so, here is what is happening: When you started the program, it stopped automatically on the "main" function on program startup. But that's not the Go main, but rather an internal runtime "main" function, whose code is written in C, (and for which there is no source available, that's why you see the assembler). This is controlled by the first option in the the launch configuration options, as you can see here:

您可以将其更改为main.main,以停止实际的Go主,或者只是取消选中。在任何情况下,如果调试器停在那里,您可以单击运行/继续(F8)继续。

You can change it to "main.main" to stop on the actual Go main, or just unchecked it. In any case, if the debugger stops there, you can just click Run / Resume (F8) to continue.

这篇关于如何使用GoClipse调试Go程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆