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/28424] New: step reverse over array expression requires two steps to complete
Date: Tue, 05 Oct 2021 18:32:15 +0000	[thread overview]
Message-ID: <bug-28424-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 28424
           Summary: step reverse over array expression requires two steps
                    to complete
           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: ---

When stepping in the reverse direction a C statement like:

a[2] = a[2] - a[3];

requires two step commands to step over the line.

The following is a stripped down version of gdb.reverse/step-reverse.c.

int main () {
   int w,x,y,z;
   int a[10], b[10];

   w = 0;       /* BREAK AT MAIN */
   x = 1;       /* NEXT TEST 1 */
   y = 2;       /* STEP TEST 1 */
   a[1] = 3;
   a[2] = a[2] - a[3]; /* TEST */
   a[3] = a[2] - a[3]; /* TEST */

   exit (0); /* end of main */
}

Compile the test program with -g and run on gdb.

The following shows that stepping in the forward direction works as expected

(gdb) break main
Breakpoint 1 at 0x838: file test-error.c, line 6.
(gdb) r
Starting program: /home/carll/test-error 

Breakpoint 1, main () at test-error.c:6
6       int main () {
(gdb) record
(gdb) step
10         w = 0;       /* BREAK AT MAIN */
(gdb) step
11         x = 1;       /* NEXT TEST 1 */
(gdb) step
12         y = 2;       /* STEP TEST 1 */
(gdb) step
13         a[1] = 3;
(gdb) step
14         a[2] = a[2] - a[3]; /* TEST */
(gdb) step
15         a[3] = a[2] - a[3]; /* TEST */
(gdb) step
17         exit (0); /* end of main */

Now reverse and step
(gdb) set exec-dir reverse
(gdb) step
15         a[3] = a[2] - a[3]; /* TEST */
(gdb) step
15         a[3] = a[2] - a[3]; /* TEST */
(gdb) step
14         a[2] = a[2] - a[3]; /* TEST */
(gdb) step
14         a[2] = a[2] - a[3]; /* TEST */
(gdb) step
13         a[1] = 3;
(gdb) step
12         y = 2;       /* STEP TEST 1 */
(gdb) step
11         x = 1;       /* NEXT TEST 1 */
(gdb) step
10         w = 0;       /* BREAK AT MAIN */
(gdb) step

No more reverse-execution history.
main () at test-error.c:6
6       int main () {


I took two step commands, instead of only one step command, to step over lines 
14 and 15 but only one step instruction for the other lines.

The error seems to occur only when there is an array expression on the right
hand side.  

This issue is causing the regression test step-precsave.exp to fail.  The test
works when an extra step command is added.  

diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp
b/gdb/testsuite/gdb.rev
erse/step-precsave.exp
index 43f6ab3a11a..3f4413ea353 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -249,7 +249,7 @@ gdb_test_multiple "stepi" "$test_message" {
 }

 # step backward into function (thru return)
-
+gdb_test "step" ".*FINISH TEST.*" "Extra step should not be needed.  BUG"
 gdb_test "step" "(RETURN FROM CALLEE|ARRIVED IN CALLEE).*" \
     "reverse step into fn call"

--

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

             reply	other threads:[~2021-10-05 18:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 18:32 cel at us dot ibm.com [this message]
2021-10-05 18:45 ` [Bug gdb/28424] " cel at us dot ibm.com
2024-02-09 17:46 ` cel at linux dot ibm.com
2024-02-09 17:49 ` 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-28424-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).