aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2016-09-11 23:45:31 -0400
committerSergio Durigan Junior <sergiodj@redhat.com>2016-09-19 00:17:29 -0400
commitbc1e6c81d5b77d78282c47f6fd7f697e564a6eb6 (patch)
tree5ea22142c6941b0310eafb381d9e14d2f32a4bcf
parent73cca75e7b187800d473ef2dc5115dd509901536 (diff)
downloadgdb-bc1e6c81d5b77d78282c47f6fd7f697e564a6eb6.zip
gdb-bc1e6c81d5b77d78282c47f6fd7f697e564a6eb6.tar.gz
gdb-bc1e6c81d5b77d78282c47f6fd7f697e564a6eb6.tar.bz2
Consolidate target_mourn_inferior between GDB and gdbserver
This patch consolidates the API of target_mourn_inferior between GDB and gdbserver, in my continuing efforts to make sharing the fork_inferior function possible between both. GDB's version of the function did not care about the inferior's ptid being mourned, but gdbserver's needed to know this information. Since it actually makes sense to pass the ptid as an argument, instead of depending on a global value directly (which GDB's version did), I decided to make the generic API to accept it. I then went on and extended all calls being made on GDB to include a ptid argument (which ended up being inferior_ptid most of the times, anyway), and now we have a more sane interface. On GDB's side, after talking to Pedro a bit about it, we decided that just an assertion to make sure that the ptid being passed is equal to inferior_ptid would be enough for now, on the GDB side. We can remove the assertion and perform more operations later if we ever pass anything different than inferior_ptid. Regression tested on our BuildBot, everything OK. I'd appreciate a special look at gdb/windows-nat.c's modification because I wasn't really sure what to do there. It seemed to me that maybe I should build a ptid out of the process information there, but then I am almost sure the assertion on GDB's side would trigger. gdb/ChangeLog: 2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com> * darwin-nat.c (darwin_kill_inferior): Adjusting call to target_mourn_inferior to include ptid_t argument. * fork-child.c (startup_inferior): Likewise. * gnu-nat.c (gnu_kill_inferior): Likewise. * inf-ptrace.c (inf_ptrace_kill): Likewise. * infrun.c (handle_inferior_event_1): Likewise. * linux-nat.c (linux_nat_attach): Likewise. (linux_nat_kill): Likewise. * nto-procfs.c (interrupt_query): Likewise. (procfs_interrupt): Likewise. (procfs_kill_inferior): Likewise. * procfs.c (procfs_kill_inferior): Likewise. * record.c (record_mourn_inferior): Likewise. * remote-sim.c (gdbsim_kill): Likewise. * remote.c (remote_detach_1): Likewise. (remote_kill): Likewise. * target.c (target_mourn_inferior): Change declaration to accept new ptid_t argument; use gdb_assert on it. * target.h (target_mourn_inferior): Move function prototype from here... * target/target.h (target_mourn_inferior): ... to here. Adjust it to accept new ptid_t argument. * windows-nat.c (get_windows_debug_event): Adjusting call to target_mourn_inferior to include ptid_t argument. gdb/gdbserver/ChangeLog: 2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com> * server.c (start_inferior): Call target_mourn_inferior instead of mourn_inferior; pass ptid_t argument to it. (resume): Likewise. (handle_target_event): Likewise. * target.c (target_mourn_inferior): New function. * target.h (mourn_inferior): Delete macro.
-rw-r--r--gdb/ChangeLog27
-rw-r--r--gdb/darwin-nat.c2
-rw-r--r--gdb/fork-child.c4
-rw-r--r--gdb/gdbserver/ChangeLog9
-rw-r--r--gdb/gdbserver/server.c6
-rw-r--r--gdb/gdbserver/target.c8
-rw-r--r--gdb/gdbserver/target.h3
-rw-r--r--gdb/gnu-nat.c2
-rw-r--r--gdb/inf-ptrace.c2
-rw-r--r--gdb/infrun.c2
-rw-r--r--gdb/linux-nat.c6
-rw-r--r--gdb/nto-procfs.c4
-rw-r--r--gdb/procfs.c2
-rw-r--r--gdb/record.c2
-rw-r--r--gdb/remote-sim.c2
-rw-r--r--gdb/remote.c6
-rw-r--r--gdb/target.c3
-rw-r--r--gdb/target.h4
-rw-r--r--gdb/target/target.h4
-rw-r--r--gdb/windows-nat.c2
20 files changed, 72 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 830d5de..8b1f0bc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,30 @@
+2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * darwin-nat.c (darwin_kill_inferior): Adjusting call to
+ target_mourn_inferior to include ptid_t argument.
+ * fork-child.c (startup_inferior): Likewise.
+ * gnu-nat.c (gnu_kill_inferior): Likewise.
+ * inf-ptrace.c (inf_ptrace_kill): Likewise.
+ * infrun.c (handle_inferior_event_1): Likewise.
+ * linux-nat.c (linux_nat_attach): Likewise.
+ (linux_nat_kill): Likewise.
+ * nto-procfs.c (interrupt_query): Likewise.
+ (procfs_interrupt): Likewise.
+ (procfs_kill_inferior): Likewise.
+ * procfs.c (procfs_kill_inferior): Likewise.
+ * record.c (record_mourn_inferior): Likewise.
+ * remote-sim.c (gdbsim_kill): Likewise.
+ * remote.c (remote_detach_1): Likewise.
+ (remote_kill): Likewise.
+ * target.c (target_mourn_inferior): Change declaration to accept
+ new ptid_t argument; use gdb_assert on it.
+ * target.h (target_mourn_inferior): Move function prototype from
+ here...
+ * target/target.h (target_mourn_inferior): ... to here. Adjust it
+ to accept new ptid_t argument.
+ * windows-nat.c (get_windows_debug_event): Adjusting call to
+ target_mourn_inferior to include ptid_t argument.
+
2016-09-18 Pedro Alves <palves@redhat.com>
* s390-linux-nat.c: Include <algorithm>.
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 590c2ad..3f54a76 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1381,7 +1381,7 @@ darwin_kill_inferior (struct target_ops *ops)
warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"),
inf->pid, safe_strerror (errno));
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
static void
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 3e29a1f..f367507 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -482,7 +482,7 @@ startup_inferior (int ntraps)
case TARGET_WAITKIND_SIGNALLED:
target_terminal_ours ();
- target_mourn_inferior ();
+ target_mourn_inferior (resume_ptid);
error (_("During startup program terminated with signal %s, %s."),
gdb_signal_to_name (ws.value.sig),
gdb_signal_to_string (ws.value.sig));
@@ -490,7 +490,7 @@ startup_inferior (int ntraps)
case TARGET_WAITKIND_EXITED:
target_terminal_ours ();
- target_mourn_inferior ();
+ target_mourn_inferior (resume_ptid);
if (ws.value.integer)
error (_("During startup program exited with code %d."),
ws.value.integer);
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 499ae3d..c97c777 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,12 @@
+2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * server.c (start_inferior): Call target_mourn_inferior instead of
+ mourn_inferior; pass ptid_t argument to it.
+ (resume): Likewise.
+ (handle_target_event): Likewise.
+ * target.c (target_mourn_inferior): New function.
+ * target.h (mourn_inferior): Delete macro.
+
2016-09-16 Andreas Arnez <arnez@linux.vnet.ibm.com>
* linux-low.c (lwp_is_stepping): New function.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 3ec585c..2996e19 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -297,7 +297,7 @@ start_inferior (char **argv)
current_thread->last_status = last_status;
}
else
- mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
+ target_mourn_inferior (last_ptid);
return signal_pid;
}
@@ -2779,7 +2779,7 @@ resume (struct thread_resume *actions, size_t num_actions)
if (last_status.kind == TARGET_WAITKIND_EXITED
|| last_status.kind == TARGET_WAITKIND_SIGNALLED)
- mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
+ target_mourn_inferior (last_ptid);
}
}
@@ -4392,7 +4392,7 @@ handle_target_event (int err, gdb_client_data client_data)
|| last_status.kind == TARGET_WAITKIND_SIGNALLED)
{
mark_breakpoints_out (process);
- mourn_inferior (process);
+ target_mourn_inferior (last_ptid);
}
else if (last_status.kind == TARGET_WAITKIND_THREAD_EXITED)
;
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 053629c..cf3da47 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -267,6 +267,14 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
/* See target/target.h. */
void
+target_mourn_inferior (ptid_t ptid)
+{
+ (*the_target->mourn) (find_process_pid (ptid_get_pid (ptid)));
+}
+
+/* See target/target.h. */
+
+void
target_continue_no_signal (ptid_t ptid)
{
struct thread_resume resume_info;
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index 4c14c20..26f7422 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -517,9 +517,6 @@ int kill_inferior (int);
#define detach_inferior(pid) \
(*the_target->detach) (pid)
-#define mourn_inferior(PROC) \
- (*the_target->mourn) (PROC)
-
#define mythread_alive(pid) \
(*the_target->thread_alive) (pid)
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index c268732..927ee5c 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2074,7 +2074,7 @@ gnu_kill_inferior (struct target_ops *ops)
task_terminate (task->port);
inf_set_pid (gnu_current_inf, -1);
}
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
/* Clean up after the inferior dies. */
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 0896cff..64aaabe 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -287,7 +287,7 @@ inf_ptrace_kill (struct target_ops *ops)
ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0);
waitpid (pid, &status, 0);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
/* Interrupt the inferior. */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index ec37ca1..2636a19 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5132,7 +5132,7 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
}
gdb_flush (gdb_stdout);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
stop_print_frame = 0;
stop_waiting (ecs);
return;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 8e9eb0b..cbf94ed 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1253,7 +1253,7 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
int exit_code = WEXITSTATUS (status);
target_terminal_ours ();
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
if (exit_code == 0)
error (_("Unable to attach: program exited normally."));
else
@@ -1265,7 +1265,7 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty)
enum gdb_signal signo;
target_terminal_ours ();
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
signo = gdb_signal_from_host (WTERMSIG (status));
error (_("Unable to attach: program terminated with signal "
@@ -3784,7 +3784,7 @@ linux_nat_kill (struct target_ops *ops)
iterate_over_lwps (ptid, kill_wait_callback, NULL);
}
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
static void
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 9d581f2..311a0b1 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -726,7 +726,7 @@ interrupt_query (void)
if (query (_("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? ")))
{
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
quit ();
}
}
@@ -1300,7 +1300,7 @@ procfs_interrupt (struct target_ops *self, ptid_t ptid)
static void
procfs_kill_inferior (struct target_ops *ops)
{
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
/* Fill buf with regset and return devctl cmd to do the setting. Return
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 0e0641e..fab15ed 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4273,7 +4273,7 @@ procfs_kill_inferior (struct target_ops *ops)
if (pi)
unconditionally_kill_inferior (pi);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
}
diff --git a/gdb/record.c b/gdb/record.c
index 1af134f..34ebd1b 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -170,7 +170,7 @@ record_mourn_inferior (struct target_ops *t)
threads are discarded. */
record_unpush (t);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
/* See record.h. */
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 11d36eb..6219000 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -554,7 +554,7 @@ gdbsim_kill (struct target_ops *ops)
/* There is no need to `kill' running simulator - the simulator is
not running. Mourning it is enough. */
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
}
/* Load an executable file into the target process. This is expected to
diff --git a/gdb/remote.c b/gdb/remote.c
index e80db79..ec8b498 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5159,7 +5159,7 @@ remote_detach_1 (const char *args, int from_tty)
/* If doing detach-on-fork, we don't mourn, because that will delete
breakpoints that should be available for the followed inferior. */
if (!is_fork_parent)
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
else
{
inferior_ptid = null_ptid;
@@ -8909,7 +8909,7 @@ remote_kill (struct target_ops *ops)
res = remote_vkill (pid, rs);
if (res == 0)
{
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
return;
}
}
@@ -8926,7 +8926,7 @@ remote_kill (struct target_ops *ops)
not in extended mode, mourning the inferior also unpushes
remote_ops from the target stack, which closes the remote
connection. */
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
return;
}
diff --git a/gdb/target.c b/gdb/target.c
index b93244d..b6a7e64 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2377,8 +2377,9 @@ default_mourn_inferior (struct target_ops *self)
}
void
-target_mourn_inferior (void)
+target_mourn_inferior (ptid_t ptid)
{
+ gdb_assert (ptid_equal (ptid, inferior_ptid));
current_target.to_mourn_inferior (&current_target);
/* We no longer need to keep handles on any of the object files.
diff --git a/gdb/target.h b/gdb/target.h
index 493a613..b458970 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1660,9 +1660,7 @@ void target_follow_exec (struct inferior *inf, char *execd_pathname);
be defined by those targets that require the debugger to perform
cleanup or internal state changes in response to the process event. */
-/* The inferior process has died. Do what is right. */
-
-void target_mourn_inferior (void);
+/* For target_mourn_inferior see target/target.h. */
/* Does target have enough data to do a run or attach command? */
diff --git a/gdb/target/target.h b/gdb/target/target.h
index 972bcb7..be41fa7 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -86,4 +86,8 @@ extern void target_continue (ptid_t ptid, enum gdb_signal signal);
extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
int options);
+/* The inferior process has died. Do what is right. */
+
+extern void target_mourn_inferior (ptid_t ptid);
+
#endif /* TARGET_COMMON_H */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 0470f31..31a9ecb 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1517,7 +1517,7 @@ get_windows_debug_event (struct target_ops *ops,
if (!windows_initialization_done)
{
target_terminal_ours ();
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
error (_("During startup program exited with code 0x%x."),
(unsigned int) current_event.u.ExitProcess.dwExitCode);
}