aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/inferiors.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-10-23 20:05:03 +0000
committerDaniel Jacobowitz <drow@false.org>2007-10-23 20:05:03 +0000
commit24a09b5f373c09e5cb56523e6fcb76e81bcd4784 (patch)
tree4fa03e2bad677d365b5a0641e2c8eb6b5e63e8ac /gdb/gdbserver/inferiors.c
parent3d5f6d122ed686b9a568cafddc3d298c10180248 (diff)
downloadgdb-24a09b5f373c09e5cb56523e6fcb76e81bcd4784.zip
gdb-24a09b5f373c09e5cb56523e6fcb76e81bcd4784.tar.gz
gdb-24a09b5f373c09e5cb56523e6fcb76e81bcd4784.tar.bz2
* inferiors.c (change_inferior_id): Delete.
(add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
Diffstat (limited to 'gdb/gdbserver/inferiors.c')
-rw-r--r--gdb/gdbserver/inferiors.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 3b23767..f631e39 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -65,21 +65,6 @@ for_each_inferior (struct inferior_list *list,
}
}
-/* When debugging a single-threaded program, the threads list (such as
- it is) is indexed by PID. When debugging a multi-threaded program,
- we index by TID. This ugly routine replaces the
- first-debugged-thread's PID with its TID. */
-
-void
-change_inferior_id (struct inferior_list *list,
- unsigned long new_id)
-{
- if (list->head != list->tail)
- error ("tried to change thread ID after multiple threads are created");
-
- list->head->id = new_id;
-}
-
void
remove_inferior (struct inferior_list *list,
struct inferior_list_entry *entry)
@@ -318,3 +303,32 @@ clear_inferiors (void)
clear_list (&all_threads);
clear_list (&all_dlls);
}
+
+/* Two utility functions for a truly degenerate inferior_list: a simple
+ PID listing. */
+
+void
+add_pid_to_list (struct inferior_list *list, unsigned long pid)
+{
+ struct inferior_list_entry *new_entry;
+
+ new_entry = malloc (sizeof (struct inferior_list_entry));
+ new_entry->id = pid;
+ add_inferior_to_list (list, new_entry);
+}
+
+int
+pull_pid_from_list (struct inferior_list *list, unsigned long pid)
+{
+ struct inferior_list_entry *new_entry;
+
+ new_entry = find_inferior_id (list, pid);
+ if (new_entry == NULL)
+ return 0;
+ else
+ {
+ remove_inferior (list, new_entry);
+ free (new_entry);
+ return 1;
+ }
+}