Mon Dec 21 12:40:10 1992 Ian Lance Taylor (ian@cygnus.com)
[binutils-gdb.git] / gdb / remote-hms.c
index e000957758ccc4d744c86105b18c06161ec7411e..216e5cf3cc72ff018282af8faee8a52411ef6695 100644 (file)
@@ -49,15 +49,6 @@ extern struct target_ops hms_ops;
 
 static int quiet = 1;
 
-#ifdef DEBUG
-# define DENTER(NAME) if (!quiet)  (printf_filtered("Entering %s\n",NAME), fflush(stdout))
-# define DEXIT(NAME)  if (!quiet)  (printf_filtered("Exiting  %s\n",NAME), fflush(stdout))
-#else
-# define DENTER(NAME)
-# define DEXIT(NAME)
-#endif
-
-
 /***********************************************************************/
 /* Caching stuff stolen from remote-nindy.c  */
 
@@ -260,11 +251,10 @@ int check_open()
 static int
 readchar ()
 {
-  int ok;
   int buf;
-  buf = serial_timedreadchar(timeout, &ok);
+  buf = serial_readchar(timeout);
 
-  if (!ok)
+  if (buf < 0)
    error ("Timeout reading from remote system.");
 
   if (!quiet)
@@ -276,10 +266,9 @@ readchar ()
 static int
 readchar_nofail ()
 {
-  int ok;
   int buf;
-  buf = serial_timedreadchar(timeout, &ok);
-  if (!ok) buf = 0;
+  buf = serial_readchar(timeout);
+  if (buf < 0) buf = 0;
   if (!quiet)
    printf("%c",buf);
   
@@ -417,8 +406,6 @@ int fromtty;
   int  n;
   char buffer[1024];
 
-   
-  DENTER("hms_load()");
   check_open();
 
   dcache_flush();
@@ -466,8 +453,6 @@ int fromtty;
   sprintf(buffer, "r PC=%x", abfd->start_address);
   hms_write_cr(buffer);
   expect_prompt();
-  
-  DEXIT("hms_load()");
 }
 
 /* This is called not only when we first attach, but also when the
@@ -480,7 +465,6 @@ hms_create_inferior (execfile, args, env)
 {
   int entry_pt;
   char buffer[100];    
-  DENTER("hms_create_inferior()");
 
   if (args && *args)
    error ("Can't pass arguments to remote hms process.");
@@ -500,9 +484,6 @@ hms_create_inferior (execfile, args, env)
 
   insert_breakpoints ();       /* Needed to get correct instruction in cache */
   proceed(entry_pt, -1, 0);
-
-
-  DEXIT("hms_create_inferior()");
 }
 
 
@@ -561,8 +542,8 @@ is_baudrate_right()
   
   while (1) 
   {
-    serial_timedreadchar(timeout, &ok);
-    if (!ok) break;
+    ok = serial_readchar(timeout);
+    if (ok < 0) break;
   }
 
   hms_write("r",1);
@@ -583,6 +564,7 @@ set_rate()
 static void
 get_baudrate_right()
 {
+#if 0
   while (!is_baudrate_right()) 
   {
     baudrate = serial_nextbaudrate(baudrate);
@@ -594,6 +576,7 @@ get_baudrate_right()
     QUIT;
     serial_setbaudrate(baudrate);
   }
+#endif
 }
 
 static void
@@ -605,27 +588,21 @@ hms_open (name, from_tty)
   unsigned int prl;
   char *p;
   
-  DENTER("hms_open()");
   if(name == 0) 
   {
     name = "";
-    
   }
   if (is_open)  
-   hms_close (0);
+    hms_close (0);
   if (name && strlen(name))
-   dev_name = strdup(name);
+    dev_name = strdup(name);
   if (!serial_open(dev_name))
-   perror_with_name ((char *)dev_name);
+    perror_with_name ((char *)dev_name);
   serial_raw();
   is_open = 1;
 
-
   dcache_init();
 
-
-  /* start_remote ();              /* Initialize gdb process mechanisms */
-
   get_baudrate_right();
   
   /* Hello?  Are you there?  */
@@ -635,10 +612,7 @@ hms_open (name, from_tty)
   /* Clear any break points */
   hms_clear_breakpoints();
 
-
   printf_filtered("Connected to remote H8/300 HMS system.\n");
-
-  DEXIT("hms_open()");
 }
 
 /* Close out all files and local state before this target loses control. */
@@ -648,7 +622,6 @@ hms_close (quitting)
      int quitting;
 {
 
-  DENTER("hms_close()");
 
   /* Clear any break points */
   hms_clear_breakpoints();
@@ -658,39 +631,8 @@ hms_close (quitting)
   serial_write("R\r", 2);
   serial_close();
   is_open = 0;
-
-  DEXIT("hms_close()");
 }
 
-/* Attach to the target that is already loaded and possibly running */
-static void
-hms_attach (args, from_tty)
-     char *args;
-     int from_tty;
-{
-
-  DENTER("hms_attach()");
-
-  /* push_target(&hms_ops);    /* This done in hms_open() */
-
-  mark_breakpoints_out ();
-
-  /* Send the hms a kill. It is ok if it is not already running */
-#if 0
-  fprintf(hms_stream, "K\r"); 
-  expect_prompt();             /* Slurp the echo */
-#endif
-  /* We will get a task spawn event immediately.  */
-  init_wait_for_inferior ();
-  clear_proceed_status ();
-  stop_soon_quietly = 1;
-  wait_for_inferior ();
-  stop_soon_quietly = 0;
-  normal_stop ();
-  DEXIT("hms_attach()");
-}
-
-
 /* Terminate the open connection to the remote debugger.
    Use this when you want to detach and do something else
    with your gdb.  */
