New commands "mt set per-command {space,time,symtab} {on,off}".
[deliverable/binutils-gdb.git] / gdb / ia64-hpux-nat.c
index 32160aad61233558c25ba29bb13fe8522c4ccb88..e4e1d3278e70773c4f44f09f7f36ac8b5233e77b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -154,12 +154,12 @@ ia64_hpux_wait (struct target_ops *ops, ptid_t ptid,
      process it, and then resume the execution as if the event did
      not happen.  */
   if (ourstatus->kind == TARGET_WAITKIND_STOPPED
-      && ourstatus->value.sig == TARGET_SIGNAL_TRAP
+      && ourstatus->value.sig == GDB_SIGNAL_TRAP
       && ia64_hpux_at_dld_breakpoint_p (new_ptid))
     {
       ia64_hpux_handle_dld_breakpoint (new_ptid);
 
-      target_resume (new_ptid, 0, TARGET_SIGNAL_0);
+      target_resume (new_ptid, 0, GDB_SIGNAL_0);
       ourstatus->kind = TARGET_WAITKIND_IGNORE;
     }
 
@@ -252,7 +252,7 @@ ia64_hpux_fetch_register (struct regcache *regcache, int regnum)
   buf = alloca (len * sizeof (gdb_byte));
   status = ia64_hpux_read_register_from_save_state_t (offset, buf, len);
   if (status < 0)
-    warning (_("Failed to read register value for %s.\n"),
+    warning (_("Failed to read register value for %s."),
              gdbarch_register_name (gdbarch, regnum));
 
   regcache_raw_supply (regcache, regnum, buf);
@@ -312,7 +312,7 @@ ia64_hpux_store_register (const struct regcache *regcache, int regnum)
   status = ia64_hpux_write_register_to_saved_state_t (offset, buf, len);
 
   if (status < 0)
-    error (_("failed to write register value for %s.\n"),
+    error (_("failed to write register value for %s."),
            gdbarch_register_name (gdbarch, regnum));
 }
 
@@ -485,6 +485,37 @@ ia64_hpux_xfer_memory_bs (struct target_ops *ops, const char *annex,
     return 0;
 }
 
+/* Get a register value as a unsigned value directly from the system,
+   instead of going through the regcache.
+
+   This function is meant to be used when inferior_ptid is not
+   a thread/process known to GDB.  */
+
+static ULONGEST
+ia64_hpux_get_register_from_save_state_t (int regnum, int reg_size)
+{
+  gdb_byte *buf = alloca (reg_size);
+  int offset = u_offsets[regnum];
+  int status;
+
+  /* The register is assumed to be available for fetching.  */
+  gdb_assert (offset != -1);
+
+  status = ia64_hpux_read_register_from_save_state_t (offset, buf, reg_size);
+  if (status < 0)
+    {
+      /* This really should not happen.  If it does, emit a warning
+        and pretend the register value is zero.  Not exactly the best
+        error recovery mechanism, but better than nothing.  We will
+        try to do better if we can demonstrate that this can happen
+        under normal circumstances.  */
+      warning (_("Failed to read value of register number %d."), regnum);
+      return 0;
+    }
+
+  return extract_unsigned_integer (buf, reg_size, BFD_ENDIAN_BIG);
+}
+
 /* The "xfer_partial" target_ops routine for ia64-hpux, in the case
    where the requested object is TARGET_OBJECT_MEMORY.  */
 
@@ -504,9 +535,24 @@ ia64_hpux_xfer_memory (struct target_ops *ops, const char *annex,
        (3) The region inside the backing-store, which needs to be
            read/written specially.  */
 
-  regcache_raw_read_unsigned (get_current_regcache (), IA64_BSP_REGNUM, &bsp);
-  regcache_raw_read_unsigned (get_current_regcache (), IA64_BSPSTORE_REGNUM,
-                              &bspstore);
+  if (in_inferior_list (ptid_get_pid (inferior_ptid)))
+    {
+      struct regcache *regcache = get_current_regcache ();
+
+      regcache_raw_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
+      regcache_raw_read_unsigned (regcache, IA64_BSPSTORE_REGNUM, &bspstore);
+    }
+  else
+    {
+      /* This is probably a child of our inferior created by a fork.
+        Because this process has not been added to our inferior list
+        (we are probably in the process of handling that child
+        process), we do not have a regcache to read the registers
+        from.  So get those values directly from the kernel.  */
+      bsp = ia64_hpux_get_register_from_save_state_t (IA64_BSP_REGNUM, 8);
+      bspstore =
+       ia64_hpux_get_register_from_save_state_t (IA64_BSPSTORE_REGNUM, 8);
+    }
 
   /* 1. Memory region before BSPSTORE.  */
 
@@ -679,10 +725,10 @@ ia64_hpux_mourn_inferior (struct target_ops *ops)
 }
 
 /* Prevent warning from -Wmissing-prototypes.  */
-void _initialize_hppa_hpux_nat (void);
+void _initialize_ia64_hpux_nat (void);
 
 void
-_initialize_hppa_hpux_nat (void)
+_initialize_ia64_hpux_nat (void)
 {
   struct target_ops *t;
 
This page took 0.027474 seconds and 4 git commands to generate.