Re: [go-nuts] GDB: How to call a function ?

280 views
Skip to first unread message

minux

unread,
Oct 1, 2012, 12:11:04 PM10/1/12
to yann Malet, golan...@googlegroups.com

On Mon, Oct 1, 2012 at 10:55 PM, yann Malet <yann....@gmail.com> wrote:
I have been trying to find out how to call a function in a GDB session. I am under the impression that `call myfunc(var)` should work but it doesn't.
sorry, but Gdb doesn't understand our calling convention, so it won't be able
to call a Go function.

in fact, you can call a Go function (note the apostrophes), but gdb (and maybe your program too) will crash.
(gdb) call 'main.greet'("hello")
infrun.c:5777: internal-error: normal_stop: Assertion `get_frame_type (frame) == DUMMY_FRAME' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

also, note that gdb also doesn't understand our string type, so it won't be able
to pass the correct string parameter to your function.

yann Malet

unread,
Oct 1, 2012, 1:14:04 PM10/1/12
to golan...@googlegroups.com, yann Malet
Is that a "bug" that will eventually be fixed at some point or a "Feature" that will remain as is ?

Ian Lance Taylor

unread,
Oct 1, 2012, 2:42:22 PM10/1/12
to yann Malet, golan...@googlegroups.com
On Mon, Oct 1, 2012 at 10:14 AM, yann Malet <yann....@gmail.com> wrote:
> Is that a "bug" that will eventually be fixed at some point or a "Feature"
> that will remain as is ?

It's a bug but I'm not aware of anybody working on it. I don't know
whether it can be fixed in the Python code
(src/pkg/runtime/runtime-gdb.py) or whether it requires changes in GDB
proper.

Ian
> --
>
>

minux

unread,
Oct 2, 2012, 1:41:10 AM10/2/12
to Ian Lance Taylor, golan...@googlegroups.com, yann Malet


On Oct 2, 2012 2:42 AM, "Ian Lance Taylor" <ia...@google.com> wrote:
>
> On Mon, Oct 1, 2012 at 10:14 AM, yann Malet <yann....@gmail.com> wrote:
> > Is that a "bug" that will eventually be fixed at some point or a "Feature"
> > that will remain as is ?
>
> It's a bug but I'm not aware of anybody working on it.  I don't know
> whether it can be fixed in the Python code
> (src/pkg/runtime/runtime-gdb.py) or whether it requires changes in GDB
> proper.

after going through http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html, i think gdb proper must be changed to accomplish this (unless there are undocumented python hooks for calling interior's functions).

Reply all
Reply to author
Forward
0 new messages