Add note to serial_open.
[deliverable/binutils-gdb.git] / gdb / hppah-nat.c
index 128d66ddc5473bedf7578ca4a50b0181c0e301ae..aab5e96ccf3b478c9c31b736dee03879ee309f7e 100644 (file)
@@ -1,5 +1,6 @@
 /* Native support code for HPUX PA-RISC.
-   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1998, 1999
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
@@ -29,6 +30,7 @@
 #include <sys/ptrace.h>
 #include "gdbcore.h"
 #include "gdb_wait.h"
+#include "regcache.h"
 #include <signal.h>
 
 extern CORE_ADDR text_end;
@@ -106,7 +108,8 @@ store_inferior_registers (int regno)
        addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
                + (REGISTER_BYTE (regno) - REGISTER_BYTE (1)));
       else
-       internal_error ("hppah-nat.c (write_register): unexpected register size");
+       internal_error (__FILE__, __LINE__,
+                       "hppah-nat.c (write_register): unexpected register size");
 
 #ifdef GDB_TARGET_IS_HPPA_20W
       /* Unbelieveable.  The PC head and tail must be written in 64bit hunks
@@ -123,7 +126,8 @@ store_inferior_registers (int regno)
          /* Set the priv level (stored in the low two bits of the PC.  */
          temp |= 0x3;
 
-         ttrace_write_reg_64 (inferior_pid, (CORE_ADDR)addr, (CORE_ADDR)&temp);
+         ttrace_write_reg_64 (PIDGET (inferior_ptid), (CORE_ADDR)addr,
+                              (CORE_ADDR)&temp);
 
          /* If we fail to write the PC, give a true error instead of
             just a warning.  */
@@ -148,7 +152,8 @@ store_inferior_registers (int regno)
       for (i = 0; i < len; i += sizeof (int))
        {
          errno = 0;
-         call_ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) addr + i,
+         call_ptrace (PT_WUREGS, PIDGET (inferior_ptid),
+                      (PTRACE_ARG3_TYPE) addr + i,
                       *(int *) &registers[REGISTER_BYTE (regno) + i]);
          if (errno != 0)
            {
@@ -222,7 +227,8 @@ fetch_register (int regno)
            + (REGISTER_BYTE (regno) - REGISTER_BYTE (1)));
 
   else
-    internal_error ("hppa-nat.c (fetch_register): unexpected register size");
+    internal_error (__FILE__, __LINE__,
+                   "hppa-nat.c (fetch_register): unexpected register size");
 
   for (i = 0; i < len; i += sizeof (int))
     {
@@ -230,7 +236,7 @@ fetch_register (int regno)
       /* Copy an int from the U area to buf.  Fill the least
          significant end if len != raw_size.  */
       * (int *) &buf[offset + i] =
-         call_ptrace (PT_RUREGS, inferior_pid,
+         call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) addr + i, 0);
       if (errno != 0)
        {
@@ -266,6 +272,7 @@ fetch_register (int regno)
 
 int
 child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+                  struct mem_attrib *mem,
                   struct target_ops *target)
 {
   register int i;
@@ -292,14 +299,15 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
        {
          /* Need part of initial word -- fetch it.  */
          buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                                  inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+                                  PIDGET (inferior_ptid),
+                                  (PTRACE_ARG3_TYPE) addr, 0);
        }
 
       if (count > 1)           /* FIXME, avoid if even boundary */
        {
          buffer[count - 1]
            = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                          inferior_pid,
+                          PIDGET (inferior_ptid),
                           (PTRACE_ARG3_TYPE) (addr
                                               + (count - 1) * sizeof (int)),
                           0);
@@ -321,7 +329,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
          errno = 0;
          pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
          pt_status = call_ptrace (pt_request,
-                                  inferior_pid,
+                                  PIDGET (inferior_ptid),
                                   (PTRACE_ARG3_TYPE) addr,
                                   buffer[i]);
 
@@ -333,14 +341,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
              errno = 0;
              pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
              pt_status = call_ptrace (pt_request,
-                                      inferior_pid,
+                                      PIDGET (inferior_ptid),
                                       (PTRACE_ARG3_TYPE) addr,
                                       buffer[i]);
 
              /* No, we still fail.  Okay, time to punt. */
              if ((pt_status == -1) && errno)
                {
-                 free (buffer);
+                 xfree (buffer);
                  return 0;
                }
            }
@@ -353,10 +361,11 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
        {
          errno = 0;
          buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                                  inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+                                  PIDGET (inferior_ptid),
+                                  (PTRACE_ARG3_TYPE) addr, 0);
          if (errno)
            {
-             free (buffer);
+             xfree (buffer);
              return 0;
            }
          QUIT;
