public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "blarsen at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug record/29745] New: gdbserver doesn't record changing return address on call instructions
Date: Thu, 03 Nov 2022 08:36:40 +0000	[thread overview]
Message-ID: <bug-29745-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 29745
           Summary: gdbserver doesn't record changing return address on
                    call instructions
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: record
          Assignee: unassigned at sourceware dot org
          Reporter: blarsen at redhat dot com
  Target Milestone: ---

Created attachment 14431
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14431&action=edit
minimal test

When running an inferior in the gdbserver in x86_64, the call instruction only
saves the register changes to $PC and possible parameters, it does not save the
change to the return address in the stack.

This makes it so when trying to next over a function or finish a function, GDB
sets a breakpoint on the wrong address, and may skip multiple functions instead
of just the expected one.

As an example, running the attached test I get the following output:

Temporary breakpoint 1, main () at
testsuite/outputs/gdb.reverse/step-reverse/step-reverse.c:10
10        foo ();
(gdb) record
(gdb) n
11        int x = 0;
(gdb) 
12        foo ();
(gdb) 
13        return 0;
(gdb) rn
12        foo ();
(gdb) 
11        int x = 0;
(gdb) 

No more reverse-execution history.
main () at testsuite/outputs/gdb.reverse/step-reverse/step-reverse.c:10
10        foo ();
(gdb) n

No more reverse-execution history.
main () at testsuite/outputs/gdb.reverse/step-reverse/step-reverse.c:13
13        return 0;

Notice that the final line is 13 when it should be line 11.

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

             reply	other threads:[~2022-11-03  8:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  8:36 blarsen at redhat dot com [this message]
2022-11-04 11:12 ` [Bug record/29745] " cvs-commit at gcc dot gnu.org
2023-05-04 15:21 ` 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-29745-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: 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).