Sun Aug 1 22:58:18 1993 Stu Grossman (grossman at cygnus.com)
[deliverable/binutils-gdb.git] / gdb / procfs.c
index 1a694e0f0d4391353bf52a14551d022fbf1ffa0f..4c8ab5ccfe9d532b274b55f387fd30aeacd2dda3 100644 (file)
@@ -1599,9 +1599,9 @@ procfs_attach (args, from_tty)
       exec_file = (char *) get_exec_file (0);
 
       if (exec_file)
-       printf ("Attaching program `%s', pid %d\n", exec_file, pid);
+       printf ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
       else
-       printf ("Attaching pid %d\n", pid);
+       printf ("Attaching to %s\n", target_pid_to_str (pid));
 
       fflush (stdout);
     }
@@ -1632,8 +1632,8 @@ procfs_detach (args, from_tty)
       char *exec_file = get_exec_file (0);
       if (exec_file == 0)
        exec_file = "";
-      printf ("Detaching program: %s pid %d\n",
-             exec_file, inferior_pid);
+      printf ("Detaching from program: %s %s\n",
+             exec_file, target_pid_to_str (inferior_pid));
       fflush (stdout);
     }
   if (args)
@@ -1664,8 +1664,8 @@ static void
 procfs_files_info (ignore)
      struct target_ops *ignore;
 {
-  printf ("\tUsing the running image of %s process %d via /proc.\n",
-         attach_flag? "attached": "child", inferior_pid);
+  printf ("\tUsing the running image of %s %s via /proc.\n",
+         attach_flag? "attached": "child", target_pid_to_str (inferior_pid));
 }
 
 /* ARGSUSED */
@@ -1761,7 +1761,7 @@ do_attach (pid)
        }
       else
        {
-         printf ("Ok, gdb will wait for process %u to stop.\n", pid);
+         printf ("Ok, gdb will wait for %s to stop.\n", target_pid_to_str (pid));
        }
     }
 
@@ -1956,10 +1956,17 @@ procfs_wait (statloc)
     }
   else if (!(pi.prstatus.pr_flags & (PR_STOPPED | PR_ISTOP)))
     {
+      if (attach_flag)
+       set_sigint_trap();      /* Causes SIGINT to be passed on to the
+                                  attached process. */
+
       if (ioctl (pi.fd, PIOCWSTOP, &pi.prstatus) < 0)
        {
          checkerr++;
        }
+
+      if (attach_flag)
+       clear_sigint_trap();
     }    
   if (checkerr)
     {
@@ -2143,50 +2150,30 @@ set_proc_siginfo (pip, signo)
     }
 }
 
-/*
-
-LOCAL FUNCTION
-
-       procfs_resume -- resume execution of the inferior process
-
-SYNOPSIS
-
-       void procfs_resume (int step, int signo)
-
-DESCRIPTION
-
-       Resume execution of the inferior process.  If STEP is nozero, then
-       just single step it.  If SIGNAL is nonzero, restart it with that
-       signal activated.
-
-NOTE
-
-       It may not be absolutely necessary to specify the PC value for
-       restarting, but to be safe we use the value that gdb considers
-       to be current.  One case where this might be necessary is if the
-       user explicitly changes the PC value that gdb considers to be
-       current.  FIXME:  Investigate if this is necessary or not.
-
-       When attaching to a child process, if we forced it to stop with
-       a PIOCSTOP, then we will have set the nopass_next_sigstop flag.
-       Upon resuming the first time after such a stop, we explicitly
-       inhibit sending it another SIGSTOP, which would be the normal
-       result of default signal handling.  One potential drawback to
-       this is that we will also ignore any attempt to by the user
-       to explicitly continue after the attach with a SIGSTOP.  Ultimately
-       this problem should be dealt with by making the routines that
-       deal with the inferior a little smarter, and possibly even allow
-       an inferior to continue running at the same time as gdb.  (FIXME?)
- */
+/* Resume execution of process PID.  If STEP is nozero, then
+   just single step it.  If SIGNAL is nonzero, restart it with that
+   signal activated.  */
 
 static void
