now, to answer your question. the debug :
$ gdb x
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 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-linux-gnu".
For bug reporting instructions, please see:
<
http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/x...done.
Loading Go Runtime support.
(gdb) b x.go:14
Breakpoint 1 at 0x400cbf: file /tmp/x.go, line 14.
(gdb) l
1 package main
2
3 import (
4 "os"
5 "fmt"
6 "image"
7 "image/jpeg"
8 )
9
10 func main() {
(gdb) l
11 o := jpeg.Options {};
12 m := image.NewRGBA(image.Rect(0, 0, 100, 100))
13 fo, _ := os.Create("output.jpg")
14 defer fo.Close()
15 jpeg.Encode (fo, m, &o);
16 fmt.Println(m.Bounds())
17 fmt.Println(m.At(0, 0).RGBA())
18 }
(gdb) r
Starting program: /tmp/x
warning: no loadable sections found in added symbol-file
system-supplied DSO at 0x7ffff7ffd000
Breakpoint 1, main.main () at /tmp/x.go:14
14 defer fo.Close()
(gdb) n
15 jpeg.Encode (fo, m, &o);
(gdb) l image/jpeg/writer.go:497
492 // Encode writes the Image m to w in JPEG 4:2:0 baseline format
with the given
493 // options. Default parameters are used if a nil *Options is passed.
494 func Encode(w io.Writer, m image.Image, o *Options) error {
495 b := m.Bounds()
496 if b.Dx() >= 1<<16 || b.Dy() >= 1<<16 {
497 return errors.New("jpeg: image is too large to encode")
498 }
499 var e encoder
500 if ww, ok := w.(writer); ok {
501 e.w = ww
(gdb) b image/jpeg/writer.go:495
Breakpoint 2 at 0x43f4d7: file
/home/aam/go/src/pkg/image/jpeg/writer.go, line 495.
(gdb) c
Continuing.
Breakpoint 2, image/jpeg.Encode (w=..., m=..., o=0x7fffe7f72eb8, ~anon3=...)
at /home/aam/go/src/pkg/image/jpeg/writer.go:495
495 b := m.Bounds()
(gdb) n
496 if b.Dx() >= 1<<16 || b.Dy() >= 1<<16 {
(gdb)
499 var e encoder
(gdb)
500 if ww, ok := w.(writer); ok {
(gdb) p
The history is empty.
(gdb) p b
$1 = {Min = {X = 0, Y = 0}, Max = {X = 100, Y = 100}}
(gdb) c
Continuing.
(0,0)-(100,100)
0 0 0 0
[LWP 4791 exited]
[Inferior 1 (process 4791) exited normally]
(gdb) quit
As for why gdb looks inside /usr/local, that's probably because you're
running the go tools from /usr/local/bin instead of your local source
installation's bin ('go env' will tell you what GOROOT is set as).
you'll probably have to adjust your paths.
autoloading the gdb go support is done via the following script posted recently:
$ cat .gdbinit
add-auto-load-safe-path /home/aam/go/src/pkg/runtime/runtime-gdb.py
define g
python
import subprocess as p
cmd = ["go", "env", "GOROOT"]
gdb_cmd = "source %s/src/pkg/runtime/runtime-gdb.py" % p.check_output(cmd)[:-1]
gdb.execute(gdb_cmd)
end