Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3452 → Rev 3451

/trunk/uspace/app/trace/trace.c
136,63 → 136,30
return 0;
}
 
void val_print(int val, val_type_t v_type)
static void print_sc_retval(int retval, rv_type_t rv_type)
{
switch (v_type) {
case V_VOID:
printf("<void>");
break;
 
case V_INTEGER:
printf("%d", val);
break;
 
case V_HASH:
printf("0x%08x", val);
break;
 
case V_ERRNO:
if (val >= -15 && val <= 0) {
printf("%d %s (%s)", val,
err_desc[-val].name,
err_desc[-val].desc);
printf (" -> ");
if (rv_type == RV_INTEGER) {
printf("%d", retval);
} else if (rv_type == RV_HASH) {
printf("0x%08x", retval);
} else if (rv_type == RV_ERRNO) {
if (retval >= -15 && retval <= 0) {
printf("%d %s (%s)", retval,
err_desc[retval].name,
err_desc[retval].desc);
} else {
printf("%d", val);
printf("%d", retval);
}
break;
case V_INT_ERRNO:
if (val >= -15 && val < 0) {
printf("%d %s (%s)", val,
err_desc[-val].name,
err_desc[-val].desc);
} else if (rv_type == RV_INT_ERRNO) {
if (retval >= -15 && retval < 0) {
printf("%d %s (%s)", retval,
err_desc[retval].name,
err_desc[retval].desc);
} else {
printf("%d", val);
printf("%d", retval);
}
break;
 
case V_CHAR:
if (val >= 0x20 && val < 0x7f) {
printf("'%c'", val);
} else {
switch (val) {
case '\a': printf("'\\a'"); break;
case '\b': printf("'\\b'"); break;
case '\n': printf("'\\n'"); break;
case '\r': printf("'\\r'"); break;
case '\t': printf("'\\t'"); break;
case '\\': printf("'\\\\'"); break;
default: printf("'\\x%X'"); break;
}
}
break;
}
}
 
 
static void print_sc_retval(int retval, val_type_t val_type)
{
printf(" -> ");
val_print(retval, val_type);
putchar('\n');
}
 
202,7 → 169,7
 
putchar('(');
if (n > 0) printf("%d", sc_args[0]);
for (i = 1; i < n; i++) {
for (i=1; i<n; i++) {
printf(", %d", sc_args[i]);
}
putchar(')');
529,22 → 496,6
proto_t *p;
oper_t *o;
 
val_type_t arg_def[OPER_MAX_ARGS] = {
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER
};
 
val_type_t resp_def[OPER_MAX_ARGS] = {
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER
};
 
next_thread_id = 1;
paused = 0;
 
551,45 → 502,38
proto_init();
 
p = proto_new("vfs");
o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
o = oper_new("read");
proto_add_oper(p, VFS_READ, o);
o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def);
o = oper_new("write");
proto_add_oper(p, VFS_WRITE, o);
o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
o = oper_new("truncate");
proto_add_oper(p, VFS_TRUNCATE, o);
o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def);
o = oper_new("mount");
proto_add_oper(p, VFS_MOUNT, o);
/* o = oper_new("unmount", 0, arg_def);
proto_add_oper(p, VFS_UNMOUNT, o);*/
o = oper_new("unmount");
proto_add_oper(p, VFS_UNMOUNT, o);
 
proto_register(SERVICE_VFS, p);
 
p = proto_new("console");
resp_def[0] = V_CHAR;
o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def);
o = oper_new("getchar");
proto_add_oper(p, CONSOLE_GETCHAR, o);
 
arg_def[0] = V_CHAR;
o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def);
o = oper_new("putchar");
proto_add_oper(p, CONSOLE_PUTCHAR, o);
o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def);
o = oper_new("clear");
proto_add_oper(p, CONSOLE_CLEAR, o);
 
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def);
o = oper_new("goto");
proto_add_oper(p, CONSOLE_GOTO, o);
 
resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER;
o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def);
o = oper_new("getsize");
proto_add_oper(p, CONSOLE_GETSIZE, o);
o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def);
o = oper_new("flush");
proto_add_oper(p, CONSOLE_FLUSH, o);
 
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def);
o = oper_new("set_style");
proto_add_oper(p, CONSOLE_SET_STYLE, o);
o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def);
o = oper_new("cursor_visibility");
proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
o = oper_new("flush");
proto_add_oper(p, CONSOLE_FLUSH, o);
 
proto_console = p;
proto_register(SERVICE_CONSOLE, p);
/trunk/uspace/app/trace/trace.h
48,21 → 48,9
 
} display_mask_t;
 
typedef enum {
V_VOID,
V_INTEGER,
V_PTR,
V_HASH,
V_ERRNO,
V_INT_ERRNO,
V_CHAR
} val_type_t;
 
/** Combination of events to print. */
extern display_mask_t display_mask;
 
void val_print(int val, val_type_t v_type);
 
#endif
 
/** @}
/trunk/uspace/app/trace/ipcp.c
46,7 → 46,6
typedef struct {
int phone_hash;
ipc_call_t question;
oper_t *oper;
 
int call_hash;
 
146,14 → 145,6
ipc_m_desc_t *desc;
oper_t *oper;
 
val_type_t arg_def[OPER_MAX_ARGS] = {
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER,
V_INTEGER
};
 
/*
* Create a pseudo-protocol 'unknown' that has no known methods.
*/
167,8 → 158,7
 
desc = ipc_methods;
while (desc->number != 0) {
oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER,
OPER_MAX_ARGS, arg_def);
oper = oper_new(desc->name);
proto_add_oper(proto_system, desc->number, oper);
 
