use remote-utils facilities for baud_rate
[deliverable/binutils-gdb.git] / gdb / remote-udi.c
index 0c67bbbe9e959793fd7f2fa3ad78b897fa0dfda1..f74569bcc73c8a5f13430a3af4f6a32c50f308f9 100644 (file)
@@ -461,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;
@@ -470,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.  */
@@ -569,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
This page took 0.024197 seconds and 4 git commands to generate.