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