public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "mariappan.balraj at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug go/30038] When using CGO and C code is calling GO function, not getting call stack of C from core dump. Only getting call stack of GO.
Date: Wed, 22 Feb 2023 05:10:38 +0000	[thread overview]
Message-ID: <bug-30038-4717-AOiottZkqv@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30038-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=30038

--- Comment #15 from mariappan balraj <mariappan.balraj at gmail dot com> ---
Hi Tromey,

Ian mentioned that "gccgo is not as well supported as the gc compiler".
https://github.com/golang/go/issues/57698

Is it possible to provide support from GDB to decode BT when the Go
compiler is used? If you can give guidance and direction then it may be
possible for me to contribute? Eagerly waiting for your strong support to
resolve this issue.

Go compiler(GC) can be invoked by using build option -compiler gc.
Optimization and inlining can be disabled by using the following command.

CGO_CFLAGS="-g" go build -compiler gc -gcflags=all="-N -l" .

Best Regards
Mariappan

On Fri, Feb 17, 2023 at 6:51 AM tromey at sourceware dot org <
sourceware-bugzilla@sourceware.org> wrote:

> https://sourceware.org/bugzilla/show_bug.cgi?id=30038
>
> --- Comment #14 from Tom Tromey <tromey at sourceware dot org> ---
> Thanks Ian.
>
> Looking into it a little bit, I think these functions are just
> being optimized out:
>
> (gdb) down
> #19 0x00000000004041a5 in runtime.cgocall (fn=0x4582e0
> <_cgo_5bc4e3e20e89_Cfunc_test3>, arg=0xc00005af70, ~r0=<optimized out>)
>     at /usr/lib/golang/src/runtime/cgocall.go:167
> 167             errno := asmcgocall(fn, arg)
> (gdb) p fn
> $1 = (void *) 0x4582e0 <_cgo_5bc4e3e20e89_Cfunc_test3>
>
>
> Let's look at that:
>
> (gdb) disassemble 0x4582e0
> Dump of assembler code for function _cgo_5bc4e3e20e89_Cfunc_test3:
>    0x00000000004582e0 <+0>:     jmp    0x4582d0 <test3>
> End of assembler dump.
>
>
> That jumps to:
>
> (gdb) disassemble 0x4582d0
> Dump of assembler code for function test3:
>    0x00000000004582d0 <+0>:     jmp    0x4582c0 <test2>
> End of assembler dump.
>
>
> So, looks like tail calls to me.
>
> I do see this frame:
>
> #20 0x00000000004581e5 in main._Cfunc_test3 (r1=...) at _cgo_gotypes.go:41
>
> which I feel proves that C functions can show up in the bt.
>
> Just to be really clear here, I know nothing about go and even less
> about non-gcc go.  This code in gdb is essentially unmaintained.
> I don't even know if it was written to assume gccgo or golang-go.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You reported the bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-02-22  5:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24  6:54 [Bug go/30038] New: " mariappan.balraj at gmail dot com
2023-01-24  6:55 ` [Bug go/30038] " mariappan.balraj at gmail dot com
2023-01-24 13:09 ` tromey at sourceware dot org
2023-01-25  5:22 ` mariappan.balraj at gmail dot com
2023-02-06  5:51 ` mariappan.balraj at gmail dot com
2023-02-13  9:41 ` mariappan.balraj at gmail dot com
2023-02-14  6:12 ` tromey at sourceware dot org
2023-02-14  6:28 ` mariappan.balraj at gmail dot com
2023-02-14  7:54 ` tromey at sourceware dot org
2023-02-14 10:29 ` mariappan.balraj at gmail dot com
2023-02-14 17:39 ` tromey at sourceware dot org
2023-02-15  5:54 ` mariappan.balraj at gmail dot com
2023-02-15 11:24 ` mariappan.balraj at gmail dot com
2023-02-15 18:17 ` tromey at sourceware dot org
2023-02-16 23:38 ` ian at airs dot com
2023-02-17  1:21 ` tromey at sourceware dot org
2023-02-22  5:10 ` mariappan.balraj at gmail dot com [this message]
2023-02-28  1:40 ` tromey at sourceware dot org
2023-04-03 11:59 ` mariappan.balraj at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30038-4717-AOiottZkqv@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).