Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3451 → Rev 3452

/trunk/uspace/app/tester/tester.c
109,6 → 109,8
 
int main(int argc, char **argv)
{
printf("x"); while(1);
 
printf("Number of arguments: %d\n", argc);
if (argv) {
printf("Arguments:");
/trunk/uspace/app/trace/trace.c
136,30 → 136,63
return 0;
}
 
static void print_sc_retval(int retval, rv_type_t rv_type)
void val_print(int val, val_type_t v_type)
{
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);
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);
} else {
printf("%d", retval);
printf("%d", val);
}
} 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);
break;
case V_INT_ERRNO:
if (val >= -15 && val < 0) {
printf("%d %s (%s)", val,
err_desc[-val].name,
err_desc[-val].desc);
} else {
printf("%d", retval);
printf("%d", val);
}
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');
}
 
169,7 → 202,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(')');
496,6 → 529,22
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;
 
502,38 → 551,45
proto_init();
 
p = proto_new("vfs");
o = oper_new("read");
o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
proto_add_oper(p, VFS_READ, o);
o = oper_new("write");
o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def);
proto_add_oper(p, VFS_WRITE, o);
o = oper_new("truncate");
o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
proto_add_oper(p, VFS_TRUNCATE, o);
o = oper_new("mount");
o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def);
proto_add_oper(p, VFS_MOUNT, o);
o = oper_new("unmount");
proto_add_oper(p, VFS_UNMOUNT, o);
/* o = oper_new("unmount", 0, arg_def);
proto_add_oper(p, VFS_UNMOUNT, o);*/
 
proto_register(SERVICE_VFS, p);
 
p = proto_new("console");
o = oper_new("getchar");
resp_def[0] = V_CHAR;
o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def);
proto_add_oper(p, CONSOLE_GETCHAR, o);
o = oper_new("putchar");
 
arg_def[0] = V_CHAR;
o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_PUTCHAR, o);
o = oper_new("clear");
o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_CLEAR, o);
o = oper_new("goto");
 
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_GOTO, o);
o = oper_new("getsize");
 
resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER;
o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def);
proto_add_oper(p, CONSOLE_GETSIZE, o);
o = oper_new("flush");
o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_FLUSH, o);
o = oper_new("set_style");
 
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def);
proto_add_oper(p, CONSOLE_SET_STYLE, o);
o = oper_new("cursor_visibility");
o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def);
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/syscalls.h
35,17 → 35,10
#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;
rv_type_t rv_type;
val_type_t rv_type;
} sc_desc_t;
 
extern const sc_desc_t syscall_desc[];
/trunk/uspace/app/trace/proto.c
37,6 → 37,7
#include <ipc/ipc.h>
#include <libadt/hash_table.h>
 
#include "trace.h"
#include "proto.h"
 
#define SRV_PROTO_TABLE_CHAINS 32
209,13 → 210,25
oper->name = name;
}
 
oper_t *oper_new(char *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 *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/trace.h
48,9 → 48,21
 
} 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/proto.h
36,9 → 36,21
#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 {
62,9 → 74,11
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);
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);
 
 
 
#endif
 
/** @}
/trunk/uspace/app/trace/ipcp.c
46,6 → 46,7
typedef struct {
int phone_hash;
ipc_call_t question;
oper_t *oper;
 
int call_hash;
 
145,6 → 146,14
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.
*/
158,7 → 167,8
 
desc = ipc_methods;
while (desc->number != 0) {
oper = oper_new(desc->name);
oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER,
OPER_MAX_ARGS, arg_def);
proto_add_oper(proto_system, desc->number, oper);
 
++desc;
179,21 → 189,20
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",
IPC_GET_ARG1(*call),
IPC_GET_ARG2(*call),
IPC_GET_ARG3(*call),
IPC_GET_ARG4(*call),
IPC_GET_ARG5(*call)
);
printf(" args: (%u, %u, %u, %u, %u)\n", args[1], args[2],
args[3], args[4], args[5]);
}
 
 
210,14 → 219,26
printf("%s(%d).%s", (proto ? proto->name : "n/a"),
phone, (oper ? oper->name : "unknown"));
 
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)
);
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');
}
} else {
oper = NULL;
}
 
/* Store call in hash table for response matching */
226,6 → 247,7
pcall->phone_hash = phone;
pcall->question = *call;
pcall->call_hash = hash;
pcall->oper = oper;
 
key[0] = hash;
 
242,6 → 264,10
proto_t *proto;
int cphone;
 
ipcarg_t *resp;
oper_t *oper;
int i;
 
// printf("parse_answer\n");
 
phone = pcall->phone_hash;
248,6 → 274,8
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),
256,7 → 284,28
}
 
if ((display_mask & DM_USER) != 0) {
printf("-> %d\n", retval);
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');
}
}
 
if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) {