Small fixes to the debugger support.

This commit is contained in:
Alexandre Julliard 2001-07-11 17:30:59 +00:00
parent e630aa0b68
commit 7614180e2d
4 changed files with 21 additions and 7 deletions

View File

@ -150,11 +150,10 @@ static void set_thread_context( struct thread *thread, unsigned int flags, CONTE
if (flags & CONTEXT_FULL) if (flags & CONTEXT_FULL)
{ {
struct kernel_user_regs_struct regs; struct kernel_user_regs_struct regs;
if (((flags | CONTEXT_i386) & CONTEXT_FULL) != CONTEXT_FULL)
{ /* need to preserve some registers (at a minimum orig_eax must always be preserved) */
/* need to preserve some registers */ if (ptrace( PTRACE_GETREGS, pid, 0, &regs ) == -1) goto error;
if (ptrace( PTRACE_GETREGS, pid, 0, &regs ) == -1) goto error;
}
if (flags & CONTEXT_INTEGER) if (flags & CONTEXT_INTEGER)
{ {
regs.eax = context->Eax; regs.eax = context->Eax;

View File

@ -411,13 +411,12 @@ static int debugger_attach( struct process *process, struct thread *debugger )
for (thread = debugger; thread; thread = thread->process->debugger) for (thread = debugger; thread; thread = thread->process->debugger)
if (thread->process == process) goto error; if (thread->process == process) goto error;
suspend_process( process ); suspend_process_for_ptrace( process );
/* we must have been able to attach all threads */ /* we must have been able to attach all threads */
for (thread = process->thread_list; thread; thread = thread->proc_next) for (thread = process->thread_list; thread; thread = thread->proc_next)
if (!thread->attached) if (!thread->attached)
{ {
fprintf( stderr, "%p not attached\n", thread );
resume_process( process ); resume_process( process );
goto error; goto error;
} }

View File

@ -491,6 +491,21 @@ void suspend_process( struct process *process )
} }
} }
/* suspend all the threads of a process to allow using ptrace on it*/
void suspend_process_for_ptrace( struct process *process )
{
if (!process->suspend++)
{
struct thread *thread = process->thread_list;
for (; thread; thread = thread->proc_next)
{
if (thread->suspend) continue;
if (suspend_for_ptrace( thread ))
thread->suspend--; /* since the process is suspended, not the thread */
}
}
}
/* resume all the threads of a process */ /* resume all the threads of a process */
void resume_process( struct process *process ) void resume_process( struct process *process )
{ {

View File

@ -81,6 +81,7 @@ extern void add_process_thread( struct process *process,
extern void remove_process_thread( struct process *process, extern void remove_process_thread( struct process *process,
struct thread *thread ); struct thread *thread );
extern void suspend_process( struct process *process ); extern void suspend_process( struct process *process );
extern void suspend_process_for_ptrace( struct process *process );
extern void resume_process( struct process *process ); extern void resume_process( struct process *process );
extern void kill_process( struct process *process, struct thread *skip, int exit_code ); extern void kill_process( struct process *process, struct thread *skip, int exit_code );
extern void kill_debugged_processes( struct thread *debugger, int exit_code ); extern void kill_debugged_processes( struct thread *debugger, int exit_code );