ntdll: Implement NtDebugActiveProcess() and NtRemoveProcessDebug().
[wine.git] / server / debugger.c
blob252a0a62b4b0afae9f31d8b075973349b1488651
1 /*
2 * Server-side debugger functions
4 * Copyright (C) 1999 Alexandre Julliard
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <assert.h>
25 #include <signal.h>
26 #include <string.h>
27 #include <stdarg.h>
28 #include <stdio.h>
30 #include "ntstatus.h"
31 #define WIN32_NO_STATUS
32 #include "windef.h"
33 #include "winternl.h"
35 #include "handle.h"
36 #include "file.h"
37 #include "process.h"
38 #include "thread.h"
39 #include "request.h"
41 enum debug_event_state { EVENT_QUEUED, EVENT_SENT, EVENT_DELAYED, EVENT_CONTINUED };
43 /* debug event */
44 struct debug_event
46 struct object obj; /* object header */
47 struct list entry; /* entry in event queue */
48 struct thread *sender; /* thread which sent this event */
49 struct file *file; /* file object for events that need one */
50 enum debug_event_state state; /* event state */
51 int status; /* continuation status */
52 debug_event_t data; /* event data */
55 /* debug object */
56 struct debug_obj
58 struct object obj; /* object header */
59 struct list event_queue; /* pending events queue */
60 unsigned int flags; /* debug flags */
64 static void debug_event_dump( struct object *obj, int verbose );
65 static int debug_event_signaled( struct object *obj, struct wait_queue_entry *entry );
66 static void debug_event_destroy( struct object *obj );
68 static const struct object_ops debug_event_ops =
70 sizeof(struct debug_event), /* size */
71 debug_event_dump, /* dump */
72 no_get_type, /* get_type */
73 add_queue, /* add_queue */
74 remove_queue, /* remove_queue */
75 debug_event_signaled, /* signaled */
76 no_satisfied, /* satisfied */
77 no_signal, /* signal */
78 no_get_fd, /* get_fd */
79 no_map_access, /* map_access */
80 default_get_sd, /* get_sd */
81 default_set_sd, /* set_sd */
82 no_get_full_name, /* get_full_name */
83 no_lookup_name, /* lookup_name */
84 no_link_name, /* link_name */
85 NULL, /* unlink_name */
86 no_open_file, /* open_file */
87 no_kernel_obj_list, /* get_kernel_obj_list */
88 no_close_handle, /* close_handle */
89 debug_event_destroy /* destroy */
92 static void debug_obj_dump( struct object *obj, int verbose );
93 static struct object_type *debug_obj_get_type( struct object *obj );
94 static int debug_obj_signaled( struct object *obj, struct wait_queue_entry *entry );
95 static unsigned int debug_obj_map_access( struct object *obj, unsigned int access );
96 static void debug_obj_destroy( struct object *obj );
98 static const struct object_ops debug_obj_ops =
100 sizeof(struct debug_obj), /* size */
101 debug_obj_dump, /* dump */
102 debug_obj_get_type, /* get_type */
103 add_queue, /* add_queue */
104 remove_queue, /* remove_queue */
105 debug_obj_signaled, /* signaled */
106 no_satisfied, /* satisfied */
107 no_signal, /* signal */
108 no_get_fd, /* get_fd */
109 debug_obj_map_access, /* map_access */
110 default_get_sd, /* get_sd */
111 default_set_sd, /* set_sd */
112 default_get_full_name, /* get_full_name */
113 no_lookup_name, /* lookup_name */
114 directory_link_name, /* link_name */
115 default_unlink_name, /* unlink_name */
116 no_open_file, /* open_file */
117 no_kernel_obj_list, /* get_kernel_obj_list */
118 no_close_handle, /* close_handle */
119 debug_obj_destroy /* destroy */
123 /* routines to build an event according to its type */
125 static void fill_exception_event( struct debug_event *event, const void *arg )
127 const debug_event_t *data = arg;
128 event->data.exception = data->exception;
129 event->data.exception.nb_params = min( event->data.exception.nb_params, EXCEPTION_MAXIMUM_PARAMETERS );
132 static void fill_create_thread_event( struct debug_event *event, const void *arg )
134 struct thread *thread = event->sender;
135 const client_ptr_t *entry = arg;
137 event->data.create_thread.teb = thread->teb;
138 if (entry) event->data.create_thread.start = *entry;
141 static void fill_create_process_event( struct debug_event *event, const void *arg )
143 struct thread *thread = event->sender;
144 struct process *process = thread->process;
145 struct process_dll *exe_module = get_process_exe_module( process );
146 const client_ptr_t *entry = arg;
148 event->data.create_process.teb = thread->teb;
149 event->data.create_process.base = exe_module->base;
150 event->data.create_process.start = *entry;
151 event->data.create_process.dbg_offset = exe_module->dbg_offset;
152 event->data.create_process.dbg_size = exe_module->dbg_size;
153 event->data.create_process.name = exe_module->name;
154 event->data.create_process.unicode = 1;
156 /* the doc says write access too, but this doesn't seem a good idea */
157 event->file = get_mapping_file( process, exe_module->base, GENERIC_READ,
158 FILE_SHARE_READ | FILE_SHARE_WRITE );
161 static void fill_exit_thread_event( struct debug_event *event, const void *arg )
163 const struct thread *thread = arg;
164 event->data.exit.exit_code = thread->exit_code;
167 static void fill_exit_process_event( struct debug_event *event, const void *arg )
169 const struct process *process = arg;
170 event->data.exit.exit_code = process->exit_code;
173 static void fill_load_dll_event( struct debug_event *event, const void *arg )
175 struct process *process = event->sender->process;
176 const struct process_dll *dll = arg;
178 event->data.load_dll.handle = 0;
179 event->data.load_dll.base = dll->base;
180 event->data.load_dll.dbg_offset = dll->dbg_offset;
181 event->data.load_dll.dbg_size = dll->dbg_size;
182 event->data.load_dll.name = dll->name;
183 event->data.load_dll.unicode = 1;
184 event->file = get_mapping_file( process, dll->base, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE );
187 static void fill_unload_dll_event( struct debug_event *event, const void *arg )
189 const mod_handle_t *base = arg;
190 event->data.unload_dll.base = *base;
193 typedef void (*fill_event_func)( struct debug_event *event, const void *arg );
195 #define NB_DEBUG_EVENTS UNLOAD_DLL_DEBUG_EVENT
197 static const fill_event_func fill_debug_event[NB_DEBUG_EVENTS] =
199 fill_exception_event, /* EXCEPTION_DEBUG_EVENT */
200 fill_create_thread_event, /* CREATE_THREAD_DEBUG_EVENT */
201 fill_create_process_event, /* CREATE_PROCESS_DEBUG_EVENT */
202 fill_exit_thread_event, /* EXIT_THREAD_DEBUG_EVENT */
203 fill_exit_process_event, /* EXIT_PROCESS_DEBUG_EVENT */
204 fill_load_dll_event, /* LOAD_DLL_DEBUG_EVENT */
205 fill_unload_dll_event /* UNLOAD_DLL_DEBUG_EVENT */
208 /* allocate the necessary handles in the event data */
209 static void alloc_event_handles( struct debug_event *event, struct process *process )
211 switch (event->data.code)
213 case CREATE_THREAD_DEBUG_EVENT:
214 /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
215 event->data.create_thread.handle = alloc_handle( process, event->sender, THREAD_ALL_ACCESS, 0 );
216 break;
217 case CREATE_PROCESS_DEBUG_EVENT:
218 event->data.create_process.thread = alloc_handle( process, event->sender, THREAD_ALL_ACCESS, 0 );
219 /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
220 event->data.create_process.process = alloc_handle( process, event->sender->process,
221 PROCESS_ALL_ACCESS, 0 );
222 if (event->file)
223 event->data.create_process.file = alloc_handle( process, event->file, GENERIC_READ, 0 );
224 break;
225 case LOAD_DLL_DEBUG_EVENT:
226 if (event->file)
227 event->data.load_dll.handle = alloc_handle( process, event->file, GENERIC_READ, 0 );
228 break;
230 clear_error(); /* ignore errors, simply set handles to 0 */
233 /* unlink the first event from the queue */
234 static void unlink_event( struct debug_obj *debug_obj, struct debug_event *event )
236 list_remove( &event->entry );
237 if (event->sender->process->debug_event == event) event->sender->process->debug_event = NULL;
238 release_object( event );
241 /* link an event at the end of the queue */
242 static void link_event( struct debug_obj *debug_obj, struct debug_event *event )
244 grab_object( event );
245 list_add_tail( &debug_obj->event_queue, &event->entry );
246 if (!event->sender->process->debug_event)
248 /* grab reference since debugger could be killed while trying to wake up */
249 grab_object( debug_obj );
250 wake_up( &debug_obj->obj, 0 );
251 release_object( debug_obj );
255 /* resume a delayed debug event already in the queue */
256 static void resume_event( struct debug_obj *debug_obj, struct debug_event *event )
258 event->state = EVENT_QUEUED;
259 if (!event->sender->process->debug_event)
261 grab_object( debug_obj );
262 wake_up( &debug_obj->obj, 0 );
263 release_object( debug_obj );
267 /* delay a debug event already in the queue to be replayed when thread wakes up */
268 static void delay_event( struct debug_obj *debug_obj, struct debug_event *event )
270 event->state = EVENT_DELAYED;
271 if (event->sender->process->debug_event == event) event->sender->process->debug_event = NULL;
274 /* find the next event that we can send to the debugger */
275 static struct debug_event *find_event_to_send( struct debug_obj *debug_obj )
277 struct debug_event *event;
279 LIST_FOR_EACH_ENTRY( event, &debug_obj->event_queue, struct debug_event, entry )
281 if (event->state == EVENT_SENT) continue; /* already sent */
282 if (event->state == EVENT_DELAYED) continue; /* delayed until thread resumes */
283 if (event->sender->process->debug_event) continue; /* process busy with another one */
284 return event;
286 return NULL;
289 static void debug_event_dump( struct object *obj, int verbose )
291 struct debug_event *debug_event = (struct debug_event *)obj;
292 assert( obj->ops == &debug_event_ops );
293 fprintf( stderr, "Debug event sender=%p code=%d state=%d\n",
294 debug_event->sender, debug_event->data.code, debug_event->state );
297 static int debug_event_signaled( struct object *obj, struct wait_queue_entry *entry )
299 struct debug_event *debug_event = (struct debug_event *)obj;
300 assert( obj->ops == &debug_event_ops );
301 return debug_event->state == EVENT_CONTINUED;
304 static void debug_event_destroy( struct object *obj )
306 struct debug_event *event = (struct debug_event *)obj;
307 assert( obj->ops == &debug_event_ops );
309 if (event->file) release_object( event->file );
310 release_object( event->sender );
313 static void debug_obj_dump( struct object *obj, int verbose )
315 struct debug_obj *debug_obj = (struct debug_obj *)obj;
316 assert( obj->ops == &debug_obj_ops );
317 fprintf( stderr, "Debug context head=%p tail=%p\n",
318 debug_obj->event_queue.next, debug_obj->event_queue.prev );
321 static struct object_type *debug_obj_get_type( struct object *obj )
323 static const WCHAR name[] = {'D','e','b','u','g','O','b','j','e','c','t'};
324 static const struct unicode_str str = { name, sizeof(name) };
325 return get_object_type( &str );
328 static int debug_obj_signaled( struct object *obj, struct wait_queue_entry *entry )
330 struct debug_obj *debug_obj = (struct debug_obj *)obj;
331 assert( obj->ops == &debug_obj_ops );
332 return find_event_to_send( debug_obj ) != NULL;
335 static unsigned int debug_obj_map_access( struct object *obj, unsigned int access )
337 if (access & GENERIC_READ) access |= STANDARD_RIGHTS_READ | DEBUG_READ_EVENT | DEBUG_QUERY_INFORMATION;
338 if (access & GENERIC_WRITE) access |= STANDARD_RIGHTS_WRITE | DEBUG_SET_INFORMATION;
339 if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE | DEBUG_PROCESS_ASSIGN;
340 if (access & GENERIC_ALL) access |= STANDARD_RIGHTS_ALL | EVENT_QUERY_STATE | EVENT_MODIFY_STATE;
341 return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
344 static void debug_obj_destroy( struct object *obj )
346 struct list *ptr;
347 struct debug_obj *debug_obj = (struct debug_obj *)obj;
348 assert( obj->ops == &debug_obj_ops );
350 detach_debugged_processes( debug_obj,
351 (debug_obj->flags & DEBUG_KILL_ON_CLOSE) ? STATUS_DEBUGGER_INACTIVE : 0 );
353 /* free all pending events */
354 while ((ptr = list_head( &debug_obj->event_queue )))
355 unlink_event( debug_obj, LIST_ENTRY( ptr, struct debug_event, entry ));
358 struct debug_obj *get_debug_obj( struct process *process, obj_handle_t handle, unsigned int access )
360 return (struct debug_obj *)get_handle_obj( process, handle, access, &debug_obj_ops );
363 static struct debug_obj *create_debug_obj( struct object *root, const struct unicode_str *name,
364 unsigned int attr, unsigned int flags,
365 const struct security_descriptor *sd )
367 struct debug_obj *debug_obj;
369 if ((debug_obj = create_named_object( root, &debug_obj_ops, name, attr, sd )))
371 if (get_error() != STATUS_OBJECT_NAME_EXISTS)
373 debug_obj->flags = flags;
374 list_init( &debug_obj->event_queue );
377 return debug_obj;
380 /* continue a debug event */
381 static int continue_debug_event( struct process *process, struct thread *thread, int status )
383 struct debug_obj *debug_obj = current->debug_obj;
385 if (debug_obj && process->debug_obj == debug_obj && thread->process == process)
387 struct debug_event *event;
389 if (status == DBG_REPLY_LATER)
391 /* if thread is suspended, delay all its events and resume process
392 * if not, reset the event for immediate replay */
393 LIST_FOR_EACH_ENTRY( event, &debug_obj->event_queue, struct debug_event, entry )
395 if (event->sender != thread) continue;
396 if (thread->suspend)
398 delay_event( debug_obj, event );
399 resume_process( process );
401 else if (event->state == EVENT_SENT)
403 assert( event->sender->process->debug_event == event );
404 event->sender->process->debug_event = NULL;
405 resume_event( debug_obj, event );
406 return 1;
409 return 1;
412 /* find the event in the queue */
413 LIST_FOR_EACH_ENTRY( event, &debug_obj->event_queue, struct debug_event, entry )
415 if (event->state != EVENT_SENT) continue;
416 if (event->sender == thread)
418 assert( event->sender->process->debug_event == event );
419 event->status = status;
420 event->state = EVENT_CONTINUED;
421 wake_up( &event->obj, 0 );
422 unlink_event( debug_obj, event );
423 resume_process( process );
424 return 1;
428 /* not debugging this process, or no such event */
429 set_error( STATUS_ACCESS_DENIED ); /* FIXME */
430 return 0;
433 /* alloc a debug event for a debugger */
434 static struct debug_event *alloc_debug_event( struct thread *thread, int code, const void *arg )
436 struct debug_event *event;
438 assert( code > 0 && code <= NB_DEBUG_EVENTS );
440 /* build the event */
441 if (!(event = alloc_object( &debug_event_ops ))) return NULL;
442 event->state = EVENT_QUEUED;
443 event->sender = (struct thread *)grab_object( thread );
444 event->file = NULL;
445 memset( &event->data, 0, sizeof(event->data) );
447 fill_debug_event[code-1]( event, arg );
448 event->data.code = code;
449 return event;
452 /* generate a debug event from inside the server and queue it */
453 void generate_debug_event( struct thread *thread, int code, const void *arg )
455 struct debug_obj *debug_obj = thread->process->debug_obj;
457 if (debug_obj)
459 struct debug_event *event = alloc_debug_event( thread, code, arg );
460 if (event)
462 link_event( debug_obj, event );
463 suspend_process( thread->process );
464 release_object( event );
466 clear_error(); /* ignore errors */
470 void resume_delayed_debug_events( struct thread *thread )
472 struct debug_obj *debug_obj = thread->process->debug_obj;
473 struct debug_event *event;
475 if (debug_obj)
477 LIST_FOR_EACH_ENTRY( event, &debug_obj->event_queue, struct debug_event, entry )
479 if (event->sender != thread) continue;
480 if (event->state != EVENT_DELAYED) continue;
481 resume_event( debug_obj, event );
482 suspend_process( thread->process );
487 /* attach a process to a debugger thread and suspend it */
488 static int debugger_attach( struct process *process, struct thread *debugger, struct debug_obj *debug_obj )
490 if (debugger->process == process) goto error;
491 if (!is_process_init_done( process )) goto error; /* still starting up */
492 if (list_empty( &process->thread_list )) goto error; /* no thread running in the process */
493 /* don't let a debugger debug its console... won't work */
494 if (debugger->process->console)
496 struct thread *renderer = console_get_renderer(debugger->process->console);
497 if (renderer && renderer->process == process) goto error;
499 if (!debugger->debug_obj) debugger->debug_obj = (struct debug_obj *)grab_object( debug_obj );
501 suspend_process( process );
503 if (!set_process_debug_flag( process, 1 ))
505 resume_process( process );
506 return 0;
508 process->debug_obj = debug_obj;
509 process->debug_children = 0;
510 generate_startup_debug_events( process, 0 );
511 resume_process( process );
512 return 1;
514 error:
515 set_error( STATUS_ACCESS_DENIED );
516 return 0;
520 /* detach a process from a debugger thread (and resume it) */
521 void debugger_detach( struct process *process, struct debug_obj *debug_obj )
523 struct debug_event *event, *next;
525 suspend_process( process );
527 /* send continue indication for all events */
528 LIST_FOR_EACH_ENTRY_SAFE( event, next, &debug_obj->event_queue, struct debug_event, entry )
530 if (event->sender->process != process) continue;
532 assert( event->state != EVENT_CONTINUED );
533 event->status = DBG_CONTINUE;
534 event->state = EVENT_CONTINUED;
535 wake_up( &event->obj, 0 );
536 unlink_event( debug_obj, event );
537 /* from queued debug event */
538 resume_process( process );
541 /* remove relationships between process and its debugger */
542 process->debug_obj = NULL;
543 if (!set_process_debug_flag( process, 0 )) clear_error(); /* ignore error */
545 resume_process( process );
548 /* generate all startup events of a given process */
549 void generate_startup_debug_events( struct process *process, client_ptr_t entry )
551 struct list *ptr;
552 struct thread *thread, *first_thread = get_process_first_thread( process );
554 generate_debug_event( first_thread, CREATE_PROCESS_DEBUG_EVENT, &entry );
555 ptr = list_head( &process->dlls ); /* skip main module reported in create process event */
557 /* generate ntdll.dll load event */
558 if (ptr && (ptr = list_next( &process->dlls, ptr )))
560 struct process_dll *dll = LIST_ENTRY( ptr, struct process_dll, entry );
561 generate_debug_event( first_thread, LOAD_DLL_DEBUG_EVENT, dll );
564 /* generate creation events */
565 LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
567 if (thread != first_thread)
568 generate_debug_event( thread, CREATE_THREAD_DEBUG_EVENT, NULL );
571 /* generate dll events (in loading order) */
572 while (ptr && (ptr = list_next( &process->dlls, ptr )))
574 struct process_dll *dll = LIST_ENTRY( ptr, struct process_dll, entry );
575 generate_debug_event( first_thread, LOAD_DLL_DEBUG_EVENT, dll );
579 /* a thread is exiting */
580 void debug_exit_thread( struct thread *thread )
582 struct debug_obj *debug_obj = thread->debug_obj;
584 if (debug_obj) /* this thread is a debugger */
586 detach_debugged_processes( debug_obj,
587 (debug_obj->flags & DEBUG_KILL_ON_CLOSE) ? STATUS_DEBUGGER_INACTIVE : 0 );
588 release_object( thread->debug_obj );
589 thread->debug_obj = NULL;
593 /* create a debug object */
594 DECL_HANDLER(create_debug_obj)
596 struct debug_obj *debug_obj;
597 struct unicode_str name;
598 struct object *root;
599 const struct security_descriptor *sd;
600 const struct object_attributes *objattr = get_req_object_attributes( &sd, &name, &root );
602 if (!objattr) return;
603 if ((debug_obj = create_debug_obj( root, &name, objattr->attributes, req->flags, sd )))
605 if (get_error() == STATUS_OBJECT_NAME_EXISTS)
606 reply->handle = alloc_handle( current->process, debug_obj, req->access, objattr->attributes );
607 else
608 reply->handle = alloc_handle_no_access_check( current->process, debug_obj,
609 req->access, objattr->attributes );
610 release_object( debug_obj );
612 if (root) release_object( root );
615 /* Wait for a debug event */
616 DECL_HANDLER(wait_debug_event)
618 struct debug_obj *debug_obj = current->debug_obj;
619 struct debug_event *event;
621 if (!debug_obj) /* current thread is not a debugger */
623 set_error( STATUS_INVALID_HANDLE );
624 return;
626 reply->wait = 0;
627 if ((event = find_event_to_send( debug_obj )))
629 event->state = EVENT_SENT;
630 event->sender->process->debug_event = event;
631 reply->pid = get_process_id( event->sender->process );
632 reply->tid = get_thread_id( event->sender );
633 alloc_event_handles( event, current->process );
634 set_reply_data( &event->data, min( get_reply_max_size(), sizeof(event->data) ));
636 else /* no event ready */
638 reply->pid = 0;
639 reply->tid = 0;
640 if (req->get_handle)
641 reply->wait = alloc_handle( current->process, debug_obj, SYNCHRONIZE, 0 );
645 /* Continue a debug event */
646 DECL_HANDLER(continue_debug_event)
648 struct process *process;
650 if (req->status != DBG_EXCEPTION_NOT_HANDLED &&
651 req->status != DBG_EXCEPTION_HANDLED &&
652 req->status != DBG_CONTINUE &&
653 req->status != DBG_REPLY_LATER)
655 set_error( STATUS_INVALID_PARAMETER );
656 return;
659 if ((process = get_process_from_id( req->pid )))
661 struct thread *thread = get_thread_from_id( req->tid );
662 if (thread)
664 continue_debug_event( process, thread, req->status );
665 release_object( thread );
667 release_object( process );
671 /* start or stop debugging an existing process */
672 DECL_HANDLER(debug_process)
674 struct debug_obj *debug_obj;
675 struct process *process = get_process_from_handle( req->handle,
676 PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_SUSPEND_RESUME );
678 if (!process) return;
679 if ((debug_obj = get_debug_obj( current->process, req->debug, DEBUG_PROCESS_ASSIGN )))
681 if (req->attach)
683 if (!process->debug_obj) debugger_attach( process, current, debug_obj );
684 else set_error( STATUS_ACCESS_DENIED );
686 else
688 if (process->debug_obj == debug_obj) debugger_detach( process, debug_obj );
689 else set_error( STATUS_ACCESS_DENIED );
691 release_object( debug_obj );
693 release_object( process );
696 /* queue an exception event */
697 DECL_HANDLER(queue_exception_event)
699 struct debug_obj *debug_obj = current->process->debug_obj;
701 reply->handle = 0;
702 if (debug_obj)
704 debug_event_t data;
705 struct debug_event *event;
706 struct thread *thread = current;
708 if ((req->len % sizeof(client_ptr_t)) != 0 ||
709 req->len > get_req_data_size() ||
710 req->len > EXCEPTION_MAXIMUM_PARAMETERS * sizeof(client_ptr_t))
712 set_error( STATUS_INVALID_PARAMETER );
713 return;
715 memset( &data, 0, sizeof(data) );
716 data.exception.first = req->first;
717 data.exception.exc_code = req->code;
718 data.exception.flags = req->flags;
719 data.exception.record = req->record;
720 data.exception.address = req->address;
721 data.exception.nb_params = req->len / sizeof(client_ptr_t);
722 memcpy( data.exception.params, get_req_data(), req->len );
724 if ((event = alloc_debug_event( thread, EXCEPTION_DEBUG_EVENT, &data )))
726 if ((reply->handle = alloc_handle( thread->process, event, SYNCHRONIZE, 0 )))
728 link_event( debug_obj, event );
729 suspend_process( thread->process );
731 release_object( event );
736 /* retrieve the status of an exception event */
737 DECL_HANDLER(get_exception_status)
739 struct debug_event *event;
741 if ((event = (struct debug_event *)get_handle_obj( current->process, req->handle,
742 0, &debug_event_ops )))
744 close_handle( current->process, req->handle );
745 set_error( event->state == EVENT_CONTINUED ? event->status : STATUS_PENDING );
746 release_object( event );
750 /* set debugger kill on exit flag */
751 DECL_HANDLER(set_debugger_kill_on_exit)
753 if (!current->debug_obj)
755 set_error( STATUS_ACCESS_DENIED );
756 return;
758 current->debug_obj->flags = req->kill_on_exit ? DEBUG_KILL_ON_CLOSE : 0;