From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J.T. Conklin" To: gdb-patches@cygnus.com Subject: stub putDebugChar cleanup Date: Thu, 03 Dec 1998 11:53:00 -0000 Message-id: <199812031953.LAA12865@jtc.redbacknetworks.com> X-SW-Source: 1998/msg00109.html The enclosed change modifies the provided stubs so that putDebugChar() is declared as a void function as described in the documentation, and fixes the stubs where putpacket() erroneously treated putDebugChar()'s return value as an int. This once bit me when interfacing the i386 stub into a system and I implemented putDebugChar() to the documented specification. (Another way to fix the ambiguity would have been to change the spec so that putDebugChar would return success/failure. However, it's not clear to me what the stub can reasonably do in such a situation. As it is now, the packet will be munged by the dropped character(s), and the protocol will recover fairly robustly). --jtc 1998-12-03 J.T. Conklin * i386-stub.c, m32r-stub.c, m68k-stub.c, sh-stub.c, sparc-stub.c, sparcl-stub, sparclet-stub.c: Changed declaration of putDebugChar to include explicit void return type as per documentation. Fixed up occasions where stubs erroneously checked return type. Index: i386-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/i386-stub.c,v retrieving revision 1.2 diff -c -r1.2 i386-stub.c *** i386-stub.c 1998/12/03 01:00:06 1.2 --- i386-stub.c 1998/12/03 19:25:47 *************** *** 100,107 **** 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 Function exceptionHandler(); /* assign an exception handler */ extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ --- 100,107 ---- typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ typedef void (*Function)(); /* pointer to a function */ ! 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 */ *************** *** 527,533 **** count = 0; while (ch=buffer[count]) { ! if (! putDebugChar(ch)) return; checksum += ch; count += 1; } --- 527,533 ---- count = 0; while (ch=buffer[count]) { ! putDebugChar(ch); checksum += ch; count += 1; } Index: m32r-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/m32r-stub.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 m32r-stub.c *** m32r-stub.c 1998/12/03 00:05:16 1.1.1.1 --- m32r-stub.c 1998/12/03 19:26:17 *************** *** 94,101 **** * * external low-level support routines */ ! extern putDebugChar(); /* write a single character */ ! extern getDebugChar(); /* read and return a single char */ extern void exceptionHandler(); /* assign an exception handler */ /***************************************************************************** --- 94,101 ---- * * external low-level support routines */ ! extern void putDebugChar(); /* write a single character */ ! extern int getDebugChar(); /* read and return a single char */ extern void exceptionHandler(); /* assign an exception handler */ /***************************************************************************** *************** *** 581,587 **** count = 0; while (ch=buffer[count]) { ! if (! putDebugChar(ch)) return; checksum += ch; count += 1; } --- 581,587 ---- count = 0; while (ch=buffer[count]) { ! putDebugChar(ch); checksum += ch; count += 1; } Index: m68k-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/m68k-stub.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 m68k-stub.c *** m68k-stub.c 1998/12/03 00:05:16 1.1.1.1 --- m68k-stub.c 1998/12/03 19:26:39 *************** *** 116,123 **** 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 Function exceptionHandler(); /* assign an exception handler */ extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ --- 116,123 ---- typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ typedef void (*Function)(); /* pointer to a function */ ! 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 */ *************** *** 594,600 **** count = 0; while (ch=buffer[count]) { ! if (! putDebugChar(ch)) return; checksum += ch; count += 1; } --- 594,600 ---- count = 0; while (ch=buffer[count]) { ! putDebugChar(ch); checksum += ch; count += 1; } Index: sh-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/sh-stub.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 sh-stub.c *** sh-stub.c 1998/12/03 00:05:22 1.1.1.1 --- sh-stub.c 1998/12/03 19:29:02 *************** *** 202,209 **** static void handle_exception (int exceptionVector); void init_serial(); ! ! int putDebugChar (char); char getDebugChar (void); /* These are in the file but in asm statements so the compiler can't see them */ --- 202,208 ---- static void handle_exception (int exceptionVector); void init_serial(); ! void putDebugChar (char); char getDebugChar (void); /* These are in the file but in asm statements so the compiler can't see them */ *************** *** 1457,1464 **** #define BPS 32 /* 9600 for 10 Mhz */ #endif - char getDebugChar (void); - int putDebugChar (char); void handleError (char theSSR); void --- 1456,1461 ---- *************** *** 1531,1537 **** return (SSR1 & SCI_TDRE); } ! int putDebugChar (char ch) { while (!putDebugCharReady()) --- 1528,1534 ---- return (SSR1 & SCI_TDRE); } ! void putDebugChar (char ch) { while (!putDebugCharReady()) *************** *** 1542,1548 **** */ TDR1 = ch; SSR1 &= ~SCI_TDRE; - return 1; } void --- 1539,1544 ---- Index: sparc-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/sparc-stub.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 sparc-stub.c *** sparc-stub.c 1998/12/03 00:05:23 1.1.1.1 --- sparc-stub.c 1998/12/03 19:30:15 *************** *** 92,99 **** * external low-level support routines */ ! extern putDebugChar(); /* write a single character */ ! extern getDebugChar(); /* read and return a single char */ /************************************************************************/ /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ --- 92,99 ---- * external low-level support routines */ ! extern void putDebugChar(); /* write a single character */ ! extern int getDebugChar(); /* read and return a single char */ /************************************************************************/ /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ *************** *** 371,378 **** while (ch = buffer[count]) { ! if (! putDebugChar(ch)) ! return; checksum += ch; count += 1; } --- 371,377 ---- while (ch = buffer[count]) { ! putDebugChar(ch); checksum += ch; count += 1; } Index: sparclet-stub.c =================================================================== RCS file: /usr/rback/release/tools-src/gdb/gdb/sparclet-stub.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 sparclet-stub.c *** sparclet-stub.c 1998/12/03 00:05:21 1.1.1.1 --- sparclet-stub.c 1998/12/03 19:32:08 *************** *** 95,102 **** * external low-level support routines */ ! extern putDebugChar(); /* write a single character */ ! extern getDebugChar(); /* read and return a single char */ /************************************************************************/ /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ --- 95,102 ---- * external low-level support routines */ ! extern void putDebugChar(); /* write a single character */ ! extern int getDebugChar(); /* read and return a single char */ /************************************************************************/ /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ *************** *** 534,541 **** while (ch = buffer[count]) { ! if (! putDebugChar(ch)) ! return; checksum += ch; count += 1; } --- 534,540 ---- while (ch = buffer[count]) { ! putDebugChar(ch); checksum += ch; count += 1; }