FAQ
When I'm debugging using gdb, and I try to step into library code, gdb
drops into C code rather than the library. For example:

runtime.convT2I (t=void, inter=void) at
/usr/local/go/src/pkg/runtime/iface.c:188


How do I step through the Go library code?

A bit more information... I've compiled my code like this, to prevent
inlining and registerization:

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


I do the usual gdb startup:

% gdb server
(gdb) b 17
(gdb) run
Breakpoint 1, main.main () at server.go:17
17 e := http.ListenAndServe(":1234", s)
(gdb) s
runtime.convT2I (t=void, inter=void) at
/usr/local/go/src/pkg/runtime/iface.c:188
188 runtime·convT2I(Type *t, InterfaceType *inter, ...)


--
Sonia Hamilton
http://www.snowfrog.net

--

Search Discussions

  • Rob Pike at Oct 5, 2012 at 3:59 am
    Doesn't 'step' do the work?

    -rob

    --
  • Sonia Hamilton at Oct 5, 2012 at 4:10 am
    No, that's the surprising thing...
    On Friday, 5 October 2012 14:00:03 UTC+10, Rob Pike wrote:

    Doesn't 'step' do the work?

    -rob
    --
  • Minux at Oct 5, 2012 at 4:50 am
    the gdb behavior is correct, because there is a call to
    convT2I before ListenAndServe.

    i suggest you add a breakpoint at ListenAndServe and
    continue.

    maybe it is a bug of the dwarf we generated, but I'm
    not sure, because stepping into runtime is occasionally
    useful.
    On Oct 5, 2012 11:54 AM, "Sonia Hamilton" wrote:

    --
  • Sonia Hamilton at Oct 5, 2012 at 7:14 am
    Thanks minux. But as you'll see from my post I'm already setting a
    breakpoint at ListenAndServe. Continuing from ListenAndServe wouldn't help
    as I want to see what ListenAndServe is actually doing.

    Any pointers?
    On Friday, 5 October 2012 14:50:49 UTC+10, minux wrote:

    the gdb behavior is correct, because there is a call to
    convT2I before ListenAndServe.

    i suggest you add a breakpoint at ListenAndServe and
    continue.

    maybe it is a bug of the dwarf we generated, but I'm
    not sure, because stepping into runtime is occasionally
    useful.
    On Oct 5, 2012 11:54 AM, "Sonia Hamilton" wrote:
    --
  • Rob Pike at Oct 5, 2012 at 7:28 am
    Set a source breakpoint on the first line of ListenAndServe.

    -rob

    --
  • Mikio Hara at Oct 5, 2012 at 7:28 am
    (gdb) b net/http.ListenAndServe
    Breakpoint 2 at 0x2bc70: file /go/src/pkg/net/http/server.go, line 1148.

    hope this helps,
    -- Mikio

    --
  • Minux at Oct 5, 2012 at 7:39 am

    On Fri, Oct 5, 2012 at 3:14 PM, Sonia Hamilton wrote:

    But as you'll see from my post I'm already setting a breakpoint
    at ListenAndServe. Continuing from ListenAndServe wouldn't help as I want
    to see what ListenAndServe is actually doing.
    I mean, set a breakpoint at http.ListenAndServe, i.e.

    b 'net/http.ListenAndServe'

    PS: step is not very useful when debugging Go programs, because there are
    lots of call
    to the runtime, if you truly want to step into a call, you'd better place
    at breakpoint at the
    called function instead of stepping into that call.

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 5, '12 at 3:54a
activeOct 5, '12 at 7:39a
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase