2012-03-01 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / i386-stub.c
index 7aa5da9369c1337fb30fa30b4c3bd87f16b4f2aa..04996b75cf68073a9bdc3baba92ad96419d567fd 100644 (file)
@@ -474,7 +474,7 @@ getpacket (void)
       count = 0;
 
       /* now, read until a # or end of buffer is found */
-      while (count < BUFMAX)
+      while (count < BUFMAX - 1)
        {
          ch = getDebugChar ();
          if (ch == '$')
@@ -532,7 +532,7 @@ putpacket (unsigned char *buffer)
   int count;
   char ch;
 
-  /*  $<packet info>#<checksum>. */
+  /*  $<packet info>#<checksum>.  */
   do
     {
       putDebugChar ('$');
@@ -758,10 +758,29 @@ handle_exception (int exceptionVector)
 
   /* reply to host that an exception has occurred */
   sigval = computeSignal (exceptionVector);
-  remcomOutBuffer[0] = 'S';
-  remcomOutBuffer[1] = hexchars[sigval >> 4];
-  remcomOutBuffer[2] = hexchars[sigval % 16];
-  remcomOutBuffer[3] = 0;
+
+  ptr = remcomOutBuffer;
+
+  *ptr++ = 'T';                        /* notify gdb with signo, PC, FP and SP */
+  *ptr++ = hexchars[sigval >> 4];
+  *ptr++ = hexchars[sigval & 0xf];
+
+  *ptr++ = hexchars[ESP]; 
+  *ptr++ = ':';
+  ptr = mem2hex((char *)&registers[ESP], ptr, 4, 0);   /* SP */
+  *ptr++ = ';';
+
+  *ptr++ = hexchars[EBP]; 
+  *ptr++ = ':';
+  ptr = mem2hex((char *)&registers[EBP], ptr, 4, 0);   /* FP */
+  *ptr++ = ';';
+
+  *ptr++ = hexchars[PC]; 
+  *ptr++ = ':';
+  ptr = mem2hex((char *)&registers[PC], ptr, 4, 0);    /* PC */
+  *ptr++ = ';';
+
+  *ptr = '\0'
 
   putpacket (remcomOutBuffer);
 
@@ -923,7 +942,7 @@ set_debug_traps (void)
 /* This function will generate a breakpoint exception.  It is used at the
    beginning of a program to sync up with a debugger and can be used
    otherwise as a quick means to stop program execution and "break" into
-   the debugger. */
+   the debugger.  */
 
 void
 breakpoint (void)
This page took 0.027191 seconds and 4 git commands to generate.