public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "greyschwinger at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug go/29357] New: gdb for golang prints wrong frame info at the ret instruction Date: Tue, 12 Jul 2022 02:37:09 +0000 [thread overview] Message-ID: <bug-29357-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=29357 Bug ID: 29357 Summary: gdb for golang prints wrong frame info at the ret instruction Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: go Assignee: unassigned at sourceware dot org Reporter: greyschwinger at gmail dot com Target Milestone: --- Prepare a hello world golang program: ``` $ cat -n ./main.go 1 package main 2 3 import "fmt" 4 5 func main() { 6 fmt.Println("hello world") 7 } ``` Compile the code using go1.18.3 linux/amd64: ``` $ go build . ``` Disassemble the main function: ``` $ gdb -ex "disas/mr 'main.main'" -ex q ./go_hello_world 5 func main() { 0x000000000047dfe0 <+0>: 49 3b 66 10 cmp 0x10(%r14),%rsp 0x000000000047dfe4 <+4>: 76 56 jbe 0x47e03c <main.main+92> 0x000000000047dfe6 <+6>: 48 83 ec 40 sub $0x40,%rsp 0x000000000047dfea <+10>: 48 89 6c 24 38 mov %rbp,0x38(%rsp) 0x000000000047dfef <+15>: 48 8d 6c 24 38 lea 0x38(%rsp),%rbp 0x000000000047e03c <+92>: 0f 1f 40 00 nopl 0x0(%rax) 0x000000000047e040 <+96>: e8 5b a9 fd ff call 0x4589a0 <runtime.morestack_noctxt> 0x000000000047e045 <+101>: eb 99 jmp 0x47dfe0 <main.main> 6 fmt.Println("hello world") 0x000000000047dff4 <+20>: 44 0f 11 7c 24 28 movups %xmm15,0x28(%rsp) 0x000000000047dffa <+26>: 48 8d 15 5f 7e 00 00 lea 0x7e5f(%rip),%rdx # 0x485e60 0x000000000047e001 <+33>: 48 89 54 24 28 mov %rdx,0x28(%rsp) 0x000000000047e006 <+38>: 48 8d 15 7b 4b 03 00 lea 0x34b7b(%rip),%rdx # 0x4b2b88 0x000000000047e00d <+45>: 48 89 54 24 30 mov %rdx,0x30(%rsp) 7 } 0x000000000047e032 <+82>: 48 8b 6c 24 38 mov 0x38(%rsp),%rbp 0x000000000047e037 <+87>: 48 83 c4 40 add $0x40,%rsp 0x000000000047e03b <+91>: c3 ret End of assembler dump. ``` Then I'll add a breakpoint at the ret instruction, <+91> ``` $ gdb ./go_hello_world (gdb) b *0x000000000047e03b Breakpoint 1 at 0x47e03b: file /home/gray/src/proving_grounds/go_hello_world/main.go, line 7. (gdb) r Thread 1 "go_hello_world" hit Breakpoint 1, 0x000000000047e03b in main.main () at /home/gray/src/proving_grounds/go_hello_world/main.go:7 7 } ``` Then let's check the frame info and register: ``` (gdb) i f Stack level 0, frame at 0xc00011cf78: rip = 0x47e03b in main.main (/home/gray/src/proving_grounds/go_hello_world/main.go:7); saved rip = 0x4324d2 source language unknown. Arglist at 0xc00011cf70, args: Locals at 0xc00011cf70, Previous frame's sp is 0xc00011cf80 Saved registers: rip at 0xc00011cf78 (gdb) p/x $rsp $1 = 0xc00011cf78 ``` However the "frame at 0xc00011cf78" is incorrect. As far as I know, "the frame at" shows the CFA of the current stack frame, and at the ret instruction, the CFA should be $rsp+8. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2022-07-12 2:37 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-12 2:37 greyschwinger at gmail dot com [this message] 2022-07-12 2:38 ` [Bug go/29357] " greyschwinger at gmail dot com 2023-03-31 0:05 ` tromey at sourceware dot org
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-29357-4717@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: linkBe 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).