aboutsummaryrefslogtreecommitdiff
path: root/gdb/inferior.c
diff options
context:
space:
mode:
authorDon Breazeal <donb@codesourcery.com>2015-12-14 11:18:05 -0800
committerDon Breazeal <donb@codesourcery.com>2015-12-14 11:18:05 -0800
commit8020350c5277e056e89b0ea5e14a8d09408f7fb3 (patch)
tree35481f843941074911f702897fd7dff5aa72f479 /gdb/inferior.c
parenta8f077dc25b1732fb272a7ff10f72b5ca6f67b70 (diff)
Target remote mode fork and exec event support
This patch implements support for fork and exec events with target remote mode Linux targets. For such targets with Linux kernels 2.5.46 and later, this enables follow-fork-mode, detach-on-fork and fork and exec catchpoints. The changes required to implement this included: * Don't exit from gdbserver if there are still active inferiors. * Allow changing the active process in remote mode. * Enable fork and exec events in remote mode. * Print "Ending remote debugging" only when disconnecting. * Combine remote_kill and extended_remote_kill into a single function that can handle the multiple inferior case for target remote. Also, the same thing for remote_mourn and extended_remote_mourn. * Enable process-style ptids in target remote. * Remove restriction on multiprocess mode in target remote. gdb/gdbserver/ChangeLog: * server.c (process_serial_event): Don't exit from gdbserver in remote mode if there are still active inferiors. gdb/ChangeLog: * inferior.c (number_of_live_inferiors): New function. (have_live_inferiors): Use number_of_live_inferiors in place of duplicate code. * inferior.h (number_of_live_inferiors): Declare new function. * remote.c (set_general_process): Remove restriction on target remote mode. (remote_query_supported): Likewise. (remote_detach_1): Exit in target remote mode only when there is just one live inferior left. (remote_disconnect): Unpush the target directly instead of calling remote_mourn. (remote_kill): Rewrite function to handle both target remote and extended-remote. Call remote_kill_k. (remote_kill_k): New function. (extended_remote_kill): Delete function. (remote_mourn, extended_remote_mourn): Combine functions into one, remote_mourn, and enable extended functionality for target remote. (remote_pid_to_str): Enable "process" style ptid string for target remote. (remote_supports_multi_process): Remove restriction on target remote mode.
Diffstat (limited to 'gdb/inferior.c')
-rw-r--r--gdb/inferior.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 157e236f9e..a0296c8536 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -459,22 +459,41 @@ have_inferiors (void)
return 0;
}
+/* Return the number of live inferiors. We account for the case
+ where an inferior might have a non-zero pid but no threads, as
+ in the middle of a 'mourn' operation. */
+
int
-have_live_inferiors (void)
+number_of_live_inferiors (void)
{
struct inferior *inf;
+ int num_inf = 0;
for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid != 0)
{
struct thread_info *tp;
-
- tp = any_thread_of_process (inf->pid);
- if (tp && target_has_execution_1 (tp->ptid))
- break;
+
+ ALL_NON_EXITED_THREADS (tp)
+ if (tp && ptid_get_pid (tp->ptid) == inf->pid)
+ if (target_has_execution_1 (tp->ptid))
+ {
+ /* Found a live thread in this inferior, go to the next
+ inferior. */
+ ++num_inf;
+ break;
+ }
}
- return inf != NULL;
+ return num_inf;
+}
+
+/* Return true if there is at least one live inferior. */
+
+int
+have_live_inferiors (void)
+{
+ return number_of_live_inferiors () > 0;
}
/* Prune away any unused inferiors, and then prune away no longer used