Fix problems introduced with my last change.
[deliverable/binutils-gdb.git] / gdb / infttrace.c
index dae4ad44065501002b1647f8ad9e7d223aae540e..89edab474689322f09c415affa4243a31dc9905f 100644 (file)
@@ -24,7 +24,7 @@
 #include "inferior.h"
 #include "target.h"
 #include "gdb_string.h"
-#include "wait.h"
+#include "gdb_wait.h"
 #include "command.h"
 
 /* Some hackery to work around a use of the #define name NO_FLAGS
@@ -45,9 +45,6 @@
 #include <sys/ioctl.h>
 
 #include <sys/ttrace.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <sys/mman.h>
 
 #ifndef NO_PTRACE_H
@@ -1403,13 +1400,12 @@ get_process_first_stopped_thread_id (pid, thread_state)
 {
   int tt_status;
 
-  tt_status = call_real_ttrace (
-                                TT_PROC_GET_FIRST_LWP_STATE,
-                                (pid_t) pid,
-                                (lwpid_t) TT_NIL,
-                                (TTRACE_ARG_TYPE) thread_state,
-                                (TTRACE_ARG_TYPE) sizeof (*thread_state),
-                                TT_NIL);
+  tt_status = call_real_ttrace (TT_PROC_GET_FIRST_LWP_STATE,
+                               (pid_t) pid,
+                               (lwpid_t) TT_NIL,
+                               (TTRACE_ARG_TYPE) thread_state,
+                               (TTRACE_ARG_TYPE) sizeof (*thread_state),
+                               TT_NIL);
 
   if (errno)
     {
@@ -4330,7 +4326,7 @@ thread_fake_step (tid, signal)
   p = find_thread_info (tid);
   if (p != NULL)
     {
-      if (p->have_signal && signal == NULL)
+      if (p->have_signal && signal == TARGET_SIGNAL_0)
        {
          /* Pass on a saved signal.
           */
@@ -5217,7 +5213,7 @@ child_pid_to_exec_file (tid)
      hack that DDE uses, of pawing through the process' data
      segment to find the pathname.
    */
-  top_of_stack = 0x7b03a000;
+  top_of_stack = (TARGET_PTR_BIT == 64 ? 0x800003ffff7f0000 : 0x7b03a000);
   name_index = 0;
   done = 0;
 
@@ -5777,7 +5773,7 @@ hppa_pid_or_tid_to_str (id)
 
   /* Does this appear to be a process?  If so, print it that way. */
   if (is_process_id (id))
-    return hppa_pid_to_str (id);
+    return child_pid_to_str (id);
 
   /* Else, print both the GDB thread number and the system thread id. */
   sprintf (buf, "thread %d (", pid_to_thread_id (id));
@@ -5864,6 +5860,55 @@ hppa_resume_execd_vforking_child_to_get_parent_vfork ()
 }
 \f
 
+/* Write a register as a 64bit value.  This may be necessary if the
+   native OS is too braindamaged to allow some (or all) registers to
+   be written in 32bit hunks such as hpux11 and the PC queue registers.
+
+   This is horribly gross and disgusting.  */
+int
+ttrace_write_reg_64 (gdb_tid, dest_addr, src_addr)
+     int gdb_tid;
+     CORE_ADDR dest_addr;
+     CORE_ADDR src_addr;
+{
+  pid_t        pid;
+  lwpid_t      tid;
+  int                  tt_status;
+
+  tid = map_from_gdb_tid (gdb_tid);
+  pid = get_pid_for (tid);
+
+  errno = 0;
+  tt_status = ttrace (TT_LWP_WUREGS, 
+                     pid, 
+                     tid, 
+                     (TTRACE_ARG_TYPE) dest_addr, 
+                     8, 
+                     (TTRACE_ARG_TYPE) src_addr );
+
+#ifdef THREAD_DEBUG
+  if (errno)
+    {
+      /* Don't bother for a known benign error: if you ask for the
+         first thread state, but there is only one thread and it's
+         not stopped, ttrace complains.
+        
+         We have this inside the #ifdef because our caller will do
+         this check for real.  */
+      if( request != TT_PROC_GET_FIRST_LWP_STATE
+          ||  errno   != EPROTO )
+        {
+          if( debug_on )
+            printf( "TT fail for %s, with pid %d, tid %d, status %d \n",
+                    get_printable_name_of_ttrace_request (TT_LWP_WUREGS),
+                    pid, tid, tt_status );
+        }
+    }
+#endif
+
+  return tt_status;
+}
 
 void
 _initialize_infttrace ()
@@ -5875,6 +5920,11 @@ _initialize_infttrace ()
   errno = 0;
   memory_page_dictionary.page_size = sysconf (_SC_PAGE_SIZE);
 
+  /* We do a lot of casts from pointers to TTRACE_ARG_TYPE; make sure
+     this is okay.  */
+  if (sizeof (TTRACE_ARG_TYPE) < sizeof (void *))
+    abort ();
+
   if (errno || (memory_page_dictionary.page_size <= 0))
     perror_with_name ("sysconf");
 }
This page took 0.024578 seconds and 4 git commands to generate.