* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / remote-udi.c
index 681854c0f491dfb49fa457d76d77858834c8e3d7..6b586cb7da7d667ff2d21bfdf50c3c96c95a5b51 100644 (file)
@@ -81,7 +81,7 @@ char   CoffFileName[100] = "";
 #define TYPE_A29050     3
 static  char *processor_name[] = { "Unknown", "Am29000", "Am29030", "Am29050" };
 static  int processor_type=TYPE_UNKNOWN;
-#define FREEZE_MODE     (read_register(CPS_REGNUM) && 0x400)
+#define FREEZE_MODE     (read_register(CPS_REGNUM) & 0x400)
 #define USE_SHADOW_PC  ((processor_type == TYPE_A29050) && FREEZE_MODE) 
 
 #define LLOG_FILE "udi.log"
@@ -238,6 +238,11 @@ udi_open (name, from_tty)
 
   target_preopen(from_tty);
 
+  entry.Offset = 0;
+
+  for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
+    bkpt_table[cnt].Type = 0;
+
   if (udi_config_id)
     free (udi_config_id);
 
@@ -391,6 +396,7 @@ udi_attach (args, from_tty)
   UDISizeT     Size = 4;
   UDICount     CountDone;
   UDIBool      HostEndian = 0;
+  UDIError     err;
 
   if (udi_session_id < 0)
       error ("UDI connection not opened yet, use the 'target udi' command.\n");
@@ -399,9 +405,9 @@ udi_attach (args, from_tty)
       printf ("Attaching to remote program %s...\n", prog_name);
 
   UDIStop();
-  From.Space = 11;
-  From.Offset = UDI29KSpecialRegs;
-  if(UDIRead(From, &PC_adds, Count, Size, &CountDone, HostEndian))
+  From.Space = UDI29KSpecialRegs;
+  From.Offset = 11;
+  if (err = UDIRead(From, &PC_adds, Count, Size, &CountDone, HostEndian))
     error ("UDIRead failed in udi_attach");
   printf ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds);
 }
@@ -488,7 +494,7 @@ udi_wait (status)
        {
        case UDIStdoutReady:
          if (UDIGetStdout (sbuf, (UDISizeT)SBUF_MAX, &CountDone))
-           error ("UDIGetStdin() failed in udi_wait");
+           error ("UDIGetStdout() failed in udi_wait");
          fwrite (sbuf, 1, CountDone, stdout);
          fflush(stdout);
          continue;
@@ -498,9 +504,13 @@ udi_wait (status)
          fflush(stderr);
          continue;
        case UDIStdinNeeded:
-         printf("DEBUG: stdin requested ... continue\n");
-         /*    UDIPutStdin(sbuf, (UDISizeT)i, &CountDone); */
+         scanf ("%s", sbuf);
+         i = strlen (sbuf);
+         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.  */
        case UDIStdinModeX:
          continue;
        default:
@@ -569,14 +579,11 @@ udi_wait (status)
     case UDINotExecuting:
       WSETSTOP ((*status), SIGTERM);
       break;
-    case UDIRunning:
-      WSETSTOP ((*status), SIGILL);
-      break;
     case UDIStopped:
       WSETSTOP ((*status), SIGTSTP);
       break;
     case UDIWarned:
-      WSETSTOP ((*status), SIGLOST);
+      WSETSTOP ((*status), SIGURG);
       break;
     case UDIStepped:
     case UDIBreak:
@@ -612,6 +619,7 @@ int regno;
   UDISizeT     Size = 4;
   UDICount     CountDone;
   UDIBool      HostEndian = 0;
+  UDIError     err;
   int          i;
 
   if (regno >= 0)  {
@@ -625,7 +633,7 @@ int regno;
   From.Offset = 1;
   To = (UDIUInt32 *)&registers[4 * GR1_REGNUM];
   Count = 1;
-  if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   register_valid[GR1_REGNUM] = 1;
@@ -638,7 +646,7 @@ int regno;
   From.Offset = 64;
   To = (UDIUInt32 *)&registers[4 * GR64_REGNUM];
   Count = 32;
-  if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++)
@@ -652,7 +660,7 @@ int regno;
   From.Offset = 96;
   To = (UDIUInt32 *)&registers[4 * GR96_REGNUM];
   Count = 32;
-  if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++)
@@ -664,7 +672,7 @@ int regno;
   From.Offset = 0;
   To = (UDIUInt32 *)&registers[4 * LR0_REGNUM];
   Count = 128;
-  if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++)
@@ -676,7 +684,7 @@ int regno;
   From.Offset = 0;
   To = (UDIUInt32 *)&registers[4 * SR_REGNUM(0)];
   Count = 15;
-  if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   for (i = SR_REGNUM(0); i < SR_REGNUM(0) + 15; i++)
@@ -693,7 +701,7 @@ int regno;
     From.Offset = 128;
     To = (UDIUInt32 *)&registers[4 * SR_REGNUM(128)];
     Count = 135-128 + 1;
