~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/server/debugger.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.