use remote-utils facilities for baud_rate
[deliverable/binutils-gdb.git] / gdb / remote-udi.c
index edb42f751770d0449459dd7041dbbef5ff2632db..f74569bcc73c8a5f13430a3af4f6a32c50f308f9 100644 (file)
@@ -45,6 +45,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "29k-share/udi/udiproc.h"
 #include "gdbcmd.h"
 #include "bfd.h"
+#include "gdbcore.h" /* For download function */
 
 /* access the register store directly, without going through
    the normal handler functions. This avoids an extra data copy.  */
@@ -52,7 +53,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 static int kiodebug;
 extern int stop_soon_quietly;           /* for wait_for_inferior */
 extern struct value *call_function_by_hand();
-static void udi_resume PARAMS ((int step, int sig));
+static void udi_resume PARAMS ((int pid, int step, int sig));
 static void udi_fetch_registers PARAMS ((int regno));
 static void udi_load PARAMS ((char *args, int from_tty));
 static void fetch_register PARAMS ((int regno));
@@ -403,8 +404,8 @@ udi_detach (args,from_tty)
 ** Tell the remote machine to resume.  */
 
 static void
-udi_resume (step, sig)
-     int step, sig;
+udi_resume (pid, step, sig)
+     int pid, step, sig;
 {
   UDIError tip_error;
   UDIUInt32 Steps = 1;
@@ -460,7 +461,10 @@ udi_wait (status)
        {
        case UDIStdoutReady:
          if (UDIGetStdout (sbuf, (UDISizeT)SBUF_MAX, &CountDone))
-           error ("UDIGetStdout() failed in udi_wait");
+           /* This is said to happen if the program tries to output
+              a whole bunch of output (more than SBUF_MAX, I would
+              guess).  It doesn't seem to happen with the simulator.  */
+           warning ("UDIGetStdout() failed in udi_wait");
          fwrite (sbuf, 1, CountDone, stdout);
          fflush(stdout);
          continue;
@@ -469,11 +473,22 @@ udi_wait (status)
          fwrite (sbuf, 1, CountDone, stderr);
          fflush(stderr);
          continue;
+
        case UDIStdinNeeded:
-         scanf ("%s", sbuf);
-         i = strlen (sbuf);
-         UDIPutStdin (sbuf, (UDISizeT)i, &CountDone);
-         continue;
+         {
+           int ch;
+           i = 0;
+           do
+             {
+               ch = getchar ();
+               if (ch == EOF)
+                 break;
+               sbuf[i++] = ch;
+             } while (i < SBUF_MAX && ch != '\n');
+           UDIPutStdin (sbuf, (UDISizeT)i, &CountDone);
+           continue;
+         }
+
        case UDIRunning:
          /* In spite of the fact that we told UDIWait to wait forever, it will
             return spuriously sometimes.  */
@@ -568,7 +583,7 @@ udi_wait (status)
 
   timeout = old_timeout;       /* Restore original timeout value */
   immediate_quit = old_immediate_quit;
-  return 0;
+  return inferior_pid;
 }
 
 /********************************************************** UDI_FETCH_REGISTERS
@@ -1038,7 +1053,7 @@ download(load_arg_string, from_tty)
        }
     }
 
-  pbfd = bfd_openr (filename, 0);
+  pbfd = bfd_openr (filename, gnutarget);
 
   if (!pbfd) 
     perror_with_name (filename);
@@ -1476,12 +1491,13 @@ void  convert16() {;}
 void  convert32() {;}
 FILE* EchoFile = 0;            /* used for debugging */
 int   QuietMode = 0;           /* used for debugging */
+\f
+/* Target_ops vector.  Not static because there does not seem to be
+   any portable way to do a forward declaration of a static variable.
+   The RS/6000 doesn't like "extern" followed by "static"; SunOS
+   /bin/cc doesn't like "static" twice.  */
 
-/****************************************************************************/
-/* 
- *  Define the target subroutine names 
- */
-static struct target_ops udi_ops = {
+struct target_ops udi_ops = {
         "udi",
        "Remote UDI connected TIP",
        "Remote debug an AMD 29k using UDI socket connection to TIP process.\n\
This page took 0.02455 seconds and 4 git commands to generate.