This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386-stub.c enhancement, cleanup


The enclosed patch cleans up the sample i386 remote debug stub and
enhances it slightly by adding support for the 'P' command (set the
value of a single register).  

The cleanup consisted of removing the waitlimit variable and the
waitabit() function (which called after the breakpoint() function).
There is no purpose to be served by such a delay (except, perhaps, to
frustrate debugger users) and no other stub has such a "feature".

	  --jtc

1998-12-02  J.T. Conklin  <jtc@redbacknetworks.com>

	* i386-stub.c (handle_exception): Add support for 'P' command.
	(NUMREGS): New macro.
	(waitabit, waitlimit): Deleted.

Index: i386-stub.c
===================================================================
RCS file: /usr/rback/release/tools-src/gdb/gdb/i386-stub.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 i386-stub.c
*** i386-stub.c	1998/12/03 00:05:14	1.1.1.1
--- i386-stub.c	1998/12/03 00:21:44
***************
*** 116,127 ****
  int     remote_debug;
  /*  debug >  0 prints ill-formed commands in valid packets & checksum errors */
  
- void waitabit();
- 
  static const char hexchars[]="0123456789abcdef";
  
  /* Number of bytes of registers.  */
! #define NUMREGBYTES 64
  enum regnames {EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI,
  	       PC /* also known as eip */,
  	       PS /* also known as eflags */,
--- 116,129 ----
  int     remote_debug;
  /*  debug >  0 prints ill-formed commands in valid packets & checksum errors */
  
  static const char hexchars[]="0123456789abcdef";
  
+ /* Number of registers.  */
+ #define NUMREGS		16
+ 
  /* Number of bytes of registers.  */
! #define NUMREGBYTES	(NUMREGS * 4)
! 
  enum regnames {EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI,
  	       PC /* also known as eip */,
  	       PS /* also known as eflags */,
***************
*** 130,136 ****
  /*
   * these should not be static cuz they can be used outside this module
   */
! int registers[NUMREGBYTES/4];
  
  #define STACKSIZE 10000
  int remcomStack[STACKSIZE/sizeof(int)];
--- 132,138 ----
  /*
   * these should not be static cuz they can be used outside this module
   */
! int registers[NUMREGS];
  
  #define STACKSIZE 10000
  int remcomStack[STACKSIZE/sizeof(int)];
***************
*** 732,741 ****
        case 'g' : /* return the value of the CPU registers */
                  mem2hex((char*) registers, remcomOutBuffer, NUMREGBYTES, 0);
                  break;
        case 'G' : /* set the value of the CPU registers - return OK */
!                 hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES, 0);
!                 strcpy(remcomOutBuffer,"OK");
!                 break;
  
        /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
        case 'm' :
--- 734,759 ----
        case 'g' : /* return the value of the CPU registers */
                  mem2hex((char*) registers, remcomOutBuffer, NUMREGBYTES, 0);
                  break;
+       case 'P' : /* set the value of a signle CPU register - return OK */
+           {
+             int regno;
+ 
+             ptr = &remcomInBuffer[1];
+             if (hexToInt (&ptr, &regno) && *ptr++ == '=') 
+               if (regno >= 0 && regno < NUMREGS)
+                 {
+                   hex2mem (ptr, (char *)&registers[regno], 4, 0);
+                   strcpy(remcomOutBuffer,"OK");
+                   break;
+                 }
+ 
+             strcpy (remcomOutBuffer, "P01");
+             break;
+           }
        case 'G' : /* set the value of the CPU registers - return OK */
!           hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES, 0);
!           strcpy(remcomOutBuffer,"OK");
!           break;
  
        /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
        case 'm' :
***************
*** 889,915 ****
  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++) ;
  }
--- 907,911 ----