--- zzzz-none-000/linux-2.4.17/arch/mips/kernel/gdb-stub.c 2001-09-09 17:43:01.000000000 +0000 +++ sangam-fb-322/linux-2.4.17/arch/mips/kernel/gdb-stub.c 2004-11-24 13:22:35.000000000 +0000 @@ -11,8 +11,6 @@ * Send complaints, suggestions etc. to * * Copyright (C) 1995 Andreas Busse - * - * $Id: gdb-stub.c,v 1.6 1999/05/01 22:40:35 ralf Exp $ */ /* @@ -128,6 +126,7 @@ #include #include #include +#include #include #include @@ -353,7 +352,9 @@ { 6, SIGBUS }, /* instruction bus error */ { 7, SIGBUS }, /* data bus error */ { 9, SIGTRAP }, /* break */ +#ifndef CONFIG_CPU_LX45XXX { 10, SIGILL }, /* reserved instruction */ +#endif /* { 11, SIGILL }, */ /* CPU unusable */ { 12, SIGFPE }, /* overflow */ { 13, SIGTRAP }, /* trap */ @@ -578,7 +579,7 @@ async_bp.addr = epc; async_bp.val = *(unsigned *)epc; *(unsigned *)epc = BP; - flush_cache_all(); + __flush_cache_all(); } @@ -593,10 +594,11 @@ int sigval; int addr; int length; + int done = 0; char *ptr; unsigned long *stack; -#if 0 +#if 0 printk("in handle_exception()\n"); show_gdbregs(regs); #endif @@ -609,7 +611,7 @@ * traps for now. */ trap = (regs->cp0_cause & 0x7c) >> 2; -/* printk("trap=%d\n",trap); */ + /* printk("trap=%d\n",trap); */ if (trap == 11) { if (((regs->cp0_cause >> CAUSEB_CE) & 3) == 1) { regs->cp0_status |= ST0_CU1; @@ -695,7 +697,7 @@ /* * Wait for input from remote GDB */ - while (1) { + while (!done) { output_buffer[0] = 0; getpacket(input_buffer); @@ -713,6 +715,15 @@ break; /* + * kill the program; same treatment as detach + */ + case 'k': + case 'D': + done = 1; + __flush_cache_all(); + break; + + /* * Return the value of the CPU registers */ case 'g': @@ -727,26 +738,21 @@ /* * set the value of the CPU registers - return OK - * FIXME: Needs to be written */ case 'G': { -#if 0 - unsigned long *newsp, psr; - ptr = &input_buffer[1]; - hex2mem(ptr, (char *)registers, 16 * 4, 0); /* G & O regs */ - - /* - * See if the stack pointer has moved. If so, then copy the - * saved locals and ins to the new location. - */ - - newsp = (unsigned long *)registers[SP]; - if (sp != newsp) - sp = memcpy(newsp, sp, 16 * 4); - -#endif + hex2mem(ptr, (char *)®s->reg0, 32*4, 0); + ptr += 32*8; + hex2mem(ptr, (char *)®s->cp0_status, 6*4, 0); + ptr += 6*8; + hex2mem(ptr, (char *)®s->fpr0, 32*4, 0); + ptr += 32*8; + hex2mem(ptr, (char *)®s->cp1_fsr, 2*4, 0); + ptr += 2*8; + hex2mem(ptr, (char *)®s->frame_ptr, 2*4, 0); + ptr += 2*8; + hex2mem(ptr, (char *)®s->cp0_index, 16*4, 0); strcpy(output_buffer,"OK"); } break; @@ -805,20 +811,13 @@ * NB: We flush both caches, just to be sure... */ - flush_cache_all(); + __flush_cache_all(); return; /* NOTREACHED */ break; /* - * kill the program - */ - case 'k' : - break; /* do nothing */ - - - /* * Reset the whole machine (FIXME: system dependent) */ case 'r': @@ -834,7 +833,7 @@ * use breakpoints and continue, instead. */ single_step(regs); - flush_cache_all(); + __flush_cache_all(); return; /* NOTREACHED */ @@ -923,11 +922,24 @@ "); } +/* + * malloc is needed by gdb client in "call func()", even a private one + * will make gdb happy + */ +static void *malloc(size_t size) +{ + return kmalloc(size, GFP_ATOMIC); +} + +static void free(void *where) +{ + kfree(where); +} + #ifdef CONFIG_GDB_CONSOLE -void gdb_puts(const char *str) +void gdb_putsn(const char *str, int l) { - int l = strlen(str); char outbuf[18]; outbuf[0]='O'; @@ -949,7 +961,7 @@ static void gdb_console_write(struct console *con, const char *s, unsigned n) { - gdb_puts(s); + gdb_putsn(s, n); } static struct console gdb_console = {