Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2936 → Rev 2937

/branches/tracing/uspace/app/debug/main.c
60,7 → 60,12
 
#define THBUF_SIZE 64
thash_t thread_hash_buf[THBUF_SIZE];
 
#define MAX_THREADS 64
thash_t thread_hash[MAX_THREADS];
int thread_id[MAX_THREADS];
unsigned n_threads;
int cwt; /* index into thread_hash/thread_id */
 
int next_thread_id;
 
187,6 → 192,7
int tb_copied;
int tb_needed;
int i;
int n;
 
cons_printf("send IPC_M_DEBUG_THREAD_READ message\n");
rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf,
194,15 → 200,15
cons_printf("-> %d\n", rc);
if (rc < 0) return rc;
 
n_threads = tb_copied / sizeof(unsigned);
n = tb_copied / sizeof(unsigned);
 
cons_printf("thread IDs:");
for (i=0; i<n_threads; i++) {
for (i=0; i<n; i++) {
cons_printf(" %u", thread_hash_buf[i]);
}
cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned));
 
return 0;
return n;
}
 
void event_thread_b(unsigned hash)
248,42 → 254,46
}
}
 
void debug_loop(void *thread_hash_arg)
void debug_loop(void *thread_buf_idx_arg)
{
int rc;
udebug_event_t ev_type;
unsigned thread_hash;
unsigned thread_id;
unsigned thread_buf_idx;
thash_t thash;
int tid;
unsigned val0, val1;
 
thread_hash = (unsigned)thread_hash_arg;
thread_id = next_thread_id++;
thread_buf_idx = (unsigned)thread_buf_idx_arg;
 
cons_printf("debug_loop(%d)\n", thread_id);
thash = thread_hash[thread_buf_idx];
tid = thread_id[thread_buf_idx];
 
cons_printf("debug_loop(%d)\n", tid);
 
while (!abort_debug) {
 
/* Run thread until an event occurs */
rc = udebug_go(app_phone, thread_hash,
rc = udebug_go(app_phone, thash,
&ev_type, &val0, &val1);
 
if (ev_type == UDEBUG_EVENT_FINISHED) {
cons_printf("thread %u debugging finished\n", thread_id);
cons_printf("thread %u debugging finished\n", tid);
break;
}
if (rc >= 0) debug_event(thread_hash, ev_type, val0);
if (rc >= 0) debug_event(thash, ev_type, val0);
}
 
cons_printf("debug_loop(%d) exiting\n", thread_id);
}
 
void thread_debug_start(unsigned thread_hash)
void thread_debug_start(unsigned thash)
{
fid_t fid;
 
thash = thread_hash;
thread_hash[n_threads] = thash;
thread_id[n_threads] = next_thread_id++;
 
fid = fibril_create(debug_loop, (void *)thread_hash);
fid = fibril_create(debug_loop, (void *)n_threads++);
if (fid == 0) {
cons_printf("Warning: Failed creating fibril\n");
}
319,7 → 329,7
 
abort_debug = false;
 
for (i = 0; i < n_threads; i++) {
for (i = 0; i < rc; i++) {
thread_debug_start(thread_hash_buf[i]);
}