X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fi386-stub.c;h=b05170b4b111fc4a39ce2184c79ecd1d57b4a26d;hb=0d2856175c7a3c7609d5a42010d3439b1f9be238;hp=7f65316584060d3b2fc1ad4d489bb7636dd77bc3;hpb=740b7efa43f092a7732fabd39d5597a7a2f310b3;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/i386-stub.c b/gdb/i386-stub.c index 7f65316584..b05170b4b1 100644 --- a/gdb/i386-stub.c +++ b/gdb/i386-stub.c @@ -92,7 +92,6 @@ #include #include -#include "ansidecl.h" /************************************************************************ * @@ -101,8 +100,8 @@ typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ typedef void (*Function)(); /* pointer to a function */ -extern putDebugChar(); /* write a single character */ -extern getDebugChar(); /* read and return a single char */ +extern void putDebugChar(); /* write a single character */ +extern int getDebugChar(); /* read and return a single char */ extern Function exceptionHandler(); /* assign an exception handler */ extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ @@ -117,12 +116,14 @@ static char initialized; /* boolean flag. != 0 means we've been initialized */ int remote_debug; /* debug > 0 prints ill-formed commands in valid packets & checksum errors */ -void waitabit(); - static const char hexchars[]="0123456789abcdef"; +/* Number of registers. */ +#define NUMREGS 16 + /* Number of bytes of registers. */ -#define NUMREGBYTES 64 +#define NUMREGBYTES (NUMREGS * 4) + enum regnames {EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, PC /* also known as eip */, PS /* also known as eflags */, @@ -131,7 +132,7 @@ enum regnames {EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, /* * these should not be static cuz they can be used outside this module */ -int registers[NUMREGBYTES/4]; +int registers[NUMREGS]; #define STACKSIZE 10000 int remcomStack[STACKSIZE/sizeof(int)]; @@ -149,7 +150,7 @@ static ExceptionHook oldExceptionHook; /* */ extern void -return_to_prog PARAMS ((void)); +return_to_prog (); /* Restore the program's registers (including the stack pointer, which means we get the right stack and don't have to worry about popping our @@ -228,6 +229,7 @@ int gdb_i386vector = -1; asm ("cmpl $0, _mem_fault_routine"); \ asm ("jne mem_fault"); +asm (".text"); asm ("mem_fault:"); /* OK to clobber temp registers; we're just going to end up in set_mem_err. */ /* Pop error code from the stack and save it. */ @@ -467,7 +469,7 @@ char * buffer; do { /* wait around for the start character, ignore all other characters */ - while ((ch = getDebugChar()) != '$'); + while ((ch = (getDebugChar() & 0x7f)) != '$'); checksum = 0; xmitcsum = -1; @@ -475,7 +477,7 @@ char * buffer; /* now, read until a # or end of buffer is found */ while (count < BUFMAX) { - ch = getDebugChar(); + ch = getDebugChar() & 0x7f; if (ch == '#') break; checksum = checksum + ch; buffer[count] = ch; @@ -484,11 +486,11 @@ char * buffer; buffer[count] = 0; if (ch == '#') { - xmitcsum = hex(getDebugChar()) << 4; - xmitcsum += hex(getDebugChar()); + xmitcsum = hex(getDebugChar() & 0x7f) << 4; + xmitcsum += hex(getDebugChar() & 0x7f); if ((remote_debug ) && (checksum != xmitcsum)) { - fprintf(stderr,"bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); + fprintf (stderr ,"bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", + checksum,xmitcsum,buffer); } if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ @@ -525,7 +527,7 @@ char * buffer; count = 0; while (ch=buffer[count]) { - if (! putDebugChar(ch)) return; + putDebugChar(ch); checksum += ch; count += 1; } @@ -534,7 +536,7 @@ char * buffer; putDebugChar(hexchars[checksum >> 4]); putDebugChar(hexchars[checksum % 16]); - } while (getDebugChar() != '+'); + } while ((getDebugChar() & 0x7f) != '+'); } @@ -547,11 +549,11 @@ void debug_error(format, parm) char * format; char * parm; { - if (remote_debug) fprintf(stderr,format,parm); + if (remote_debug) fprintf (stderr,format,parm); } /* Address of a routine to RTE to if we get a memory fault. */ -static NORETURN void (*mem_fault_routine)() = NULL; +static void (*volatile mem_fault_routine)() = NULL; /* Indicate to caller of mem2hex or hex2mem that there has been an error. */ @@ -736,6 +738,22 @@ void handle_exception(int exceptionVector) hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES, 0); strcpy(remcomOutBuffer,"OK"); break; + case 'P' : /* set the value of a single CPU register - return OK */ + { + int regno; + + ptr = &remcomInBuffer[1]; + if (hexToInt (&ptr, ®no) && *ptr++ == '=') + if (regno >= 0 && regno < NUMREGS) + { + hex2mem (ptr, (char *)®isters[regno], 4, 0); + strcpy(remcomOutBuffer,"OK"); + break; + } + + strcpy (remcomOutBuffer, "E01"); + break; + } /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ case 'm' : @@ -829,7 +847,11 @@ void handle_exception(int exceptionVector) /* kill the program */ case 'k' : /* do nothing */ +#if 0 + /* Huh? This doesn't look like "nothing". + m68k-stub.c and sparc-stub.c don't have it. */ BREAKPOINT(); +#endif break; } /* switch */ @@ -869,12 +891,7 @@ int exception; exceptionHook = remcomHandler; } - /* In case GDB is started before us, ack any packets (presumably - "$?#xx") sitting there. */ - putDebugChar ('+'); - initialized = 1; - } /* This function will generate a breakpoint exception. It is used at the @@ -885,27 +902,5 @@ int exception; void breakpoint() { if (initialized) -#if 0 - handle_exception(3); -#else BREAKPOINT(); -#endif - waitabit(); -} - -int waitlimit = 1000000; - -#if 0 -void -bogon() -{ - waitabit(); -} -#endif - -void -waitabit() -{ - int i; - for (i = 0; i < waitlimit; i++) ; }