FAQ
Hi.

After panic or signal or some other problem, one gets stack traces for each
goroutine.
In these stack traces one can see function calls with arguments, e.g.:

foobar/bumpd/storage.(*Storage).QueueItemRemove(0xc820012240,
0x55e581f500000001, 0x55e5c974, 0x55e581f50036fd63, 0x4730c877427c180b,
0x55e57e03, 0xc1b64e8ac22d3e1d, 0x0, 0x0)

We can see 9 arguments here, but in a go file, function QueueItemRemove()
have only one argument which is a structure.

Where can I read about how to map arguments from stack trace to arguments
in go file?

There are some rules I fugured myself already:

    1. First argument is usually a 'self' argument with pointer to the object
    2. If you pass struct by value, then this struct can be unfolded as we
    see in an example
    3. If you pass 32bit values then two 32bit values can be merged into one
    64bit value

--
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/d/optout.

Search Discussions

  • Ian Lance Taylor at Sep 1, 2015 at 5:35 pm

    On Tue, Sep 1, 2015 at 9:56 AM, Marko Kevac wrote:
    After panic or signal or some other problem, one gets stack traces for each
    goroutine.
    In these stack traces one can see function calls with arguments, e.g.:

    foobar/bumpd/storage.(*Storage).QueueItemRemove(0xc820012240,
    0x55e581f500000001, 0x55e5c974, 0x55e581f50036fd63, 0x4730c877427c180b,
    0x55e57e03, 0xc1b64e8ac22d3e1d, 0x0, 0x0)

    We can see 9 arguments here, but in a go file, function QueueItemRemove()
    have only one argument which is a structure.

    Where can I read about how to map arguments from stack trace to arguments in
    go file?
    I don't think this is written down anywhere, but it's pretty simple.
    There are some rules I fugured myself already:

    First argument is usually a 'self' argument with pointer to the object
    The first argument of a method will be the receiver of the method.
    For a pointer method, it will indeed be a pointer.
    If you pass struct by value, then this struct can be unfolded as we see in
    an example Yes.
    If you pass 32bit values then two 32bit values can be merged into one 64bit
    value
    Yes.

    Basically, imagine there is a struct that contains the receiver (if
    any) followed by the function parameters, followed by the result
    parameters. Lay that struct out in memory. What you see in the
    backtrace is each word of the struct, where the word is 32-bits on a
    32-bit system or 64-bits on a 64-bit system.

    Ian

    --
    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/d/optout.
  • Tim K at Sep 1, 2015 at 5:51 pm
    Are there any tools that help visualize the arguments back into the source
    code form?
    On Tuesday, September 1, 2015 at 10:35:07 AM UTC-7, Ian Lance Taylor wrote:

    On Tue, Sep 1, 2015 at 9:56 AM, Marko Kevac <ma...@kevac.org <javascript:>>
    wrote:
    After panic or signal or some other problem, one gets stack traces for each
    goroutine.
    In these stack traces one can see function calls with arguments, e.g.:

    foobar/bumpd/storage.(*Storage).QueueItemRemove(0xc820012240,
    0x55e581f500000001, 0x55e5c974, 0x55e581f50036fd63, 0x4730c877427c180b,
    0x55e57e03, 0xc1b64e8ac22d3e1d, 0x0, 0x0)

    We can see 9 arguments here, but in a go file, function
    QueueItemRemove()
    have only one argument which is a structure.

    Where can I read about how to map arguments from stack trace to
    arguments in
    go file?
    I don't think this is written down anywhere, but it's pretty simple.
    There are some rules I fugured myself already:

    First argument is usually a 'self' argument with pointer to the object
    The first argument of a method will be the receiver of the method.
    For a pointer method, it will indeed be a pointer.
    If you pass struct by value, then this struct can be unfolded as we see in
    an example Yes.
    If you pass 32bit values then two 32bit values can be merged into one 64bit
    value
    Yes.

    Basically, imagine there is a struct that contains the receiver (if
    any) followed by the function parameters, followed by the result
    parameters. Lay that struct out in memory. What you see in the
    backtrace is each word of the struct, where the word is 32-bits on a
    32-bit system or 64-bits on a 64-bit system.

    Ian
    --
    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/d/optout.
  • Giulio Iotti at Sep 1, 2015 at 8:15 pm

    On Tuesday, September 1, 2015 at 8:51:50 PM UTC+3, Tim K wrote:
    Are there any tools that help visualize the arguments back into the source
    code form?
    Maybe this[1] or worth contributing to it?

    [1] https://github.com/maruel/panicparse

    --
    Giulio Iotti
    https://twitter.com/dullboy

    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 1, '15 at 4:56p
activeSep 1, '15 at 8:15p
posts4
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase