binutils-gdb/gdb/testsuite/gdb.mi
Pedro Alves 243a925328 Replace "struct continuation" mechanism by something more extensible
This adds an object oriented replacement for the "struct continuation"
mechanism, and converts the stepping commands (step, next, stepi,
nexti) and the "finish" commands to use it.

It adds a new thread "class" (struct thread_fsm) that contains the
necessary info and callbacks to manage the state machine of a thread's
execution command.

This allows getting rid of some hacks.  E.g., in fetch_inferior_event
and normal_stop we no longer need to know whether a thread is doing a
multi-step (e.g., step N).  This effectively makes the
intermediate_continuations unused -- they'll be garbage collected in a
separate patch.  (They were never a proper abstraction, IMO.  See how
fetch_inferior_event needs to check step_multi before knowing whether
to call INF_EXEC_CONTINUE or INF_EXEC_COMPLETE.)

The target async vs !async uiout hacks in mi_on_normal_stop go away
too.

print_stop_event is no longer called from normal_stop.  Instead it is
now called from within each interpreter's normal_stop observer.  This
clears the path to make each interpreter print a stop event the way it
sees fit.  Currently we have some hacks in common code to
differenciate CLI vs TUI vs MI around this area.

The "finish" command's FSM class stores the return value plus that
value's position in the value history, so that those can be printed to
both MI and CLI's streams.  This fixes the CLI "finish" command when
run from MI -- it now also includes the function's return value in the
CLI stream:

  (gdb)
  ~"callee3 (strarg=0x400730 \"A string argument.\") at src/gdb/testsuite/gdb.mi/basics.c:35\n"
  ~"35\t}\n"
 +~"Value returned is $1 = 0\n"
  *stopped,reason="function-finished",frame=...,gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0"
 -FAIL: gdb.mi/mi-cli.exp: CLI finish: check CLI output
 +PASS: gdb.mi/mi-cli.exp: CLI finish: check CLI output

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMMON_OBS): Add thread-fsm.o.
	* breakpoint.c (handle_jit_event): Print debug output.
	(bpstat_what): Split event callback handling to ...
	(bpstat_run_callbacks): ... this new function.
	(momentary_bkpt_print_it): No longer handle bp_finish here.
	* breakpoint.h (bpstat_run_callbacks): Declare.
	* gdbthread.h (struct thread_info) <step_multi>: Delete field.
	<thread_fsm>: New field.
	(thread_cancel_execution_command): Declare.
	* infcmd.c: Include thread-fsm.h.
	(struct step_command_fsm): New.
	(step_command_fsm_ops): New global.
	(new_step_command_fsm, step_command_fsm_prepare): New functions.
	(step_1): Adjust to use step_command_fsm_prepare and
	prepare_one_step.
	(struct step_1_continuation_args): Delete.
	(step_1_continuation): Delete.
	(step_command_fsm_should_stop): New function.
	(step_once): Delete.
	(step_command_fsm_clean_up, step_command_fsm_async_reply_reason)
	(prepare_one_step): New function, based on step_once.
	(until_next_command): Remove step_multi reference.
	(struct return_value_info): New.
	(print_return_value): Rename to ...
	(print_return_value_1): ... this.  New struct return_value_info
	parameter.  Adjust.
	(print_return_value): Reimplement as wrapper around
	print_return_value_1.
	(struct finish_command_fsm): New.
	(finish_command_continuation): Delete.
	(finish_command_fsm_ops): New global.
	(new_finish_command_fsm, finish_command_fsm_should_stop): New
	functions.
	(finish_command_fsm_clean_up, finish_command_fsm_return_value):
	New.
	(finish_command_continuation_free_arg): Delete.
	(finish_command_fsm_async_reply_reason): New.
	(finish_backward, finish_forward): Change symbol parameter to a
	finish_command_fsm.  Adjust.
	(finish_command): Create a finish_command_fsm.  Adjust.
	* infrun.c: Include "thread-fsm.h".
	(clear_proceed_status_thread): Delete the thread's FSM.
	(infrun_thread_stop_requested_callback): Cancel the thread's
	execution command.
	(clean_up_just_stopped_threads_fsms): New function.
	(fetch_inferior_event): Handle the event_thread's should_stop
	method saying the command isn't done yet.
	(process_event_stop_test): Run breakpoint callbacks here.
	(print_stop_event): Rename to ...
	(print_stop_location): ... this.
	(restore_current_uiout_cleanup): New function.
	(print_stop_event): Reimplement.
	(normal_stop): No longer notify the end_stepping_range observers
	here handle "step N" nor "finish" here.  No longer call
	print_stop_event here.
	* infrun.h (struct return_value_info): Forward declare.
	(print_return_value): Declare.
	(print_stop_event): Change prototype.
	* thread-fsm.c: New file.
	* thread-fsm.h: New file.
	* thread.c: Include "thread-fsm.h".
	(thread_cancel_execution_command): New function.
	(clear_thread_inferior_resources): Call it.
	* cli/cli-interp.c (cli_on_normal_stop): New function.
	(cli_interpreter_init): Install cli_on_normal_stop as normal_stop
	observer.
	* mi/mi-interp.c: Include "thread-fsm.h".
	(restore_current_uiout_cleanup): Delete.
	(mi_on_normal_stop): If the thread has an FSM associated, and it
	finished, ask it for the async-reply-reason to print.  Always call
	print_stop_event here, regardless of the top-level interpreter.
	Check bpstat_what to tell whether an asynchronous breakpoint hit
	triggered.
	* tui/tui-interp.c (tui_on_normal_stop): New function.
	(tui_init): Install tui_on_normal_stop as normal_stop observer.