@@ -365,7 +374,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
       /* Copy appropriate bytes out of the buffer.  */
       memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
     }
-  free (buffer);
+  xfree (buffer);
   return len;
 }
 
@@ -384,7 +393,7 @@ child_post_follow_inferior_by_clone (void)
      At this point, the clone has attached to the child.  Because of
      the SIGSTOP, we must now deliver a SIGCONT to the child, or it
      won't behave properly. */
-  status = kill (inferior_pid, SIGCONT);
+  status = kill (PIDGET (inferior_ptid), SIGCONT);
 }
 
 
@@ -428,13 +437,14 @@ child_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
 /* Format a process id, given PID.  Be sure to terminate
    this with a null--it's going to be printed via a "%s".  */
 char *
-child_pid_to_str (pid_t pid)
+child_pid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
+  pid_t pid = PIDGET (ptid);
 
-  /* Extra NULLs for paranoia's sake */
-  sprintf (buf, "process %d\0\0\0\0", pid);
+  /* Extra NUL for paranoia's sake */
+  sprintf (buf, "process %d%c", pid, '\0');
 
   return buf;
 }
@@ -445,13 +455,16 @@ child_pid_to_str (pid_t pid)
    Note: This is a core-gdb tid, not the actual system tid.
    See infttrace.c for details.  */
 char *
-hppa_tid_to_str (pid_t tid)
+hppa_tid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
+  /* This seems strange, but when I did the ptid conversion, it looked
+     as though a pid was always being passed.  - Kevin Buettner  */
+  pid_t tid = PIDGET (ptid);
 
   /* Extra NULLs for paranoia's sake */
-  sprintf (buf, "system thread %d\0\0\0\0", tid);
+  sprintf (buf, "system thread %d%c", tid, '\0');
 
   return buf;
 }
@@ -621,7 +634,7 @@ hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len)
 }
 
 char *
-hppa_pid_or_tid_to_str (pid_t id)
+hppa_pid_or_tid_to_str (ptid_t id)
 {
   /* In the ptrace world, there are only processes. */
   return child_pid_to_str (id);
@@ -809,9 +822,9 @@ child_acknowledge_created_inferior (int pid)
 }
 
 void
-child_post_startup_inferior (int pid)
+child_post_startup_inferior (ptid_t ptid)
 {
-  require_notification_of_events (pid);
+  require_notification_of_events (PIDGET (ptid));
 }
 
 void
@@ -1035,7 +1048,7 @@ child_pid_to_exec_file (int pid)
   char four_chars[4];
   int name_index;
   int i;
-  int saved_inferior_pid;
+  ptid_t saved_inferior_ptid;
   boolean done;
 
 #ifdef PT_GET_PROCESS_PATHNAME
@@ -1057,19 +1070,19 @@ child_pid_to_exec_file (int pid)
   name_index = 0;
   done = 0;
 
-  /* On the chance that pid != inferior_pid, set inferior_pid
-     to pid, so that (grrrr!) implicit uses of inferior_pid get
+  /* On the chance that pid != inferior_ptid, set inferior_ptid
+     to pid, so that (grrrr!) implicit uses of inferior_ptid get
      the right id.  */
 
-  saved_inferior_pid = inferior_pid;
-  inferior_pid = pid;
+  saved_inferior_ptid = inferior_ptid;
+  inferior_ptid = pid_to_ptid (pid);
 
   /* Try to grab a null-terminated string. */
   while (!done)
     {
       if (target_read_memory (top_of_stack, four_chars, 4) != 0)
        {
-         inferior_pid = saved_inferior_pid;
+         inferior_ptid = saved_inferior_ptid;
          return NULL;
        }
       for (i = 0; i < 4; i++)
@@ -1084,11 +1097,11 @@ child_pid_to_exec_file (int pid)
 
   if (exec_file_buffer[0] == '\0')
     {
-      inferior_pid = saved_inferior_pid;
+      inferior_ptid = saved_inferior_ptid;
       return NULL;
     }
 
-  inferior_pid = saved_inferior_pid;
+  inferior_ptid = saved_inferior_ptid;
   return exec_file_buffer;
 }
 
@@ -1119,7 +1132,7 @@ pre_fork_inferior (void)
    return "TRUE".  */
 
 int
-child_thread_alive (int pid)
+child_thread_alive (ptid_t ptid)
 {
   return 1;
 }
This page took 0.027104 seconds and 4 git commands to generate.