Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2936 → Rev 2937

/branches/tracing/uspace/app/debug/cmd.c
45,9 → 45,13
#include "cmd.h"
 
static void cmd_break(int argc, char *argv[]);
void cmd_go(int argc, char *argv[]);
static void cmd_ct(int argc, char *argv[]);
static void cmd_go(int argc, char *argv[]);
void cmd_help(int argc, char *argv[]);
static void cmd_pwt(int argc, char *argv[]);
static void cmd_read(int argc, char *argv[]);
static void cmd_step(int argc, char *argv[]);
static void cmd_threads(int argc, char *argv[]);
static void cmd_quit(int argc, char *argv[]);
 
volatile bool quit = false;
54,9 → 58,12
 
cmd_desc_t cmd_table[] = {
{ 1, "break", cmd_break },
{ 1, "ct", cmd_ct },
{ 0, "go", cmd_go },
{ 0, "help", cmd_help },
{ 0, "pwt", cmd_pwt },
{ 2, "read", cmd_read },
{ 0, "threads", cmd_threads },
{ 0, "quit", cmd_quit },
{ -1, NULL, NULL }
};
72,6 → 79,27
arch_breakpoint_add(addr);
}
 
static void cmd_ct(int argc, char *argv[])
{
int i;
int tid;
 
(void)argc;
tid = strtoul(argv[1], NULL, 0);
 
for (i = 0; i < n_threads; ++i) {
if (thread_id[i] == tid) break;
}
if (thread_id[i] == tid) {
cons_printf("changed working thread to: %d [hash 0x%x]\n",
thread_id[cwt], thread_hash[cwt]);
} else {
cons_printf("no such thread\n");
}
}
 
 
void cmd_go(int argc, char *argv[])
{
fcv_broadcast(&go_cv);
135,7 → 163,29
}
}
 
void cmd_step(int argc, char *argv[])
{
fcv_broadcast(&go_cv);
}
 
void cmd_pwt(int argc, char *argv[])
{
(void)argc; (void)argv;
cons_printf("working thread: %d [hash 0x%x]\n", thread_id[cwt],
thread_hash[cwt]);
}
 
void cmd_threads(int argc, char *argv[])
{
int i;
 
(void)argc; (void)argv;
for (i = 0; i < n_threads; ++i) {
cons_printf("%d [hash 0x%x]\n", thread_id[i], thread_hash[i]);
}
}
 
 
static void cmd_quit(int argc, char *argv[])
{
(void)argc; (void)argv;
/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]);
}
 
/branches/tracing/uspace/app/debug/main.h
35,6 → 35,8
#ifndef MAIN_H_
#define MAIN_H_
 
#include <udebug.h>
 
#include "include/arch/types.h"
#include "fib_synch.h"
 
50,6 → 52,11
extern int app_phone;
extern fcv_t go_cv;
 
extern thash_t thread_hash[];
extern int thread_id[];
extern unsigned n_threads;
extern int cwt;
 
void breakpoint_hit(void);