Changeset abf3564 in mainline
- Timestamp:
- 2008-09-18T22:19:42Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f7176b1
- Parents:
- 073c9e6
- Location:
- uspace/app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/tester.c
r073c9e6 rabf3564 110 110 int main(int argc, char **argv) 111 111 { 112 printf("x"); while(1); 113 112 114 printf("Number of arguments: %d\n", argc); 113 115 if (argv) { -
uspace/app/trace/ipcp.c
r073c9e6 rabf3564 47 47 int phone_hash; 48 48 ipc_call_t question; 49 oper_t *oper; 49 50 50 51 int call_hash; … … 146 147 oper_t *oper; 147 148 149 val_type_t arg_def[OPER_MAX_ARGS] = { 150 V_INTEGER, 151 V_INTEGER, 152 V_INTEGER, 153 V_INTEGER, 154 V_INTEGER 155 }; 156 148 157 /* 149 158 * Create a pseudo-protocol 'unknown' that has no known methods. … … 159 168 desc = ipc_methods; 160 169 while (desc->number != 0) { 161 oper = oper_new(desc->name); 170 oper = oper_new(desc->name, OPER_MAX_ARGS, arg_def, V_INTEGER, 171 OPER_MAX_ARGS, arg_def); 162 172 proto_add_oper(proto_system, desc->number, oper); 163 173 … … 180 190 unsigned long key[1]; 181 191 oper_t *oper; 192 ipcarg_t *args; 193 int i; 182 194 183 195 if (have_conn[phone]) proto = connections[phone].proto; 184 196 else proto = NULL; 197 198 args = call->args; 185 199 186 200 if ((display_mask & DM_IPC) != 0) { … … 188 202 phone, (proto ? proto->name : "n/a")); 189 203 ipc_m_print(proto, IPC_GET_METHOD(*call)); 190 printf(" args: (%u, %u, %u, %u, %u)\n", 191 IPC_GET_ARG1(*call), 192 IPC_GET_ARG2(*call), 193 IPC_GET_ARG3(*call), 194 IPC_GET_ARG4(*call), 195 IPC_GET_ARG5(*call) 196 ); 204 printf(" args: (%u, %u, %u, %u, %u)\n", args[1], args[2], 205 args[3], args[4], args[5]); 197 206 } 198 207 … … 211 220 phone, (oper ? oper->name : "unknown")); 212 221 213 printf("(%u, %u, %u, %u, %u)\n", 214 IPC_GET_ARG1(*call), 215 IPC_GET_ARG2(*call), 216 IPC_GET_ARG3(*call), 217 IPC_GET_ARG4(*call), 218 IPC_GET_ARG5(*call) 219 ); 220 } 222 putchar('('); 223 for (i = 1; i <= oper->argc; ++i) { 224 if (i > 1) printf(", "); 225 val_print(args[i], oper->arg_type[i - 1]); 226 } 227 putchar(')'); 228 229 if (oper->rv_type == V_VOID && oper->respc == 0) { 230 /* 231 * No response data (typically the task will 232 * not be interested in the response). 233 * We will not display response. 234 */ 235 putchar('.'); 236 } 237 238 putchar('\n'); 239 } 240 } else { 241 oper = NULL; 221 242 } 222 243 … … 227 248 pcall->question = *call; 228 249 pcall->call_hash = hash; 250 pcall->oper = oper; 229 251 230 252 key[0] = hash; … … 243 265 int cphone; 244 266 267 ipcarg_t *resp; 268 oper_t *oper; 269 int i; 270 245 271 // printf("parse_answer\n"); 246 272 … … 248 274 method = IPC_GET_METHOD(pcall->question); 249 275 retval = IPC_GET_RETVAL(*answer); 276 277 resp = answer->args; 250 278 251 279 if ((display_mask & DM_IPC) != 0) { … … 257 285 258 286 if ((display_mask & DM_USER) != 0) { 259 printf("-> %d\n", retval); 287 oper = pcall->oper; 288 289 if (oper->rv_type != V_VOID || oper->respc > 0) { 290 printf("->"); 291 292 if (oper->rv_type != V_VOID) { 293 putchar(' '); 294 val_print(retval, oper->rv_type); 295 } 296 297 if (oper->respc > 0) { 298 putchar(' '); 299 putchar('('); 300 for (i = 1; i <= oper->respc; ++i) { 301 if (i > 1) printf(", "); 302 val_print(resp[i], oper->resp_type[i - 1]); 303 } 304 putchar(')'); 305 } 306 307 putchar('\n'); 308 } 260 309 } 261 310 -
uspace/app/trace/proto.c
r073c9e6 rabf3564 38 38 #include <libadt/hash_table.h> 39 39 40 #include "trace.h" 40 41 #include "proto.h" 41 42 … … 210 211 } 211 212 212 oper_t *oper_new(char *name) 213 oper_t *oper_new(char *name, int argc, val_type_t *arg_types, 214 val_type_t rv_type, int respc, val_type_t *resp_types) 213 215 { 214 216 oper_t *o; 217 int i; 215 218 216 219 o = malloc(sizeof(oper_t)); 217 220 oper_struct_init(o, name); 218 221 222 o->argc = argc; 223 for (i = 0; i < argc; i++) 224 o->arg_type[i] = arg_types[i]; 225 226 o->rv_type = rv_type; 227 228 o->respc = respc; 229 for (i = 0; i < respc; i++) 230 o->resp_type[i] = resp_types[i]; 231 219 232 return o; 220 233 } -
uspace/app/trace/proto.h
r073c9e6 rabf3564 37 37 38 38 #include <libadt/hash_table.h> 39 #include <ipc/ipc.h> 40 #include "trace.h" 41 42 #define OPER_MAX_ARGS (IPC_CALL_LEN - 1) 39 43 40 44 typedef struct { 41 45 char *name; 46 47 int argc; 48 val_type_t arg_type[OPER_MAX_ARGS]; 49 50 val_type_t rv_type; 51 52 int respc; 53 val_type_t resp_type[OPER_MAX_ARGS]; 42 54 } oper_t; 43 55 … … 63 75 oper_t *proto_get_oper(proto_t *proto, int method); 64 76 65 oper_t *oper_new(char *name); 77 oper_t *oper_new(char *name, int argc, val_type_t *arg_types, 78 val_type_t rv_type, int respc, val_type_t *resp_types); 79 66 80 67 81 -
uspace/app/trace/syscalls.h
r073c9e6 rabf3564 36 36 #define SYSCALLS_H_ 37 37 38 typedef enum {39 RV_INTEGER,40 RV_HASH,41 RV_ERRNO,42 RV_INT_ERRNO43 } rv_type_t;44 45 38 typedef struct { 46 39 char *name; 47 40 int n_args; 48 rv_type_t rv_type;41 val_type_t rv_type; 49 42 } sc_desc_t; 50 43 -
uspace/app/trace/trace.c
r073c9e6 rabf3564 137 137 } 138 138 139 static void print_sc_retval(int retval, rv_type_t rv_type) 140 { 141 printf (" -> "); 142 if (rv_type == RV_INTEGER) { 143 printf("%d", retval); 144 } else if (rv_type == RV_HASH) { 145 printf("0x%08x", retval); 146 } else if (rv_type == RV_ERRNO) { 147 if (retval >= -15 && retval <= 0) { 148 printf("%d %s (%s)", retval, 149 err_desc[retval].name, 150 err_desc[retval].desc); 139 void val_print(int val, val_type_t v_type) 140 { 141 switch (v_type) { 142 case V_VOID: 143 printf("<void>"); 144 break; 145 146 case V_INTEGER: 147 printf("%d", val); 148 break; 149 150 case V_HASH: 151 printf("0x%08x", val); 152 break; 153 154 case V_ERRNO: 155 if (val >= -15 && val <= 0) { 156 printf("%d %s (%s)", val, 157 err_desc[-val].name, 158 err_desc[-val].desc); 151 159 } else { 152 printf("%d", retval); 153 } 154 } else if (rv_type == RV_INT_ERRNO) { 155 if (retval >= -15 && retval < 0) { 156 printf("%d %s (%s)", retval, 157 err_desc[retval].name, 158 err_desc[retval].desc); 160 printf("%d", val); 161 } 162 break; 163 case V_INT_ERRNO: 164 if (val >= -15 && val < 0) { 165 printf("%d %s (%s)", val, 166 err_desc[-val].name, 167 err_desc[-val].desc); 159 168 } else { 160 printf("%d", retval); 161 } 162 } 169 printf("%d", val); 170 } 171 break; 172 173 case V_CHAR: 174 if (val >= 0x20 && val < 0x7f) { 175 printf("'%c'", val); 176 } else { 177 switch (val) { 178 case '\a': printf("'\\a'"); break; 179 case '\b': printf("'\\b'"); break; 180 case '\n': printf("'\\n'"); break; 181 case '\r': printf("'\\r'"); break; 182 case '\t': printf("'\\t'"); break; 183 case '\\': printf("'\\\\'"); break; 184 default: printf("'\\x%X'"); break; 185 } 186 } 187 break; 188 } 189 } 190 191 192 static void print_sc_retval(int retval, val_type_t val_type) 193 { 194 printf(" -> "); 195 val_print(retval, val_type); 163 196 putchar('\n'); 164 197 } … … 170 203 putchar('('); 171 204 if (n > 0) printf("%d", sc_args[0]); 172 for (i =1; i<n; i++) {205 for (i = 1; i < n; i++) { 173 206 printf(", %d", sc_args[i]); 174 207 } … … 497 530 oper_t *o; 498 531 532 val_type_t arg_def[OPER_MAX_ARGS] = { 533 V_INTEGER, 534 V_INTEGER, 535 V_INTEGER, 536 V_INTEGER, 537 V_INTEGER 538 }; 539 540 val_type_t resp_def[OPER_MAX_ARGS] = { 541 V_INTEGER, 542 V_INTEGER, 543 V_INTEGER, 544 V_INTEGER, 545 V_INTEGER 546 }; 547 499 548 next_thread_id = 1; 500 549 paused = 0; … … 503 552 504 553 p = proto_new("vfs"); 505 o = oper_new("read" );554 o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); 506 555 proto_add_oper(p, VFS_READ, o); 507 o = oper_new("write" );556 o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); 508 557 proto_add_oper(p, VFS_WRITE, o); 509 o = oper_new("truncate" );558 o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); 510 559 proto_add_oper(p, VFS_TRUNCATE, o); 511 o = oper_new("mount" );560 o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def); 512 561 proto_add_oper(p, VFS_MOUNT, o); 513 o = oper_new("unmount");514 proto_add_oper(p, VFS_UNMOUNT, o); 562 /* o = oper_new("unmount", 0, arg_def); 563 proto_add_oper(p, VFS_UNMOUNT, o);*/ 515 564 516 565 proto_register(SERVICE_VFS, p); 517 566 518 567 p = proto_new("console"); 519 o = oper_new("getchar"); 568 resp_def[0] = V_CHAR; 569 o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def); 520 570 proto_add_oper(p, CONSOLE_GETCHAR, o); 521 o = oper_new("putchar"); 571 572 arg_def[0] = V_CHAR; 573 o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); 522 574 proto_add_oper(p, CONSOLE_PUTCHAR, o); 523 o = oper_new("clear" );575 o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); 524 576 proto_add_oper(p, CONSOLE_CLEAR, o); 525 o = oper_new("goto"); 577 578 arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; 579 o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def); 526 580 proto_add_oper(p, CONSOLE_GOTO, o); 527 o = oper_new("getsize"); 581 582 resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; 583 o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def); 528 584 proto_add_oper(p, CONSOLE_GETSIZE, o); 529 o = oper_new("flush" );585 o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def); 530 586 proto_add_oper(p, CONSOLE_FLUSH, o); 531 o = oper_new("set_style"); 587 588 arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; 589 o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def); 532 590 proto_add_oper(p, CONSOLE_SET_STYLE, o); 533 o = oper_new("cursor_visibility" );591 o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def); 534 592 proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); 535 o = oper_new("flush");536 proto_add_oper(p, CONSOLE_FLUSH, o);537 593 538 594 proto_console = p; -
uspace/app/trace/trace.h
r073c9e6 rabf3564 49 49 } display_mask_t; 50 50 51 typedef enum { 52 V_VOID, 53 V_INTEGER, 54 V_PTR, 55 V_HASH, 56 V_ERRNO, 57 V_INT_ERRNO, 58 V_CHAR 59 } val_type_t; 60 51 61 /** Combination of events to print. */ 52 62 extern display_mask_t display_mask; 63 64 void val_print(int val, val_type_t v_type); 53 65 54 66 #endif
Note:
See TracChangeset
for help on using the changeset viewer.