Summary: | FAIL: gdb.reverse/step-reverse.exp: reverse step into fn call | ||
---|---|---|---|
Product: | gdb | Reporter: | Tom de Vries <vries> |
Component: | gdb | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unknown | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
log file including debug infrun output (gcc 9.4.0 case)
log file including debug infrun output (gcc 12.2.1 case) Tentative patch |
Description
Tom de Vries
2023-01-04 10:09:17 UTC
Hmm, I'm starting to wonder if I mis-analyzed this. Looking at: ... stepi^M 78 a[5] = a[3] - a[4]; /* FINISH TEST */^M (gdb) PASS: gdb.reverse/step-reverse.exp: simple reverse stepi step^M 78 a[5] = a[3] - a[4]; /* FINISH TEST */^M (gdb) FAIL: gdb.reverse/step-reverse.exp: reverse step into fn call ... we see a step from line 78 to line ... 78. That looks like the problem. The decision to stop stepping happens here in this code in process_event_stop_test: ... /* When stepping backward, stop at beginning of line range (unless it's the function entry point, in which case keep going back to the call point). */ CORE_ADDR stop_pc = ecs->event_thread->stop_pc (); if (stop_pc == ecs->event_thread->control.step_range_start && stop_pc != ecs->stop_func_start && execution_direction == EXEC_REVERSE) end_stepping_range (ecs); else keep_going (ecs); return; } /* We stepped out of the stepping range. */ ... AFAICT, there just isn't enough information at this point to decide to stop stepping. This code is part of an early-out that tries to do: ... /* If stepping through a line, keep going if still within it. ... As mentioned before, this failure shows up with gcc 9.4.0. It doesn't show up with gcc 12.2.1, because of a difference in generated code. In the 12.2.1 case we have 4 insns: ... 401208: 8b 55 cc mov -0x34(%rbp),%edx 40120b: 8b 45 d0 mov -0x30(%rbp),%eax 40120e: 29 c2 sub %eax,%edx 401210: 89 55 d4 mov %edx,-0x2c(%rbp) ... each with their line number entry: ... step-reverse.c 78 0x401208 x step-reverse.c 78 0x40120b x step-reverse.c 78 0x40120e x step-reverse.c 78 0x401210 x ... (In reply to Tom de Vries from comment #3) > As mentioned before, this failure shows up with gcc 9.4.0. > > It doesn't show up with gcc 12.2.1, because of a difference in generated > code. > > In the 12.2.1 case we have 4 insns: > ... > 401208: 8b 55 cc mov -0x34(%rbp),%edx > 40120b: 8b 45 d0 mov -0x30(%rbp),%eax > 40120e: 29 c2 sub %eax,%edx > 401210: 89 55 d4 mov %edx,-0x2c(%rbp) > ... > each with their line number entry: > ... > step-reverse.c 78 0x401208 x > step-reverse.c 78 0x40120b x > step-reverse.c 78 0x40120e x > step-reverse.c 78 0x401210 x > ... In the gcc 9.4.0 case, we have 5 insns: ... 401228: 8b 55 cc mov -0x34(%rbp),%edx 40122b: 8b 45 d0 mov -0x30(%rbp),%eax 40122e: 29 c2 sub %eax,%edx 401230: 89 d0 mov %edx,%eax 401232: 89 45 d4 mov %eax,-0x2c(%rbp) ... but still 4 line number entries: ... step-reverse.c 78 0x401228 x step-reverse.c 78 0x40122b x step-reverse.c 78 0x40122e x step-reverse.c 78 0x401232 x ... Note that the insn at 0x401230 doesn't have it's own line number entry. So, we are at line 79: ... (gdb) stepi^M 79 callee(); /* STEPI TEST */^M ... and do a stepi, which lands us, as expected at insn 0x401232: ... stepi^M 78 a[5] = a[3] - a[4]; /* FINISH TEST */^M (gdb) PASS: gdb.reverse/step-reverse.exp: simple reverse stepi print /x $pc^M $2 = 0x401232^M (gdb) PASS: gdb.reverse/step-reverse.exp: print /x $pc ... Then we do a step, which lands us, unexpectedly, at insn 0x40122e: ... step^M 78 a[5] = a[3] - a[4]; /* FINISH TEST */^M (gdb) FAIL: gdb.reverse/step-reverse.exp: reverse step into fn call print /x $pc^M $3 = 0x40122e^M (gdb) PASS: gdb.reverse/step-reverse.exp: print /x $pc ... It's stepping over the 0x401230 insn without line number entry that triggers the problem. Created attachment 14575 [details]
log file including debug infrun output (gcc 9.4.0 case)
$ gdb -q -batch outputs/gdb.reverse/step-reverse/step-reverse -ex "set trace-commands on" -ex start -ex record -ex "break 79" -ex continue -ex reverse-stepi -ex "set debug infrun 1" -ex reverse-step 2>&1 | tee log.txt
Created attachment 14576 [details]
log file including debug infrun output (gcc 12.2.1 case)
This passes gdb.reverse/*.exp: ... diff --git a/gdb/infrun.c b/gdb/infrun.c index 181d961d80d..ba0b10de965 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -6900,11 +6900,12 @@ process_event_stop_test (struct execution_control_state *ecs) if (stop_pc == ecs->event_thread->control.step_range_start && stop_pc != ecs->stop_func_start && execution_direction == EXEC_REVERSE) - end_stepping_range (ecs); + ; else - keep_going (ecs); - - return; + { + keep_going (ecs); + return; + } } /* We stepped out of the stepping range. */ @@ -7401,6 +7402,8 @@ process_event_stop_test (struct execution_control_state *ecs) "it's not the start of a statement"); } } + else if (execution_direction == EXEC_REVERSE) + refresh_step_info = false; /* We aren't done stepping. ... Created attachment 14588 [details]
Tentative patch
|