diff --git a/src/libsys/gdb_stub.c b/src/libsys/gdb_stub.c index 9974804..75f971e 100644 --- a/src/libsys/gdb_stub.c +++ b/src/libsys/gdb_stub.c @@ -115,7 +115,6 @@ void flush_i_cache() /* at least NUMREGBYTES*2 are needed for register packets */ #define BUFMAX 2048 -static int initialized = 0; /* !0 means we've been initialized */ static const char hexchars[]="0123456789abcdef"; #define NUMREGS 72 @@ -335,11 +334,13 @@ hex2mem (unsigned char *buf, unsigned char *mem, int count, int may_fault) signals, which are primarily what GDB understands. It also indicates which hardware traps we need to commandeer when initializing the stub. */ -static struct hard_trap_info +struct hard_trap_info_t { - unsigned char tt; /* Trap type code for SPARClite */ - unsigned char signo; /* Signal that we map this trap into */ -} hard_trap_info[] = + unsigned long tt; /* Trap type code for SPARClite */ + unsigned long signo; /* Signal that we map this trap into */ +}; + +static struct hard_trap_info_t hard_trap_info[] = { {0, SIGINT}, /* Interrupt (Int) */ {1, SIGSEGV}, /* TLB modification (Mod) */ @@ -357,21 +358,20 @@ static struct hard_trap_info {0, 0} /* Must be last */ }; -/* Set up exception handlers for tracing and breakpoints */ - -void -set_debug_traps (void) -{ - // Register exception handler - - initialized = 1; -} - /* Convert the SPARC hardware trap type code to a unix signal number. */ static unsigned long computeSignal (unsigned long tt) { // Determine linux signal from CPU specific exception code + struct hard_trap_info_t *ht; + + for (ht = hard_trap_info; ht->signo != 0; ht++) + { + if (ht->tt == tt) + { + return ht->signo; + } + } return SIGHUP; /* default for things we don't know about */ } @@ -424,7 +424,7 @@ handle_exception (unsigned long *registers) registers[PC] += 4; } - sp = (unsigned long *)registers[R29]; + sp = (unsigned long *)®isters[R29]; tt = (registers[CR] >> 2) & 0x1f; @@ -436,14 +436,14 @@ handle_exception (unsigned long *registers) *ptr++ = hexchars[sigval >> 4]; *ptr++ = hexchars[sigval & 0xf]; - *ptr++ = hexchars[PC >> 4]; - *ptr++ = hexchars[PC & 0xf]; + *ptr++ = hexchars[37 >> 4]; + *ptr++ = hexchars[37 & 0xf]; *ptr++ = ':'; ptr = mem2hex((char *)®isters[PC], ptr, 4, 0); *ptr++ = ';'; - *ptr++ = hexchars[R29 >> 4]; - *ptr++ = hexchars[R29 & 0xf]; + *ptr++ = hexchars[29 >> 4]; + *ptr++ = hexchars[29 & 0xf]; *ptr++ = ':'; ptr = mem2hex((char *)sp, ptr, 4, 0); *ptr++ = ';';