Added an implementation of the MSVCRTD.DLL debugging C runtime DLL.
[wine] / server / debugger.c
1 /*
2  * Server-side debugger functions
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <assert.h>
25 #include <signal.h>
26 #include <string.h>
27 #include <stdio.h>
28
29 #include "winbase.h"
30
31 #include "handle.h"
32 #include "process.h"
33 #include "thread.h"
34 #include "request.h"
35 #include "console.h"
36
37 enum debug_event_state { EVENT_QUEUED, EVENT_SENT, EVENT_CONTINUED };
38
39 /* debug event */
40 struct debug_event
41 {
42     struct object          obj;       /* object header */
43     struct debug_event    *next;      /* event queue */
44     struct debug_event    *prev;
45     struct thread         *sender;    /* thread which sent this event */
46     struct thread         *debugger;  /* debugger thread receiving the event */
47     enum debug_event_state state;     /* event state */
48     int                    status;    /* continuation status */
49     debug_event_t          data;      /* event data */
50     CONTEXT                context;   /* register context */
51 };
52
53 /* debug context */
54 struct debug_ctx
55 {
56     struct object        obj;         /* object header */
57     struct debug_event  *event_head;  /* head of pending events queue */
58     struct debug_event  *event_tail;  /* tail of pending events queue */
59     int                  kill_on_exit;/* kill debuggees on debugger exit ? */
60 };
61
62
63 static void debug_event_dump( struct object *obj, int verbose );
64 static int debug_event_signaled( struct object *obj, struct thread *thread );
65 static void debug_event_destroy( struct object *obj );
66
67 static const struct object_ops debug_event_ops =
68 {
69     sizeof(struct debug_event),    /* size */
70     debug_event_dump,              /* dump */
71     add_queue,                     /* add_queue */
72     remove_queue,                  /* remove_queue */
73     debug_event_signaled,          /* signaled */
74     no_satisfied,                  /* satisfied */
75     no_get_fd,                     /* get_fd */
76     debug_event_destroy            /* destroy */
77 };
78
79 static void debug_ctx_dump( struct object *obj, int verbose );
80 static int debug_ctx_signaled( struct object *obj, struct thread *thread );
81 static void debug_ctx_destroy( struct object *obj );
82
83 static const struct object_ops debug_ctx_ops =
84 {
85     sizeof(struct debug_ctx),      /* size */
86     debug_ctx_dump,                /* dump */
87     add_queue,                     /* add_queue */
88     remove_queue,                  /* remove_queue */
89     debug_ctx_signaled,            /* signaled */
90     no_satisfied,                  /* satisfied */
91     no_get_fd,                     /* get_fd */
92     debug_ctx_destroy              /* destroy */
93 };
94
95
96 /* routines to build an event according to its type */
97
98 static int fill_exception_event( struct debug_event *event, void *arg )
99 {
100     memcpy( &event->data.info.exception, arg, sizeof(event->data.info.exception) );
101     return 1;
102 }
103
104 static int fill_create_thread_event( struct debug_event *event, void *arg )
105 {
106     struct process *debugger = event->debugger->process;
107     struct thread *thread = event->sender;
108     obj_handle_t handle;
109
110     /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
111     if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE ))) return 0;
112     event->data.info.create_thread.handle = handle;
113     event->data.info.create_thread.teb    = thread->teb;
114     event->data.info.create_thread.start  = arg;
115     return 1;
116 }
117
118 static int fill_create_process_event( struct debug_event *event, void *arg )
119 {
120     struct process *debugger = event->debugger->process;
121     struct thread *thread = event->sender;
122     struct process *process = thread->process;
123     obj_handle_t handle;
124
125     /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
126     if (!(handle = alloc_handle( debugger, process, PROCESS_ALL_ACCESS, FALSE ))) return 0;
127     event->data.info.create_process.process = handle;
128
129     /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
130     if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE )))
131     {
132         close_handle( debugger, event->data.info.create_process.process, NULL );
133         return 0;
134     }
135     event->data.info.create_process.thread = handle;
136
137     handle = 0;
138     if (process->exe.file &&
139         /* the doc says write access too, but this doesn't seem a good idea */
140         !(handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, FALSE )))
141     {
142         close_handle( debugger, event->data.info.create_process.process, NULL );
143         close_handle( debugger, event->data.info.create_process.thread, NULL );
144         return 0;
145     }
146     event->data.info.create_process.file       = handle;
147     event->data.info.create_process.teb        = thread->teb;
148     event->data.info.create_process.base       = process->exe.base;
149     event->data.info.create_process.start      = arg;
150     event->data.info.create_process.dbg_offset = process->exe.dbg_offset;
151     event->data.info.create_process.dbg_size   = process->exe.dbg_size;
152     event->data.info.create_process.name       = process->exe.name;
153     event->data.info.create_process.unicode    = 0;
154     return 1;
155 }
156
157 static int fill_exit_thread_event( struct debug_event *event, void *arg )
158 {
159     struct thread *thread = arg;
160     event->data.info.exit.exit_code = thread->exit_code;
161     return 1;
162 }
163
164 static int fill_exit_process_event( struct debug_event *event, void *arg )
165 {
166     struct process *process = arg;
167     event->data.info.exit.exit_code = process->exit_code;
168     return 1;
169 }
170
171 static int fill_load_dll_event( struct debug_event *event, void *arg )
172 {
173     struct process *debugger = event->debugger->process;
174     struct process_dll *dll = arg;
175     obj_handle_t handle = 0;
176
177     if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, FALSE )))
178         return 0;
179     event->data.info.load_dll.handle     = handle;
180     event->data.info.load_dll.base       = dll->base;
181     event->data.info.load_dll.dbg_offset = dll->dbg_offset;
182     event->data.info.load_dll.dbg_size   = dll->dbg_size;
183     event->data.info.load_dll.name       = dll->name;
184     event->data.info.load_dll.unicode    = 0;
185     return 1;
186 }
187
188 static int fill_unload_dll_event( struct debug_event *event, void *arg )
189 {
190     event->data.info.unload_dll.base = arg;
191     return 1;
192 }
193
194 static int fill_output_debug_string_event( struct debug_event *event, void *arg )
195 {
196     struct debug_event_output_string *data = arg;
197     event->data.info.output_string = *data;
198     return 1;
199 }
200
201 typedef int (*fill_event_func)( struct debug_event *event, void *arg );
202
203 #define NB_DEBUG_EVENTS OUTPUT_DEBUG_STRING_EVENT  /* RIP_EVENT not supported */
204
205 static const fill_event_func fill_debug_event[NB_DEBUG_EVENTS] =
206 {
207     fill_exception_event,            /* EXCEPTION_DEBUG_EVENT */
208     fill_create_thread_event,        /* CREATE_THREAD_DEBUG_EVENT */
209     fill_create_process_event,       /* CREATE_PROCESS_DEBUG_EVENT */
210     fill_exit_thread_event,          /* EXIT_THREAD_DEBUG_EVENT */
211     fill_exit_process_event,         /* EXIT_PROCESS_DEBUG_EVENT */
212     fill_load_dll_event,             /* LOAD_DLL_DEBUG_EVENT */
213     fill_unload_dll_event,           /* UNLOAD_DLL_DEBUG_EVENT */
214     fill_output_debug_string_event   /* OUTPUT_DEBUG_STRING_EVENT */
215 };
216
217
218 /* unlink the first event from the queue */
219 static void unlink_event( struct debug_ctx *debug_ctx, struct debug_event *event )
220 {
221     if (event->prev) event->prev->next = event->next;
222     else debug_ctx->event_head = event->next;
223     if (event->next) event->next->prev = event->prev;
224     else debug_ctx->event_tail = event->prev;
225     event->next = event->prev = NULL;
226     if (event->sender->debug_event == event) event->sender->debug_event = NULL;
227     release_object( event );
228 }
229
230 /* link an event at the end of the queue */
231 static void link_event( struct debug_event *event )
232 {
233     struct debug_ctx *debug_ctx = event->debugger->debug_ctx;
234
235     assert( debug_ctx );
236     grab_object( event );
237     event->next = NULL;
238     event->prev = debug_ctx->event_tail;
239     debug_ctx->event_tail = event;
240     if (event->prev) event->prev->next = event;
241     else debug_ctx->event_head = event;
242     if (!event->sender->debug_event) wake_up( &debug_ctx->obj, 0 );
243 }
244
245 /* find the next event that we can send to the debugger */
246 static struct debug_event *find_event_to_send( struct debug_ctx *debug_ctx )
247 {
248     struct debug_event *event;
249     for (event = debug_ctx->event_head; event; event = event->next)
250     {
251         if (event->state == EVENT_SENT) continue;  /* already sent */
252         if (event->sender->debug_event) continue;  /* thread busy with another one */
253         break;
254     }
255     return event;
256 }
257
258 static void debug_event_dump( struct object *obj, int verbose )
259 {
260     struct debug_event *debug_event = (struct debug_event *)obj;
261     assert( obj->ops == &debug_event_ops );
262     fprintf( stderr, "Debug event sender=%p code=%d state=%d\n",
263              debug_event->sender, debug_event->data.code, debug_event->state );
264 }
265
266 static int debug_event_signaled( struct object *obj, struct thread *thread )
267 {
268     struct debug_event *debug_event = (struct debug_event *)obj;
269     assert( obj->ops == &debug_event_ops );
270     return debug_event->state == EVENT_CONTINUED;
271 }
272
273 static void debug_event_destroy( struct object *obj )
274 {
275     struct debug_event *event = (struct debug_event *)obj;
276     assert( obj->ops == &debug_event_ops );
277
278     /* cannot still be in the queue */
279     assert( !event->next );
280     assert( !event->prev );
281
282     /* If the event has been sent already, the handles are now under the */
283     /* responsibility of the debugger process, so we don't touch them    */
284     if (event->state == EVENT_QUEUED)
285     {
286         struct process *debugger = event->debugger->process;
287         switch(event->data.code)
288         {
289         case CREATE_THREAD_DEBUG_EVENT:
290             close_handle( debugger, event->data.info.create_thread.handle, NULL );
291             break;
292         case CREATE_PROCESS_DEBUG_EVENT:
293             if (event->data.info.create_process.file)
294                 close_handle( debugger, event->data.info.create_process.file, NULL );
295             close_handle( debugger, event->data.info.create_process.thread, NULL );
296             close_handle( debugger, event->data.info.create_process.process, NULL );
297             break;
298         case LOAD_DLL_DEBUG_EVENT:
299             if (event->data.info.load_dll.handle)
300                 close_handle( debugger, event->data.info.load_dll.handle, NULL );
301             break;
302         }
303     }
304     if (event->sender->context == &event->context) event->sender->context = NULL;
305     release_object( event->sender );
306     release_object( event->debugger );
307 }
308
309 static void debug_ctx_dump( struct object *obj, int verbose )
310 {
311     struct debug_ctx *debug_ctx = (struct debug_ctx *)obj;
312     assert( obj->ops == &debug_ctx_ops );
313     fprintf( stderr, "Debug context head=%p tail=%p\n",
314              debug_ctx->event_head, debug_ctx->event_tail );
315 }
316
317 static int debug_ctx_signaled( struct object *obj, struct thread *thread )
318 {
319     struct debug_ctx *debug_ctx = (struct debug_ctx *)obj;
320     assert( obj->ops == &debug_ctx_ops );
321     return find_event_to_send( debug_ctx ) != NULL;
322 }
323
324 static void debug_ctx_destroy( struct object *obj )
325 {
326     struct debug_event *event;
327     struct debug_ctx *debug_ctx = (struct debug_ctx *)obj;
328     assert( obj->ops == &debug_ctx_ops );
329
330     /* free all pending events */
331     while ((event = debug_ctx->event_head) != NULL) unlink_event( debug_ctx, event );
332 }
333
334 /* continue a debug event */
335 static int continue_debug_event( struct process *process, struct thread *thread, int status )
336 {
337     struct debug_event *event;
338     struct debug_ctx *debug_ctx = current->debug_ctx;
339
340     if (!debug_ctx || process->debugger != current || thread->process != process) goto error;
341
342     /* find the event in the queue */
343     for (event = debug_ctx->event_head; event; event = event->next)
344     {
345         if (event->state != EVENT_SENT) continue;
346         if (event->sender == thread) break;
347     }
348     if (!event) goto error;
349
350     assert( event->sender->debug_event == event );
351
352     event->status = status;
353     event->state  = EVENT_CONTINUED;
354     wake_up( &event->obj, 0 );
355
356     unlink_event( debug_ctx, event );
357     resume_process( process );
358     return 1;
359  error:
360     /* not debugging this process, or no such event */
361     set_error( STATUS_ACCESS_DENIED );  /* FIXME */
362     return 0;
363 }
364
365 /* alloc a debug event for a debugger */
366 static struct debug_event *alloc_debug_event( struct thread *thread, int code,
367                                               void *arg, const CONTEXT *context )
368 {
369     struct thread *debugger = thread->process->debugger;
370     struct debug_event *event;
371
372     assert( code > 0 && code <= NB_DEBUG_EVENTS );
373     /* cannot queue a debug event for myself */
374     assert( debugger->process != thread->process );
375
376     /* build the event */
377     if (!(event = alloc_object( &debug_event_ops ))) return NULL;
378     event->next      = NULL;
379     event->prev      = NULL;
380     event->state     = EVENT_QUEUED;
381     event->sender    = (struct thread *)grab_object( thread );
382     event->debugger  = (struct thread *)grab_object( debugger );
383     event->data.code = code;
384
385     if (!fill_debug_event[code-1]( event, arg ))
386     {
387         event->data.code = -1;  /* make sure we don't attempt to close handles */
388         release_object( event );
389         return NULL;
390     }
391     if (context)
392     {
393         memcpy( &event->context, context, sizeof(event->context) );
394         thread->context = &event->context;
395     }
396     return event;
397 }
398
399 /* generate a debug event from inside the server and queue it */
400 void generate_debug_event( struct thread *thread, int code, void *arg )
401 {
402     if (thread->process->debugger)
403     {
404         struct debug_event *event = alloc_debug_event( thread, code, arg, NULL );
405         if (event)
406         {
407             link_event( event );
408             suspend_process( thread->process );
409             release_object( event );
410         }
411     }
412 }
413
414 /* attach a process to a debugger thread and suspend it */
415 static int debugger_attach( struct process *process, struct thread *debugger )
416 {
417     struct thread *thread;
418
419     if (process->debugger) goto error;  /* already being debugged */
420     if (!is_process_init_done( process )) goto error;  /* still starting up */
421     if (!process->thread_list) goto error;  /* no thread running in the process */
422
423     /* make sure we don't create a debugging loop */
424     for (thread = debugger; thread; thread = thread->process->debugger)
425         if (thread->process == process) goto error;
426
427     /* don't let a debugger debug its console... won't work */
428     if (debugger->process->console && debugger->process->console->renderer->process == process)
429         goto error;
430
431     suspend_process( process );
432     if (!attach_process( process ) || !set_process_debugger( process, debugger ))
433     {
434         resume_process( process );
435         return 0;
436     }
437     return 1;
438
439  error:
440     set_error( STATUS_ACCESS_DENIED );
441     return 0;
442 }
443
444
445 /* detach a process from a debugger thread (and resume it ?) */
446 int debugger_detach( struct process *process, struct thread *debugger )
447 {
448     struct debug_event *event;
449     struct debug_ctx *debug_ctx;
450
451     if (!process->debugger || process->debugger != debugger)
452         goto error;  /* not currently debugged, or debugged by another debugger */
453     if (!debugger->debug_ctx ) goto error; /* should be a debugger */
454     /* init should be done, otherwise wouldn't be attached */
455     assert(is_process_init_done(process));
456
457     suspend_process( process );
458     /* send continue indication for all events */
459     debug_ctx = debugger->debug_ctx;
460
461     /* find the event in the queue
462      * FIXME: could loop on process' threads and look the debug_event field */
463     for (event = debug_ctx->event_head; event; event = event->next)
464     {
465         if (event->state != EVENT_QUEUED) continue;
466
467         if (event->sender->process == process)
468         {
469             assert( event->sender->debug_event == event );
470             event->status = DBG_CONTINUE;
471             event->state  = EVENT_CONTINUED;
472             wake_up( &event->obj, 0 );
473             unlink_event( debug_ctx, event );
474             /* from queued debug event */
475             resume_process( process );
476         }
477     }
478
479     /* remove relationships between process and its debugger */
480     process->debugger = NULL;
481     release_object( debugger->debug_ctx );
482     debugger->debug_ctx = NULL;
483     detach_process( process );
484
485     /* from this function */
486     resume_process( process );
487     return 0;
488
489  error:
490     set_error( STATUS_ACCESS_DENIED );
491     return 0;
492 }
493
494 /* generate all startup events of a given process */
495 void generate_startup_debug_events( struct process *process, void *entry )
496 {
497     struct process_dll *dll;
498     struct thread *thread = process->thread_list;
499
500     /* generate creation events */
501     generate_debug_event( thread, CREATE_PROCESS_DEBUG_EVENT, entry );
502     while ((thread = thread->proc_next))
503         generate_debug_event( thread, CREATE_THREAD_DEBUG_EVENT, NULL );
504
505     /* generate dll events (in loading order, i.e. reverse list order) */
506     dll = &process->exe;
507     while (dll->next) dll = dll->next;
508     while (dll != &process->exe)
509     {
510         generate_debug_event( process->thread_list, LOAD_DLL_DEBUG_EVENT, dll );
511         dll = dll->prev;
512     }
513 }
514
515 /* set the debugger of a given process */
516 int set_process_debugger( struct process *process, struct thread *debugger )
517 {
518     struct debug_ctx *debug_ctx;
519
520     assert( !process->debugger );
521
522     if (!debugger->debug_ctx)  /* need to allocate a context */
523     {
524         if (!(debug_ctx = alloc_object( &debug_ctx_ops ))) return 0;
525         debug_ctx->event_head = NULL;
526         debug_ctx->event_tail = NULL;
527         debug_ctx->kill_on_exit = 1;
528         debugger->debug_ctx = debug_ctx;
529     }
530     process->debugger = debugger;
531     return 1;
532 }
533
534 /* a thread is exiting */
535 void debug_exit_thread( struct thread *thread )
536 {
537     if (thread->debug_ctx)  /* this thread is a debugger */
538     {
539         if (thread->debug_ctx->kill_on_exit)
540         {
541             /* kill all debugged processes */
542             kill_debugged_processes( thread, thread->exit_code );
543         }
544         else
545         {
546             detach_debugged_processes( thread );
547         }
548         release_object( thread->debug_ctx );
549         thread->debug_ctx = NULL;
550     }
551 }
552
553 /* Wait for a debug event */
554 DECL_HANDLER(wait_debug_event)
555 {
556     struct debug_ctx *debug_ctx = current->debug_ctx;
557     struct debug_event *event;
558
559     if (!debug_ctx)  /* current thread is not a debugger */
560     {
561         set_error( STATUS_INVALID_HANDLE );
562         return;
563     }
564     reply->wait = 0;
565     if ((event = find_event_to_send( debug_ctx )))
566     {
567         size_t size = get_reply_max_size();
568         event->state = EVENT_SENT;
569         event->sender->debug_event = event;
570         reply->pid = get_process_id( event->sender->process );
571         reply->tid = get_thread_id( event->sender );
572         if (size > sizeof(debug_event_t)) size = sizeof(debug_event_t);
573         set_reply_data( &event->data, size );
574     }
575     else  /* no event ready */
576     {
577         reply->pid  = 0;
578         reply->tid  = 0;
579         if (req->get_handle)
580             reply->wait = alloc_handle( current->process, debug_ctx, SYNCHRONIZE, FALSE );
581     }
582 }
583
584 /* Continue a debug event */
585 DECL_HANDLER(continue_debug_event)
586 {
587     struct process *process = get_process_from_id( req->pid );
588     if (process)
589     {
590         struct thread *thread = get_thread_from_id( req->tid );
591         if (thread)
592         {
593             continue_debug_event( process, thread, req->status );
594             release_object( thread );
595         }
596         release_object( process );
597     }
598 }
599
600 /* Start debugging an existing process */
601 DECL_HANDLER(debug_process)
602 {
603     struct process *process = get_process_from_id( req->pid );
604     if (!process) return;
605
606     if (!req->attach)
607     {
608         debugger_detach( process, current );
609     }
610     else if (debugger_attach( process, current ))
611     {
612         struct debug_event_exception data;
613
614         generate_startup_debug_events( process, NULL );
615         resume_process( process );
616
617         data.record.ExceptionCode    = EXCEPTION_BREAKPOINT;
618         data.record.ExceptionFlags   = EXCEPTION_CONTINUABLE;
619         data.record.ExceptionRecord  = NULL;
620         data.record.ExceptionAddress = get_thread_ip( process->thread_list );
621         data.record.NumberParameters = 0;
622         data.first = 1;
623         generate_debug_event( process->thread_list, EXCEPTION_DEBUG_EVENT, &data );
624     }
625     release_object( process );
626 }
627
628 /* queue an exception event */
629 DECL_HANDLER(queue_exception_event)
630 {
631     reply->handle = 0;
632     if (current->process->debugger)
633     {
634         struct debug_event_exception data;
635         struct debug_event *event;
636         const CONTEXT *context = get_req_data();
637         EXCEPTION_RECORD *rec = (EXCEPTION_RECORD *)(context + 1);
638
639         if (get_req_data_size() < sizeof(*rec) + sizeof(*context))
640         {
641             set_error( STATUS_INVALID_PARAMETER );
642             return;
643         }
644         data.record = *rec;
645         data.first  = req->first;
646         if ((event = alloc_debug_event( current, EXCEPTION_DEBUG_EVENT, &data, context )))
647         {
648             if ((reply->handle = alloc_handle( current->process, event, SYNCHRONIZE, FALSE )))
649             {
650                 link_event( event );
651                 suspend_process( current->process );
652             }
653             release_object( event );
654         }
655     }
656 }
657
658 /* retrieve the status of an exception event */
659 DECL_HANDLER(get_exception_status)
660 {
661     struct debug_event *event;
662
663     reply->status = 0;
664     if ((event = (struct debug_event *)get_handle_obj( current->process, req->handle,
665                                                        0, &debug_event_ops )))
666     {
667         if (event->state == EVENT_CONTINUED)
668         {
669             reply->status = event->status;
670             if (current->context == &event->context)
671             {
672                 size_t size = min( sizeof(CONTEXT), get_reply_max_size() );
673                 set_reply_data( &event->context, size );
674                 current->context = NULL;
675             }
676         }
677         else set_error( STATUS_PENDING );
678         release_object( event );
679     }
680 }
681
682 /* send an output string to the debugger */
683 DECL_HANDLER(output_debug_string)
684 {
685     struct debug_event_output_string data;
686
687     data.string  = req->string;
688     data.unicode = req->unicode;
689     data.length  = req->length;
690     generate_debug_event( current, OUTPUT_DEBUG_STRING_EVENT, &data );
691 }
692
693 /* simulate a breakpoint in a process */
694 DECL_HANDLER(debug_break)
695 {
696     struct process *process;
697
698     reply->self = 0;
699     if (!(process = get_process_from_handle( req->handle, PROCESS_SET_INFORMATION /*FIXME*/ )))
700         return;
701     if (process != current->process)
702     {
703         /* find a suitable thread to signal */
704         struct thread *thread;
705         for (thread = process->thread_list; thread; thread = thread->proc_next)
706         {
707             if (send_thread_signal( thread, SIGTRAP )) break;
708         }
709         if (!thread) set_error( STATUS_ACCESS_DENIED );
710     }
711     else reply->self = 1;
712     release_object( process );
713 }
714
715 /* set debugger kill on exit flag */
716 DECL_HANDLER(set_debugger_kill_on_exit)
717 {
718     if (!current->debug_ctx)
719     {
720         set_error( STATUS_ACCESS_DENIED );
721         return;
722     }
723     current->debug_ctx->kill_on_exit = req->kill_on_exit;
724 }