public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug record/29721] [gdb, record, aarch64] FAIL: gdb.reverse/solib-precsave.exp: reverse-next third shr1
Date: Thu, 19 Jan 2023 17:30:31 +0000	[thread overview]
Message-ID: <bug-29721-4717-Dc9bKi0YUG@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29721-4717@http.sourceware.org/bugzilla/>

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

--- Comment #31 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to B. Larsen from comment #30)
> > Say we assume that they are equal if the target contains an epilogue unwinder, but if not, we're handling things more conservatively.  This kind of fix could be backported to fix the regression that was introduced.
> 
> This sounds ok, but I wonder if "handling things more conservatively" will
> regress
> [record/16678](https://sourceware.org/bugzilla/show_bug.cgi?id=16678). To
> fix that bug I assumed that we knew the frame ID would be the same
> throughout the whole function. If we can't rely on that, how are we supposed
> to detect a breakpoint being hit in a recursive call?

Well, you've fixed that problem for a recursive function with debug info, and
for x86_64 without debug info (meaning, also using
-fno-asynchronous-unwind-tables to make sure there's no cfi directives).

On aarch64 though, I see:
...
$ cat test.c
extern int factorial (int x);
int v;
int main() {
  v = 1;
  factorial(5);
  return 0;
}
$ cat test2.c
int factorial(int x) {
  if (x == 1) return 1;
  int result = x * factorial(x-1);
  return result;
}
$ gcc test2.c -c ; gcc test.c test2.o -g
$ gdb a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x40056c: file test.c, line 4.
Starting program: a.out 

Temporary breakpoint 1, main () at test.c:4
4         v = 1;
(gdb) record
(gdb) next
5         factorial(5);
(gdb) next
6         return 0;
(gdb) reverse-next
0x00000000004005d4 in factorial ()
(gdb) 
...

This is essentially the same problem as in this PR ... and I'm proposing that
we fix it, in a target-independent fashion.

I think the following cases can be distinguished:
- cfi info present, assume frame ID's accurate, no special handling needed
- cfi info not present, but target has an epilogue unwinder , assume frame
  ID's accurate, no special handling needed
- cfi info not present, no epilogue unwinder. Special handling needed,
  but no need to worry about breaking handling of recursive function,
  because it's already broken, and the special handling intends to fix it.

My naive idea on how to approach this was to instead of doing a step-resume
breakpoint at the last insn and resume, do first a single step back, and then
insert the step-resume breakpoint and resume.  This will already fix the
aarch64 case.  There may be cases where this gives the wrong answer, but AFAIU
those cases are broken anyway.

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

  parent reply	other threads:[~2023-01-19 17:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 13:30 [Bug record/29721] New: " vries at gcc dot gnu.org
2022-10-25 16:20 ` [Bug record/29721] " vries at gcc dot gnu.org
2022-10-26 11:56 ` blarsen at redhat dot com
2022-10-26 14:16 ` vries at gcc dot gnu.org
2022-10-26 14:36 ` blarsen at redhat dot com
2022-10-26 14:43 ` vries at gcc dot gnu.org
2022-10-26 14:47 ` vries at gcc dot gnu.org
2022-10-27 20:15 ` luis.machado at arm dot com
2022-11-02 14:05 ` vries at gcc dot gnu.org
2022-11-02 15:42 ` blarsen at redhat dot com
2022-11-08 16:08 ` blarsen at redhat dot com
2022-11-10 12:07 ` blarsen at redhat dot com
2022-11-10 12:40 ` luis.machado at arm dot com
2022-11-10 14:18 ` vries at gcc dot gnu.org
2022-11-10 14:20 ` vries at gcc dot gnu.org
2022-12-13 14:57 ` blarsen at redhat dot com
2023-01-16 10:43 ` vries at gcc dot gnu.org
2023-01-16 15:58 ` vries at gcc dot gnu.org
2023-01-16 16:40 ` vries at gcc dot gnu.org
2023-01-16 18:59 ` luis.machado at arm dot com
2023-01-16 19:39 ` vries at gcc dot gnu.org
2023-01-16 19:53 ` luis.machado at arm dot com
2023-01-16 19:57 ` vries at gcc dot gnu.org
2023-01-17 16:47 ` vries at gcc dot gnu.org
2023-01-19 13:42 ` vries at gcc dot gnu.org
2023-01-19 13:46 ` vries at gcc dot gnu.org
2023-01-19 13:47 ` vries at gcc dot gnu.org
2023-01-19 13:56 ` luis.machado at arm dot com
2023-01-19 14:00 ` vries at gcc dot gnu.org
2023-01-19 14:14 ` vries at gcc dot gnu.org
2023-01-19 14:28 ` blarsen at redhat dot com
2023-01-19 17:30 ` vries at gcc dot gnu.org [this message]
2023-01-20  8:57 ` blarsen at redhat 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-29721-4717-Dc9bKi0YUG@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).