++desc;
189,20 → 179,21
proto_t *proto;
unsigned long key[1];
oper_t *oper;
ipcarg_t *args;
int i;
 
if (have_conn[phone]) proto = connections[phone].proto;
else proto = NULL;
 
args = call->args;
 
if ((display_mask & DM_IPC) != 0) {
printf("Call ID: 0x%x, phone: %d, proto: %s, method: ", hash,
phone, (proto ? proto->name : "n/a"));
ipc_m_print(proto, IPC_GET_METHOD(*call));
printf(" args: (%u, %u, %u, %u, %u)\n", args[1], args[2],
args[3], args[4], args[5]);
printf(" args: (%u, %u, %u, %u, %u)\n",
IPC_GET_ARG1(*call),
IPC_GET_ARG2(*call),
IPC_GET_ARG3(*call),
IPC_GET_ARG4(*call),
IPC_GET_ARG5(*call)
);
}
 
 
219,26 → 210,14
printf("%s(%d).%s", (proto ? proto->name : "n/a"),
phone, (oper ? oper->name : "unknown"));
 
putchar('(');
for (i = 1; i <= oper->argc; ++i) {
if (i > 1) printf(", ");
val_print(args[i], oper->arg_type[i - 1]);
}
putchar(')');
 
if (oper->rv_type == V_VOID && oper->respc == 0) {
/*
* No response data (typically the task will
* not be interested in the response).
* We will not display response.
*/
putchar('.');
}
 
putchar('\n');
printf("(%u, %u, %u, %u, %u)\n",
IPC_GET_ARG1(*call),
IPC_GET_ARG2(*call),
IPC_GET_ARG3(*call),
IPC_GET_ARG4(*call),
IPC_GET_ARG5(*call)
);
}
} else {
oper = NULL;
}
 
/* Store call in hash table for response matching */
247,7 → 226,6
pcall->phone_hash = phone;
pcall->question = *call;
pcall->call_hash = hash;
pcall->oper = oper;
 
key[0] = hash;
 
264,10 → 242,6
proto_t *proto;
int cphone;
 
ipcarg_t *resp;
oper_t *oper;
int i;
 
// printf("parse_answer\n");
 
phone = pcall->phone_hash;
274,8 → 248,6
method = IPC_GET_METHOD(pcall->question);
retval = IPC_GET_RETVAL(*answer);
 
resp = answer->args;
 
if ((display_mask & DM_IPC) != 0) {
printf("Response to 0x%x: retval=%d, args = (%u, %u, %u, %u, %u)\n",
hash, retval, IPC_GET_ARG1(*answer),
284,28 → 256,7
}
 
if ((display_mask & DM_USER) != 0) {
oper = pcall->oper;
 
if (oper->rv_type != V_VOID || oper->respc > 0) {
printf("->");
 
if (oper->rv_type != V_VOID) {
putchar(' ');
val_print(retval, oper->rv_type);
}
if (oper->respc > 0) {
putchar(' ');
putchar('(');
for (i = 1; i <= oper->respc; ++i) {
if (i > 1) printf(", ");
val_print(resp[i], oper->resp_type[i - 1]);
}
putchar(')');
}
 
putchar('\n');
}
printf("-> %d\n", retval);
}
 
if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) {
/trunk/uspace/app/trace/proto.c
37,7 → 37,6
#include <ipc/ipc.h>
#include <libadt/hash_table.h>
 
#include "trace.h"
#include "proto.h"
 
#define SRV_PROTO_TABLE_CHAINS 32
210,25 → 209,13
oper->name = name;
}
 
oper_t *oper_new(char *name, int argc, val_type_t *arg_types,
val_type_t rv_type, int respc, val_type_t *resp_types)
oper_t *oper_new(char *name)
{
oper_t *o;
int i;
 
o = malloc(sizeof(oper_t));
oper_struct_init(o, name);
 
o->argc = argc;
for (i = 0; i < argc; i++)
o->arg_type[i] = arg_types[i];
 
o->rv_type = rv_type;
 
o->respc = respc;
for (i = 0; i < respc; i++)
o->resp_type[i] = resp_types[i];
 
return o;
}
 
/trunk/uspace/app/trace/proto.h
36,21 → 36,9
#define PROTO_H_
 
#include <libadt/hash_table.h>
#include <ipc/ipc.h>
#include "trace.h"
 
#define OPER_MAX_ARGS (IPC_CALL_LEN - 1)
 
typedef struct {
char *name;
 
int argc;
val_type_t arg_type[OPER_MAX_ARGS];
 
val_type_t rv_type;
 
int respc;
val_type_t resp_type[OPER_MAX_ARGS];
} oper_t;
 
typedef struct {
74,11 → 62,9
void proto_add_oper(proto_t *proto, int method, oper_t *oper);
oper_t *proto_get_oper(proto_t *proto, int method);
 
oper_t *oper_new(char *name, int argc, val_type_t *arg_types,
val_type_t rv_type, int respc, val_type_t *resp_types);
oper_t *oper_new(char *name);
 
 
 
#endif
 
/** @}
/trunk/uspace/app/trace/syscalls.h
35,10 → 35,17
#ifndef SYSCALLS_H_
#define SYSCALLS_H_
 
typedef enum {
RV_INTEGER,
RV_HASH,
RV_ERRNO,
RV_INT_ERRNO
} rv_type_t;
 
typedef struct {
char *name;
int n_args;
val_type_t rv_type;
rv_type_t rv_type;
} sc_desc_t;
 
extern const sc_desc_t syscall_desc[];
/trunk/uspace/app/tester/tester.c
109,8 → 109,6
 
int main(int argc, char **argv)
{
printf("x"); while(1);
 
printf("Number of arguments: %d\n", argc);
if (argv) {
printf("Arguments:");