public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cel at us dot ibm.com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/28426] New: Step reverse over line with multiple
Date: Tue, 05 Oct 2021 22:12:53 +0000	[thread overview]
Message-ID: <bug-28426-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 28426
           Summary: Step reverse over line with multiple
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: cel at us dot ibm.com
  Target Milestone: ---

The gdb command step is supposed to step over the next line in the program.

When executing in reverse, the step command for a line that contains two
executable statements requires two step commands to get to the previous line
not one step command as expected.

The following is a test program to demonstrate the behavior.  It is based on
the regression test gdb.reverese/solib-reverse.c.

int main ()                                                                     
{                                                                               
  int b[2] = {5,8};                                                             

  b[0] = 1;
  b[1] = 2;

  b[0] = 6;   b[1] = 9;         /* generic statement, end part two */           

  b[1] = 10;
  b[0] = 20;

  return 0;
} /* end of main */

Compile the program with -g and run on gdb

Start by enabling recording and stepping forward.

(gdb) break main
Breakpoint 1 at 0x838: file solib-reverse-bug.c, line 2.
(gdb) run
Starting program: /home/carll/solib-reverse-bug 

Breakpoint 1, main () at solib-reverse-bug.c:2
2       {
(gdb) list
1       int main ()
2       {
3         int b[2] = {5,8};
4       
5         b[0] = 1;
6         b[1] = 2;
7       
8         b[0] = 6;   b[1] = 9;         /* generic statement, end part two */
9       
10        b[1] = 10;
(gdb) 
11        b[0] = 20;
12      
13        return 0;
14      }
(gdb) record
(gdb) step
3         int b[2] = {5,8};
(gdb) step
5         b[0] = 1;
(gdb) step
6         b[1] = 2;
(gdb) step
8         b[0] = 6;   b[1] = 9;         /* generic statement, end part two */
(gdb) step
10        b[1] = 10;
(gdb) step
11        b[0] = 20;
(gdb) step
13        return 0;

As expected step advances to the next line each time, specifically line 8.

Set the execution direction to reverse and step

(gdb) set exec-dir reverse
(gdb) step
11        b[0] = 20;
(gdb) step
10        b[1] = 10;
(gdb) step
8         b[0] = 6;   b[1] = 9;         /* generic statement, end part two */
(gdb) step
8         b[0] = 6;   b[1] = 9;         /* generic statement, end part two */
(gdb) step
6         b[1] = 2;
(gdb) step
5         b[0] = 1;
(gdb) step
3         int b[2] = {5,8};
(gdb) step

You will note, that line 8 required two steps to get to the previous line. 
Step over the other lines worked as expected.

This issue has been observed on Power PC and Intel.

Note the above bug results in gdb.reverse/solib-presave.exp and
gdb.reverse/solib-reverse.exp to fail.



./

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

             reply	other threads:[~2021-10-05 22:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 22:12 cel at us dot ibm.com [this message]
2021-10-05 23:15 ` [Bug gdb/28426] Step reverse over line with multiple executable statements cel at us dot ibm.com
2022-10-26 14:00 ` vries at gcc dot gnu.org
2022-10-26 14:29 ` vries at gcc dot gnu.org
2023-01-25 10:04 ` blarsen at redhat dot com
2024-02-09 17:47 ` cel at linux dot ibm.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-28426-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).