-procfs_resume (step, signo)
+procfs_resume (pid, step, signo)
+     int pid;
      int step;
      int signo;
 {
+  int signal_to_pass;
+
   errno = 0;
   pi.prrun.pr_flags = PRSTRACE | PRSFAULT | PRCFAULT;
 
+#if 0
+  /* It should not be necessary.  If the user explicitly changes the value,
+     value_assign calls write_register_bytes, which writes it.  */
+/*     It may not be absolutely necessary to specify the PC value for
+       restarting, but to be safe we use the value that gdb considers
+       to be current.  One case where this might be necessary is if the
+       user explicitly changes the PC value that gdb considers to be
+       current.  FIXME:  Investigate if this is necessary or not.  */
+
 #ifdef PRSVADDR_BROKEN
 /* Can't do this under Solaris running on a Sparc, as there seems to be no
    place to put nPC.  In fact, if you use this, nPC seems to be set to some
@@ -2196,10 +2183,45 @@ procfs_resume (step, signo)
   pi.prrun.pr_vaddr = (caddr_t) *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
   pi.prrun.pr_flags != PRSVADDR;
 #endif
+#endif
+
+  if (signo == SIGSTOP && pi.nopass_next_sigstop)
+    /* When attaching to a child process, if we forced it to stop with
+       a PIOCSTOP, then we will have set the nopass_next_sigstop flag.
+       Upon resuming the first time after such a stop, we explicitly
+       inhibit sending it another SIGSTOP, which would be the normal
+       result of default signal handling.  One potential drawback to
+       this is that we will also ignore any attempt to by the user
+       to explicitly continue after the attach with a SIGSTOP.  Ultimately
+       this problem should be dealt with by making the routines that
+       deal with the inferior a little smarter, and possibly even allow
+       an inferior to continue running at the same time as gdb.  (FIXME?)  */
+    signal_to_pass = 0;
+  else if (signo == SIGTSTP
+          && pi.prstatus.pr_cursig == SIGTSTP
+          && pi.prstatus.pr_action.sa_handler == SIG_DFL)
+
+    /* We are about to pass the inferior a SIGTSTP whose action is
+       SIG_DFL.  The SIG_DFL action for a SIGTSTP is to stop
+       (notifying the parent via wait()), and then keep going from the
+       same place when the parent is ready for you to keep going.  So
+       under the debugger, it should do nothing (as if the program had
+       been stopped and then later resumed.  Under ptrace, this
+       happens for us, but under /proc, the system obligingly stops
+       the process, and wait_for_inferior would have no way of
+       distinguishing that type of stop (which indicates that we
+       should just start it again), with a stop due to the pr_trace
+       field of the prrun_t struct.
+
+       Note that if the SIGTSTP is being caught, we *do* need to pass it,
+       because the handler needs to get executed.  */
+    signal_to_pass = 0;
+  else
+    signal_to_pass = signo;
 
-  if (signo && !(signo == SIGSTOP && pi.nopass_next_sigstop))
+  if (signal_to_pass)
     {
-      set_proc_siginfo (&pi, signo);
+      set_proc_siginfo (&pi, signal_to_pass);
     }
   else
     {
@@ -2253,66 +2275,6 @@ procfs_fetch_registers (regno)
 
 /*
 
-GLOBAL FUNCTION
-
-       fetch_core_registers -- fetch current registers from core file data
-
-SYNOPSIS
-
-       void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
-                                  int which, unsigned in reg_addr)
-
-DESCRIPTION
-
-       Read the values of either the general register set (WHICH equals 0)
-       or the floating point register set (WHICH equals 2) from the core
-       file data (pointed to by CORE_REG_SECT), and update gdb's idea of
-       their current values.  The CORE_REG_SIZE parameter is ignored.
-
-NOTES
-
-       Use the indicated sizes to validate the gregset and fpregset
-       structures.
-*/
-
-void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
-     char *core_reg_sect;
-     unsigned core_reg_size;
-     int which;
-     unsigned int reg_addr;    /* Unused in this version */
-{
-
-  if (which == 0)
-    {
-      if (core_reg_size != sizeof (pi.gregset))
-       {
-         warning ("wrong size gregset struct in core file");
-       }
-      else
-       {
-         memcpy ((char *) &pi.gregset, core_reg_sect, sizeof (pi.gregset));
-         supply_gregset (&pi.gregset);
-       }
-    }
-  else if (which == 2)
-    {
-      if (core_reg_size != sizeof (pi.fpregset))
-       {
-         warning ("wrong size fpregset struct in core file");
-       }
-      else
-       {
-         memcpy ((char *) &pi.fpregset, core_reg_sect, sizeof (pi.fpregset));
-#if defined (FP0_REGNUM)
-         supply_fpregset (&pi.fpregset);
-#endif
-       }
-    }
-}
-
-/*
-
 LOCAL FUNCTION
 
        proc_init_failed - called whenever /proc access initialization fails
@@ -2591,7 +2553,8 @@ info_proc_siginfo (pip, summary)
            }
          if (sip -> si_code <= 0)
            {
-             printf_filtered ("sent by pid %d, uid %d ", sip -> si_pid,
+             printf_filtered ("sent by %s, uid %d ",
+                              target_pid_to_str (sip -> si_pid),
                               sip -> si_uid);
            }
          else
@@ -2606,8 +2569,8 @@ info_proc_siginfo (pip, summary)
                }
              else if ((sip -> si_signo == SIGCHLD))
                {
-                 printf_filtered ("child pid %u, status %u ",
-                                  sip -> si_pid,
+                 printf_filtered ("child %s, status %u ",
+                                  target_pid_to_str (sip -> si_pid),
                                   sip -> si_status);
                }
              else if ((sip -> si_signo == SIGPOLL))
@@ -2629,7 +2592,7 @@ info_proc_siginfo (pip, summary)
            }
          if (sip -> si_code <= 0)
            {
-             printf_filtered ("\t%-16u %s\n", sip -> si_pid,
+             printf_filtered ("\t%-16u %s\n", sip -> si_pid, /* XXX need target_pid_to_str() */
                               "PID of process sending signal");
              printf_filtered ("\t%-16u %s\n", sip -> si_uid,
                               "UID of process sending signal");
@@ -2652,7 +2615,7 @@ info_proc_siginfo (pip, summary)
                }
              else if ((sip -> si_signo == SIGCHLD))
                {
-                 printf_filtered ("\t%-16u %s.\n", sip -> si_pid,
+                 printf_filtered ("\t%-16u %s.\n", sip -> si_pid, /* XXX need target_pid_to_str() */
                                   "Child process ID");
                  printf_filtered ("\t%-16u %s.\n", sip -> si_status,
                                   "Child process exit value or signal");
@@ -3014,7 +2977,8 @@ info_proc (args, from_tty)
 
   if (!pip -> valid)
     {
-      error ("No process.  Run an inferior or specify an explicit pid.");
+      error ("\
+No process.  Start debugging a program or specify an explicit process ID.");
     }
   if (ioctl (pip -> fd, PIOCSTATUS, &(pip -> prstatus)) < 0)
     {
This page took 0.028045 seconds and 4 git commands to generate.