@@ -699,7 +641,6 @@ hms_detach (args,from_tty)
      char *args;
      int from_tty;
 {
-  DENTER("hms_detach()");
   if (is_open)
   { 
        hms_clear_breakpoints();
@@ -708,7 +649,6 @@ hms_detach (args,from_tty)
   pop_target();                /* calls hms_close to do the real work */
   if (from_tty)
     printf_filtered ("Ending remote %s debugging\n", target_shortname);
-  DEXIT("hms_detach()");
 }
  
 /* Tell the remote machine to resume.  */
@@ -717,7 +657,6 @@ void
 hms_resume (step, sig)
      int step, sig;
 {
-  DENTER("hms_resume()");
   dcache_flush();
   
   if (step)    
@@ -735,7 +674,6 @@ hms_resume (step, sig)
     hms_write_cr("g");
     expect("g");
   }
-  DEXIT("hms_resume()");
 }
 
 /* Wait until the remote machine stops, then return,
@@ -769,8 +707,6 @@ hms_wait (status)
   int old_immediate_quit = immediate_quit;
   int swallowed_cr = 0;
   
-  DENTER("hms_wait()");
-
   WSETEXIT ((*status), 0);
 
   if (need_artificial_trap != 0)
@@ -844,7 +780,6 @@ hms_wait (status)
   
   timeout = old_timeout;
   immediate_quit = old_immediate_quit;
-  DEXIT("hms_wait()");
   return 0;
 }
 
@@ -1009,9 +944,6 @@ hms_store_register (regno)
     hms_write_cr(buffer);
     expect_prompt();
   }
-  
-  DEXIT("hms_store_registers()");
-
 }
 
 
@@ -1296,7 +1228,6 @@ hms_insert_breakpoint(addr, save)
 CORE_ADDR      addr;
 char           *save;  /* Throw away, let hms save instructions */
 {
-  DENTER("hms_insert_breakpoint()"); 
   check_open();
   
   if (num_brkpts < MAX_BREAKS) 
@@ -1306,14 +1237,12 @@ char            *save;  /* Throw away, let hms save instructions */
     sprintf(buffer,"b %x", addr & 0xffff);
     hms_write_cr(buffer);
     expect_prompt ();
-    DEXIT("hms_insert_breakpoint() success"); 
     return(0);
   }
   else 
   {
     fprintf_filtered(stderr,
                     "Too many break points, break point not installed\n");
-    DEXIT("hms_insert_breakpoint() failure"); 
     return(1);
   }
 
@@ -1324,7 +1253,6 @@ hms_remove_breakpoint(addr, save)
 CORE_ADDR      addr;
 char           *save;  /* Throw away, let hms save instructions */
 {
-  DENTER("hms_remove_breakpoint()");
   if (num_brkpts > 0) 
   {
     char buffer[100];
@@ -1335,7 +1263,6 @@ char              *save;  /* Throw away, let hms save instructions */
     expect_prompt();
       
   }
-  DEXIT("hms_remove_breakpoint()");
   return(0);
 }
 
@@ -1344,21 +1271,17 @@ static int
 hms_clear_breakpoints() 
 { 
 
-  DENTER("hms_clear_breakpoint()");
   if (is_open) {
     hms_write_cr("b -");
     expect_prompt ();
   }
   num_brkpts = 0;
-  DEXIT("hms_clear_breakpoint()");
 }
 static void
 hms_mourn() 
 { 
-  DENTER("hms_mourn()");
   hms_clear_breakpoints();
   generic_mourn_inferior ();
-  DEXIT("hms_mourn()");
 }
 
 
@@ -1393,9 +1316,9 @@ struct target_ops hms_ops = {
 by a serial line.",
 
        hms_open, hms_close, 
-       hms_attach, hms_detach, hms_resume, hms_wait,
+       0, hms_detach, hms_resume, hms_wait,    /* attach */
        hms_fetch_register, hms_store_register,
-       hms_prepare_to_store, 0, 0,     /* conv_to, conv_from */
+       hms_prepare_to_store,
        hms_xfer_inferior_memory, 
        hms_files_info,
        hms_insert_breakpoint, hms_remove_breakpoint, /* Breakpoints */
@@ -1405,6 +1328,8 @@ by a serial line.",
        0,                      /* lookup_symbol */
        hms_create_inferior,    /* create_inferior */ 
        hms_mourn,              /* mourn_inferior FIXME */
+       0,                      /* can_run */
+       0,                      /* notice_signals */
        process_stratum, 0, /* next */
        1, 1, 1, 1, 1,  /* all mem, mem, stack, regs, exec */
        0,0,            /* Section pointers */
@@ -1475,7 +1400,8 @@ _initialize_remote_hms ()
   add_com ("speed", class_obscure, hms_speed,
           "Set the terminal line speed for HMS communications");
   
+#if 0
   dev_name = serial_default_name();
+#endif
+  dev_name = NULL;
 }
-
-