Bug 29260 - Stopped event should contain reason for 'No more reverse-execution history'
Summary: Stopped event should contain reason for 'No more reverse-execution history'
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: record (show other bugs)
Version: unknown
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-17 17:35 UTC by trass3r
Modified: 2023-01-18 13:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2022-06-18 00:00:00
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description trass3r 2022-06-17 17:35:56 UTC
When stepping past the reverse execution history buffer bounds
gdb prints 'No more reverse-execution history' to the output but does not give a reason in the MI stopped event, leading to a bad UX.

https://github.com/microsoft/MIEngine/pull/1037#issuecomment-750299377
1: (62155) <-1057-exec-next --reverse
1: (62156) ->1057^running
1: (62156) ->*running,thread-id="1"
1: (62156) ->(gdb)
1: (62163) ->~"\nNo more reverse-execution history.\n"
1: (62164) ->~"main (argc=1, argv=0x7fffffffdb78) at ../test.cpp:25\n"
1: (62164) ->~"25\t\tstd::u16string s = u\"test\";\n"
1: (62164) ->*stopped,frame={addr="0x000055555555734b",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdb78"}],file="../test.cpp",fullname="/tmp/test.cpp",line="25",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="2"

Test case:
https://github.com/microsoft/MIEngine/pull/1037#issuecomment-1158743492
int main()
{
	int i = 0;
	++i;
	++i;
	return i;
}

$ gdb --batch -ex 'b main' -ex r -ex n -ex 'p i' -ex 'record full' -ex n -ex 'p i' -ex n -ex 'p i' -ex n -ex 'p i' -ex 'reverse-next' -ex 'p i' -ex 'reverse-next' -ex 'p i' -ex 'reverse-next' -ex 'p i' test
Comment 1 trass3r 2022-06-17 20:58:57 UTC
Code of interest:

handle_inferior_event(infrun.c:5858):

    case TARGET_WAITKIND_NO_HISTORY:
      /* Reverse execution: target ran out of history info.  */

      /* Switch to the stopped thread.  */
      context_switch (ecs);
      infrun_debug_printf ("stopped");

      delete_just_stopped_threads_single_step_breakpoints ();
      ecs->event_thread->set_stop_pc
	(regcache_read_pc (get_thread_regcache (inferior_thread ())));

      if (handle_stop_requested (ecs))
	return;

      gdb::observers::no_history.notify (); // just prints the line in print_no_history_reason
      stop_waiting (ecs);
Comment 2 Tom Tromey 2022-06-18 16:20:27 UTC
FWIW I think there may be other cases where a stop reason is missing.
Comment 3 trass3r 2022-06-18 17:08:57 UTC
I also saw https://sourceware.org/bugzilla/show_bug.cgi?id=15072 about reverse finish with breakpoints. But that's about the whole stopped event missing.
Comment 4 Guinevere Larsen 2023-01-18 13:49:35 UTC
Commit 37f54063ed0daaffbd52f69efbdb4c8e0a9c9cca gdb/mi: add no-history stop reason  fixed this bug (but I forgot to reference this bug, oops). It is fixed on master now.