* wince.c: Change realloc to xrealloc throughout.
[external/binutils.git] / gdb / wince.c
index 7081dd2..0442c96 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-vector operations for controlling Windows CE child processes, for GDB.
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions, A Red Hat Company.
 
    This file is part of GDB.
@@ -54,8 +54,8 @@
 #include "gdbcmd.h"
 #include <sys/param.h>
 #include "wince-stub.h"
-#include "dcache.h"
 #include <time.h>
+#include "regcache.h"
 
 /* The ui's event loop. */
 extern int (*ui_loop_hook) (int signo);
@@ -89,8 +89,6 @@ extern int (*ui_loop_hook) (int signo);
 
 static int connection_initialized = 0; /* True if we've initialized a RAPI session. */
 
-static DCACHE *remote_dcache;
-
 /* The directory where the stub and executable files are uploaded. */
 static const char *remote_directory = "\\gdb";
 
@@ -604,10 +602,10 @@ towide (const char *s, gdb_wince_len * out_len)
     n = 0;                     /* wrap */
 
   /* Allocate space for the converted string, reusing any previously allocated
-     space, if applicable. Note that if outs[n] is NULL, realloc will act as
+     space, if applicable. Note that if outs[n] is NULL, xrealloc will act as
      a malloc (under cygwin, at least).
    */
-  outs[n] = (LPWSTR) realloc (outs[n], *out_len);
+  outs[n] = (LPWSTR) xrealloc (outs[n], *out_len);
   memset (outs[n], 0, *out_len);
   (void) MultiByteToWideChar (CP_ACP, 0, s, -1, outs[n], *out_len);
   return outs[n];
@@ -1078,7 +1076,7 @@ child_init_thread_list (void)
       thread_info *here = th->next;
       th->next = here->next;
       (void) close_handle (here->h);
-      free (here);
+      xfree (here);
     }
 }
 
@@ -1102,7 +1100,7 @@ child_delete_thread (DWORD id)
       thread_info *here = th->next;
       th->next = here->next;
       close_handle (here->h);
-      free (here);
+      xfree (here);
     }
 }
 
@@ -1158,7 +1156,7 @@ child_store_inferior_registers (int r)
    of error; store status through argument pointer OURSTATUS.  */
 
 static int
-handle_load_dll (PTR dummy)
+handle_load_dll (void *dummy)
 {
   LOAD_DLL_DEBUG_INFO *event = &current_event.u.LoadDll;
   char dll_buf[MAX_PATH + 1];
@@ -1575,7 +1573,7 @@ upload_to_device (const char *to, const char *from)
     error ("no filename found to upload - %s.", in_to);
 
   len = strlen (dir) + strlen (to) + 2;
-  remotefile = (char *) realloc (remotefile, len);
+  remotefile = (char *) xrealloc (remotefile, len);
   strcpy (remotefile, dir);
   strcat (remotefile, "\\");
   strcat (remotefile, to);
@@ -1729,10 +1727,6 @@ child_create_inferior (char *exec_file, char *args, char **env)
   flags = DEBUG_PROCESS;
 
   wince_initialize ();         /* Make sure we've got a connection. */
-  if (!remote_dcache)
-    remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-  else
-    dcache_invd (remote_dcache);
 
   exec_file = upload_to_device (exec_file, exec_file);
 
@@ -1798,7 +1792,13 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
 {
   if (len <= 0)
     return 0;
-  return dcache_xfer_memory (remote_dcache, memaddr, our, len, write);
+
+  if (write)
+    res = remote_write_bytes (memaddr, our, len);
+  else
+    res = remote_read_bytes (memaddr, our, len);
+
+  return res;
 }
 
 /* Terminate the process and wait for child to tell us it has completed. */
@@ -1842,8 +1842,6 @@ child_resume (int pid, int step, enum target_signal sig)
       th->context.ContextFlags = 0;
     }
 
-  dcache_invd (remote_dcache);
-
   /* Allow continuing with the same signal that interrupted us.
      Otherwise complain. */
   if (sig && sig != last_sig)
@@ -1926,7 +1924,7 @@ init_child_ops (void)
 
 #define replace_upload(what) \
       upload_when = what; \
-      remote_upload = realloc (remote_upload, strlen (upload_options[upload_when].name) + 1); \
+      remote_upload = xrealloc (remote_upload, strlen (upload_options[upload_when].name) + 1); \
       strcpy (remote_upload, upload_options[upload_when].name);
 
 static void
@@ -1978,7 +1976,6 @@ _initialize_inftarg (void)
   add_show_from_set (set, &showlist);
   set->function.cfunc = set_upload_type;
   set_upload_type (NULL, 0);
-  set_dcache_state (1);
 
   add_show_from_set
     (add_set_cmd ((char *) "debugexec", class_support, var_boolean,