gdb/continuations: turn continuation functions into inferior methods

Turn continuations-related functions into methods of the inferior
class.  This is a refactoring.

gdb/ChangeLog:
2021-04-22  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* Makefile.in (COMMON_SFILES): Remove continuations.c.
	* inferior.c (inferior::add_continuation): New method, adapted
	from 'add_inferior_continuation'.
	(inferior::do_all_continuations): New method, adapted from
	'do_all_inferior_continuations'.
	(inferior::~inferior): Clear the list of continuations directly.
	* inferior.h (class inferior) <continuations>: Rename into...
	<m_continuations>: ...this and make private.
	* continuations.c: Remove.
	* continuations.h: Remove.
	* event-top.c: Don't include "continuations.h".

	Update the users below.
	* inf-loop.c (inferior_event_handler)
	* infcmd.c (attach_command)
	(notice_new_inferior): Update.
This commit is contained in:
Tankut Baris Aktemur
2021-04-22 17:22:39 +02:00
parent c4c493de2b
commit 4efeb0d3e8
9 changed files with 51 additions and 108 deletions

View File

@ -422,6 +422,14 @@ public:
inline safe_inf_threads_range threads_safe ()
{ return safe_inf_threads_range (this->thread_list); }
/* Continuations-related methods. A continuation is an std::function
to be called to finish the execution of a command when running
GDB asynchronously. A continuation is executed after any thread
of this inferior stops. Continuations are used by the attach
command and the remote target when a new inferior is detected. */
void add_continuation (std::function<void ()> &&cont);
void do_all_continuations ();
/* Set/get file name for default use for standard in/out in the
inferior. On Unix systems, we try to make TERMINAL_NAME the
inferior's controlling terminal. If TERMINAL_NAME is nullptr or
@ -508,10 +516,6 @@ public:
/* True if we're in the process of detaching from this inferior. */
bool detaching = false;
/* What is left to do for an execution command after any thread of
this inferior stops. */
std::list<std::function<void ()>> continuations;
/* True if setup_inferior wasn't called for this inferior yet.
Until that is done, we must not access inferior memory or
registers, as we haven't determined the target
@ -559,6 +563,9 @@ private:
/* The name of terminal device to use for I/O. */
gdb::unique_xmalloc_ptr<char> m_terminal;
/* The list of continuations. */
std::list<std::function<void ()>> m_continuations;
};
/* Keep a registry of per-inferior data-pointers required by other GDB