Subversion Repositories HelenOS

Rev

Rev 4659 | Rev 4661 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4659 Rev 4660
Line 66... Line 66...
66
uintptr_t thread_hash_buf[THBUF_SIZE];
66
uintptr_t thread_hash_buf[THBUF_SIZE];
67
int n_threads;
67
int n_threads;
68
 
68
 
69
int next_thread_id;
69
int next_thread_id;
70
 
70
 
-
 
71
ipc_call_t thread_ipc_req[THBUF_SIZE];
-
 
72
 
71
int phoneid;
73
int phoneid;
72
bool abort_trace;
74
bool abort_trace;
73
 
75
 
74
uintptr_t thash;
76
uintptr_t thash;
75
static bool paused;
77
static bool paused;
Line 337... Line 339...
337
 
339
 
338
//  printf("call ipc_call_sync\n");
340
//  printf("call ipc_call_sync\n");
339
    ipcp_call_sync(phoneidx, &question, &reply);
341
    ipcp_call_sync(phoneidx, &question, &reply);
340
}
342
}
341
 
343
 
342
static void sc_ipc_call_sync_slow(sysarg_t *sc_args)
344
static void sc_ipc_call_sync_slow_b(unsigned thread_id, sysarg_t *sc_args)
343
{
345
{
344
    ipc_call_t question, reply;
346
    ipc_call_t question, reply;
345
    int rc;
347
    int rc;
346
 
348
 
347
    memset(&question, 0, sizeof(question));
349
    memset(&question, 0, sizeof(question));
348
    rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
350
    rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
-
 
351
    if (rc < 0) {
349
    printf("dmr->%d\n", rc);
352
        printf("Error: mem_read->%d\n", rc);
350
    if (rc < 0) return;
353
        return;
-
 
354
    }
-
 
355
 
-
 
356
    thread_ipc_req[thread_id] = question;
-
 
357
}
-
 
358
 
-
 
359
static void sc_ipc_call_sync_slow_e(unsigned thread_id, sysarg_t *sc_args)
-
 
360
{
-
 
361
    ipc_call_t question, reply;
-
 
362
    int rc;
351
 
363
 
352
    memset(&reply, 0, sizeof(reply));
364
    memset(&reply, 0, sizeof(reply));
353
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
365
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
-
 
366
    if (rc < 0) {
354
    printf("dmr->%d\n", rc);
367
        printf("Error: mem_read->%d\n", rc);
355
    if (rc < 0) return;
368
        return;
-
 
369
    }
356
 
370
 
357
    ipcp_call_sync(sc_args[0], &question, &reply);
371
    ipcp_call_sync(sc_args[0], &thread_ipc_req[thread_id], &reply);
358
}
372
}
359
 
373
 
360
static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
374
static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
361
{
375
{
362
    ipc_call_t call;
376
    ipc_call_t call;
Line 397... Line 411...
397
        /* Print syscall name and arguments */
411
        /* Print syscall name and arguments */
398
        printf("%s", syscall_desc[sc_id].name);
412
        printf("%s", syscall_desc[sc_id].name);
399
        print_sc_args(sc_args, syscall_desc[sc_id].n_args);
413
        print_sc_args(sc_args, syscall_desc[sc_id].n_args);
400
    }
414
    }
401
 
415
 
-
 
416
    switch (sc_id) {
-
 
417
    case SYS_IPC_CALL_SYNC_SLOW:
-
 
418
        sc_ipc_call_sync_slow_b(thread_id, sc_args);
-
 
419
        break;
-
 
420
    default:
-
 
421
        break;
-
 
422
    }
-
 
423
 
402
    async_serialize_end();
424
    async_serialize_end();
403
}
425
}
404
 
426
 
405
static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash,
427
static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash,
406
    unsigned sc_id, sysarg_t sc_rc)
428
    unsigned sc_id, sysarg_t sc_rc)
Line 437... Line 459...
437
        break;
459
        break;
438
    case SYS_IPC_CALL_SYNC_FAST:
460
    case SYS_IPC_CALL_SYNC_FAST:
439
        sc_ipc_call_sync_fast(sc_args);
461
        sc_ipc_call_sync_fast(sc_args);
440
        break;
462
        break;
441
    case SYS_IPC_CALL_SYNC_SLOW:
463
    case SYS_IPC_CALL_SYNC_SLOW:
442
        sc_ipc_call_sync_slow(sc_args);
464
        sc_ipc_call_sync_slow_e(thread_id, sc_args);
443
        break;
465
        break;
444
    case SYS_IPC_WAIT:
466
    case SYS_IPC_WAIT:
445
        sc_ipc_wait(sc_args, sc_rc);
467
        sc_ipc_wait(sc_args, sc_rc);
446
        break;
468
        break;
447
    default:
469
    default:
Line 468... Line 490...
468
    unsigned thread_id;
490
    unsigned thread_id;
469
    sysarg_t val0, val1;
491
    sysarg_t val0, val1;
470
 
492
 
471
    thread_hash = (uintptr_t)thread_hash_arg;
493
    thread_hash = (uintptr_t)thread_hash_arg;
472
    thread_id = next_thread_id++;
494
    thread_id = next_thread_id++;
-
 
495
    if (thread_id >= THBUF_SIZE) {
-
 
496
        printf("Too many threads.\n");
-
 
497
        return ELIMIT;
-
 
498
    }
473
 
499
 
474
    printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);
500
    printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);
475
 
501
 
476
    while (!abort_trace) {
502
    while (!abort_trace) {
477
 
503