This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: invoking GDB from FE and signals


> > We send the signal to the inferior ... the problem when running gdb is to
> > ... get the inferior PID ... sigh. We have circumvent the problem is
> > commercial products but did not fine a generic way to get the pid.
> 
> You should use the 'set tty' command to run the user's program under
> its own pseudo-tty, and then stuff the appropriate control characters
> at the master side.  That's the only way to do the right thing if the
> inferior is doing job-control-like stuff, like a shell.

OK, I agree with all of this, and Jim your comments have been extremly
helpful. I'm left confused on 2 issues.

Do I ever want to send a ^c signal to GDB? That is, if the inferior is
not running, should I still send the ^c to the inferior's tty? If I'm
supposed to send the ^c to GDB when it is running and to the inferior
when it is running, then that is impossible from my point of view. And a
good argument against using the tty command.

The other confusion point for me is that there is a magic ioctl that
will send a signal to the tty process group. After looking in emacs, I'm
thinking that the confusion was that there is an ioctl to get the
character that needs to be written via 'write' to the pty in order to
have the pty generate the signal. Look at the code below, is it true
that the FE should just call 'write' but with the appropriate character.

I find in emacs:process.c code that they send the SIGINT in different
ways
    /* If possible, send signals to the entire pgrp
       by sending an input character to it.  */

    /* TERMIOS is the latest and bestest, and seems most likely to
       work.  If the system has it, use it.  */
    case SIGINT:
      sig_char = &t.c_cc[VINTR];
      break;
    ...
    send_process (proc, sig_char, 1, Qnil);

which is simply getting the ^c char tha the terminal expects to send it
or

   /* On Berkeley descendants, the following IOCTL's retrieve the
      current control characters.  */
   case SIGINT:
     ioctl (XINT (p->infd), TIOCGETC, &c);
     send_process (proc, &c.t_intrc, 1, Qnil);
or
  /* On SYSV descendants, the TCGETA ioctl retrieves the current
   * control characters.  */
  case SIGINT:
    ioctl (XINT (p->infd), TCGETA, &t);
    send_process (proc, &t.c_cc[VINTR], 1, Qnil);
or
    case SIGINT:
      send_process (proc, "\003", 1, Qnil);     /* ^C */
      goto whoosh;

Thanks,
Bob Rossi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]