Added support for dumping variable-size data of server replies.
Added cmd_line and cmd_show in new_process request.
This commit is contained in:
parent
bfe8c8c808
commit
d2b7a0ba65
|
@ -53,6 +53,7 @@ struct new_process_request
|
|||
int hstdin; /* handle for stdin */
|
||||
int hstdout; /* handle for stdout */
|
||||
int hstderr; /* handle for stderr */
|
||||
int cmd_show; /* main window show mode */
|
||||
void* env_ptr; /* pointer to environment (FIXME: hack) */
|
||||
char cmd_line[0]; /* command line */
|
||||
};
|
||||
|
@ -95,7 +96,9 @@ struct init_process_reply
|
|||
int hstdin; /* handle for stdin */
|
||||
int hstdout; /* handle for stdout */
|
||||
int hstderr; /* handle for stderr */
|
||||
int cmd_show; /* main window show mode */
|
||||
void* env_ptr; /* pointer to environment (FIXME: hack) */
|
||||
char cmdline[0]; /* command line */
|
||||
};
|
||||
|
||||
|
||||
|
@ -285,12 +288,12 @@ struct select_request
|
|||
int count; /* handles count */
|
||||
int flags; /* wait flags (see below) */
|
||||
int timeout; /* timeout in ms */
|
||||
/* int handles[] */
|
||||
int handles[0]; /* handles to select on */
|
||||
};
|
||||
struct select_reply
|
||||
{
|
||||
int signaled; /* signaled handle */
|
||||
/* void* apcs[]; */ /* async procedures to call */
|
||||
void* apcs[0]; /* async procedures to call */
|
||||
};
|
||||
#define SELECT_ALL 1
|
||||
#define SELECT_ALERTABLE 2
|
||||
|
|
|
@ -97,7 +97,7 @@ struct process *create_initial_process(void)
|
|||
}
|
||||
|
||||
/* create a new process */
|
||||
static struct process *create_process( struct new_process_request *req )
|
||||
static struct process *create_process( struct new_process_request *req, const char *cmd_line )
|
||||
{
|
||||
struct process *process = NULL;
|
||||
struct process *parent = current->process;
|
||||
|
@ -110,8 +110,9 @@ static struct process *create_process( struct new_process_request *req )
|
|||
}
|
||||
init_process( process );
|
||||
|
||||
if (!(process->info = mem_alloc( sizeof(*process->info) ))) goto error;
|
||||
if (!(process->info = mem_alloc( sizeof(*process->info) + strlen(cmd_line) + 1 ))) goto error;
|
||||
memcpy( process->info, req, sizeof(*req) );
|
||||
strcpy( process->info->cmd_line, cmd_line );
|
||||
|
||||
/* set the process console */
|
||||
if (req->create_flags & CREATE_NEW_CONSOLE)
|
||||
|
@ -202,21 +203,6 @@ struct process *get_process_from_handle( int handle, unsigned int access )
|
|||
access, &process_ops );
|
||||
}
|
||||
|
||||
/* retrieve the initialization info for a new process */
|
||||
static int get_process_init_info( struct process *process, struct init_process_reply *reply )
|
||||
{
|
||||
struct new_process_request *info;
|
||||
if (!(info = process->info)) return 0;
|
||||
process->info = NULL;
|
||||
reply->start_flags = info->start_flags;
|
||||
reply->hstdin = info->hstdin;
|
||||
reply->hstdout = info->hstdout;
|
||||
reply->hstderr = info->hstderr;
|
||||
reply->env_ptr = info->env_ptr;
|
||||
free( info );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* a process has been killed (i.e. its last thread died) */
|
||||
static void process_killed( struct process *process, int exit_code )
|
||||
{
|
||||
|
@ -377,8 +363,10 @@ DECL_HANDLER(new_process)
|
|||
{
|
||||
struct new_process_reply reply;
|
||||
struct process *process;
|
||||
char *cmd_line = (char *)data;
|
||||
|
||||
if ((process = create_process( req )))
|
||||
CHECK_STRING( "new_process", cmd_line, len );
|
||||
if ((process = create_process( req, cmd_line )))
|
||||
{
|
||||
reply.pid = process;
|
||||
reply.handle = alloc_handle( current->process, process,
|
||||
|
@ -397,17 +385,28 @@ DECL_HANDLER(new_process)
|
|||
DECL_HANDLER(init_process)
|
||||
{
|
||||
struct init_process_reply reply;
|
||||
struct new_process_request *info;
|
||||
|
||||
if (current->state != RUNNING)
|
||||
{
|
||||
fatal_protocol_error( "init_process: init_thread not called yet\n" );
|
||||
return;
|
||||
}
|
||||
if (!get_process_init_info( current->process, &reply ))
|
||||
if (!(info = current->process->info))
|
||||
{
|
||||
fatal_protocol_error( "init_process: called twice\n" );
|
||||
return;
|
||||
}
|
||||
send_reply( current, -1, 1, &reply, sizeof(reply) );
|
||||
current->process->info = NULL;
|
||||
reply.start_flags = info->start_flags;
|
||||
reply.hstdin = info->hstdin;
|
||||
reply.hstdout = info->hstdout;
|
||||
reply.hstderr = info->hstderr;
|
||||
reply.cmd_show = info->cmd_show;
|
||||
reply.env_ptr = info->env_ptr;
|
||||
send_reply( current, -1, 2, &reply, sizeof(reply),
|
||||
info->cmd_line, strlen(info->cmd_line) + 1 );
|
||||
free( info );
|
||||
}
|
||||
|
||||
/* open a handle to a process */
|
||||
|
|
380
server/trace.c
380
server/trace.c
|
@ -6,6 +6,40 @@
|
|||
#include "server.h"
|
||||
#include "thread.h"
|
||||
|
||||
static int dump_chars( void *ptr, int len )
|
||||
{
|
||||
fprintf( stderr, "\"%.*s\"", len, (char *)ptr );
|
||||
return len;
|
||||
}
|
||||
|
||||
static int dump_ints( void *ptr, int len )
|
||||
{
|
||||
int i;
|
||||
if (!(len /= sizeof(int)))
|
||||
{
|
||||
fprintf( stderr, "{}" );
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
fprintf( stderr, "%c%d", i ? ',' : '{', *((int *)ptr + i) );
|
||||
fprintf( stderr, "}" );
|
||||
return len * sizeof(int);
|
||||
}
|
||||
|
||||
static int dump_ptrs( void *ptr, int len )
|
||||
{
|
||||
int i;
|
||||
if (!(len /= sizeof(void*)))
|
||||
{
|
||||
fprintf( stderr, "{}" );
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
fprintf( stderr, "%c%p", i ? ',' : '{', *((void **)ptr + i) );
|
||||
fprintf( stderr, "}" );
|
||||
return len * sizeof(void*);
|
||||
}
|
||||
|
||||
static int dump_new_process_request( struct new_process_request *req, int len )
|
||||
{
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
|
@ -15,9 +49,10 @@ static int dump_new_process_request( struct new_process_request *req, int len )
|
|||
fprintf( stderr, " hstdin=%d,", req->hstdin );
|
||||
fprintf( stderr, " hstdout=%d,", req->hstdout );
|
||||
fprintf( stderr, " hstderr=%d,", req->hstderr );
|
||||
fprintf( stderr, " cmd_show=%d,", req->cmd_show );
|
||||
fprintf( stderr, " env_ptr=%p,", req->env_ptr );
|
||||
fprintf( stderr, " cmd_line=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " cmd_line=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_new_process_reply( struct new_process_reply *req, int len )
|
||||
|
@ -60,8 +95,10 @@ static int dump_init_process_reply( struct init_process_reply *req, int len )
|
|||
fprintf( stderr, " hstdin=%d,", req->hstdin );
|
||||
fprintf( stderr, " hstdout=%d,", req->hstdout );
|
||||
fprintf( stderr, " hstderr=%d,", req->hstderr );
|
||||
fprintf( stderr, " env_ptr=%p", req->env_ptr );
|
||||
return (int)sizeof(*req);
|
||||
fprintf( stderr, " cmd_show=%d,", req->cmd_show );
|
||||
fprintf( stderr, " env_ptr=%p,", req->env_ptr );
|
||||
fprintf( stderr, " cmdline=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_init_thread_request( struct init_thread_request *req, int len )
|
||||
|
@ -239,14 +276,16 @@ static int dump_select_request( struct select_request *req, int len )
|
|||
{
|
||||
fprintf( stderr, " count=%d,", req->count );
|
||||
fprintf( stderr, " flags=%d,", req->flags );
|
||||
fprintf( stderr, " timeout=%d", req->timeout );
|
||||
return (int)sizeof(*req);
|
||||
fprintf( stderr, " timeout=%d,", req->timeout );
|
||||
fprintf( stderr, " handles=" );
|
||||
return dump_ints( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_select_reply( struct select_reply *req, int len )
|
||||
{
|
||||
fprintf( stderr, " signaled=%d", req->signaled );
|
||||
return (int)sizeof(*req);
|
||||
fprintf( stderr, " signaled=%d,", req->signaled );
|
||||
fprintf( stderr, " apcs=" );
|
||||
return dump_ptrs( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_event_request( struct create_event_request *req, int len )
|
||||
|
@ -254,8 +293,8 @@ static int dump_create_event_request( struct create_event_request *req, int len
|
|||
fprintf( stderr, " manual_reset=%d,", req->manual_reset );
|
||||
fprintf( stderr, " initial_state=%d,", req->initial_state );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_event_reply( struct create_event_reply *req, int len )
|
||||
|
@ -275,8 +314,8 @@ static int dump_open_event_request( struct open_event_request *req, int len )
|
|||
{
|
||||
fprintf( stderr, " access=%08x,", req->access );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_open_event_reply( struct open_event_reply *req, int len )
|
||||
|
@ -289,8 +328,8 @@ static int dump_create_mutex_request( struct create_mutex_request *req, int len
|
|||
{
|
||||
fprintf( stderr, " owned=%d,", req->owned );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_mutex_reply( struct create_mutex_reply *req, int len )
|
||||
|
@ -309,8 +348,8 @@ static int dump_open_mutex_request( struct open_mutex_request *req, int len )
|
|||
{
|
||||
fprintf( stderr, " access=%08x,", req->access );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_open_mutex_reply( struct open_mutex_reply *req, int len )
|
||||
|
@ -324,8 +363,8 @@ static int dump_create_semaphore_request( struct create_semaphore_request *req,
|
|||
fprintf( stderr, " initial=%08x,", req->initial );
|
||||
fprintf( stderr, " max=%08x,", req->max );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_semaphore_reply( struct create_semaphore_reply *req, int len )
|
||||
|
@ -351,8 +390,8 @@ static int dump_open_semaphore_request( struct open_semaphore_request *req, int
|
|||
{
|
||||
fprintf( stderr, " access=%08x,", req->access );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_open_semaphore_reply( struct open_semaphore_reply *req, int len )
|
||||
|
@ -368,8 +407,8 @@ static int dump_create_file_request( struct create_file_request *req, int len )
|
|||
fprintf( stderr, " sharing=%08x,", req->sharing );
|
||||
fprintf( stderr, " create=%d,", req->create );
|
||||
fprintf( stderr, " attrs=%08x,", req->attrs );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_file_reply( struct create_file_reply *req, int len )
|
||||
|
@ -538,8 +577,8 @@ static int dump_set_console_info_request( struct set_console_info_request *req,
|
|||
fprintf( stderr, " mask=%d,", req->mask );
|
||||
fprintf( stderr, " cursor_size=%d,", req->cursor_size );
|
||||
fprintf( stderr, " cursor_visible=%d,", req->cursor_visible );
|
||||
fprintf( stderr, " title=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " title=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_get_console_info_request( struct get_console_info_request *req, int len )
|
||||
|
@ -603,8 +642,8 @@ static int dump_create_mapping_request( struct create_mapping_request *req, int
|
|||
fprintf( stderr, " protect=%d,", req->protect );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " handle=%d,", req->handle );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_create_mapping_reply( struct create_mapping_reply *req, int len )
|
||||
|
@ -617,8 +656,8 @@ static int dump_open_mapping_request( struct open_mapping_request *req, int len
|
|||
{
|
||||
fprintf( stderr, " access=%08x,", req->access );
|
||||
fprintf( stderr, " inherit=%d,", req->inherit );
|
||||
fprintf( stderr, " name=\"%.*s\"", len - (int)sizeof(*req), (char *)(req+1) );
|
||||
return len;
|
||||
fprintf( stderr, " name=" );
|
||||
return dump_chars( req+1, len - (int)sizeof(*req) ) + sizeof(*req);
|
||||
}
|
||||
|
||||
static int dump_open_mapping_reply( struct open_mapping_reply *req, int len )
|
||||
|
@ -722,139 +761,136 @@ static int dump_debug_process_request( struct debug_process_request *req, int le
|
|||
fprintf( stderr, " pid=%p", req->pid );
|
||||
return (int)sizeof(*req);
|
||||
}
|
||||
typedef int (*dump_func)( void *req, int len );
|
||||
|
||||
struct dumper
|
||||
{
|
||||
int (*dump_req)( void *data, int len );
|
||||
void (*dump_reply)( void *data );
|
||||
static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
|
||||
(dump_func)dump_new_process_request,
|
||||
(dump_func)dump_new_thread_request,
|
||||
(dump_func)dump_set_debug_request,
|
||||
(dump_func)dump_init_process_request,
|
||||
(dump_func)dump_init_thread_request,
|
||||
(dump_func)dump_terminate_process_request,
|
||||
(dump_func)dump_terminate_thread_request,
|
||||
(dump_func)dump_get_process_info_request,
|
||||
(dump_func)dump_set_process_info_request,
|
||||
(dump_func)dump_get_thread_info_request,
|
||||
(dump_func)dump_set_thread_info_request,
|
||||
(dump_func)dump_suspend_thread_request,
|
||||
(dump_func)dump_resume_thread_request,
|
||||
(dump_func)dump_debugger_request,
|
||||
(dump_func)dump_queue_apc_request,
|
||||
(dump_func)dump_close_handle_request,
|
||||
(dump_func)dump_get_handle_info_request,
|
||||
(dump_func)dump_set_handle_info_request,
|
||||
(dump_func)dump_dup_handle_request,
|
||||
(dump_func)dump_open_process_request,
|
||||
(dump_func)dump_select_request,
|
||||
(dump_func)dump_create_event_request,
|
||||
(dump_func)dump_event_op_request,
|
||||
(dump_func)dump_open_event_request,
|
||||
(dump_func)dump_create_mutex_request,
|
||||
(dump_func)dump_release_mutex_request,
|
||||
(dump_func)dump_open_mutex_request,
|
||||
(dump_func)dump_create_semaphore_request,
|
||||
(dump_func)dump_release_semaphore_request,
|
||||
(dump_func)dump_open_semaphore_request,
|
||||
(dump_func)dump_create_file_request,
|
||||
(dump_func)dump_get_read_fd_request,
|
||||
(dump_func)dump_get_write_fd_request,
|
||||
(dump_func)dump_set_file_pointer_request,
|
||||
(dump_func)dump_truncate_file_request,
|
||||
(dump_func)dump_set_file_time_request,
|
||||
(dump_func)dump_flush_file_request,
|
||||
(dump_func)dump_get_file_info_request,
|
||||
(dump_func)dump_lock_file_request,
|
||||
(dump_func)dump_unlock_file_request,
|
||||
(dump_func)dump_create_pipe_request,
|
||||
(dump_func)dump_alloc_console_request,
|
||||
(dump_func)dump_free_console_request,
|
||||
(dump_func)dump_open_console_request,
|
||||
(dump_func)dump_set_console_fd_request,
|
||||
(dump_func)dump_get_console_mode_request,
|
||||
(dump_func)dump_set_console_mode_request,
|
||||
(dump_func)dump_set_console_info_request,
|
||||
(dump_func)dump_get_console_info_request,
|
||||
(dump_func)dump_write_console_input_request,
|
||||
(dump_func)dump_read_console_input_request,
|
||||
(dump_func)dump_create_change_notification_request,
|
||||
(dump_func)dump_create_mapping_request,
|
||||
(dump_func)dump_open_mapping_request,
|
||||
(dump_func)dump_get_mapping_info_request,
|
||||
(dump_func)dump_create_device_request,
|
||||
(dump_func)dump_create_snapshot_request,
|
||||
(dump_func)dump_next_process_request,
|
||||
(dump_func)dump_wait_debug_event_request,
|
||||
(dump_func)dump_send_debug_event_request,
|
||||
(dump_func)dump_continue_debug_event_request,
|
||||
(dump_func)dump_debug_process_request,
|
||||
};
|
||||
|
||||
static const struct dumper dumpers[REQ_NB_REQUESTS] =
|
||||
{
|
||||
{ (int(*)(void *,int))dump_new_process_request,
|
||||
(void(*)())dump_new_process_reply },
|
||||
{ (int(*)(void *,int))dump_new_thread_request,
|
||||
(void(*)())dump_new_thread_reply },
|
||||
{ (int(*)(void *,int))dump_set_debug_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_init_process_request,
|
||||
(void(*)())dump_init_process_reply },
|
||||
{ (int(*)(void *,int))dump_init_thread_request,
|
||||
(void(*)())dump_init_thread_reply },
|
||||
{ (int(*)(void *,int))dump_terminate_process_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_terminate_thread_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_process_info_request,
|
||||
(void(*)())dump_get_process_info_reply },
|
||||
{ (int(*)(void *,int))dump_set_process_info_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_thread_info_request,
|
||||
(void(*)())dump_get_thread_info_reply },
|
||||
{ (int(*)(void *,int))dump_set_thread_info_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_suspend_thread_request,
|
||||
(void(*)())dump_suspend_thread_reply },
|
||||
{ (int(*)(void *,int))dump_resume_thread_request,
|
||||
(void(*)())dump_resume_thread_reply },
|
||||
{ (int(*)(void *,int))dump_debugger_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_queue_apc_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_close_handle_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_handle_info_request,
|
||||
(void(*)())dump_get_handle_info_reply },
|
||||
{ (int(*)(void *,int))dump_set_handle_info_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_dup_handle_request,
|
||||
(void(*)())dump_dup_handle_reply },
|
||||
{ (int(*)(void *,int))dump_open_process_request,
|
||||
(void(*)())dump_open_process_reply },
|
||||
{ (int(*)(void *,int))dump_select_request,
|
||||
(void(*)())dump_select_reply },
|
||||
{ (int(*)(void *,int))dump_create_event_request,
|
||||
(void(*)())dump_create_event_reply },
|
||||
{ (int(*)(void *,int))dump_event_op_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_open_event_request,
|
||||
(void(*)())dump_open_event_reply },
|
||||
{ (int(*)(void *,int))dump_create_mutex_request,
|
||||
(void(*)())dump_create_mutex_reply },
|
||||
{ (int(*)(void *,int))dump_release_mutex_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_open_mutex_request,
|
||||
(void(*)())dump_open_mutex_reply },
|
||||
{ (int(*)(void *,int))dump_create_semaphore_request,
|
||||
(void(*)())dump_create_semaphore_reply },
|
||||
{ (int(*)(void *,int))dump_release_semaphore_request,
|
||||
(void(*)())dump_release_semaphore_reply },
|
||||
{ (int(*)(void *,int))dump_open_semaphore_request,
|
||||
(void(*)())dump_open_semaphore_reply },
|
||||
{ (int(*)(void *,int))dump_create_file_request,
|
||||
(void(*)())dump_create_file_reply },
|
||||
{ (int(*)(void *,int))dump_get_read_fd_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_write_fd_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_set_file_pointer_request,
|
||||
(void(*)())dump_set_file_pointer_reply },
|
||||
{ (int(*)(void *,int))dump_truncate_file_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_set_file_time_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_flush_file_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_file_info_request,
|
||||
(void(*)())dump_get_file_info_reply },
|
||||
{ (int(*)(void *,int))dump_lock_file_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_unlock_file_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_create_pipe_request,
|
||||
(void(*)())dump_create_pipe_reply },
|
||||
{ (int(*)(void *,int))dump_alloc_console_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_free_console_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_open_console_request,
|
||||
(void(*)())dump_open_console_reply },
|
||||
{ (int(*)(void *,int))dump_set_console_fd_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_console_mode_request,
|
||||
(void(*)())dump_get_console_mode_reply },
|
||||
{ (int(*)(void *,int))dump_set_console_mode_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_set_console_info_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_get_console_info_request,
|
||||
(void(*)())dump_get_console_info_reply },
|
||||
{ (int(*)(void *,int))dump_write_console_input_request,
|
||||
(void(*)())dump_write_console_input_reply },
|
||||
{ (int(*)(void *,int))dump_read_console_input_request,
|
||||
(void(*)())dump_read_console_input_reply },
|
||||
{ (int(*)(void *,int))dump_create_change_notification_request,
|
||||
(void(*)())dump_create_change_notification_reply },
|
||||
{ (int(*)(void *,int))dump_create_mapping_request,
|
||||
(void(*)())dump_create_mapping_reply },
|
||||
{ (int(*)(void *,int))dump_open_mapping_request,
|
||||
(void(*)())dump_open_mapping_reply },
|
||||
{ (int(*)(void *,int))dump_get_mapping_info_request,
|
||||
(void(*)())dump_get_mapping_info_reply },
|
||||
{ (int(*)(void *,int))dump_create_device_request,
|
||||
(void(*)())dump_create_device_reply },
|
||||
{ (int(*)(void *,int))dump_create_snapshot_request,
|
||||
(void(*)())dump_create_snapshot_reply },
|
||||
{ (int(*)(void *,int))dump_next_process_request,
|
||||
(void(*)())dump_next_process_reply },
|
||||
{ (int(*)(void *,int))dump_wait_debug_event_request,
|
||||
(void(*)())dump_wait_debug_event_reply },
|
||||
{ (int(*)(void *,int))dump_send_debug_event_request,
|
||||
(void(*)())dump_send_debug_event_reply },
|
||||
{ (int(*)(void *,int))dump_continue_debug_event_request,
|
||||
(void(*)())0 },
|
||||
{ (int(*)(void *,int))dump_debug_process_request,
|
||||
(void(*)())0 },
|
||||
static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
|
||||
(dump_func)dump_new_process_reply,
|
||||
(dump_func)dump_new_thread_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_init_process_reply,
|
||||
(dump_func)dump_init_thread_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_process_info_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_thread_info_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_suspend_thread_reply,
|
||||
(dump_func)dump_resume_thread_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_handle_info_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_dup_handle_reply,
|
||||
(dump_func)dump_open_process_reply,
|
||||
(dump_func)dump_select_reply,
|
||||
(dump_func)dump_create_event_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_open_event_reply,
|
||||
(dump_func)dump_create_mutex_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_open_mutex_reply,
|
||||
(dump_func)dump_create_semaphore_reply,
|
||||
(dump_func)dump_release_semaphore_reply,
|
||||
(dump_func)dump_open_semaphore_reply,
|
||||
(dump_func)dump_create_file_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_set_file_pointer_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_file_info_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_create_pipe_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_open_console_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_console_mode_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
(dump_func)dump_get_console_info_reply,
|
||||
(dump_func)dump_write_console_input_reply,
|
||||
(dump_func)dump_read_console_input_reply,
|
||||
(dump_func)dump_create_change_notification_reply,
|
||||
(dump_func)dump_create_mapping_reply,
|
||||
(dump_func)dump_open_mapping_reply,
|
||||
(dump_func)dump_get_mapping_info_reply,
|
||||
(dump_func)dump_create_device_reply,
|
||||
(dump_func)dump_create_snapshot_reply,
|
||||
(dump_func)dump_next_process_reply,
|
||||
(dump_func)dump_wait_debug_event_reply,
|
||||
(dump_func)dump_send_debug_event_reply,
|
||||
(dump_func)0,
|
||||
(dump_func)0,
|
||||
};
|
||||
|
||||
static const char * const req_names[REQ_NB_REQUESTS] =
|
||||
|
@ -928,7 +964,7 @@ void trace_request( enum request req, void *data, int len, int fd )
|
|||
int size;
|
||||
current->last_req = req;
|
||||
fprintf( stderr, "%08x: %s(", (unsigned int)current, req_names[req] );
|
||||
size = dumpers[req].dump_req( data, len );
|
||||
size = req_dumpers[req]( data, len );
|
||||
if ((len -= size) > 0)
|
||||
{
|
||||
unsigned char *ptr = (unsigned char *)data + size;
|
||||
|
@ -952,24 +988,26 @@ void trace_kill( int exit_code )
|
|||
void trace_reply( struct thread *thread, int type, int pass_fd,
|
||||
struct iovec *vec, int veclen )
|
||||
{
|
||||
static char buffer[MAX_MSG_LENGTH];
|
||||
|
||||
if (!thread) return;
|
||||
fprintf( stderr, "%08x: %s() = %d",
|
||||
(unsigned int)thread, req_names[thread->last_req], type );
|
||||
if (veclen)
|
||||
{
|
||||
char *p = buffer;
|
||||
int len;
|
||||
for (; veclen; veclen--, vec++)
|
||||
{
|
||||
memcpy( p, vec->iov_base, vec->iov_len );
|
||||
p += vec->iov_len;
|
||||
}
|
||||
fprintf( stderr, " {" );
|
||||
if (dumpers[thread->last_req].dump_reply)
|
||||
{
|
||||
dumpers[thread->last_req].dump_reply( vec->iov_base );
|
||||
vec++;
|
||||
veclen--;
|
||||
}
|
||||
for (; veclen; veclen--, vec++)
|
||||
{
|
||||
unsigned char *ptr = vec->iov_base;
|
||||
int len = vec->iov_len;
|
||||
while (len--) fprintf( stderr, ", %02x", *ptr++ );
|
||||
}
|
||||
len = p - buffer;
|
||||
if (reply_dumpers[thread->last_req])
|
||||
len -= reply_dumpers[thread->last_req]( buffer, len );
|
||||
p -= len;
|
||||
while (len--) fprintf( stderr, ", %02x", *p++ );
|
||||
fprintf( stderr, " }" );
|
||||
}
|
||||
if (pass_fd != -1) fprintf( stderr, " fd=%d\n", pass_fd );
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
"int" => "%d",
|
||||
"long" => "%ld",
|
||||
"char" => "%c",
|
||||
"char[0]" => "\\\"%.*s\\\"",
|
||||
"unsigned int" => "%08x",
|
||||
"void*" => "%p",
|
||||
"time_t" => "%ld"
|
||||
"time_t" => "%ld",
|
||||
"char[0]" => "dump_chars",
|
||||
"int[0]" => "dump_ints",
|
||||
"void*[0]" => "dump_ptrs"
|
||||
);
|
||||
|
||||
my @requests = ();
|
||||
|
@ -34,6 +36,40 @@ print TRACE <<EOF;
|
|||
#include <sys/uio.h>
|
||||
#include "server.h"
|
||||
#include "thread.h"
|
||||
|
||||
static int dump_chars( void *ptr, int len )
|
||||
{
|
||||
fprintf( stderr, "\\\"%.*s\\\"", len, (char *)ptr );
|
||||
return len;
|
||||
}
|
||||
|
||||
static int dump_ints( void *ptr, int len )
|
||||
{
|
||||
int i;
|
||||
if (!(len /= sizeof(int)))
|
||||
{
|
||||
fprintf( stderr, "{}" );
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
fprintf( stderr, "%c%d", i ? ',' : '{', *((int *)ptr + i) );
|
||||
fprintf( stderr, "}" );
|
||||
return len * sizeof(int);
|
||||
}
|
||||
|
||||
static int dump_ptrs( void *ptr, int len )
|
||||
{
|
||||
int i;
|
||||
if (!(len /= sizeof(void*)))
|
||||
{
|
||||
fprintf( stderr, "{}" );
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
fprintf( stderr, "%c%p", i ? ',' : '{', *((void **)ptr + i) );
|
||||
fprintf( stderr, "}" );
|
||||
return len * sizeof(void*);
|
||||
}
|
||||
EOF
|
||||
|
||||
### Parse server.h to find request/reply structure definitions
|
||||
|
@ -46,29 +82,22 @@ while (<SERVER>)
|
|||
|
||||
### Output the dumping function tables
|
||||
|
||||
print TRACE<<EOF;
|
||||
|
||||
struct dumper
|
||||
{
|
||||
int (*dump_req)( void *data, int len );
|
||||
void (*dump_reply)( void *data );
|
||||
};
|
||||
|
||||
static const struct dumper dumpers[REQ_NB_REQUESTS] =
|
||||
{
|
||||
EOF
|
||||
|
||||
print TRACE "typedef int (*dump_func)( void *req, int len );\n\n";
|
||||
print TRACE "static const dump_func req_dumpers[REQ_NB_REQUESTS] = {\n";
|
||||
foreach $req (@requests)
|
||||
{
|
||||
$request = $req . "_request";
|
||||
$reply = $replies{$req} ? "dump_${req}_reply" : "0";
|
||||
print TRACE " { (int(*)(void *,int))dump_$request,\n";
|
||||
print TRACE " (void(*)())$reply },\n";
|
||||
print TRACE " (dump_func)dump_${req}_request,\n";
|
||||
}
|
||||
print TRACE "};\n\n";
|
||||
|
||||
print TRACE "static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {\n";
|
||||
foreach $req (@requests)
|
||||
{
|
||||
print TRACE " (dump_func)", $replies{$req} ? "dump_${req}_reply,\n" : "0,\n";
|
||||
}
|
||||
print TRACE "};\n\n";
|
||||
|
||||
print TRACE <<EOF;
|
||||
};
|
||||
|
||||
static const char * const req_names[REQ_NB_REQUESTS] =
|
||||
{
|
||||
EOF
|
||||
|
@ -87,7 +116,7 @@ void trace_request( enum request req, void *data, int len, int fd )
|
|||
int size;
|
||||
current->last_req = req;
|
||||
fprintf( stderr, "%08x: %s(", (unsigned int)current, req_names[req] );
|
||||
size = dumpers[req].dump_req( data, len );
|
||||
size = req_dumpers[req]( data, len );
|
||||
if ((len -= size) > 0)
|
||||
{
|
||||
unsigned char *ptr = (unsigned char *)data + size;
|
||||
|
@ -111,24 +140,26 @@ void trace_kill( int exit_code )
|
|||
void trace_reply( struct thread *thread, int type, int pass_fd,
|
||||
struct iovec *vec, int veclen )
|
||||
{
|
||||
static char buffer[MAX_MSG_LENGTH];
|
||||
|
||||
if (!thread) return;
|
||||
fprintf( stderr, "%08x: %s() = %d",
|
||||
(unsigned int)thread, req_names[thread->last_req], type );
|
||||
if (veclen)
|
||||
{
|
||||
char *p = buffer;
|
||||
int len;
|
||||
for (; veclen; veclen--, vec++)
|
||||
{
|
||||
memcpy( p, vec->iov_base, vec->iov_len );
|
||||
p += vec->iov_len;
|
||||
}
|
||||
fprintf( stderr, " {" );
|
||||
if (dumpers[thread->last_req].dump_reply)
|
||||
{
|
||||
dumpers[thread->last_req].dump_reply( vec->iov_base );
|
||||
vec++;
|
||||
veclen--;
|
||||
}
|
||||
for (; veclen; veclen--, vec++)
|
||||
{
|
||||
unsigned char *ptr = vec->iov_base;
|
||||
int len = vec->iov_len;
|
||||
while (len--) fprintf( stderr, ", %02x", *ptr++ );
|
||||
}
|
||||
len = p - buffer;
|
||||
if (reply_dumpers[thread->last_req])
|
||||
len -= reply_dumpers[thread->last_req]( buffer, len );
|
||||
p -= len;
|
||||
while (len--) fprintf( stderr, ", %02x", *p++ );
|
||||
fprintf( stderr, " }" );
|
||||
}
|
||||
if (pass_fd != -1) fprintf( stderr, " fd=%d\\n", pass_fd );
|
||||
|
@ -238,18 +269,20 @@ sub DO_DUMP_FUNC
|
|||
{
|
||||
my $type = shift;
|
||||
my $var = shift;
|
||||
print TRACE " fprintf( stderr, \" $var=$formats{$type}";
|
||||
print TRACE "," if ($#_ > 0);
|
||||
print TRACE "\", ";
|
||||
if ($type =~ s/\[0\]$//g) # vararg type?
|
||||
if ($type =~ /\[0\]$/) # vararg type?
|
||||
{
|
||||
$vararg = 1;
|
||||
print TRACE "len - (int)sizeof(*req), ($type *)(req+1) );\n";
|
||||
print TRACE " fprintf( stderr, \" $var=\" );\n";
|
||||
print TRACE " return $formats{$type}( req+1, len - (int)sizeof(*req) ) + sizeof(*req);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print TRACE " fprintf( stderr, \" $var=$formats{$type}";
|
||||
print TRACE "," if ($#_ > 0);
|
||||
print TRACE "\", ";
|
||||
print TRACE "req->$var );\n";
|
||||
}
|
||||
}
|
||||
print TRACE " return ", $vararg ? "len" : "(int)sizeof(*req)", ";\n}\n";
|
||||
print TRACE " return (int)sizeof(*req);\n" unless $vararg;
|
||||
print TRACE "}\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue