Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2940 → Rev 2941

/branches/tracing/uspace/app/debug/include/arch.h
37,14 → 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);
void arch_dump_regs(thash_t thash);
 
#define istate_get_pc(istate) ((istate)[OFFSET_PC])
 
#endif
 
/** @}
/branches/tracing/uspace/app/debug/cmd.c
50,8 → 50,9
static void cmd_go(int argc, char *argv[]);
static void cmd_istep(int argc, char *argv[]);
void cmd_help(int argc, char *argv[]);
static void cmd_memr(int argc, char *argv[]);
static void cmd_pwt(int argc, char *argv[]);
static void cmd_read(int argc, char *argv[]);
static void cmd_regs(int argc, char *argv[]);
static void cmd_stop(int argc, char *argv[]);
static void cmd_threads(int argc, char *argv[]);
static void cmd_quit(int argc, char *argv[]);
63,8 → 64,9
{ 1, "ct", cmd_ct },
{ 0, "go", cmd_go },
{ 0, "help", cmd_help },
{ 2, "memr", cmd_memr },
{ 0, "pwt", cmd_pwt },
{ 2, "read", cmd_read },
{ 0, "regs", cmd_regs },
{ 0 , "stop", cmd_stop },
{ 0, "istep", cmd_istep },
{ 0, "threads", cmd_threads },
141,16 → 143,9
/*TODO*/
}
 
void cmd_pwt(int argc, char *argv[])
{
(void)argc; (void)argv;
 
cons_printf("working thread: %d [hash 0x%x]\n", cwt->id, cwt->hash);
}
 
#define BYTES_PER_LINE 16
 
static void cmd_read(int argc, char *argv[])
static void cmd_memr(int argc, char *argv[])
{
uintptr_t addr;
size_t length;
194,8 → 189,20
}
}
 
void cmd_pwt(int argc, char *argv[])
{
(void)argc; (void)argv;
 
cons_printf("working thread: %d [hash 0x%x]\n", cwt->id, cwt->hash);
}
 
void cmd_regs(int argc, char *argv[])
{
(void)argc; (void)argv;
 
if (cwt) arch_dump_regs(cwt->hash);
}
 
void cmd_stop(int argc, char *argv[])
{
link_t *cur;
/branches/tracing/uspace/app/debug/dthread.c
129,16 → 129,16
 
unsigned dthread_get_pc(dthread_t *dt)
{
static unsigned istate_buffer[1024];
static istate_t istate;
int rc;
 
rc = udebug_regs_read(app_phone, dt->hash, istate_buffer);
rc = udebug_regs_read(app_phone, dt->hash, &istate);
if (rc < 0) {
printf("failed reading registers (%d)\n", rc);
return 0;
}
 
return istate_get_pc(istate_buffer);
return istate_get_pc(&istate);
}
 
/** @}
/branches/tracing/uspace/app/debug/arch/mips32/include/types.h
41,6 → 41,45
uint32_t back;
} breakpoint_arch_t;
 
typedef struct {
uint32_t at;
uint32_t v0;
uint32_t v1;
uint32_t a0;
uint32_t a1;
uint32_t a2;
uint32_t a3;
uint32_t t0;
uint32_t t1;
uint32_t t2;
uint32_t t3;
uint32_t t4;
uint32_t t5;
uint32_t t6;
uint32_t t7;
uint32_t s0;
uint32_t s1;
uint32_t s2;
uint32_t s3;
uint32_t s4;
uint32_t s5;
uint32_t s6;
uint32_t s7;
uint32_t t8;
uint32_t t9;
uint32_t gp;
uint32_t sp;
uint32_t s8;
uint32_t ra;
uint32_t lo;
uint32_t hi;
 
uint32_t status; /* cp0_status */
uint32_t epc; /* cp0_epc */
uint32_t k1; /* We use it as thread-local pointer */
} istate_t;
 
#endif
 
/** @}
/branches/tracing/uspace/app/debug/arch/mips32/src/mips32.c
131,5 → 131,9
(void)thread_hash;
}
 
void arch_dump_regs(thash_t thash)
{
}
 
/** @}
*/
/branches/tracing/uspace/app/debug/arch/ia32/include/types.h
39,8 → 39,32
unsigned char back;
} breakpoint_arch_t;
 
#define OFFSET_PC 12
typedef struct {
uint32_t eax;
uint32_t ecx;
uint32_t edx;
uint32_t esi;
uint32_t edi;
uint32_t ebp;
uint32_t ebx;
 
uint32_t gs;
uint32_t fs;
uint32_t es;
uint32_t ds;
 
uint32_t error_word;
uint32_t eip;
uint32_t cs;
uint32_t eflags;
uint32_t stack[];
} istate_t;
 
static inline uint32_t istate_get_pc(istate_t *istate)
{
return istate->eip;
}
 
#endif
 
/** @}
/branches/tracing/uspace/app/debug/arch/ia32/src/ia32.c
37,6 → 37,8
#include <sys/types.h>
#include <udebug.h>
 
#include <kernel/arch/context_offset.h>
 
#include "../../../cons.h"
#include "../../../main.h"
#include "../../../include/arch.h"
72,7 → 74,7
brk->set = 1;
}
 
static unsigned buffer[1024];
static istate_t istate;
static breakpoint_t *lifted_brkpt;
 
void arch_event_breakpoint(thash_t thread_hash)
79,10 → 81,10
{
int rc;
 
rc = udebug_regs_read(app_phone, thread_hash, buffer);
rc = udebug_regs_read(app_phone, thread_hash, &istate);
cons_printf("udebug_regs_read -> %d\n", rc);
cons_printf("EIP was 0x%08x\n", buffer[ISTATE_OFF_EIP]);
int brk_addr = buffer[ISTATE_OFF_EIP] - 1;
cons_printf("EIP was 0x%08x\n", istate.eip);
int brk_addr = istate.eip - 1;
int bi;
for (bi = 0; bi < MAX_BRKPTS; bi++) {
if (brk_list[bi].set && brk_list[bi].addr == brk_addr)
93,10 → 95,10
cons_printf("breakpoint %d hit\n", bi);
breakpoint_hit();
 
buffer[ISTATE_OFF_EIP] = brk_addr;
buffer[ISTATE_OFF_EFLAGS] |= 0x0100; /* trap flag */
cons_printf("setting EIP to 0x%08x\n", buffer[ISTATE_OFF_EIP]);
rc = udebug_regs_write(app_phone, thread_hash, buffer);
istate.eip = brk_addr;
istate.eflags |= 0x0100; /* trap flag */
cons_printf("setting EIP to 0x%08x\n", istate.eip);
rc = udebug_regs_write(app_phone, thread_hash, &istate);
rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 1);
cons_printf("udebug_mem_write(phone, 0x%x, 0x%02x, 1) -> %d\n", brk_addr, brk_list[bi].arch.back, rc);
lifted_brkpt = &brk_list[bi];
117,11 → 119,28
rc = udebug_mem_write(app_phone, brkinstr, lb->addr, 1);
cons_printf("restore breakpoint -> %d\n", rc);
 
rc = udebug_regs_read(app_phone, thread_hash, buffer);
rc = udebug_regs_read(app_phone, thread_hash, &istate);
cons_printf("udebug_regs_read -> %d\n", rc);
buffer[ISTATE_OFF_EFLAGS] &= ~0x0100; /* trap flag */
rc = udebug_regs_write(app_phone, thread_hash, buffer);
istate.eflags &= ~0x0100; /* trap flag */
rc = udebug_regs_write(app_phone, thread_hash, &istate);
}
 
void arch_dump_regs(thash_t thash)
{
int rc;
 
printf("arch_dump_regs...\n");
 
rc = udebug_regs_read(app_phone, thash, &istate);
if (rc < 0) { cons_printf("Error reading regs\n"); return; }
 
cons_printf(
"eip:%08x eflags:%08x eax:%08x ebx:%08x ecx:%08x edx:%08x\n"
"esi:%08x edi:%08x cs:%04x ds:%04x es:%04x fs:%04x gs:%04x\n",
istate.eip, istate.eflags, istate.eax, istate.ebx,
istate.ecx, istate.edx, istate.esi, istate.edi, istate.cs,
istate.ds, istate.es, istate.fs, istate.gs);
}
 
/** @}
*/