Subversion Repositories HelenOS

Rev

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

Rev 4653 Rev 4654
Line 44... Line 44...
44
#include <mem.h>
44
#include <mem.h>
45
#include <string.h>
45
#include <string.h>
46
#include <loader/loader.h>
46
#include <loader/loader.h>
47
#include <io/console.h>
47
#include <io/console.h>
48
#include <io/keycode.h>
48
#include <io/keycode.h>
-
 
49
#include <fibril_sync.h>
49
 
50
 
50
#include <libc.h>
51
#include <libc.h>
51
 
52
 
52
// Temporary: service and method names
53
// Temporary: service and method names
53
#include "proto.h"
54
#include "proto.h"
Line 69... Line 70...
69
int phoneid;
70
int phoneid;
70
int abort_trace;
71
int abort_trace;
71
 
72
 
72
uintptr_t thash;
73
uintptr_t thash;
73
volatile int paused;
74
volatile int paused;
-
 
75
fibril_condvar_t paused_cv;
-
 
76
fibril_mutex_t paused_lock;
74
 
77
 
75
void thread_trace_start(uintptr_t thread_hash);
78
void thread_trace_start(uintptr_t thread_hash);
76
 
79
 
77
static proto_t *proto_console;
80
static proto_t *proto_console;
78
static task_id_t task_id;
81
static task_id_t task_id;
Line 451... Line 454...
451
 
454
 
452
    printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);
455
    printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);
453
 
456
 
454
    while (!abort_trace) {
457
    while (!abort_trace) {
455
 
458
 
-
 
459
        fibril_mutex_lock(&paused_lock);
456
        if (paused) {
460
        if (paused) {
457
            printf("Press R to resume.\n");
461
            printf("Thread [%d] paused. Press R to resume.\n",
-
 
462
                thread_id);
-
 
463
 
458
            while (paused) {
464
            while (paused)
459
                async_usleep(1000000);
465
                fibril_condvar_wait(&paused_cv, &paused_lock);
460
            }
466
 
461
            printf("Resumed\n");
467
            printf("Thread [%d] resumed.\n", thread_id);
462
        }
468
        }
-
 
469
        fibril_mutex_unlock(&paused_lock);
463
 
470
 
464
        /* Run thread until an event occurs */
471
        /* Run thread until an event occurs */
465
        rc = udebug_go(phoneid, thread_hash,
472
        rc = udebug_go(phoneid, thread_hash,
466
            &ev_type, &val0, &val1);
473
            &ev_type, &val0, &val1);
467
 
474
 
Line 479... Line 486...
479
            case UDEBUG_EVENT_SYSCALL_E:
486
            case UDEBUG_EVENT_SYSCALL_E:
480
                event_syscall_e(thread_id, thread_hash, val0, (int)val1);
487
                event_syscall_e(thread_id, thread_hash, val0, (int)val1);
481
                break;
488
                break;
482
            case UDEBUG_EVENT_STOP:
489
            case UDEBUG_EVENT_STOP:
483
                printf("Stop event\n");
490
                printf("Stop event\n");
-
 
491
                fibril_mutex_lock(&paused_lock);
-
 
492
                paused = 1;
-
 
493
                fibril_mutex_unlock(&paused_lock);
484
                break;
494
                break;
485
            case UDEBUG_EVENT_THREAD_B:
495
            case UDEBUG_EVENT_THREAD_B:
486
                event_thread_b(val0);
496
                event_thread_b(val0);
487
                break;
497
                break;
488
            case UDEBUG_EVENT_THREAD_E:
498
            case UDEBUG_EVENT_THREAD_E:
Line 596... Line 606...
596
            done = true;
606
            done = true;
597
            break;
607
            break;
598
        case KC_P:
608
        case KC_P:
599
            printf("Pause...\n");
609
            printf("Pause...\n");
600
            rc = udebug_stop(phoneid, thash);
610
            rc = udebug_stop(phoneid, thash);
601
            if (rc == EOK)
611
            if (rc != EOK)
602
                paused = 1;
-
 
603
            else
-
 
604
                printf("stop -> %d\n", rc);
612
                printf("Error: stop -> %d\n", rc);
605
            break;
613
            break;
606
        case KC_R:
614
        case KC_R:
-
 
615
            fibril_mutex_lock(&paused_lock);
607
            paused = 0;
616
            paused = 0;
-
 
617
            fibril_condvar_broadcast(&paused_cv);
-
 
618
            fibril_mutex_unlock(&paused_lock);
608
            printf("Resume...\n");
619
            printf("Resume...\n");
609
            break;
620
            break;
610
        }
621
        }
611
    }
622
    }
612
 
623
 
Line 642... Line 653...
642
        V_INTEGER
653
        V_INTEGER
643
    };
654
    };
644
 
655
 
645
    next_thread_id = 1;
656
    next_thread_id = 1;
646
    paused = 0;
657
    paused = 0;
-
 
658
    fibril_mutex_initialize(&paused_lock);
-
 
659
    fibril_condvar_initialize(&paused_cv);
647
 
660
 
648
    proto_init();
661
    proto_init();
649
 
662
 
650
    p = proto_new("vfs");
663
    p = proto_new("vfs");
651
    o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
664
    o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);