opened
tycho
username_0
Please answer these questions before submitting your issue. Thanks!

### What version of Go are you using (`go version`)?
```
$ go version
go version go1.8.3 linux/amd64
```

### What operating system and processor architecture are you using (`go env`)?
I'm running on Arch Linux.
```
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/steven/Development/gocode"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build883327425=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
```

### What did you do?

```
$ go get github.com/yohcop/openid-go
$ cd $GOPATH/src/github.com/yohcop/openid-go
$ go run -exec gdb _example/server.go 
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/go-build581838362/command-line-arguments/_obj/exe/server...b(no debugging symbols found)...done.
(gdb) break main
Breakpoint 1 at 0x456c80
(gdb) run
Starting program: /tmp/go-build581838362/command-line-arguments/_obj/exe/server 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Breakpoint 1, 0x0000000000456c80 in main ()
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb)
```

### What did you expect to see?
I expected GDB **not** to say "no debugging symbols found" or "no symbol table loaded". I also expected it to show me a source listing when requested.

### What did you see instead?
GDB apparently doesn't see any debug symbols in the binary.

---

Any idea what I'm doing wrong? I'm pretty sure it's not just my distribution of Go. Tried a Fedora 25 image (which has go1.7.5 and GDB 7.12.1-48-fc25) and got the same result.

From [what I've read](https://golang.org/doc/gdb), it sounds like my version of Go and GDB should be working better than this, albeit with the numerous caveats mentioned on that page.

Also, I'm trying to figure out the right workflow for developing Go programs, and one of my first bullet points is a debugger. Is there a more appropriate debugger for Go? I'd prefer to not have to resort to "printf debugging" everything.
gdb can't find symbols in go1.8.3-compiled binaries
issue
created
ianlancetaylor
username_1
The `main` function is not a user-written function in Go.  Try breaking on `main.main`.  Since gdb doesn't understand that Go function names contain a dot character, you have to literally type

    break 'main.main'

with the quotes.
comment
created
tycho
username_0
Still no debug symbols, so it can't show me anything useful:

```
(gdb) break 'main.main'                                                                                 
Breakpoint 1 at 0x6fa000                                                                                
(gdb) run                                                                                               
Starting program: /tmp/go-build564374196/command-line-arguments/_obj/exe/server                         
[Thread debugging using libthread_db enabled]                                                           
Using host libthread_db library "/usr/lib/libthread_db.so.1".                                           
[New Thread 0x7ffff7817700 (LWP 15886)]                                                                 
[New Thread 0x7ffff7016700 (LWP 15887)]                                                                 
[New Thread 0x7ffff6815700 (LWP 15888)]                                                                 
[New Thread 0x7ffff6014700 (LWP 15889)]                                                                 
                                                                                                        
Thread 1 "server" hit Breakpoint 1, 0x00000000006fa000 in main.main ()                                  
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb) 
```
comment
created
cherrymui
username_2
`go run` builds a binary without debug info. Use `go build` to build the binary and run `gdb` with it.
comment
created
tycho
username_0
@username_2 Perfect! That did it. Thanks!
comment
closed
tycho
username_0
issue
created
dcheney-atlassian
username_3
Is this true?
comment
created
tycho
username_0
Sure seems that way.
comment
created
dcheney-atlassian
username_3
Wow. TIL.
comment
created
tycho
username_0
Yeah, I would kind of expect that "go run -exec gdb" would be a common use
case but I guess not. There's no apparent flags to enable or disable debug
symbols there either.
comment
created
dcheney-atlassian
username_3
You're not expected to use go run for anything larger than throw away
snippets (think a local play.golang.org)

On Mon, Jun 5, 2017 at 10:33 AM, Steven Noonan <notifications@github.com>
wrote:

> Yeah, I would kind of expect that "go run -exec gdb" would be a common use
> case but I guess not. There's no apparent flags to enable or disable debug
> symbols there either.
>
>
comment
created
tycho
username_0
Hmm. Then what's the typical development workflow? I'm coming from a c/c++
background so I'm not sure how it all works.

On 4 Jun 2017 5:36 pm, "David Cheney" <notifications@github.com> wrote:

> You're not expected to use go run for anything larger than throw away
> snippets (think a local play.golang.org)
>
> On Mon, Jun 5, 2017 at 10:33 AM, Steven Noonan <notifications@github.com>
> wrote:
>
> > Yeah, I would kind of expect that "go run -exec gdb" would be a common
> use
> > case but I guess not. There's no apparent flags to enable or disable
> debug
> > symbols there either.
> >
> >
comment
created
bradfitz
username_4
See https://golang.org/doc/code.html
comment
created
dcheney-atlassian
username_3
I use

go install && $GOPATH/bin/$BINARY

On Mon, Jun 5, 2017 at 12:16 PM, Steven Noonan <notifications@github.com>
wrote:

> Hmm. Then what's the typical development workflow? I'm coming from a c/c++
> background so I'm not sure how it all works.
>
> On 4 Jun 2017 5:36 pm, "David Cheney" <notifications@github.com> wrote:
>
> > You're not expected to use go run for anything larger than throw away
> > snippets (think a local play.golang.org)
> >
> > On Mon, Jun 5, 2017 at 10:33 AM, Steven Noonan <notifications@github.com
> >
> > wrote:
> >
> > > Yeah, I would kind of expect that "go run -exec gdb" would be a common
> > use
> > > case but I guess not. There's no apparent flags to enable or disable
> > debug
> > > symbols there either.
> > >
> > >
comment