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
22 #include "wine/port.h"
31 #define WIN32_NO_STATUS
41 enum debug_event_state
{ EVENT_QUEUED
, EVENT_SENT
, EVENT_DELAYED
, EVENT_CONTINUED
};
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 */
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 const client_ptr_t
*entry
= arg
;
136 if (entry
) event
->data
.create_thread
.start
= *entry
;
139 static void fill_create_process_event( struct debug_event
*event
, const void *arg
)
141 const struct memory_view
*view
= arg
;
142 const pe_image_info_t
*image_info
= get_view_image_info( view
, &event
->data
.create_process
.base
);
144 event
->data
.create_process
.start
= image_info
->entry_point
;
145 event
->data
.create_process
.dbg_offset
= image_info
->dbg_offset
;
146 event
->data
.create_process
.dbg_size
= image_info
->dbg_size
;
147 /* the doc says write access too, but this doesn't seem a good idea */
148 event
->file
= get_view_file( view
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
);
151 static void fill_exit_thread_event( struct debug_event
*event
, const void *arg
)
153 const struct thread
*thread
= arg
;
154 event
->data
.exit
.exit_code
= thread
->exit_code
;
157 static void fill_exit_process_event( struct debug_event
*event
, const void *arg
)
159 const struct process
*process
= arg
;
160 event
->data
.exit
.exit_code
= process
->exit_code
;
163 static void fill_load_dll_event( struct debug_event
*event
, const void *arg
)
165 struct process
*process
= event
->sender
->process
;
166 const struct process_dll
*dll
= arg
;
167 struct memory_view
*view
= find_mapped_view( process
, dll
->base
);
168 const pe_image_info_t
*image_info
= get_view_image_info( view
, &event
->data
.load_dll
.base
);
170 event
->data
.load_dll
.dbg_offset
= image_info
->dbg_offset
;
171 event
->data
.load_dll
.dbg_size
= image_info
->dbg_size
;
172 event
->data
.load_dll
.name
= dll
->name
;
173 event
->file
= get_view_file( view
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
);
176 static void fill_unload_dll_event( struct debug_event
*event
, const void *arg
)
178 const mod_handle_t
*base
= arg
;
179 event
->data
.unload_dll
.base
= *base
;
182 typedef void (*fill_event_func
)( struct debug_event
*event
, const void *arg
);
184 static const fill_event_func fill_debug_event
[] =
186 fill_create_thread_event
, /* DbgCreateThreadStateChange */
187 fill_create_process_event
, /* DbgCreateProcessStateChange */
188 fill_exit_thread_event
, /* DbgExitThreadStateChange */
189 fill_exit_process_event
, /* DbgExitProcessStateChange */
190 fill_exception_event
, /* DbgExceptionStateChange */
191 fill_exception_event
, /* DbgBreakpointStateChange */
192 fill_exception_event
, /* DbgSingleStepStateChange */
193 fill_load_dll_event
, /* DbgLoadDllStateChange */
194 fill_unload_dll_event
/* DbgUnloadDllStateChange */
197 /* allocate the necessary handles in the event data */
198 static void alloc_event_handles( struct debug_event
*event
, struct process
*process
)
200 switch (event
->data
.code
)
202 case DbgCreateThreadStateChange
:
203 /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
204 event
->data
.create_thread
.handle
= alloc_handle( process
, event
->sender
, THREAD_ALL_ACCESS
, 0 );
206 case DbgCreateProcessStateChange
:
207 event
->data
.create_process
.thread
= alloc_handle( process
, event
->sender
, THREAD_ALL_ACCESS
, 0 );
208 /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
209 event
->data
.create_process
.process
= alloc_handle( process
, event
->sender
->process
,
210 PROCESS_ALL_ACCESS
, 0 );
212 event
->data
.create_process
.file
= alloc_handle( process
, event
->file
, GENERIC_READ
, 0 );
214 case DbgLoadDllStateChange
:
216 event
->data
.load_dll
.handle
= alloc_handle( process
, event
->file
, GENERIC_READ
, 0 );
219 clear_error(); /* ignore errors, simply set handles to 0 */
222 /* unlink the first event from the queue */
223 static void unlink_event( struct debug_obj
*debug_obj
, struct debug_event
*event
)
225 list_remove( &event
->entry
);
226 if (event
->sender
->process
->debug_event
== event
) event
->sender
->process
->debug_event
= NULL
;
227 release_object( event
);
230 /* link an event at the end of the queue */
231 static void link_event( struct debug_obj
*debug_obj
, struct debug_event
*event
)
233 grab_object( event
);
234 list_add_tail( &debug_obj
->event_queue
, &event
->entry
);
235 if (!event
->sender
->process
->debug_event
)
237 /* grab reference since debugger could be killed while trying to wake up */
238 grab_object( debug_obj
);
239 wake_up( &debug_obj
->obj
, 0 );
240 release_object( debug_obj
);
244 /* resume a delayed debug event already in the queue */
245 static void resume_event( struct debug_obj
*debug_obj
, struct debug_event
*event
)
247 event
->state
= EVENT_QUEUED
;
248 if (!event
->sender
->process
->debug_event
)
250 grab_object( debug_obj
);
251 wake_up( &debug_obj
->obj
, 0 );
252 release_object( debug_obj
);
256 /* delay a debug event already in the queue to be replayed when thread wakes up */
257 static void delay_event( struct debug_obj
*debug_obj
, struct debug_event
*event
)
259 event
->state
= EVENT_DELAYED
;
260 if (event
->sender
->process
->debug_event
== event
) event
->sender
->process
->debug_event
= NULL
;
263 /* find the next event that we can send to the debugger */
264 static struct debug_event
*find_event_to_send( struct debug_obj
*debug_obj
)
266 struct debug_event
*event
;
268 LIST_FOR_EACH_ENTRY( event
, &debug_obj
->event_queue
, struct debug_event
, entry
)
270 if (event
->state
== EVENT_SENT
) continue; /* already sent */
271 if (event
->state
== EVENT_DELAYED
) continue; /* delayed until thread resumes */
272 if (event
->sender
->process
->debug_event
) continue; /* process busy with another one */
278 static void debug_event_dump( struct object
*obj
, int verbose
)
280 struct debug_event
*debug_event
= (struct debug_event
*)obj
;
281 assert( obj
->ops
== &debug_event_ops
);
282 fprintf( stderr
, "Debug event sender=%p code=%d state=%d\n",
283 debug_event
->sender
, debug_event
->data
.code
, debug_event
->state
);
286 static int debug_event_signaled( struct object
*obj
, struct wait_queue_entry
*entry
)
288 struct debug_event
*debug_event
= (struct debug_event
*)obj
;
289 assert( obj
->ops
== &debug_event_ops
);
290 return debug_event
->state
== EVENT_CONTINUED
;
293 static void debug_event_destroy( struct object
*obj
)
295 struct debug_event
*event
= (struct debug_event
*)obj
;
296 assert( obj
->ops
== &debug_event_ops
);
298 if (event
->file
) release_object( event
->file
);
299 release_object( event
->sender
);
302 static void debug_obj_dump( struct object
*obj
, int verbose
)
304 struct debug_obj
*debug_obj
= (struct debug_obj
*)obj
;
305 assert( obj
->ops
== &debug_obj_ops
);
306 fprintf( stderr
, "Debug context head=%p tail=%p\n",
307 debug_obj
->event_queue
.next
, debug_obj
->event_queue
.prev
);
310 static struct object_type
*debug_obj_get_type( struct object
*obj
)
312 static const WCHAR name
[] = {'D','e','b','u','g','O','b','j','e','c','t'};
313 static const struct unicode_str str
= { name
, sizeof(name
) };
314 return get_object_type( &str
);
317 static int debug_obj_signaled( struct object
*obj
, struct wait_queue_entry
*entry
)
319 struct debug_obj
*debug_obj
= (struct debug_obj
*)obj
;
320 assert( obj
->ops
== &debug_obj_ops
);
321 return find_event_to_send( debug_obj
) != NULL
;
324 static unsigned int debug_obj_map_access( struct object
*obj
, unsigned int access
)
326 if (access
& GENERIC_READ
) access
|= STANDARD_RIGHTS_READ
| DEBUG_READ_EVENT
| DEBUG_QUERY_INFORMATION
;
327 if (access
& GENERIC_WRITE
) access
|= STANDARD_RIGHTS_WRITE
| DEBUG_SET_INFORMATION
;
328 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
| DEBUG_PROCESS_ASSIGN
;
329 if (access
& GENERIC_ALL
) access
|= STANDARD_RIGHTS_ALL
| EVENT_QUERY_STATE
| EVENT_MODIFY_STATE
;
330 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
333 static void debug_obj_destroy( struct object
*obj
)
336 struct debug_obj
*debug_obj
= (struct debug_obj
*)obj
;
337 assert( obj
->ops
== &debug_obj_ops
);
339 detach_debugged_processes( debug_obj
,
340 (debug_obj
->flags
& DEBUG_KILL_ON_CLOSE
) ? STATUS_DEBUGGER_INACTIVE
: 0 );
342 /* free all pending events */
343 while ((ptr
= list_head( &debug_obj
->event_queue
)))
344 unlink_event( debug_obj
, LIST_ENTRY( ptr
, struct debug_event
, entry
));
347 struct debug_obj
*get_debug_obj( struct process
*process
, obj_handle_t handle
, unsigned int access
)
349 return (struct debug_obj
*)get_handle_obj( process
, handle
, access
, &debug_obj_ops
);
352 static struct debug_obj
*create_debug_obj( struct object
*root
, const struct unicode_str
*name
,
353 unsigned int attr
, unsigned int flags
,
354 const struct security_descriptor
*sd
)
356 struct debug_obj
*debug_obj
;
358 if ((debug_obj
= create_named_object( root
, &debug_obj_ops
, name
, attr
, sd
)))
360 if (get_error() != STATUS_OBJECT_NAME_EXISTS
)
362 debug_obj
->flags
= flags
;
363 list_init( &debug_obj
->event_queue
);
369 /* continue a debug event */
370 static int continue_debug_event( struct debug_obj
*debug_obj
, struct process
*process
,
371 struct thread
*thread
, int status
)
373 if (process
->debug_obj
== debug_obj
&& thread
->process
== process
)
375 struct debug_event
*event
;
377 if (status
== DBG_REPLY_LATER
)
379 /* if thread is suspended, delay all its events and resume process
380 * if not, reset the event for immediate replay */
381 LIST_FOR_EACH_ENTRY( event
, &debug_obj
->event_queue
, struct debug_event
, entry
)
383 if (event
->sender
!= thread
) continue;
386 delay_event( debug_obj
, event
);
387 resume_process( process
);
389 else if (event
->state
== EVENT_SENT
)
391 assert( event
->sender
->process
->debug_event
== event
);
392 event
->sender
->process
->debug_event
= NULL
;
393 resume_event( debug_obj
, event
);
400 /* find the event in the queue */
401 LIST_FOR_EACH_ENTRY( event
, &debug_obj
->event_queue
, struct debug_event
, entry
)
403 if (event
->state
!= EVENT_SENT
) continue;
404 if (event
->sender
== thread
)
406 assert( event
->sender
->process
->debug_event
== event
);
407 event
->status
= status
;
408 event
->state
= EVENT_CONTINUED
;
409 wake_up( &event
->obj
, 0 );
410 unlink_event( debug_obj
, event
);
411 resume_process( process
);
416 /* not debugging this process, or no such event */
417 set_error( STATUS_ACCESS_DENIED
); /* FIXME */
421 /* alloc a debug event for a debugger */
422 static struct debug_event
*alloc_debug_event( struct thread
*thread
, int code
, const void *arg
)
424 struct debug_event
*event
;
426 assert( code
>= DbgCreateThreadStateChange
&& code
<= DbgUnloadDllStateChange
);
428 /* build the event */
429 if (!(event
= alloc_object( &debug_event_ops
))) return NULL
;
430 event
->state
= EVENT_QUEUED
;
431 event
->sender
= (struct thread
*)grab_object( thread
);
433 memset( &event
->data
, 0, sizeof(event
->data
) );
434 fill_debug_event
[code
- DbgCreateThreadStateChange
]( event
, arg
);
435 event
->data
.code
= code
;
439 /* generate a debug event from inside the server and queue it */
440 void generate_debug_event( struct thread
*thread
, int code
, const void *arg
)
442 struct debug_obj
*debug_obj
= thread
->process
->debug_obj
;
446 struct debug_event
*event
= alloc_debug_event( thread
, code
, arg
);
449 link_event( debug_obj
, event
);
450 suspend_process( thread
->process
);
451 release_object( event
);
453 clear_error(); /* ignore errors */
457 void resume_delayed_debug_events( struct thread
*thread
)
459 struct debug_obj
*debug_obj
= thread
->process
->debug_obj
;
460 struct debug_event
*event
;
464 LIST_FOR_EACH_ENTRY( event
, &debug_obj
->event_queue
, struct debug_event
, entry
)
466 if (event
->sender
!= thread
) continue;
467 if (event
->state
!= EVENT_DELAYED
) continue;
468 resume_event( debug_obj
, event
);
469 suspend_process( thread
->process
);
474 /* attach a process to a debugger thread and suspend it */
475 static int debugger_attach( struct process
*process
, struct thread
*debugger
, struct debug_obj
*debug_obj
)
477 if (debugger
->process
== process
) goto error
;
478 if (!is_process_init_done( process
)) goto error
; /* still starting up */
479 if (list_empty( &process
->thread_list
)) goto error
; /* no thread running in the process */
480 /* don't let a debugger debug its console... won't work */
481 if (debugger
->process
->console
)
483 struct thread
*renderer
= console_get_renderer(debugger
->process
->console
);
484 if (renderer
&& renderer
->process
== process
) goto error
;
487 suspend_process( process
);
489 if (!set_process_debug_flag( process
, 1 ))
491 resume_process( process
);
494 process
->debug_obj
= debug_obj
;
495 process
->debug_children
= 0;
496 generate_startup_debug_events( process
);
497 resume_process( process
);
501 set_error( STATUS_ACCESS_DENIED
);
506 /* detach a process from a debugger thread (and resume it) */
507 void debugger_detach( struct process
*process
, struct debug_obj
*debug_obj
)
509 struct debug_event
*event
, *next
;
511 suspend_process( process
);
513 /* send continue indication for all events */
514 LIST_FOR_EACH_ENTRY_SAFE( event
, next
, &debug_obj
->event_queue
, struct debug_event
, entry
)
516 if (event
->sender
->process
!= process
) continue;
518 assert( event
->state
!= EVENT_CONTINUED
);
519 event
->status
= DBG_CONTINUE
;
520 event
->state
= EVENT_CONTINUED
;
521 wake_up( &event
->obj
, 0 );
522 unlink_event( debug_obj
, event
);
523 /* from queued debug event */
524 resume_process( process
);
527 /* remove relationships between process and its debugger */
528 process
->debug_obj
= NULL
;
529 if (!set_process_debug_flag( process
, 0 )) clear_error(); /* ignore error */
531 resume_process( process
);
534 /* generate all startup events of a given process */
535 void generate_startup_debug_events( struct process
*process
)
538 struct memory_view
*view
= get_exe_view( process
);
539 struct thread
*thread
, *first_thread
= get_process_first_thread( process
);
542 generate_debug_event( first_thread
, DbgCreateProcessStateChange
, view
);
543 ptr
= list_head( &process
->dlls
); /* skip main module reported in create process event */
545 /* generate ntdll.dll load event */
546 if (ptr
&& (ptr
= list_next( &process
->dlls
, ptr
)))
548 struct process_dll
*dll
= LIST_ENTRY( ptr
, struct process_dll
, entry
);
549 generate_debug_event( first_thread
, DbgLoadDllStateChange
, dll
);
552 /* generate creation events */
553 LIST_FOR_EACH_ENTRY( thread
, &process
->thread_list
, struct thread
, proc_entry
)
555 if (thread
!= first_thread
)
556 generate_debug_event( thread
, DbgCreateThreadStateChange
, NULL
);
559 /* generate dll events (in loading order) */
560 while (ptr
&& (ptr
= list_next( &process
->dlls
, ptr
)))
562 struct process_dll
*dll
= LIST_ENTRY( ptr
, struct process_dll
, entry
);
563 generate_debug_event( first_thread
, DbgLoadDllStateChange
, dll
);
567 /* create a debug object */
568 DECL_HANDLER(create_debug_obj
)
570 struct debug_obj
*debug_obj
;
571 struct unicode_str name
;
573 const struct security_descriptor
*sd
;
574 const struct object_attributes
*objattr
= get_req_object_attributes( &sd
, &name
, &root
);
576 if (!objattr
) return;
577 if ((debug_obj
= create_debug_obj( root
, &name
, objattr
->attributes
, req
->flags
, sd
)))
579 if (get_error() == STATUS_OBJECT_NAME_EXISTS
)
580 reply
->handle
= alloc_handle( current
->process
, debug_obj
, req
->access
, objattr
->attributes
);
582 reply
->handle
= alloc_handle_no_access_check( current
->process
, debug_obj
,
583 req
->access
, objattr
->attributes
);
584 release_object( debug_obj
);
586 if (root
) release_object( root
);
589 /* Wait for a debug event */
590 DECL_HANDLER(wait_debug_event
)
592 struct debug_obj
*debug_obj
;
593 struct debug_event
*event
;
595 if (!(debug_obj
= get_debug_obj( current
->process
, req
->debug
, DEBUG_READ_EVENT
))) return;
597 if ((event
= find_event_to_send( debug_obj
)))
599 event
->state
= EVENT_SENT
;
600 event
->sender
->process
->debug_event
= event
;
601 reply
->pid
= get_process_id( event
->sender
->process
);
602 reply
->tid
= get_thread_id( event
->sender
);
603 alloc_event_handles( event
, current
->process
);
604 set_reply_data( &event
->data
, min( get_reply_max_size(), sizeof(event
->data
) ));
608 int state
= list_empty( &debug_obj
->event_queue
) ? DbgIdle
: DbgReplyPending
;
609 set_reply_data( &state
, min( get_reply_max_size(), sizeof(state
) ));
611 release_object( debug_obj
);
614 /* Continue a debug event */
615 DECL_HANDLER(continue_debug_event
)
617 struct debug_obj
*debug_obj
;
618 struct process
*process
;
620 if (req
->status
!= DBG_EXCEPTION_NOT_HANDLED
&&
621 req
->status
!= DBG_EXCEPTION_HANDLED
&&
622 req
->status
!= DBG_CONTINUE
&&
623 req
->status
!= DBG_REPLY_LATER
)
625 set_error( STATUS_INVALID_PARAMETER
);
629 if (!(debug_obj
= get_debug_obj( current
->process
, req
->debug
, DEBUG_READ_EVENT
))) return;
631 if ((process
= get_process_from_id( req
->pid
)))
633 struct thread
*thread
= get_thread_from_id( req
->tid
);
636 continue_debug_event( debug_obj
, process
, thread
, req
->status
);
637 release_object( thread
);
639 release_object( process
);
641 release_object( debug_obj
);
644 /* start or stop debugging an existing process */
645 DECL_HANDLER(debug_process
)
647 struct debug_obj
*debug_obj
;
648 struct process
*process
= get_process_from_handle( req
->handle
,
649 PROCESS_VM_READ
| PROCESS_VM_WRITE
| PROCESS_SUSPEND_RESUME
);
651 if (!process
) return;
652 if ((debug_obj
= get_debug_obj( current
->process
, req
->debug
, DEBUG_PROCESS_ASSIGN
)))
656 if (!process
->debug_obj
) debugger_attach( process
, current
, debug_obj
);
657 else set_error( STATUS_ACCESS_DENIED
);
661 if (process
->debug_obj
== debug_obj
) debugger_detach( process
, debug_obj
);
662 else set_error( STATUS_ACCESS_DENIED
);
664 release_object( debug_obj
);
666 release_object( process
);
669 /* queue an exception event */
670 DECL_HANDLER(queue_exception_event
)
672 struct debug_obj
*debug_obj
= current
->process
->debug_obj
;
678 struct debug_event
*event
;
679 struct thread
*thread
= current
;
681 if ((req
->len
% sizeof(client_ptr_t
)) != 0 ||
682 req
->len
> get_req_data_size() ||
683 req
->len
> EXCEPTION_MAXIMUM_PARAMETERS
* sizeof(client_ptr_t
))
685 set_error( STATUS_INVALID_PARAMETER
);
688 memset( &data
, 0, sizeof(data
) );
689 data
.exception
.first
= req
->first
;
690 data
.exception
.exc_code
= req
->code
;
691 data
.exception
.flags
= req
->flags
;
692 data
.exception
.record
= req
->record
;
693 data
.exception
.address
= req
->address
;
694 data
.exception
.nb_params
= req
->len
/ sizeof(client_ptr_t
);
695 memcpy( data
.exception
.params
, get_req_data(), req
->len
);
697 if ((event
= alloc_debug_event( thread
, DbgExceptionStateChange
, &data
)))
699 if ((reply
->handle
= alloc_handle( thread
->process
, event
, SYNCHRONIZE
, 0 )))
701 link_event( debug_obj
, event
);
702 suspend_process( thread
->process
);
704 release_object( event
);
709 /* retrieve the status of an exception event */
710 DECL_HANDLER(get_exception_status
)
712 struct debug_event
*event
;
714 if ((event
= (struct debug_event
*)get_handle_obj( current
->process
, req
->handle
,
715 0, &debug_event_ops
)))
717 close_handle( current
->process
, req
->handle
);
718 set_error( event
->state
== EVENT_CONTINUED
? event
->status
: STATUS_PENDING
);
719 release_object( event
);
723 /* set debug object information */
724 DECL_HANDLER(set_debug_obj_info
)
726 struct debug_obj
*debug_obj
;
728 if (!(debug_obj
= get_debug_obj( current
->process
, req
->debug
, DEBUG_SET_INFORMATION
))) return;
729 debug_obj
->flags
= req
->flags
;
730 release_object( debug_obj
);