2000-12-22 Fernando Nasser <fnasser@redhat.com>
[deliverable/binutils-gdb.git] / gdb / go32-nat.c
index 7d35d7b9eb0407fd4741d3046c737d1d18b87dec..41170066ce272e313ec511df71ec72bffd57e981 100644 (file)
@@ -389,6 +389,13 @@ go32_wait (int pid ATTRIBUTE_UNUSED, struct target_waitstatus *status)
      point of changing back to where GDB thinks is its cwd, when we
      return control to the debugger, but restore child's cwd before we
      run it.  */
+  /* Initialize child_cwd, before the first call to run_child and not
+     in the initialization, so the child get also the changed directory
+     set with the gdb-command "cd ..." */
+  if (!*child_cwd)
+    /* Initialize child's cwd with the current one.  */
+    getcwd (child_cwd, sizeof (child_cwd));
+    
   chdir (child_cwd);
 
 #if __DJGPP_MINOR__ < 3
@@ -603,6 +610,11 @@ go32_create_inferior (char *exec_file, char *args, char **env)
     }
   resume_signal = -1;
   resume_is_step = 0;
+
+  /* Initialize child's cwd as empty to be initialized when starting
+     the child.  */
+  *child_cwd = 0;
+
   /* Init command line storage.  */
   if (redir_debug_init (&child_cmd) == -1)
     internal_error ("Cannot allocate redirection storage: not enough memory.\n");
@@ -859,20 +871,19 @@ go32_handle_nonaligned_watchpoint (wp_op what, CORE_ADDR waddr, CORE_ADDR addr,
   int size;
   int rv = 0, status = 0;
 
-  static int size_try_array[16] =
+  static int size_try_array[4][4] =
   {
-    1, 1, 1, 1,                        /* trying size one */
-    2, 1, 2, 1,                        /* trying size two */
-    2, 1, 2, 1,                        /* trying size three */
-    4, 1, 2, 1                 /* trying size four */
+    { 1, 1, 1, 1 },            /* trying size one */
+    { 2, 1, 2, 1 },            /* trying size two */
+    { 2, 1, 2, 1 },            /* trying size three */
+    { 4, 1, 2, 1 }             /* trying size four */
   };
 
   while (len > 0)
     {
       align = addr % 4;
-      /* Four is the maximum length for 386.  */
-      size = (len > 4) ? 3 : len - 1;
-      size = size_try_array[size * 4 + align];
+      /* Four is the maximum length a 386 debug register can watch.  */
+      size = size_try_array[len > 4 ? 3 : len - 1][align];
       if (what == wp_insert)
        status = go32_insert_aligned_watchpoint (waddr, addr, size, rw);
       else if (what == wp_remove)
@@ -880,7 +891,7 @@ go32_handle_nonaligned_watchpoint (wp_op what, CORE_ADDR waddr, CORE_ADDR addr,
       else if (what == wp_count)
        rv++;
       else
-       status = -1;
+       status = EINVAL;
       /* We keep the loop going even after a failure, because some of
         the other aligned watchpoints might still succeed, e.g. if
         they watch addresses that are already watched, and thus just
@@ -1056,7 +1067,7 @@ go32_insert_hw_breakpoint (CORE_ADDR addr, void *shadow ATTRIBUTE_UNUSED)
     }
   SHOW_DR (insert_hw, 0);
 
-  return i < 4 ? 0 : -1;
+  return i < 4 ? 0 : EBUSY;
 }
 
 /* Put the device open on handle FD into either raw or cooked
@@ -1225,8 +1236,9 @@ init_go32_ops (void)
   go32_ops.to_has_execution = 1;
   go32_ops.to_magic = OPS_MAGIC;
 
-  /* Initialize child's cwd with the current one.  */
-  getcwd (child_cwd, sizeof (child_cwd));
+  /* Initialize child's cwd as empty to be initialized when starting
+     the child.  */
+  *child_cwd = 0;
 
   /* Initialize child's command line storage.  */
   if (redir_debug_init (&child_cmd) == -1)
This page took 0.024889 seconds and 4 git commands to generate.