FAQ
Hi,
I have a sample program here - http://ideone.com/RZ7Rop
I'd like to step through the source code of jpeg encoding. When I do a step
into line 15, it gets into interface resolution logic (if I understood it
right) ... is there an easy way to step into the jpeg library?
Also, I find that when I debug, the source code is looked for at /usr/local
even though I had go in my home directory somewhere.
Regards,
Kashyap

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Andrey mirtchovski at May 10, 2013 at 5:39 pm
    Please don't ignore errors.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brad Fitzpatrick at May 10, 2013 at 5:44 pm
    Also, please share Go code snippets with http://play.golang.org/ ... it was
    hard to find the code on that page with all those ads.


    On Fri, May 10, 2013 at 10:36 AM, C K Kashyap wrote:

    Hi,
    I have a sample program here - http://ideone.com/RZ7Rop
    I'd like to step through the source code of jpeg encoding. When I do a
    step into line 15, it gets into interface resolution logic (if I understood
    it right) ... is there an easy way to step into the jpeg library?
    Also, I find that when I debug, the source code is looked for at
    /usr/local even though I had go in my home directory somewhere.
    Regards,
    Kashyap

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brad Fitzpatrick at May 10, 2013 at 5:45 pm
    Oh, ideone also compiles. I thought it was just a pastebin.

    Unfortunate about the UI, though.


    On Fri, May 10, 2013 at 10:44 AM, Brad Fitzpatrick wrote:

    Also, please share Go code snippets with http://play.golang.org/ ... it
    was hard to find the code on that page with all those ads.


    On Fri, May 10, 2013 at 10:36 AM, C K Kashyap wrote:

    Hi,
    I have a sample program here - http://ideone.com/RZ7Rop
    I'd like to step through the source code of jpeg encoding. When I do a
    step into line 15, it gets into interface resolution logic (if I understood
    it right) ... is there an easy way to step into the jpeg library?
    Also, I find that when I debug, the source code is looked for at
    /usr/local even though I had go in my home directory somewhere.
    Regards,
    Kashyap

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Andrey mirtchovski at May 10, 2013 at 5:59 pm
    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

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • C K Kashyap at May 11, 2013 at 3:32 am
    Thanks Andrey ,
    Yeah, I'll use play-golang in future. Btw, is there a way to run a local
    instance of play-golang?
    Regards,
    Kashyap


    On Fri, May 10, 2013 at 11:29 PM, andrey mirtchovski
    wrote:
    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
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Andrey mirtchovski at May 11, 2013 at 3:46 am

    Thanks Andrey ,
    Yeah, I'll use play-golang in future. Btw, is there a way to run a local
    instance of play-golang?
    Regards,
    Kashyap
    I believe so, although I haven't tried recently:

    https://code.google.com/p/go-playground/

    if you want to try out code just compile it locally. the playground is
    only going to impose restrictions, not give you more features.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • C K Kashyap at May 11, 2013 at 9:53 am
    Thank you Andrey.
    Regards,
    Kashyap


    On Sat, May 11, 2013 at 9:16 AM, andrey mirtchovski
    wrote:
    Thanks Andrey ,
    Yeah, I'll use play-golang in future. Btw, is there a way to run a local
    instance of play-golang?
    Regards,
    Kashyap
    I believe so, although I haven't tried recently:

    https://code.google.com/p/go-playground/

    if you want to try out code just compile it locally. the playground is
    only going to impose restrictions, not give you more features.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 10, '13 at 5:36p
activeMay 11, '13 at 9:53a
posts8
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase