Platform:    Sun SPARC Solaris 2.6
GDB Version: 5.0

The sequence of commands in gdb that will bring up the message

"process is already running, pretend to resume and hope for the best"

are:
                                                            
attach pid                                                                  
continue                                                                     
^C                                                                           
continue                                                                

After the first three commands, we expect that the inferior process
(one being debugged) would have stopped. gdb 5.0 does not stop the
process. One can test this out by running commands against the
inferior process and they will complete. When the fourth command is
executed, gdb asks proc API to run this process (writing a
PCRUN). proc API gives an error (EBUSY) since the process was never
stopped and gdb is asking the process to run. This results in the
message that you see.

attach pid  -> write PCSTOP to ctl_fd                                       
               write PCWSTOP to ctl_fd (retry 4 times)                     
                                                                             
continue    -> write PCWSTOP to ctl_fd                                       
                  (wait for automatic stop by an external signal sent
                   to inferior)     
^C          -> interrupts the system call sending PCWSTOP and returns         
               errno==EINTR. The inferior process is not asked to stop       
               at all.                                                   

I have made a fix for myself in procfs.c. The new function is shown
below and the changes are shown with a '>' in the first column. There
can be more/better fixes added since for now I have just done a
print_filtered when proc_stop_process fails. Please let me know if you
have any questions.

Also, if someone can explain why we do the retry 4 times when we know
that a process has stopped that would be cool too.

Thanks,
Kodi.
----------------------------------------------------------------------

int
proc_wait_for_stop (pi)
     procinfo *pi;
{
  int win;

  /*
   * We should never have to apply this operation to any procinfo
   * except the one for the main process.  If that ever changes
   * for any reason, then take out the following clause and 
   * replace it with one that makes sure the ctl_fd is open.
   */
  
  if (pi->tid != 0)
    pi = find_procinfo_or_die (pi->pid, 0);

#ifdef NEW_PROC_API
  {
    int cmd = PCWSTOP;
> break_wait_again:
    
    win = (write (pi->ctl_fd, (char *) &cmd, sizeof (cmd)) == sizeof
           (cmd));
>    if (win == 0 && errno == EINTR)
>    {
>      /* ask the process to stop. I got a sig INT, I guess */
>      if (!proc_stop_process(pi))
>      {
>        printf_filtered("failed to stop process %d\n", __LINE__);
>      }
>      printf_filtered("waiting for process to stop\n");
>
>      goto break_wait_again;
>    }

    /* We been runnin' and we stopped -- need to update status.  */
    pi->status_valid = 0;
  }
#else   /* ioctl method */
  win = (ioctl (pi->ctl_fd, PIOCWSTOP, &pi->prstatus) >= 0);
  /* Above call also refreshes the prstatus.  */
  if (win)
    {
      pi->status_valid = 1;
      PROC_PRETTYFPRINT_STATUS (proc_flags (pi), 
                                proc_why (pi),
                                proc_what (pi), 
                                proc_get_current_thread (pi));
    }
#endif

  return win;
}


        

--
Kothanda Umamageswaran, VOS, 650-506-8036, 4op1365, [EMAIL PROTECTED],
http://metallica.us.oracle.com/


Reply via email to