server: Removed the thread attached flag, since we always detach now.
diff --git a/server/ptrace.c b/server/ptrace.c
index 51101d3..817b0ec 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -90,7 +90,6 @@
}
if (thread && (WIFSIGNALED(status) || WIFEXITED(status)))
{
- thread->attached = 0;
thread->unix_pid = -1;
thread->unix_tid = -1;
if (debug_level)
@@ -155,7 +154,6 @@
{
thread->unix_pid = -1;
thread->unix_tid = -1;
- thread->attached = 0;
}
else perror( "wait4" );
stop_watchdog();
@@ -193,52 +191,11 @@
{
thread->unix_pid = -1;
thread->unix_tid = -1;
- thread->attached = 0;
}
}
return (ret != -1);
}
-/* attach to a Unix process with ptrace */
-int attach_process( struct process *process )
-{
- struct thread *thread;
- int ret = 1;
-
- if (list_empty( &process->thread_list )) /* need at least one running thread */
- {
- set_error( STATUS_ACCESS_DENIED );
- return 0;
- }
-
- LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
- {
- if (thread->attached) continue;
- if (suspend_for_ptrace( thread )) resume_after_ptrace( thread );
- else ret = 0;
- }
- return ret;
-}
-
-/* detach from a ptraced Unix process */
-void detach_process( struct process *process )
-{
- struct thread *thread;
-
- LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
- {
- if (thread->attached)
- {
- /* make sure it is stopped */
- suspend_for_ptrace( thread );
- if (thread->unix_pid == -1) return;
- if (debug_level) fprintf( stderr, "%04x: *detached*\n", thread->id );
- ptrace( PTRACE_DETACH, get_ptrace_pid(thread), (caddr_t)1, 0 );
- thread->attached = 0;
- }
- }
-}
-
/* suspend a thread to allow using ptrace on it */
/* you must do a resume_after_ptrace when finished with the thread */
int suspend_for_ptrace( struct thread *thread )
@@ -246,21 +203,11 @@
/* can't stop a thread while initialisation is in progress */
if (thread->unix_pid == -1 || !is_process_init_done(thread->process)) goto error;
- if (thread->attached)
+ /* this may fail if the client is already being debugged */
+ if (ptrace( PTRACE_ATTACH, get_ptrace_pid(thread), 0, 0 ) == -1)
{
- if (!send_thread_signal( thread, SIGSTOP )) goto error;
- }
- else
- {
- /* this may fail if the client is already being debugged */
- if (!use_ptrace) goto error;
- if (ptrace( PTRACE_ATTACH, get_ptrace_pid(thread), 0, 0 ) == -1)
- {
- if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */
- goto error;
- }
- if (debug_level) fprintf( stderr, "%04x: *attached*\n", thread->id );
- thread->attached = 1;
+ if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */
+ goto error;
}
if (wait4_thread( thread, SIGSTOP )) return 1;
resume_after_ptrace( thread );
@@ -273,13 +220,10 @@
void resume_after_ptrace( struct thread *thread )
{
if (thread->unix_pid == -1) return;
- assert( thread->attached );
if (ptrace( PTRACE_DETACH, get_ptrace_pid(thread), (caddr_t)1, 0 ) == -1)
{
if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */
}
- if (debug_level) fprintf( stderr, "%04x: *detached*\n", thread->id );
- thread->attached = 0;
}
/* read an int from a thread address space */