2

I am trying to debug a Go-program using gdb and setting breakpoints works normally in all packages, except for one. In my src-folder I have 3 subfolders that each contain packages:

  • crawler/
    • crawler.go
  • model/
    • page.go
  • urlutils/
    • urlutils.go

I cannot set a breakpoint in page.go on any line as it gives me the following error:

(gdb) break model/page.go:14
No source file named model/page.go.
Make breakpoint pending on future shared library load? (y or [n])

I do not understand why this is happening with only this one package. "model/page" is also an import in the file that contains the main function and is used when the program runs, so it must be in the executable. Does anyone have an idea?

2
  • Related: stackoverflow.com/questions/12965726/… and stackoverflow.com/questions/1735539/… Commented Oct 15, 2013 at 13:20
  • 1
    I found those questions as well, but I am not using eclipse and a rebuild of the project didn't work (the go build command does a full rebuild and packs everything in one executable anyway). Commented Oct 15, 2013 at 14:52

1 Answer 1

3

I found a solution:

I needed to add a flag to my go build command:

go build -gcflags "-N -l" launch.go

This disables the code optimization performed by the go compiler which lead to my breakpoint working. The paths were correct and also the absolute path didn't work.

Nevertheless, thank you tomwilde for pointing me into a direction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.