gdb/testsuite/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-cli.exp: Add CLI finish tests.
2015-09-09 18:24:00 +01:00
..
ChangeLog-1999-2003
Makefile.in Fix breakpoint thread condition missing with mi and a pending breakpoint. 2015-03-24 08:38:49 -04:00
array.f Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
basics.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dw2-ref-missing-frame-func.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dw2-ref-missing-frame-main.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dw2-ref-missing-frame.S Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dw2-ref-missing-frame.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gdb669.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gdb680.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gdb701.c
gdb701.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gdb792.cc
gdb792.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gdb2549.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-async.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-basics.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-break.exp Explicit locations: MI support for explicit locations 2015-08-11 17:09:36 -07:00
mi-breakpoint-changed.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-catch-load-so.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-catch-load.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-catch-load.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-cli.exp Replace "struct continuation" mechanism by something more extensible 2015-09-09 18:24:00 +01:00
mi-cmd-param-changed.exp Rename dwarf2 to dwarf in "set debug" and maintenance commands. 2015-05-26 16:50:57 -07:00
mi-condbreak-call-thr-state-mt.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-condbreak-call-thr-state-st.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-condbreak-call-thr-state.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-condbreak-call-thr-state.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-console.c GDB testsuite: Fix warnings with -std=gnu11 2014-11-13 10:20:44 +01:00
mi-console.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-detach.exp Fix =thread-exited not showing up when detaching (PR 15564) 2015-06-02 15:32:57 -04:00
mi-disassemble.exp New /s modifier for the disassemble command. 2015-08-14 21:45:54 -07:00
mi-dprintf-pending.c Fix MI dprintf-insert not printing on a resolved pending location. 2015-06-12 08:43:17 -04:00
mi-dprintf-pending.exp Fix MI dprintf-insert not printing on a resolved pending location. 2015-06-12 08:43:17 -04:00
mi-dprintf-pendshr.c Fix MI dprintf-insert not printing on a resolved pending location. 2015-06-12 08:43:17 -04:00
mi-dprintf.c Unbuffer all tests that rely on stdio 2015-07-29 11:09:45 +01:00
mi-dprintf.exp Explicit locations: MI support for explicit locations 2015-08-11 17:09:36 -07:00
mi-eval.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-exit-code.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-exit-code.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-file-transfer.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-file.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-fill-memory.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-fullname-deleted.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-hack-cli.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-i-cmd.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-info-os.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-inheritance-syntax-error.cc
mi-inheritance-syntax-error.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-language.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-logging.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-memory-changed.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-nonstop-exit.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-nonstop.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-ns-stale-regcache.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-nsintrall.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-nsmoribund.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-nsthrexec.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-pending.c gdb.mi/mi-pending.c: Return NULL instead of nothing in thread function 2015-07-27 15:49:24 -04:00
mi-pending.exp Fix mi-pending.exp test output to allow stable test diffing 2015-03-24 13:38:19 -04:00
mi-pendshr.c Fix breakpoint thread condition missing with mi and a pending breakpoint. 2015-03-24 08:38:49 -04:00
mi-pendshr2.c Fix breakpoint thread condition missing with mi and a pending breakpoint. 2015-03-24 08:38:49 -04:00
mi-pthreads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-read-memory.c
mi-read-memory.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-record-changed.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-reg-undefined.S Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-reg-undefined.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-reg-undefined.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-regs.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-return.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-reverse.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-simplerun.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-solib.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-stack.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-stack.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-start.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-start.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-stepi.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-stepn.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-stepn.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-syn-frame.c GDB testsuite: Fix warnings with -std=gnu11 2014-11-13 10:20:44 +01:00
mi-syn-frame.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-undefined-cmd.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-until.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-block.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-child-f.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-child.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-child.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-cmd.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-cp.cc Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-cp.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-create-rtti.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-create-rtti.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-display.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-invalidate.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-list-children-invalid-grandchild.c Catch exception in value_rtti_indirect_type 2015-01-23 12:59:24 -05:00
mi-var-list-children-invalid-grandchild.exp Catch exception in value_rtti_indirect_type 2015-01-23 12:59:24 -05:00
mi-var-rtti.cc Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-var-rtti.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-vla-c99.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-watch-nonstop.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi-watch.exp Remove xfail in gdb.mi/mi-watch.exp 2015-07-27 15:02:37 -04:00
mi2-amd64-entry-value.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi2-amd64-entry-value.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi2-amd64-entry-value.s Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi2-prompt.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
mi2-var-child.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-stop-exit.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-stop.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
ns-stale-regcache.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
nsintrall.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
nsmoribund.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
nsthrexec.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
pending.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pendshr1.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pendshr2.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pr11022.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pr11022.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pthreads.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
solib-lib.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
solib-main.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
testcmds
until.c Eliminate literal line numbers in mi-until.exp 2014-11-17 10:26:30 +01:00
var-cmd.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
vla.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watch-nonstop.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00