gdbserver/linux-low: turn process/thread addition/deletion ops into methods

gdbserver/ChangeLog:
2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn the 'new_process', 'delete_process', 'new_thread',
	'delete_thread', and 'new_fork' linux target ops into methods
	of linux_process_target.

	* linux-low.h (struct linux_target_ops): Remove the ops.
	(class linux_process_target) <add_linux_process>
	<add_lwp>
	<delete_lwp>
	<attach_lwp>
	<detach_one_lwp>
	<check_zombie_leaders>
	<filter_exit_event>
	<low_new_process>
	<low_delete_process>
	<low_new_thread>
	<low_delete_thread>
	<low_new_fork>: Declare.
	* linux-low.cc (delete_lwp): Turn into...
	(linux_process_target::delete_lwp): ...this.
	(linux_process_target::low_delete_thread): Define.
	(linux_add_process): Turn into...
	(linux_process_target::add_linux_process): ...this.
	(linux_process_target::low_new_process): Define.
	(linux_process_target::low_delete_process): Define.
	(linux_process_target::low_new_fork): Define.
	(add_lwp): Turn into...
	(linux_process_target::add_lwp): ...this.
	(linux_process_target::low_new_thread): Define.
	(linux_attach_lwp): Turn into...
	(linux_process_target::attach_lwp): ...this.
	(linux_detach_one_lwp): Turn into...
	(linux_process_target::detach_one_lwp): ...this.
	(linux_detach_lwp_callback): Remove and inline...
	(linux_process_target::detach): ...here.
	(check_zombie_leaders): Turn into...
	(linux_process_target::check_zombie_leaders): ...this.
	(filter_exit_event): Turn into...
	(linux_process_target::filter_exit_event): ...this.

	Update the callers below.

	(linux_process_target::handle_extended_wait)
	(linux_process_target::create_inferior)
	(attach_proc_task_lwp_callback)
	(linux_process_target::attach)
	(linux_process_target::detach)
	(linux_process_target::mourn)
	* thread-db.cc (attach_thread)

	* linux-x86-low.cc (class x86_target) <low_new_process>
	<low_delete_process>
	<low_new_thread>
	<low_delete_thread>
	<low_new_fork>: Declare.
	(x86_linux_new_process): Turn into...
	(x86_target::low_new_process): ...this.
	(x86_linux_delete_process): Turn into...
	(x86_target::low_delete_process): ...this.
	(x86_target::low_new_thread): Define.
	(x86_target::low_delete_thread): Define.
	(x86_linux_new_fork): Turn into...
	(x86_target::low_new_fork): ...this.
	(the_low_target): Remove the op fields.
	* linux-aarch64-low.cc (class aarch64_target) <low_new_process>
	<low_delete_process>
	<low_new_thread>
	<low_delete_thread>
	<low_new_fork>: Declare.
	(aarch64_linux_new_process): Turn into...
	(aarch64_target::low_new_process): ...this.
	(aarch64_linux_delete_process): Turn into...
	(aarch64_target::low_delete_process): ...this.
	(aarch64_target::low_new_thread): Define.
	(aarch64_target::low_delete_thread): Define.
	(aarch64_linux_new_fork): Turn into...
	(aarch64_target::low_new_fork): ...this.
	(the_low_target): Remove the op fields.
	* linux-arm-low.cc (class arm_target) <low_new_process>
	<low_delete_process>
	<low_new_thread>
	<low_delete_thread>
	<low_new_fork>: Declare.
	(arm_new_process): Turn into...
	(arm_target::low_new_process): ...this.
	(arm_delete_process): Turn into...
	(arm_target::low_delete_process): ...this.
	(arm_new_thread): Turn into...
	(arm_target::low_new_thread): ...this.
	(arm_delete_thread): Turn into...
	(arm_target::low_delete_thread): ...this.
	(arm_new_fork): Turn into...
	(arm_target::low_new_fork): ...this.
	(the_low_target): Remove the op fields.
	* linux-mips-low.cc (class mips_target) <low_new_process>
	<low_delete_process>
	<low_new_thread>
	<low_delete_thread>
	<low_new_fork>: Declare.
	(mips_linux_new_process): Turn into...
	(mips_target::low_new_process): ...this.
	(mips_linux_delete_process): Turn into...
	(mips_target::low_delete_process): ...this.
	(mips_linux_new_thread): Turn into...
	(mips_target::low_new_thread): ...this.
	(mips_linux_delete_thread): Turn into...
	(mips_target::low_delete_thread): ...this.
	(mips_linux_new_fork): Turn into...
	(mips_target::low_new_fork): ...this.
	(the_low_target): Remove the op fields.
	* linux-bfin-low.cc (the_low_target): Remove the op fields.
	* linux-crisv32-low.cc (the_low_target): Ditto.
	* linux-m32r-low.cc (the_low_target): Ditto.
	* linux-m68k-low.cc (the_low_target): Ditto.
	* linux-ppc-low.cc (the_low_target): Ditto.
	* linux-s390-low.cc (the_low_target): Ditto.
	* linux-sh-low.cc (the_low_target): Ditto.
	* linux-tic6x-low.cc (the_low_target): Ditto.
	* linux-tile-low.cc (the_low_target): Ditto.
	* linux-xtensa-low.cc (the_low_target): Ditto.
