Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2939 → Rev 2940

/branches/tracing/uspace/app/debug/dthread.h
59,6 → 59,7
void dthread_stop_me(void);
void dthread_resume(dthread_t *dt);
 
unsigned dthread_get_pc(dthread_t *dthread);
 
#endif
 
/branches/tracing/uspace/app/debug/include/arch.h
37,11 → 37,14
 
#include <sys/types.h>
#include <udebug.h>
#include "arch/types.h"
 
void arch_breakpoint_add(uintptr_t addr);
void arch_event_breakpoint(thash_t thread_hash);
void arch_event_trap(thash_t thread_hash);
 
#define istate_get_pc(istate) ((istate)[OFFSET_PC])
 
#endif
 
/** @}
/branches/tracing/uspace/app/debug/main.c
59,8 → 59,6
int cmd_argc;
char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */
 
#define THBUF_SIZE 64
thash_t thread_hash_buf[THBUF_SIZE];
 
int next_thread_id;
 
142,9 → 140,11
static void thread_stop(void)
{
dthread_t *dt;
uintptr_t pc;
 
dt = dthread_get();
cons_printf("[thread %d] stopped\n", dt->id);
pc = dthread_get_pc(dt);
cons_printf("[thread %d] stopped at 0x%lx\n", dt->id, pc);
dthread_stop_me();
cons_printf("[thread %d] go\n", dt->id);
}
183,29 → 183,58
return 0;
}
 
static int get_thread_list(void)
#define THASH_BUF_INIT_LENGTH 32
 
static int get_thread_list(thash_t **thash_buf_ptr, int *n)
{
int rc;
int tb_copied;
int tb_needed;
int i;
int n;
size_t tb_size;
thash_t *thash_buf;
 
cons_printf("send IPC_M_DEBUG_THREAD_READ message\n");
rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf,
THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
cons_printf("-> %d\n", rc);
tb_size = THASH_BUF_INIT_LENGTH * sizeof(thash_t);
thash_buf = malloc(tb_size);
 
rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf,
tb_size, &tb_copied, &tb_needed);
if (rc < 0) return rc;
 
n = tb_copied / sizeof(unsigned);
if (tb_needed > tb_size) {
/* Larger buffer needed */
 
cons_printf("thread IDs:");
for (i=0; i<n; i++) {
cons_printf(" %u", thread_hash_buf[i]);
free(thash_buf);
 
tb_size = tb_needed;
thash_buf = malloc(tb_size);
 
if (!thash_buf) {
printf("malloc failed\n");
exit(1);
}
 
/* Try again */
rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf,
tb_size, &tb_copied, &tb_needed);
 
if (rc < 0) return rc;
}
cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned));
 
return n;
*n = tb_copied / sizeof(thash_t);
 
cons_printf("thread hashes:");
 
for (i = 0; i < *n; ++i) {
cons_printf("0x%x\n", thash_buf[i]);
}
 
cons_printf("Total of %u threads\n", *n);
 
*thash_buf_ptr = thash_buf;
 
return 0;
}
 
void event_thread_b(unsigned hash)
295,6 → 324,9
int rc;
int c;
 
thash_t *thash_buffer;
int n_threads;
 
cons_printf("Breakpoint Debugger\n");
cons_printf("Press 'c' to connect\n");
while ((i = getchar()) != 'c')
309,16 → 341,16
 
cons_printf("Connected to task %d\n", taskid);
 
rc = get_thread_list();
rc = get_thread_list(&thash_buffer, &n_threads);
if (rc < 0) {
cons_printf("Failed to get thread list (error %d)\n", rc);
cons_printf("Failed to get thread list\n", rc);
return;
}
 
abort_debug = false;
 
for (i = 0; i < rc; i++) {
thread_debug_start(thread_hash_buf[i]);
for (i = 0; i < n_threads; i++) {
thread_debug_start(thash_buffer[i]);
}
 
while (!quit) {
/branches/tracing/uspace/app/debug/dthread.c
38,6 → 38,8
#include <futex.h>
#include <async.h>
 
#include "include/arch.h"
#include "main.h"
#include "dthread.h"
 
static int last_thread_id = 0;
125,6 → 127,19
futex_up(&async_futex);
}
 
unsigned dthread_get_pc(dthread_t *dt)
{
static unsigned istate_buffer[1024];
int rc;
 
rc = udebug_regs_read(app_phone, dt->hash, istate_buffer);
if (rc < 0) {
printf("failed reading registers (%d)\n", rc);
return 0;
}
 
return istate_get_pc(istate_buffer);
}
 
/** @}
*/
/branches/tracing/uspace/app/debug/arch/ia32/include/types.h
39,6 → 39,8
unsigned char back;
} breakpoint_arch_t;
 
#define OFFSET_PC 12
 
#endif
 
/** @}