public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "wilson at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/28371] gdb: watchpoint for local variable doesn't work on RISC-V Date: Fri, 24 Sep 2021 22:51:36 +0000 [thread overview] Message-ID: <bug-28371-4717-c2q9mmFW2R@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-28371-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=28371 Jim Wilson <wilson at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wilson at gcc dot gnu.org --- Comment #2 from Jim Wilson <wilson at gcc dot gnu.org> --- I can reproduce natively on an Unmatched with the SiFive OpenEmbedded distro. Looking at the gcc and clang output. I see that the epilogue for func2 in the gcc output is ld s0,24(sp) .cfi_restore 8 .cfi_def_cfa 2, 32 addi sp,sp,32 .cfi_def_cfa_offset 0 jr ra .cfi_endproc And the epilogue for func2 in the clang output is ld s0, 16(sp) # 8-byte Folded Reload ld ra, 24(sp) # 8-byte Folded Reload addi sp, sp, 32 ret .Ltmp3: .Lfunc_end1: .size func2, .Lfunc_end1-func2 .cfi_endproc So the clang output has no unwind info for epilogues. I believe that is a known problem with clang. Somehow this lack of epilogue unwind info is confusing gdb, and it thinks that the variable q has gone out of scope when it sees the frame pointer popped from the stack without corresponding unwind info. This makes some sense, since gdb has to parse the frame to find the local q in the parent function, and if the unwind info is wrong it won't be able to do that. I don't know if this can be fixed in gdb. It can certainly be fixed in clang by emitting unwind info for function epilogues. Also note that if you put a breakpoint in the func2 epilogue and type the "up" command, this works with the gcc output, taking you to main, but fails in the clang output, taking you to __libc_start_call_main which is a glibc function. Epilogue unwind info is needed for this to work right also. This whole mess is probably complicated by the fact that we don't have hardware watchpoints (except with openocd), so we have to single step through code and check for a change to q after every instruction. If we had hardware watchpoints, the watchpoint for q would work correctly. Without hardware watchpoints, we need function epilogue unwind info to be correct. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2021-09-24 22:51 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-22 7:00 [Bug gdb/28371] New: " shivam98.tkg at gmail dot com 2021-09-23 4:03 ` [Bug gdb/28371] " shivam98.tkg at gmail dot com 2021-09-24 22:51 ` wilson at gcc dot gnu.org [this message] 2021-09-26 18:17 ` shivam98.tkg at gmail dot com 2021-09-26 18:39 ` shivam98.tkg at gmail dot com 2021-09-28 2:07 ` evandro.menezes at sifive dot com 2021-09-29 21:28 ` wilson at gcc dot gnu.org 2021-09-29 21:42 ` jrtc27 at jrtc27 dot com 2021-09-29 21:42 ` jrtc27 at jrtc27 dot com 2021-09-30 9:56 ` shivam98.tkg at gmail dot com 2021-09-30 9:57 ` shivam98.tkg at gmail dot com 2021-09-30 9:59 ` shivam98.tkg at gmail dot com 2021-09-30 10:02 ` shivam98.tkg at gmail dot com 2021-09-30 10:35 ` schwab@linux-m68k.org 2021-10-01 19:48 ` wilson at gcc dot gnu.org 2021-10-11 10:11 ` shivam98.tkg at gmail dot com 2021-10-26 6:03 ` shivam98.tkg at gmail dot com 2021-10-26 10:18 ` shivam98.tkg 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-28371-4717-c2q9mmFW2R@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).