-    if (UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+    if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
       error("UDIRead() failed in udi_fetch_registers");
 
     for (i = SR_REGNUM(128); i < SR_REGNUM(128) + 135-128+1; i++)
@@ -1028,9 +1036,9 @@ download(load_arg_string, from_tty)
        {
          token++;
 
-         if (strcmp (token, "ms") == 0)
+         if (STREQ (token, "ms"))
            stack_sizes[1] = atol (strtok (NULL, " \t"));
-         else if (strcmp (token, "rs") == 0)
+         else if (STREQ (token, "rs"))
            stack_sizes[0] = atol (strtok (NULL, " \t"));
          else
            {
@@ -1087,13 +1095,13 @@ download(load_arg_string, from_tty)
          const char *section_name;
 
          section_name = bfd_get_section_name (pbfd, section);
-         if (strcmp (section_name, ".text") == 0 && !load_text)
+         if (STREQ (section_name, ".text") && !load_text)
            continue;
-         else if (strcmp (section_name, ".data") == 0 && !load_data)
+         else if (STREQ (section_name, ".data") && !load_data)
            continue;
-         else if (strcmp (section_name, ".bss") == 0 && !load_bss)
+         else if (STREQ (section_name, ".bss") && !load_bss)
            continue;
-         else if (strcmp (section_name, ".lit") == 0 && !load_lit)
+         else if (STREQ (section_name, ".lit") && !load_lit)
            continue;
 
          To.Offset = bfd_get_section_vma (pbfd, section);
@@ -1158,30 +1166,40 @@ download(load_arg_string, from_tty)
          else                  /* BSS */
            {
              UDIResource From;
-             char zero = 0;
+             unsigned long zero = 0;
 
              /* Write a zero byte at the vma */
              err = UDIWrite ((UDIHostMemPtr)&zero,     /* From */
                              To,                       /* To */
                              (UDICount)1,              /* Count */
-                             (UDISizeT)1,              /* Size */
+                             (UDISizeT)4,              /* Size */
                              &Count,                   /* CountDone */
                              (UDIBool)0);              /* HostEndian */
              if (err)
                error ("UDIWrite failed, error = %d", err);
 
              From = To;
-             To.Offset++;
+             To.Offset+=4;
 
              /* Now, duplicate it for the length of the BSS */
              err = UDICopy (From,                      /* From */
                             To,                        /* To */
-                            (UDICount)section_size - 1, /* Count */
-                            (UDISizeT)1,               /* Size */
+                            (UDICount)(section_size/4 - 1), /* Count */
+                            (UDISizeT)4,               /* Size */
                             &Count,                    /* CountDone */
                             (UDIBool)1);               /* Direction */
              if (err)
-               error ("UDICopy failed, error = %d", err);
+               {
+                 char message[100];
+                 int xerr;
+
+                 xerr = UDIGetErrorMsg(err, 100, message, &Count);
+                 if (!xerr)
+                   fprintf (stderr, "Error is %s\n", message);
+                 else
+                   fprintf (stderr, "xerr is %d\n", xerr);
+                 error ("UDICopy failed, error = %d", err);
+               }
            }
 
        }
@@ -1259,6 +1277,7 @@ udi_read_inferior_memory(memaddr, myaddr, len)
   UDISizeT     Size = 1;
   UDICount     CountDone = 0;
   UDIBool      HostEndian = 0;
+  UDIError     err;
   
   From.Space = udi_memory_space(memaddr);      
   To = (UDIUInt32*)myaddr;
@@ -1267,8 +1286,8 @@ udi_read_inferior_memory(memaddr, myaddr, len)
   {    Count = len - nread;
        if (Count > MAXDATA) Count = MAXDATA;
        From.Offset = memaddr + nread;
-        if(UDIRead(From, To, Count, Size, &CountDone, HostEndian))
-       {  error("UDIWrite() failed in udi_read_inferrior_memory");
+        if(err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
+       {  error("UDIRead() failed in udi_read_inferrior_memory");
           break;       
        }
        else
@@ -1302,6 +1321,7 @@ fetch_register (regno)
   UDISizeT     Size = 4;
   UDICount     CountDone;
   UDIBool      HostEndian = 0;
+  UDIError     err;
   int                  result;
 
   if (regno == GR1_REGNUM)
@@ -1342,7 +1362,7 @@ fetch_register (regno)
       From.Offset = regnum_to_srnum(regno); 
     }
 
-  if (UDIRead(From, &To, Count, Size, &CountDone, HostEndian))
+  if (err = UDIRead(From, &To, Count, Size, &CountDone, HostEndian))
     error("UDIRead() failed in udi_fetch_registers");
 
   supply_register(regno, (char *) &To);
This page took 0.027341 seconds and 4 git commands to generate.