This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

Patch for RDI target code to allow user-specified devices



Hello,

The attached patch against 4.18 sources modifies the RDI target
unix comm code to allow users to specify any device they please
to be used for serial and/or parallel communication with the
target.

The current routines limit the user to a certain set of devices
(which never seems to include the one I want).  I've tripped
over this many times.  With the patch applied, the target
commands like

 target rdi s=/whatever/flipping/device/the/user/wants
 target rdi s=/serial/device/name,p=/parallel/device/name

Will accept whatever the user specifies (I think the path is
limited to 64 characters).  After all it's _my_ computer and I
do, in fact, know which serial port is hooked to the target!
The fact that the ARM Ltd. code won't believe me has always
been annoying...

Yes, I know, the patched code uses a different indenting style
that the rest of the file -- if this is a problem, feel free to
re-indent it however you please.  I simply can not easily grok
the existing style.

-- 
Grant Edwards
grante@visi.com
--- /home/grante/gdb-4.18/gdb/rdi-share/unixcomm.c	Mon Feb 21 13:59:36 2000
+++ /home/grante/gdb-4.18.working/gdb/rdi-share/unixcomm.c	Mon Feb 21 11:33:38 2000
@@ -106,7 +106,7 @@
 #define SERIAL_PREFIX "com"
 #endif
 
-
+#define min(a,b) ((a)<(b) ? (a) : (b))
 
 /*
  * Parallel port output pins, used for signalling to target
@@ -195,30 +195,37 @@
         len=(j-i);
 
         /* And now try to match the serial / parallel port */
-        switch (ch) {
-          case 's': {
-            /* Match serial port */
-            if (len==1) {
-              if (name[i]=='1') 
-                  sername=SERPORT1;
-              else if (name[i]=='2') 
-                  sername=SERPORT2;
-            } else if (len==strlen(SERPORT1)) {
-              if (strncmp(name+i,SERPORT1,strlen(SERPORT1)) == 0)
-                sername=SERPORT1;
-              else if (strncmp(name+i,SERPORT2,strlen(SERPORT2)) == 0)
-                sername=SERPORT2;
-            }
-
+        switch (ch) 
+          {
+           case 's': 
+              {
+                /* Match serial port */
+                if (len==1) 
+                  {
+                    if (name[i]=='1') 
+                      sername=SERPORT1;
+                    else if (name[i]=='2') 
+                      sername=SERPORT2;
+                  }
+                else
+                  {
+                    /* let them use whatever port they want! */
+                    static char serPortName[64];
+                    int    l = min(len,(sizeof serPortName)-1);
+                    strncpy(serPortName,name+i,l);
+                    serPortName[l] = '\0';
+                    sername = serPortName;
+                  }
+              }
+            
             break;
-          }
-
-          case 'h': 
+            
+           case 'h': 
             /* We don't actually deal with the H case here, we just
              * match it and allow it through.
              */
             break;
-        }
+          }
 
         if (continue_from == -1) return sername;
         i = continue_from;
@@ -407,41 +414,59 @@
         len=(j-i);
 
         /* And now try to match the serial / parallel port */
-        switch (ch) {
-          case 's': {
-            /* Match serial port */
-            if (len==1) {
-              if (portstring[i]=='1') *sername=SERPORT1;
-              else if (portstring[i]=='2') *sername=SERPORT2;
-            } else if (len==strlen(SERPORT1)) {
-              if (strncmp(portstring+i,SERPORT1,strlen(SERPORT1)) == 0)
-                *sername=SERPORT1;
-              else if (strncmp(portstring+i,SERPORT2,strlen(SERPORT2)) == 0)
-                *sername=SERPORT2;
-            }
+        switch (ch) 
+          {
+           case 's': 
+              {
+                /* Match serial port */
+                if (len==1) 
+                  {
+                    if (portstring[i]=='1') 
+                      *sername=SERPORT1;
+                    else if (portstring[i]=='2') 
+                      *sername=SERPORT2;
+                  } 
+                else
+                  {
+                    /* let them use whatever port they want! */
+                    static char serPortName[64];
+                    int    l = min(len,(sizeof serPortName)-1);
+                    strncpy(serPortName,portstring+i,l);
+                    serPortName[l] = '\0';
+                    *sername = serPortName;
+                  }
+              }
             break;
-          }
+            
+           case 'p': 
+              {
+                /* Match parallel port */
+                if (len==1) 
+                  {
+                  if (portstring[i]=='1') 
+                      *parname=PARPORT1;
+                    else if (portstring[i]=='2') 
+                      *parname=PARPORT2;
+                  } 
+                else
+                  {
+                    /* let them use whatever port they want! */
+                    static char parPortName[64];
+                    int    l = min(len,(sizeof parPortName)-1);
+                    strncpy(parPortName,portstring+i,l);
+                    parPortName[l] = '\0';
+                    *parname = parPortName;
+                  }
 
-          case 'p': {
-            /* Match parallel port */
-            if (len==1) {
-              if (portstring[i]=='1') *parname=PARPORT1;
-              else if (portstring[i]=='2') *parname=PARPORT2;
-            } else if (len==strlen(PARPORT1)) {
-              if (strncmp(portstring+i,PARPORT1,strlen(PARPORT1)) == 0)
-                *parname=PARPORT1;
-              else if (strncmp(portstring+i,PARPORT2,strlen(PARPORT2)) == 0)
-                *parname=PARPORT2;
-            }
+              }
             break;
-          }
-
-          case 'h': 
+            
+           case 'h': 
             /* We don't actually deal with the H case here, we just
              * match it and allow it through.
              */
             break;
-        }
+          }
 
         if (continue_from == -1) return;
         i = continue_from;

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