Added support for ReadProcessMemory through the server.
[wine] / server / trace.c
1 /*
2  * Server request tracing
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  */
6
7 #include <stdio.h>
8 #include <sys/types.h>
9 #include <sys/uio.h>
10 #include "winsock2.h"
11 #include "request.h"
12
13
14 /* utility functions */
15
16 static void dump_ints( const int *ptr, int len )
17 {
18     fputc( '{', stderr );
19     while (len)
20     {
21         fprintf( stderr, "%d", *ptr++ );
22         if (--len) fputc( ',', stderr );
23     }
24     fputc( '}', stderr );
25 }
26
27 static void dump_bytes( const unsigned char *ptr, int len )
28 {
29     fputc( '{', stderr );
30     while (len)
31     {
32         fprintf( stderr, "%02x", *ptr++ );
33         if (--len) fputc( ',', stderr );
34     }
35     fputc( '}', stderr );
36 }
37
38 /* dumping for functions for requests that have a variable part */
39
40 static void dump_varargs_select( struct select_request *req )
41 {
42     dump_ints( req->handles, req->count );
43 }
44
45 static void dump_varargs_get_apcs( struct get_apcs_request *req )
46 {
47     int i;
48     for (i = 0; i < 2 * req->count; i++)
49         fprintf( stderr, "%c%p", i ? ',' : '{', req->apcs[i] );
50     fprintf( stderr, "}" );
51 }
52
53 static void dump_varargs_get_socket_event( struct get_socket_event_request *req )
54 {
55     dump_ints( req->errors, FD_MAX_EVENTS );
56 }
57
58 static void dump_varargs_read_process_memory( struct read_process_memory_request *req )
59 {
60     int count = MIN( req->len, get_req_size( req->data, sizeof(int) ) );
61     dump_bytes( (unsigned char *)req->data, count * sizeof(int) );
62 }
63
64
65 typedef void (*dump_func)( const void *req );
66
67 /* Everything below this line is generated automatically by tools/make_requests */
68 /* ### make_requests begin ### */
69
70 static void dump_new_process_request( struct new_process_request *req )
71 {
72     fprintf( stderr, " inherit=%d,", req->inherit );
73     fprintf( stderr, " inherit_all=%d,", req->inherit_all );
74     fprintf( stderr, " create_flags=%d,", req->create_flags );
75     fprintf( stderr, " start_flags=%d,", req->start_flags );
76     fprintf( stderr, " hstdin=%d,", req->hstdin );
77     fprintf( stderr, " hstdout=%d,", req->hstdout );
78     fprintf( stderr, " hstderr=%d,", req->hstderr );
79     fprintf( stderr, " event=%d,", req->event );
80     fprintf( stderr, " cmd_show=%d,", req->cmd_show );
81     fprintf( stderr, " env_ptr=%p,", req->env_ptr );
82     fprintf( stderr, " cmdline=\"%s\"", req->cmdline );
83 }
84
85 static void dump_new_process_reply( struct new_process_request *req )
86 {
87     fprintf( stderr, " pid=%p,", req->pid );
88     fprintf( stderr, " handle=%d", req->handle );
89 }
90
91 static void dump_new_thread_request( struct new_thread_request *req )
92 {
93     fprintf( stderr, " pid=%p,", req->pid );
94     fprintf( stderr, " suspend=%d,", req->suspend );
95     fprintf( stderr, " inherit=%d", req->inherit );
96 }
97
98 static void dump_new_thread_reply( struct new_thread_request *req )
99 {
100     fprintf( stderr, " tid=%p,", req->tid );
101     fprintf( stderr, " handle=%d", req->handle );
102 }
103
104 static void dump_set_debug_request( struct set_debug_request *req )
105 {
106     fprintf( stderr, " level=%d", req->level );
107 }
108
109 static void dump_init_process_request( struct init_process_request *req )
110 {
111 }
112
113 static void dump_init_process_reply( struct init_process_request *req )
114 {
115     fprintf( stderr, " start_flags=%d,", req->start_flags );
116     fprintf( stderr, " hstdin=%d,", req->hstdin );
117     fprintf( stderr, " hstdout=%d,", req->hstdout );
118     fprintf( stderr, " hstderr=%d,", req->hstderr );
119     fprintf( stderr, " cmd_show=%d,", req->cmd_show );
120     fprintf( stderr, " env_ptr=%p,", req->env_ptr );
121     fprintf( stderr, " cmdline=\"%s\"", req->cmdline );
122 }
123
124 static void dump_init_process_done_request( struct init_process_done_request *req )
125 {
126     fprintf( stderr, " dummy=%d", req->dummy );
127 }
128
129 static void dump_init_thread_request( struct init_thread_request *req )
130 {
131     fprintf( stderr, " unix_pid=%d,", req->unix_pid );
132     fprintf( stderr, " teb=%p", req->teb );
133 }
134
135 static void dump_init_thread_reply( struct init_thread_request *req )
136 {
137     fprintf( stderr, " pid=%p,", req->pid );
138     fprintf( stderr, " tid=%p", req->tid );
139 }
140
141 static void dump_get_thread_buffer_request( struct get_thread_buffer_request *req )
142 {
143     fprintf( stderr, " dummy=%d", req->dummy );
144 }
145
146 static void dump_terminate_process_request( struct terminate_process_request *req )
147 {
148     fprintf( stderr, " handle=%d,", req->handle );
149     fprintf( stderr, " exit_code=%d", req->exit_code );
150 }
151
152 static void dump_terminate_thread_request( struct terminate_thread_request *req )
153 {
154     fprintf( stderr, " handle=%d,", req->handle );
155     fprintf( stderr, " exit_code=%d", req->exit_code );
156 }
157
158 static void dump_get_process_info_request( struct get_process_info_request *req )
159 {
160     fprintf( stderr, " handle=%d", req->handle );
161 }
162
163 static void dump_get_process_info_reply( struct get_process_info_request *req )
164 {
165     fprintf( stderr, " pid=%p,", req->pid );
166     fprintf( stderr, " exit_code=%d,", req->exit_code );
167     fprintf( stderr, " priority=%d,", req->priority );
168     fprintf( stderr, " process_affinity=%d,", req->process_affinity );
169     fprintf( stderr, " system_affinity=%d", req->system_affinity );
170 }
171
172 static void dump_set_process_info_request( struct set_process_info_request *req )
173 {
174     fprintf( stderr, " handle=%d,", req->handle );
175     fprintf( stderr, " mask=%d,", req->mask );
176     fprintf( stderr, " priority=%d,", req->priority );
177     fprintf( stderr, " affinity=%d", req->affinity );
178 }
179
180 static void dump_get_thread_info_request( struct get_thread_info_request *req )
181 {
182     fprintf( stderr, " handle=%d", req->handle );
183 }
184
185 static void dump_get_thread_info_reply( struct get_thread_info_request *req )
186 {
187     fprintf( stderr, " tid=%p,", req->tid );
188     fprintf( stderr, " exit_code=%d,", req->exit_code );
189     fprintf( stderr, " priority=%d", req->priority );
190 }
191
192 static void dump_set_thread_info_request( struct set_thread_info_request *req )
193 {
194     fprintf( stderr, " handle=%d,", req->handle );
195     fprintf( stderr, " mask=%d,", req->mask );
196     fprintf( stderr, " priority=%d,", req->priority );
197     fprintf( stderr, " affinity=%d", req->affinity );
198 }
199
200 static void dump_suspend_thread_request( struct suspend_thread_request *req )
201 {
202     fprintf( stderr, " handle=%d", req->handle );
203 }
204
205 static void dump_suspend_thread_reply( struct suspend_thread_request *req )
206 {
207     fprintf( stderr, " count=%d", req->count );
208 }
209
210 static void dump_resume_thread_request( struct resume_thread_request *req )
211 {
212     fprintf( stderr, " handle=%d", req->handle );
213 }
214
215 static void dump_resume_thread_reply( struct resume_thread_request *req )
216 {
217     fprintf( stderr, " count=%d", req->count );
218 }
219
220 static void dump_debugger_request( struct debugger_request *req )
221 {
222     fprintf( stderr, " op=%d", req->op );
223 }
224
225 static void dump_queue_apc_request( struct queue_apc_request *req )
226 {
227     fprintf( stderr, " handle=%d,", req->handle );
228     fprintf( stderr, " func=%p,", req->func );
229     fprintf( stderr, " param=%p", req->param );
230 }
231
232 static void dump_get_apcs_request( struct get_apcs_request *req )
233 {
234 }
235
236 static void dump_get_apcs_reply( struct get_apcs_request *req )
237 {
238     fprintf( stderr, " count=%d,", req->count );
239     fprintf( stderr, " apcs=" );
240     dump_varargs_get_apcs( req );
241 }
242
243 static void dump_close_handle_request( struct close_handle_request *req )
244 {
245     fprintf( stderr, " handle=%d", req->handle );
246 }
247
248 static void dump_get_handle_info_request( struct get_handle_info_request *req )
249 {
250     fprintf( stderr, " handle=%d", req->handle );
251 }
252
253 static void dump_get_handle_info_reply( struct get_handle_info_request *req )
254 {
255     fprintf( stderr, " flags=%d", req->flags );
256 }
257
258 static void dump_set_handle_info_request( struct set_handle_info_request *req )
259 {
260     fprintf( stderr, " handle=%d,", req->handle );
261     fprintf( stderr, " flags=%d,", req->flags );
262     fprintf( stderr, " mask=%d", req->mask );
263 }
264
265 static void dump_dup_handle_request( struct dup_handle_request *req )
266 {
267     fprintf( stderr, " src_process=%d,", req->src_process );
268     fprintf( stderr, " src_handle=%d,", req->src_handle );
269     fprintf( stderr, " dst_process=%d,", req->dst_process );
270     fprintf( stderr, " access=%08x,", req->access );
271     fprintf( stderr, " inherit=%d,", req->inherit );
272     fprintf( stderr, " options=%d", req->options );
273 }
274
275 static void dump_dup_handle_reply( struct dup_handle_request *req )
276 {
277     fprintf( stderr, " handle=%d", req->handle );
278 }
279
280 static void dump_open_process_request( struct open_process_request *req )
281 {
282     fprintf( stderr, " pid=%p,", req->pid );
283     fprintf( stderr, " access=%08x,", req->access );
284     fprintf( stderr, " inherit=%d", req->inherit );
285 }
286
287 static void dump_open_process_reply( struct open_process_request *req )
288 {
289     fprintf( stderr, " handle=%d", req->handle );
290 }
291
292 static void dump_select_request( struct select_request *req )
293 {
294     fprintf( stderr, " count=%d,", req->count );
295     fprintf( stderr, " flags=%d,", req->flags );
296     fprintf( stderr, " timeout=%d,", req->timeout );
297     fprintf( stderr, " handles=" );
298     dump_varargs_select( req );
299 }
300
301 static void dump_select_reply( struct select_request *req )
302 {
303     fprintf( stderr, " signaled=%d", req->signaled );
304 }
305
306 static void dump_create_event_request( struct create_event_request *req )
307 {
308     fprintf( stderr, " manual_reset=%d,", req->manual_reset );
309     fprintf( stderr, " initial_state=%d,", req->initial_state );
310     fprintf( stderr, " inherit=%d,", req->inherit );
311     fprintf( stderr, " name=\"%s\"", req->name );
312 }
313
314 static void dump_create_event_reply( struct create_event_request *req )
315 {
316     fprintf( stderr, " handle=%d", req->handle );
317 }
318
319 static void dump_event_op_request( struct event_op_request *req )
320 {
321     fprintf( stderr, " handle=%d,", req->handle );
322     fprintf( stderr, " op=%d", req->op );
323 }
324
325 static void dump_open_event_request( struct open_event_request *req )
326 {
327     fprintf( stderr, " access=%08x,", req->access );
328     fprintf( stderr, " inherit=%d,", req->inherit );
329     fprintf( stderr, " name=\"%s\"", req->name );
330 }
331
332 static void dump_open_event_reply( struct open_event_request *req )
333 {
334     fprintf( stderr, " handle=%d", req->handle );
335 }
336
337 static void dump_create_mutex_request( struct create_mutex_request *req )
338 {
339     fprintf( stderr, " owned=%d,", req->owned );
340     fprintf( stderr, " inherit=%d,", req->inherit );
341     fprintf( stderr, " name=\"%s\"", req->name );
342 }
343
344 static void dump_create_mutex_reply( struct create_mutex_request *req )
345 {
346     fprintf( stderr, " handle=%d", req->handle );
347 }
348
349 static void dump_release_mutex_request( struct release_mutex_request *req )
350 {
351     fprintf( stderr, " handle=%d", req->handle );
352 }
353
354 static void dump_open_mutex_request( struct open_mutex_request *req )
355 {
356     fprintf( stderr, " access=%08x,", req->access );
357     fprintf( stderr, " inherit=%d,", req->inherit );
358     fprintf( stderr, " name=\"%s\"", req->name );
359 }
360
361 static void dump_open_mutex_reply( struct open_mutex_request *req )
362 {
363     fprintf( stderr, " handle=%d", req->handle );
364 }
365
366 static void dump_create_semaphore_request( struct create_semaphore_request *req )
367 {
368     fprintf( stderr, " initial=%08x,", req->initial );
369     fprintf( stderr, " max=%08x,", req->max );
370     fprintf( stderr, " inherit=%d,", req->inherit );
371     fprintf( stderr, " name=\"%s\"", req->name );
372 }
373
374 static void dump_create_semaphore_reply( struct create_semaphore_request *req )
375 {
376     fprintf( stderr, " handle=%d", req->handle );
377 }
378
379 static void dump_release_semaphore_request( struct release_semaphore_request *req )
380 {
381     fprintf( stderr, " handle=%d,", req->handle );
382     fprintf( stderr, " count=%08x", req->count );
383 }
384
385 static void dump_release_semaphore_reply( struct release_semaphore_request *req )
386 {
387     fprintf( stderr, " prev_count=%08x", req->prev_count );
388 }
389
390 static void dump_open_semaphore_request( struct open_semaphore_request *req )
391 {
392     fprintf( stderr, " access=%08x,", req->access );
393     fprintf( stderr, " inherit=%d,", req->inherit );
394     fprintf( stderr, " name=\"%s\"", req->name );
395 }
396
397 static void dump_open_semaphore_reply( struct open_semaphore_request *req )
398 {
399     fprintf( stderr, " handle=%d", req->handle );
400 }
401
402 static void dump_create_file_request( struct create_file_request *req )
403 {
404     fprintf( stderr, " access=%08x,", req->access );
405     fprintf( stderr, " inherit=%d,", req->inherit );
406     fprintf( stderr, " sharing=%08x,", req->sharing );
407     fprintf( stderr, " create=%d,", req->create );
408     fprintf( stderr, " attrs=%08x,", req->attrs );
409     fprintf( stderr, " name=\"%s\"", req->name );
410 }
411
412 static void dump_create_file_reply( struct create_file_request *req )
413 {
414     fprintf( stderr, " handle=%d", req->handle );
415 }
416
417 static void dump_alloc_file_handle_request( struct alloc_file_handle_request *req )
418 {
419     fprintf( stderr, " access=%08x", req->access );
420 }
421
422 static void dump_alloc_file_handle_reply( struct alloc_file_handle_request *req )
423 {
424     fprintf( stderr, " handle=%d", req->handle );
425 }
426
427 static void dump_get_read_fd_request( struct get_read_fd_request *req )
428 {
429     fprintf( stderr, " handle=%d", req->handle );
430 }
431
432 static void dump_get_write_fd_request( struct get_write_fd_request *req )
433 {
434     fprintf( stderr, " handle=%d", req->handle );
435 }
436
437 static void dump_set_file_pointer_request( struct set_file_pointer_request *req )
438 {
439     fprintf( stderr, " handle=%d,", req->handle );
440     fprintf( stderr, " low=%d,", req->low );
441     fprintf( stderr, " high=%d,", req->high );
442     fprintf( stderr, " whence=%d", req->whence );
443 }
444
445 static void dump_set_file_pointer_reply( struct set_file_pointer_request *req )
446 {
447     fprintf( stderr, " new_low=%d,", req->new_low );
448     fprintf( stderr, " new_high=%d", req->new_high );
449 }
450
451 static void dump_truncate_file_request( struct truncate_file_request *req )
452 {
453     fprintf( stderr, " handle=%d", req->handle );
454 }
455
456 static void dump_set_file_time_request( struct set_file_time_request *req )
457 {
458     fprintf( stderr, " handle=%d,", req->handle );
459     fprintf( stderr, " access_time=%ld,", req->access_time );
460     fprintf( stderr, " write_time=%ld", req->write_time );
461 }
462
463 static void dump_flush_file_request( struct flush_file_request *req )
464 {
465     fprintf( stderr, " handle=%d", req->handle );
466 }
467
468 static void dump_get_file_info_request( struct get_file_info_request *req )
469 {
470     fprintf( stderr, " handle=%d", req->handle );
471 }
472
473 static void dump_get_file_info_reply( struct get_file_info_request *req )
474 {
475     fprintf( stderr, " type=%d,", req->type );
476     fprintf( stderr, " attr=%d,", req->attr );
477     fprintf( stderr, " access_time=%ld,", req->access_time );
478     fprintf( stderr, " write_time=%ld,", req->write_time );
479     fprintf( stderr, " size_high=%d,", req->size_high );
480     fprintf( stderr, " size_low=%d,", req->size_low );
481     fprintf( stderr, " links=%d,", req->links );
482     fprintf( stderr, " index_high=%d,", req->index_high );
483     fprintf( stderr, " index_low=%d,", req->index_low );
484     fprintf( stderr, " serial=%08x", req->serial );
485 }
486
487 static void dump_lock_file_request( struct lock_file_request *req )
488 {
489     fprintf( stderr, " handle=%d,", req->handle );
490     fprintf( stderr, " offset_low=%08x,", req->offset_low );
491     fprintf( stderr, " offset_high=%08x,", req->offset_high );
492     fprintf( stderr, " count_low=%08x,", req->count_low );
493     fprintf( stderr, " count_high=%08x", req->count_high );
494 }
495
496 static void dump_unlock_file_request( struct unlock_file_request *req )
497 {
498     fprintf( stderr, " handle=%d,", req->handle );
499     fprintf( stderr, " offset_low=%08x,", req->offset_low );
500     fprintf( stderr, " offset_high=%08x,", req->offset_high );
501     fprintf( stderr, " count_low=%08x,", req->count_low );
502     fprintf( stderr, " count_high=%08x", req->count_high );
503 }
504
505 static void dump_create_pipe_request( struct create_pipe_request *req )
506 {
507     fprintf( stderr, " inherit=%d", req->inherit );
508 }
509
510 static void dump_create_pipe_reply( struct create_pipe_request *req )
511 {
512     fprintf( stderr, " handle_read=%d,", req->handle_read );
513     fprintf( stderr, " handle_write=%d", req->handle_write );
514 }
515
516 static void dump_create_socket_request( struct create_socket_request *req )
517 {
518     fprintf( stderr, " access=%08x,", req->access );
519     fprintf( stderr, " inherit=%d,", req->inherit );
520     fprintf( stderr, " family=%d,", req->family );
521     fprintf( stderr, " type=%d,", req->type );
522     fprintf( stderr, " protocol=%d", req->protocol );
523 }
524
525 static void dump_create_socket_reply( struct create_socket_request *req )
526 {
527     fprintf( stderr, " handle=%d", req->handle );
528 }
529
530 static void dump_accept_socket_request( struct accept_socket_request *req )
531 {
532     fprintf( stderr, " lhandle=%d,", req->lhandle );
533     fprintf( stderr, " access=%08x,", req->access );
534     fprintf( stderr, " inherit=%d", req->inherit );
535 }
536
537 static void dump_accept_socket_reply( struct accept_socket_request *req )
538 {
539     fprintf( stderr, " handle=%d", req->handle );
540 }
541
542 static void dump_set_socket_event_request( struct set_socket_event_request *req )
543 {
544     fprintf( stderr, " handle=%d,", req->handle );
545     fprintf( stderr, " mask=%08x,", req->mask );
546     fprintf( stderr, " event=%d", req->event );
547 }
548
549 static void dump_get_socket_event_request( struct get_socket_event_request *req )
550 {
551     fprintf( stderr, " handle=%d,", req->handle );
552     fprintf( stderr, " service=%d,", req->service );
553     fprintf( stderr, " s_event=%d", req->s_event );
554 }
555
556 static void dump_get_socket_event_reply( struct get_socket_event_request *req )
557 {
558     fprintf( stderr, " mask=%08x,", req->mask );
559     fprintf( stderr, " pmask=%08x,", req->pmask );
560     fprintf( stderr, " state=%08x,", req->state );
561     fprintf( stderr, " errors=" );
562     dump_varargs_get_socket_event( req );
563 }
564
565 static void dump_enable_socket_event_request( struct enable_socket_event_request *req )
566 {
567     fprintf( stderr, " handle=%d,", req->handle );
568     fprintf( stderr, " mask=%08x,", req->mask );
569     fprintf( stderr, " sstate=%08x,", req->sstate );
570     fprintf( stderr, " cstate=%08x", req->cstate );
571 }
572
573 static void dump_alloc_console_request( struct alloc_console_request *req )
574 {
575     fprintf( stderr, " access=%08x,", req->access );
576     fprintf( stderr, " inherit=%d", req->inherit );
577 }
578
579 static void dump_alloc_console_reply( struct alloc_console_request *req )
580 {
581     fprintf( stderr, " handle_in=%d,", req->handle_in );
582     fprintf( stderr, " handle_out=%d", req->handle_out );
583 }
584
585 static void dump_free_console_request( struct free_console_request *req )
586 {
587     fprintf( stderr, " dummy=%d", req->dummy );
588 }
589
590 static void dump_open_console_request( struct open_console_request *req )
591 {
592     fprintf( stderr, " output=%d,", req->output );
593     fprintf( stderr, " access=%08x,", req->access );
594     fprintf( stderr, " inherit=%d", req->inherit );
595 }
596
597 static void dump_open_console_reply( struct open_console_request *req )
598 {
599     fprintf( stderr, " handle=%d", req->handle );
600 }
601
602 static void dump_set_console_fd_request( struct set_console_fd_request *req )
603 {
604     fprintf( stderr, " handle=%d,", req->handle );
605     fprintf( stderr, " file_handle=%d,", req->file_handle );
606     fprintf( stderr, " pid=%d", req->pid );
607 }
608
609 static void dump_get_console_mode_request( struct get_console_mode_request *req )
610 {
611     fprintf( stderr, " handle=%d", req->handle );
612 }
613
614 static void dump_get_console_mode_reply( struct get_console_mode_request *req )
615 {
616     fprintf( stderr, " mode=%d", req->mode );
617 }
618
619 static void dump_set_console_mode_request( struct set_console_mode_request *req )
620 {
621     fprintf( stderr, " handle=%d,", req->handle );
622     fprintf( stderr, " mode=%d", req->mode );
623 }
624
625 static void dump_set_console_info_request( struct set_console_info_request *req )
626 {
627     fprintf( stderr, " handle=%d,", req->handle );
628     fprintf( stderr, " mask=%d,", req->mask );
629     fprintf( stderr, " cursor_size=%d,", req->cursor_size );
630     fprintf( stderr, " cursor_visible=%d,", req->cursor_visible );
631     fprintf( stderr, " title=\"%s\"", req->title );
632 }
633
634 static void dump_get_console_info_request( struct get_console_info_request *req )
635 {
636     fprintf( stderr, " handle=%d", req->handle );
637 }
638
639 static void dump_get_console_info_reply( struct get_console_info_request *req )
640 {
641     fprintf( stderr, " cursor_size=%d,", req->cursor_size );
642     fprintf( stderr, " cursor_visible=%d,", req->cursor_visible );
643     fprintf( stderr, " pid=%d,", req->pid );
644     fprintf( stderr, " title=\"%s\"", req->title );
645 }
646
647 static void dump_write_console_input_request( struct write_console_input_request *req )
648 {
649     fprintf( stderr, " handle=%d,", req->handle );
650     fprintf( stderr, " count=%d", req->count );
651 }
652
653 static void dump_write_console_input_reply( struct write_console_input_request *req )
654 {
655     fprintf( stderr, " written=%d", req->written );
656 }
657
658 static void dump_read_console_input_request( struct read_console_input_request *req )
659 {
660     fprintf( stderr, " handle=%d,", req->handle );
661     fprintf( stderr, " count=%d,", req->count );
662     fprintf( stderr, " flush=%d", req->flush );
663 }
664
665 static void dump_read_console_input_reply( struct read_console_input_request *req )
666 {
667     fprintf( stderr, " read=%d", req->read );
668 }
669
670 static void dump_create_change_notification_request( struct create_change_notification_request *req )
671 {
672     fprintf( stderr, " subtree=%d,", req->subtree );
673     fprintf( stderr, " filter=%d", req->filter );
674 }
675
676 static void dump_create_change_notification_reply( struct create_change_notification_request *req )
677 {
678     fprintf( stderr, " handle=%d", req->handle );
679 }
680
681 static void dump_create_mapping_request( struct create_mapping_request *req )
682 {
683     fprintf( stderr, " size_high=%d,", req->size_high );
684     fprintf( stderr, " size_low=%d,", req->size_low );
685     fprintf( stderr, " protect=%d,", req->protect );
686     fprintf( stderr, " inherit=%d,", req->inherit );
687     fprintf( stderr, " file_handle=%d,", req->file_handle );
688     fprintf( stderr, " name=\"%s\"", req->name );
689 }
690
691 static void dump_create_mapping_reply( struct create_mapping_request *req )
692 {
693     fprintf( stderr, " handle=%d", req->handle );
694 }
695
696 static void dump_open_mapping_request( struct open_mapping_request *req )
697 {
698     fprintf( stderr, " access=%08x,", req->access );
699     fprintf( stderr, " inherit=%d,", req->inherit );
700     fprintf( stderr, " name=\"%s\"", req->name );
701 }
702
703 static void dump_open_mapping_reply( struct open_mapping_request *req )
704 {
705     fprintf( stderr, " handle=%d", req->handle );
706 }
707
708 static void dump_get_mapping_info_request( struct get_mapping_info_request *req )
709 {
710     fprintf( stderr, " handle=%d", req->handle );
711 }
712
713 static void dump_get_mapping_info_reply( struct get_mapping_info_request *req )
714 {
715     fprintf( stderr, " size_high=%d,", req->size_high );
716     fprintf( stderr, " size_low=%d,", req->size_low );
717     fprintf( stderr, " protect=%d", req->protect );
718 }
719
720 static void dump_create_device_request( struct create_device_request *req )
721 {
722     fprintf( stderr, " access=%08x,", req->access );
723     fprintf( stderr, " inherit=%d,", req->inherit );
724     fprintf( stderr, " id=%d", req->id );
725 }
726
727 static void dump_create_device_reply( struct create_device_request *req )
728 {
729     fprintf( stderr, " handle=%d", req->handle );
730 }
731
732 static void dump_create_snapshot_request( struct create_snapshot_request *req )
733 {
734     fprintf( stderr, " inherit=%d,", req->inherit );
735     fprintf( stderr, " flags=%d", req->flags );
736 }
737
738 static void dump_create_snapshot_reply( struct create_snapshot_request *req )
739 {
740     fprintf( stderr, " handle=%d", req->handle );
741 }
742
743 static void dump_next_process_request( struct next_process_request *req )
744 {
745     fprintf( stderr, " handle=%d,", req->handle );
746     fprintf( stderr, " reset=%d", req->reset );
747 }
748
749 static void dump_next_process_reply( struct next_process_request *req )
750 {
751     fprintf( stderr, " pid=%p,", req->pid );
752     fprintf( stderr, " threads=%d,", req->threads );
753     fprintf( stderr, " priority=%d", req->priority );
754 }
755
756 static void dump_wait_debug_event_request( struct wait_debug_event_request *req )
757 {
758     fprintf( stderr, " timeout=%d", req->timeout );
759 }
760
761 static void dump_wait_debug_event_reply( struct wait_debug_event_request *req )
762 {
763     fprintf( stderr, " code=%d,", req->code );
764     fprintf( stderr, " pid=%p,", req->pid );
765     fprintf( stderr, " tid=%p", req->tid );
766 }
767
768 static void dump_send_debug_event_request( struct send_debug_event_request *req )
769 {
770     fprintf( stderr, " code=%d", req->code );
771 }
772
773 static void dump_send_debug_event_reply( struct send_debug_event_request *req )
774 {
775     fprintf( stderr, " status=%d", req->status );
776 }
777
778 static void dump_continue_debug_event_request( struct continue_debug_event_request *req )
779 {
780     fprintf( stderr, " pid=%p,", req->pid );
781     fprintf( stderr, " tid=%p,", req->tid );
782     fprintf( stderr, " status=%d", req->status );
783 }
784
785 static void dump_debug_process_request( struct debug_process_request *req )
786 {
787     fprintf( stderr, " pid=%p", req->pid );
788 }
789
790 static void dump_read_process_memory_request( struct read_process_memory_request *req )
791 {
792     fprintf( stderr, " handle=%d,", req->handle );
793     fprintf( stderr, " addr=%p,", req->addr );
794     fprintf( stderr, " len=%d", req->len );
795 }
796
797 static void dump_read_process_memory_reply( struct read_process_memory_request *req )
798 {
799     fprintf( stderr, " data=" );
800     dump_varargs_read_process_memory( req );
801 }
802
803 static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
804     (dump_func)dump_new_process_request,
805     (dump_func)dump_new_thread_request,
806     (dump_func)dump_set_debug_request,
807     (dump_func)dump_init_process_request,
808     (dump_func)dump_init_process_done_request,
809     (dump_func)dump_init_thread_request,
810     (dump_func)dump_get_thread_buffer_request,
811     (dump_func)dump_terminate_process_request,
812     (dump_func)dump_terminate_thread_request,
813     (dump_func)dump_get_process_info_request,
814     (dump_func)dump_set_process_info_request,
815     (dump_func)dump_get_thread_info_request,
816     (dump_func)dump_set_thread_info_request,
817     (dump_func)dump_suspend_thread_request,
818     (dump_func)dump_resume_thread_request,
819     (dump_func)dump_debugger_request,
820     (dump_func)dump_queue_apc_request,
821     (dump_func)dump_get_apcs_request,
822     (dump_func)dump_close_handle_request,
823     (dump_func)dump_get_handle_info_request,
824     (dump_func)dump_set_handle_info_request,
825     (dump_func)dump_dup_handle_request,
826     (dump_func)dump_open_process_request,
827     (dump_func)dump_select_request,
828     (dump_func)dump_create_event_request,
829     (dump_func)dump_event_op_request,
830     (dump_func)dump_open_event_request,
831     (dump_func)dump_create_mutex_request,
832     (dump_func)dump_release_mutex_request,
833     (dump_func)dump_open_mutex_request,
834     (dump_func)dump_create_semaphore_request,
835     (dump_func)dump_release_semaphore_request,
836     (dump_func)dump_open_semaphore_request,
837     (dump_func)dump_create_file_request,
838     (dump_func)dump_alloc_file_handle_request,
839     (dump_func)dump_get_read_fd_request,
840     (dump_func)dump_get_write_fd_request,
841     (dump_func)dump_set_file_pointer_request,
842     (dump_func)dump_truncate_file_request,
843     (dump_func)dump_set_file_time_request,
844     (dump_func)dump_flush_file_request,
845     (dump_func)dump_get_file_info_request,
846     (dump_func)dump_lock_file_request,
847     (dump_func)dump_unlock_file_request,
848     (dump_func)dump_create_pipe_request,
849     (dump_func)dump_create_socket_request,
850     (dump_func)dump_accept_socket_request,
851     (dump_func)dump_set_socket_event_request,
852     (dump_func)dump_get_socket_event_request,
853     (dump_func)dump_enable_socket_event_request,
854     (dump_func)dump_alloc_console_request,
855     (dump_func)dump_free_console_request,
856     (dump_func)dump_open_console_request,
857     (dump_func)dump_set_console_fd_request,
858     (dump_func)dump_get_console_mode_request,
859     (dump_func)dump_set_console_mode_request,
860     (dump_func)dump_set_console_info_request,
861     (dump_func)dump_get_console_info_request,
862     (dump_func)dump_write_console_input_request,
863     (dump_func)dump_read_console_input_request,
864     (dump_func)dump_create_change_notification_request,
865     (dump_func)dump_create_mapping_request,
866     (dump_func)dump_open_mapping_request,
867     (dump_func)dump_get_mapping_info_request,
868     (dump_func)dump_create_device_request,
869     (dump_func)dump_create_snapshot_request,
870     (dump_func)dump_next_process_request,
871     (dump_func)dump_wait_debug_event_request,
872     (dump_func)dump_send_debug_event_request,
873     (dump_func)dump_continue_debug_event_request,
874     (dump_func)dump_debug_process_request,
875     (dump_func)dump_read_process_memory_request,
876 };
877
878 static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
879     (dump_func)dump_new_process_reply,
880     (dump_func)dump_new_thread_reply,
881     (dump_func)0,
882     (dump_func)dump_init_process_reply,
883     (dump_func)0,
884     (dump_func)dump_init_thread_reply,
885     (dump_func)0,
886     (dump_func)0,
887     (dump_func)0,
888     (dump_func)dump_get_process_info_reply,
889     (dump_func)0,
890     (dump_func)dump_get_thread_info_reply,
891     (dump_func)0,
892     (dump_func)dump_suspend_thread_reply,
893     (dump_func)dump_resume_thread_reply,
894     (dump_func)0,
895     (dump_func)0,
896     (dump_func)dump_get_apcs_reply,
897     (dump_func)0,
898     (dump_func)dump_get_handle_info_reply,
899     (dump_func)0,
900     (dump_func)dump_dup_handle_reply,
901     (dump_func)dump_open_process_reply,
902     (dump_func)dump_select_reply,
903     (dump_func)dump_create_event_reply,
904     (dump_func)0,
905     (dump_func)dump_open_event_reply,
906     (dump_func)dump_create_mutex_reply,
907     (dump_func)0,
908     (dump_func)dump_open_mutex_reply,
909     (dump_func)dump_create_semaphore_reply,
910     (dump_func)dump_release_semaphore_reply,
911     (dump_func)dump_open_semaphore_reply,
912     (dump_func)dump_create_file_reply,
913     (dump_func)dump_alloc_file_handle_reply,
914     (dump_func)0,
915     (dump_func)0,
916     (dump_func)dump_set_file_pointer_reply,
917     (dump_func)0,
918     (dump_func)0,
919     (dump_func)0,
920     (dump_func)dump_get_file_info_reply,
921     (dump_func)0,
922     (dump_func)0,
923     (dump_func)dump_create_pipe_reply,
924     (dump_func)dump_create_socket_reply,
925     (dump_func)dump_accept_socket_reply,
926     (dump_func)0,
927     (dump_func)dump_get_socket_event_reply,
928     (dump_func)0,
929     (dump_func)dump_alloc_console_reply,
930     (dump_func)0,
931     (dump_func)dump_open_console_reply,
932     (dump_func)0,
933     (dump_func)dump_get_console_mode_reply,
934     (dump_func)0,
935     (dump_func)0,
936     (dump_func)dump_get_console_info_reply,
937     (dump_func)dump_write_console_input_reply,
938     (dump_func)dump_read_console_input_reply,
939     (dump_func)dump_create_change_notification_reply,
940     (dump_func)dump_create_mapping_reply,
941     (dump_func)dump_open_mapping_reply,
942     (dump_func)dump_get_mapping_info_reply,
943     (dump_func)dump_create_device_reply,
944     (dump_func)dump_create_snapshot_reply,
945     (dump_func)dump_next_process_reply,
946     (dump_func)dump_wait_debug_event_reply,
947     (dump_func)dump_send_debug_event_reply,
948     (dump_func)0,
949     (dump_func)0,
950     (dump_func)dump_read_process_memory_reply,
951 };
952
953 static const char * const req_names[REQ_NB_REQUESTS] = {
954     "new_process",
955     "new_thread",
956     "set_debug",
957     "init_process",
958     "init_process_done",
959     "init_thread",
960     "get_thread_buffer",
961     "terminate_process",
962     "terminate_thread",
963     "get_process_info",
964     "set_process_info",
965     "get_thread_info",
966     "set_thread_info",
967     "suspend_thread",
968     "resume_thread",
969     "debugger",
970     "queue_apc",
971     "get_apcs",
972     "close_handle",
973     "get_handle_info",
974     "set_handle_info",
975     "dup_handle",
976     "open_process",
977     "select",
978     "create_event",
979     "event_op",
980     "open_event",
981     "create_mutex",
982     "release_mutex",
983     "open_mutex",
984     "create_semaphore",
985     "release_semaphore",
986     "open_semaphore",
987     "create_file",
988     "alloc_file_handle",
989     "get_read_fd",
990     "get_write_fd",
991     "set_file_pointer",
992     "truncate_file",
993     "set_file_time",
994     "flush_file",
995     "get_file_info",
996     "lock_file",
997     "unlock_file",
998     "create_pipe",
999     "create_socket",
1000     "accept_socket",
1001     "set_socket_event",
1002     "get_socket_event",
1003     "enable_socket_event",
1004     "alloc_console",
1005     "free_console",
1006     "open_console",
1007     "set_console_fd",
1008     "get_console_mode",
1009     "set_console_mode",
1010     "set_console_info",
1011     "get_console_info",
1012     "write_console_input",
1013     "read_console_input",
1014     "create_change_notification",
1015     "create_mapping",
1016     "open_mapping",
1017     "get_mapping_info",
1018     "create_device",
1019     "create_snapshot",
1020     "next_process",
1021     "wait_debug_event",
1022     "send_debug_event",
1023     "continue_debug_event",
1024     "debug_process",
1025     "read_process_memory",
1026 };
1027
1028 /* ### make_requests end ### */
1029 /* Everything above this line is generated automatically by tools/make_requests */
1030
1031 void trace_request( enum request req, int fd )
1032 {
1033     current->last_req = req;
1034     if (req < REQ_NB_REQUESTS)
1035     {
1036         fprintf( stderr, "%08x: %s(", (unsigned int)current, req_names[req] );
1037         req_dumpers[req]( current->buffer );
1038     }
1039     else
1040         fprintf( stderr, "%08x: %d(", (unsigned int)current, req );
1041     if (fd != -1) fprintf( stderr, " ) fd=%d\n", fd );
1042     else fprintf( stderr, " )\n" );
1043 }
1044
1045 void trace_timeout(void)
1046 {
1047     fprintf( stderr, "%08x: *timeout*\n", (unsigned int)current );
1048 }
1049
1050 void trace_kill( int exit_code )
1051 {
1052     fprintf( stderr,"%08x: *killed* exit_code=%d\n",
1053              (unsigned int)current, exit_code );
1054 }
1055
1056 void trace_reply( struct thread *thread, unsigned int res, int pass_fd )
1057 {
1058     fprintf( stderr, "%08x: %s() = %d",
1059              (unsigned int)thread, req_names[thread->last_req], res );
1060     if (reply_dumpers[thread->last_req])
1061     {
1062         fprintf( stderr, " {" );
1063         reply_dumpers[thread->last_req]( thread->buffer );
1064         fprintf( stderr, " }" );
1065     }
1066     if (pass_fd != -1) fprintf( stderr, " fd=%d\n", pass_fd );
1067     else fprintf( stderr, "\n" );
1068 }