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