This commit is contained in:
Tankut Baris Aktemur
2020-04-02 15:11:28 +02:00
parent cb63de7ca8
commit fd000fb3df
18 changed files with 356 additions and 205 deletions

View File

@@ -131,27 +131,6 @@ struct lwp_info;
struct linux_target_ops
{
/* Hook to call when a new process is created or attached to.
If extra per-process architecture-specific data is needed,
allocate it here. */
struct arch_process_info * (*new_process) (void);
/* Hook to call when a process is being deleted. If extra per-process
architecture-specific data is needed, delete it here. */
void (*delete_process) (struct arch_process_info *info);
/* Hook to call when a new thread is detected.
If extra per-thread architecture-specific data is needed,
allocate it here. */
void (*new_thread) (struct lwp_info *);
/* Hook to call when a thread is being deleted. If extra per-thread
architecture-specific data is needed, delete it here. */
void (*delete_thread) (struct arch_lwp_info *);
/* Hook to call, if any, when a new fork is attached. */
void (*new_fork) (struct process_info *parent, struct process_info *child);
/* Hook to call prior to resuming a thread. */
void (*prepare_to_resume) (struct lwp_info *);
@@ -627,6 +606,37 @@ private:
void siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo,
int direction);
/* Add a process to the common process list, and set its private
data. */
process_info *add_linux_process (int pid, int attached);
/* Add a new thread. */
lwp_info *add_lwp (ptid_t ptid);
/* Delete a thread. */
void delete_lwp (lwp_info *lwp);
public: /* Make this public because it's used from outside. */
/* Attach to an inferior process. Returns 0 on success, ERRNO on
error. */
int attach_lwp (ptid_t ptid);
private: /* Back to private. */
/* Detach from LWP. */
void detach_one_lwp (lwp_info *lwp);
/* Detect zombie thread group leaders, and "exit" them. We can't
reap their exits until all other threads in the group have
exited. */
void check_zombie_leaders ();
/* Convenience function that is called when the kernel reports an exit
event. This decides whether to report the event to GDB as a
process exit event, a thread exit event, or to suppress the
event. */
ptid_t filter_exit_event (lwp_info *event_child,
target_waitstatus *ourstatus);
protected:
/* The architecture-specific "low" methods are listed below. */
@@ -689,6 +699,27 @@ protected:
virtual bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
int direction);
/* Hook to call when a new process is created or attached to.
If extra per-process architecture-specific data is needed,
allocate it here. */
virtual arch_process_info *low_new_process ();
/* Hook to call when a process is being deleted. If extra per-process
architecture-specific data is needed, delete it here. */
virtual void low_delete_process (arch_process_info *info);
/* Hook to call when a new thread is detected.
If extra per-thread architecture-specific data is needed,
allocate it here. */
virtual void low_new_thread (lwp_info *);
/* Hook to call when a thread is being deleted. If extra per-thread
architecture-specific data is needed, delete it here. */
virtual void low_delete_thread (arch_lwp_info *);
/* Hook to call, if any, when a new fork is attached. */
virtual void low_new_fork (process_info *parent, process_info *child);
/* How many bytes the PC should be decremented after a break. */
virtual int low_decr_pc_after_break ();
};