3

I installed LiteIDE and GDB. I opened my Go project in LiteIDE and added a breakpoint to some point in the code. Then i switched back to terminal and ran the project binary that was supposed to envoke the breakpoint and nothing happened. What am i doing wrong?

llSourcell
  • 29
  • 1
  • 2
  • You have to launch the binary to be debugged from within LiteIDE somehow, but I'm not currently using debugging or LiteIDE so I'm unfortunately ltitle help. :/ – twotwotwo Sep 29 '14 at 01:46
  • Can I ask what you're attaching the debugger for? Without plugging my own lib too much.. I did write something that lets you "watch" variables interactively (in a browser) with a go lib import. Otherwise, unit tests are pretty good at verifying functionality. I have never quite got the hang of GDB with Go.. it seems to crash randomly for me .. and always at the worst possible time :( – Simon Whitehead Sep 29 '14 at 02:57

2 Answers2

1

You have to actually launch the executable from the IDE for breakpoints to mean anything.

Also keep in mind that gdb is mostly meaningless with Go 1.3.x and even more so with 1.4 (dev).

From https://golang.org/doc/gdb:

GDB does not understand Go programs well. The stack management, threading, and runtime contain aspects that differ enough from the execution model GDB expects that they can confuse the debugger, even when the program is compiled with gccgo. As a consequence, although GDB can be useful in some situations, it is not a reliable debugger for Go programs, particularly heavily concurrent ones. Moreover, it is not a priority for the Go project to address these issues, which are difficult. In short, the instructions below should be taken only as a guide to how to use GDB when it works, not as a guarantee of success.

In time, a more Go-centric debugging architecture may be required.

Community
  • 1
  • 1
OneOfOne
  • 95,033
  • 20
  • 184
  • 185
  • why is it meaningless in go 1.3.x? Go is an up and coming language, how am i supposed to debug like i did in xcode? (my previous environment for 3 years) – llSourcell Sep 29 '14 at 06:38
  • 3
    @llSourcell sadly gdb support is broken in 1.3, and it's even more so in 1.4. So pretty much the only real debuging tool is a lot of `fmt.Printf`s – OneOfOne Sep 29 '14 at 07:02
  • Debugging 1.0 :) But somehow I don't miss the debugger that much. Go is way more easy to reason about than for example Python and the static typing is a big help here. Also having proper tests helps a lot in debugging stuff. – RickyA Oct 01 '14 at 10:25
0

I use this package https://github.com/gostart/debug/ and so far it is the best solution that I have found. Hope this helps.

  • That just seems to be a collection of utilities that are already in the standard lib. I know I am not supposed to self promote here .. but since this question of using GDB and _basic_ debugging keeps coming up.. I'll link to my "debugger" for Go: https://github.com/simon-whitehead/go-debug – Simon Whitehead Sep 29 '14 at 10:47
  • Hi Simon, thanks for the tool, it looks promising. It would be nice to have the Dump functionality like the lib that I mentioned. It is very handy when debugging complex types and to me this, along the stacktrace, are essential when using complex third party libraries. – Николай Колев Sep 30 '14 at 18:10
  • ...all things I can add. Thanks for the feedback :) – Simon Whitehead Sep 30 '14 at 22:54