This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 07/58] gdbserver: turn target op 'mourn' into a method
gdbserver/ChangeLog:
2020-02-10 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Make process_stratum_target's mourn op a method of
process_target.
* target.h (struct process_stratum_target): Remove the target op.
(class process_target): Add the target op.
Update the derived structs and callers below.
* target.c (target_mourn_inferior): Update.
* linux-low.c (linux_target_ops): Update.
(linux_mourn): Turn into ...
(linux_process_target::mourn): ... this.
(handle_extended_wait): Update.
(linux_process_target::kill): Update.
(linux_process_target::detach): Update.
* linux-low.h (class linux_process_target): Update.
* lynx-low.c (lynx_target_ops): Update.
(lynx_mourn): Turn into ...
(lynx_process_target::mourn): ... this.
* lynx-low.h (class lynx_process_target): Update.
* nto-low.c (nto_target_ops): Update.
(nto_mourn): Turn into ...
(nto_process_target::mourn): ... this.
* nto-low.h (class nto_process_target): Update.
* win32-low.c (win32_target_ops): Update.
(win32_mourn): Turn into ...
(win32_process_target::mourn): ... this.
* win32-low.h (class win32_process_target): Update.
---
gdbserver/linux-low.c | 12 +++++-------
gdbserver/linux-low.h | 2 ++
gdbserver/lynx-low.c | 9 ++++-----
gdbserver/lynx-low.h | 2 ++
gdbserver/nto-low.c | 5 ++---
gdbserver/nto-low.h | 2 ++
gdbserver/target.c | 2 +-
gdbserver/target.h | 7 +++----
gdbserver/win32-low.c | 5 ++---
gdbserver/win32-low.h | 2 ++
10 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/gdbserver/linux-low.c b/gdbserver/linux-low.c
index 5fe0cae0b8a..fb2f79c2204 100644
--- a/gdbserver/linux-low.c
+++ b/gdbserver/linux-low.c
@@ -270,7 +270,6 @@ static int linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
int *wstat, int options);
static int linux_wait_for_event (ptid_t ptid, int *wstat, int options);
static struct lwp_info *add_lwp (ptid_t ptid);
-static void linux_mourn (struct process_info *process);
static int linux_stopped_by_watchpoint (void);
static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
static int lwp_is_marked_dead (struct lwp_info *lwp);
@@ -707,7 +706,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
syscalls_to_catch = std::move (proc->syscalls_to_catch);
/* Delete the execing process and all its threads. */
- linux_mourn (proc);
+ the_target->pt->mourn (proc);
current_thread = NULL;
/* Create a new process/lwp/thread. */
@@ -1413,7 +1412,7 @@ linux_process_target::kill (process_info *process)
else
kill_wait_lwp (lwp);
- the_target->mourn (process);
+ mourn (process);
/* Since we presently can only stop all lwps of all processes, we
need to unstop lwps of other processes. */
@@ -1634,7 +1633,7 @@ linux_process_target::detach (process_info *process)
main_lwp = find_lwp_pid (ptid_t (process->pid));
linux_detach_one_lwp (main_lwp);
- the_target->mourn (process);
+ mourn (process);
/* Since we presently can only stop all lwps of all processes, we
need to unstop lwps of other processes. */
@@ -1644,8 +1643,8 @@ linux_process_target::detach (process_info *process)
/* Remove all LWPs that belong to process PROC from the lwp list. */
-static void
-linux_mourn (struct process_info *process)
+void
+linux_process_target::mourn (process_info *process)
{
struct process_info_private *priv;
@@ -7359,7 +7358,6 @@ linux_get_hwcap2 (int wordsize)
static linux_process_target the_linux_target;
static process_stratum_target linux_target_ops = {
- linux_mourn,
linux_join,
linux_thread_alive,
linux_resume,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index b2e8b7d591f..4b9d6ce65b6 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -279,6 +279,8 @@ public:
int kill (process_info *proc) override;
int detach (process_info *proc) override;
+
+ void mourn (process_info *proc) override;
};
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.c b/gdbserver/lynx-low.c
index e3887020df0..55721ac87b2 100644
--- a/gdbserver/lynx-low.c
+++ b/gdbserver/lynx-low.c
@@ -529,7 +529,7 @@ lynx_process_target::kill (process_info *process)
lynx_ptrace (PTRACE_KILL, ptid, 0, 0, 0);
lynx_wait (ptid, &status, 0);
- the_target->mourn (process);
+ mourn (process);
return 0;
}
@@ -541,14 +541,14 @@ lynx_process_target::detach (process_info *process)
ptid_t ptid = lynx_ptid_t (process->pid, 0);
lynx_ptrace (PTRACE_DETACH, ptid, 0, 0, 0);
- the_target->mourn (process);
+ mourn (process);
return 0;
}
/* Implement the mourn target_ops method. */
-static void
-lynx_mourn (struct process_info *proc)
+void
+lynx_process_target::mourn (struct process_info *proc)
{
for_each_thread (proc->pid, remove_thread);
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
/* The LynxOS target_ops vector. */
static process_stratum_target lynx_target_ops = {
- lynx_mourn,
lynx_join,
lynx_thread_alive,
lynx_resume,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 42c5eff4e62..b290922e4b4 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -65,6 +65,8 @@ public:
int kill (process_info *proc) override;
int detach (process_info *proc) override;
+
+ void mourn (process_info *proc) override;
};
/* The inferior's target description. This is a global because the
diff --git a/gdbserver/nto-low.c b/gdbserver/nto-low.c
index d5ad30ad5ad..09ae60219a6 100644
--- a/gdbserver/nto-low.c
+++ b/gdbserver/nto-low.c
@@ -417,8 +417,8 @@ nto_process_target::detach (process_info *proc)
return 0;
}
-static void
-nto_mourn (struct process_info *process)
+void
+nto_process_target::mourn (struct process_info *process)
{
remove_process (process);
}
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
static nto_process_target the_nto_target;
static process_stratum_target nto_target_ops = {
- nto_mourn,
NULL, /* nto_join */
nto_thread_alive,
nto_resume,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 87e6c824cf2..fd675811753 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -55,6 +55,8 @@ public:
int kill (process_info *proc) override;
int detach (process_info *proc) override;
+
+ void mourn (process_info *proc) override;
};
/* The inferior's target description. This is a global because the
diff --git a/gdbserver/target.c b/gdbserver/target.c
index a9632aa8cd9..f6d8d927b85 100644
--- a/gdbserver/target.c
+++ b/gdbserver/target.c
@@ -231,7 +231,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
void
target_mourn_inferior (ptid_t ptid)
{
- (*the_target->mourn) (find_process_pid (ptid.pid ()));
+ the_target->pt->mourn (find_process_pid (ptid.pid ()));
}
/* See target/target.h. */
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 7637bd2b7bc..4c0a98b3ed0 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
shared code. */
struct process_stratum_target
{
- /* The inferior process has died. Do what is right. */
-
- void (*mourn) (struct process_info *proc);
-
/* Wait for process PID to exit. */
void (*join) (int pid);
@@ -485,6 +481,9 @@ public:
/* Detach from process PROC. Return -1 on failure, and 0 on
success. */
virtual int detach (process_info *proc) = 0;
+
+ /* The inferior process has died. Do what is right. */
+ virtual void mourn (process_info *proc) = 0;
};
extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c
index a215afec0aa..c7ba29567d4 100644
--- a/gdbserver/win32-low.c
+++ b/gdbserver/win32-low.c
@@ -867,8 +867,8 @@ win32_process_target::detach (process_info *process)
return 0;
}
-static void
-win32_mourn (struct process_info *process)
+void
+win32_process_target::mourn (struct process_info *process)
{
remove_process (process);
}
@@ -1828,7 +1828,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
static win32_process_target the_win32_target;
static process_stratum_target win32_target_ops = {
- win32_mourn,
win32_join,
win32_thread_alive,
win32_resume,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 54a11c981c8..4ab92dbdae8 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -114,6 +114,8 @@ public:
int kill (process_info *proc) override;
int detach (process_info *proc) override;
+
+ void mourn (process_info *proc) override;
};
/* Retrieve the context for this thread, if not already retrieved. */
--
2.17.1