RE: Reverse-next bug test case

Carl Love via Gdb-patches
2023-02-01T18:41:32Z

Pedro:

On Wed, 2023-02-01 at 14:37 +0000, Pedro Alves wrote:
> On 2023-01-31 12:17 a.m., Carl Love wrote:
> > +# The second reverse step should take us call of func2 ().
> > +gdb_test "reverse-step" ".*func1 \\(\\); func2 \\(\\);.*" \
> > + "reverse-step to line func1(); func2(), at call for func2 "
> > +
>
> From <
> https://sourceware.org/gdb/current/onlinedocs/gdb.html/Reverse-Execution.html
> > :
>
> "Like the step command, reverse-step will only stop at the beginning
> of a source line. "
>
> So when reverse-stepping is ongoing and execution internally stops at
> the call to func2, gdb
> should realize it is not really at the beginning of a source line,
> and continue stepping.
> That should take it inside func1, and stop there (at the beginning of
> a line), as it will have
> reached a different line.
>
> I would start by looking at making either of these pass:
>
> $ make check TESTS="*/pedro_test.exp"
> RUNTESTFLAGS="CC_FOR_TARGET='gcc -gno-column-info'"

OK, when I try the test with no column info, the test on PowerPC fails.
The initial Test 2 expected the second reverse-step to stop at func1();
func2() after stepping into func2 (). When the Test 2 is updated to
remove the second reverse-step:

...
gdb_continue_to_breakpoint \
"stopped at command reverse-step test start location" \
".*$srcfile:$bp_start_reverse_test\r\n.*"

# The first reverse step should take us call of func2 ().
gdb_test "reverse-step" ".*}.*" \
"reverse-step into func2 "

# The second reverse step should take us call of func2 ().
## ERROR, should not stop here as that is in the middle of the source line
#gdb_test "reverse-step" ".*func1 \\(\\); func2 \\(\\);.*" \
# "reverse-step to line func1(); func2(), at call for func2 "

# The third reverse step should take us into func1 ().
gdb_test "reverse-step" ".*}.*" \
"reverse-step into func1 "

# The fourth reverse step should take us call of func1 ().
gdb_test "reverse-step" ".*func1 \\(\\); func2 \\(\\);.*" \
"reverse-step to line func1(); func2(), at call for func1 "

# The fifth reverse step should take us to b = 2 ().
gdb_test "reverse-step" ".*b = 2;.*" \
"reverse-step to line b = 2 "

Then the test passes when running with no column info.

OK, that helps. Thanks.

Carl

>
> $ make check TESTS="*/pedro_test.exp"
> RUNTESTFLAGS="CC_FOR_TARGET=clang"
>
> ... as the misbehavior happens due to GDB misinterpreting multiple
> lines entries for the
> same line when column info is emitted by current gcc. If you disable
> the column info, then gdb
> should not stop in the middle of a line, and that's how gdb should
> always behave. (Making use
> of column info is certainly interesting to support statement
> stepping, but that's orthogonal.)