Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@codesourcery.com>
To: gdb@sources.redhat.com
Subject: Re: invoking GDB from FE and signals
Date: Thu, 18 May 2006 21:56:00 -0000	[thread overview]
Message-ID: <vt27j4jkz1r.fsf@theseus.home.> (raw)
In-Reply-To: <20060518172253.GE21003@brasko.net> (Bob Rossi's message of "Thu, 18 May 2006 13:22:53 -0400")


Bob Rossi <bob_rossi@cox.net> writes:
>> > 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.

I think you're coming at the problem in an odd way.  You seem to be
thinking, "I've got this C-c --- what do I do with it?"  Instead,
think about what facilities your user needs.

- They need a way to stop their program and get control back to GDB.
- They may (or may not, it's not clear to me) need a way to interrupt
  GDB when it's doing a long computation.

There's a clear need for the first thing.  The user's program isn't
behaving as expected; that's why they're debugging it.  So you need to
provide some command to interrupt a running program.  This can be
implemented by sending a SIGINT via the pty.

The second thing, I'm not sure you need.  I mean, how many word
processors provide a way to interrupt some long internal computation
they're doing?  If you do find a case like this, well, your front end
knows what it just asked GDB to do; when it sends some request that it
thinks might take a long time and would like to allow the user to
interrupt, it can tell the user interface about that and handle
requests to bail by sending a SIGINT to the GDB process itself.  And
make sure your parser is prepared for whatever kind of malformed stuff
that produces (if it does; I don't know).

> 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;

You're right.  I had been sure there was some way to just get the pty
to send the signal to its current process group directly, but this
seems to be the way it's done.

(My advice: just implement the TERMIOS case, and wait until people
complain before you worry about the other cases.  That Emacs code is
very old, and the termios interface is very widely available these
days.)


  reply	other threads:[~2006-05-18 17:44 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-18 16:27 Alain Magloire
2006-05-18 16:55 ` Bob Rossi
2006-05-18 16:59 ` Andreas Schwab
     [not found] ` <vt2bqtvl157.fsf@theseus.home.>
2006-05-18 17:44   ` Bob Rossi
2006-05-18 21:56     ` Jim Blandy [this message]
2006-05-19  1:19       ` Bob Rossi
2006-05-19  3:00         ` Daniel Jacobowitz
2006-05-19 12:49           ` Bob Rossi
2006-05-19 15:37             ` Daniel Jacobowitz
2006-05-19 15:56               ` Bob Rossi
2006-05-19 17:55                 ` Jim Blandy
2006-05-19 19:22                   ` Bob Rossi
2006-05-23  3:46                     ` Jim Blandy
2006-05-18 22:51     ` Andreas Schwab
2006-05-18 23:25       ` Bob Rossi
2006-05-19  1:17         ` Andreas Schwab
2006-05-18 23:28       ` Jim Blandy
2006-05-19  0:59         ` Andreas Schwab
  -- strict thread matches above, loose matches on Subject: below --
2006-05-13 15:09 Bob Rossi
2006-05-13 15:11 ` Daniel Jacobowitz
2006-05-13 15:19   ` Bob Rossi
2006-05-13 15:48     ` Daniel Jacobowitz
2006-05-13 15:49       ` Bob Rossi
2006-05-13 17:11         ` Daniel Jacobowitz
2006-05-14  3:25           ` Bob Rossi
2006-05-14  4:17             ` Nick Roberts
2006-05-14  4:18               ` Eli Zaretskii
2006-05-14  5:01               ` Daniel Jacobowitz
2006-05-15  6:55                 ` Nick Roberts
2006-05-15 13:35                   ` Daniel Jacobowitz
2006-05-15 13:39                 ` Bob Rossi
2006-05-15 15:04                   ` Daniel Jacobowitz
2006-05-15 19:04                   ` Jim Blandy
2006-05-15 13:37             ` Jim Blandy
2006-05-15 14:58               ` Bob Rossi
2006-05-15 18:50                 ` Jim Blandy
2006-05-15 20:09               ` Bob Rossi
2006-05-15 18:42           ` PAUL GILLIAM
2006-05-15 19:18             ` Bob Rossi
2006-05-15 19:43               ` Daniel Jacobowitz
2006-05-15 20:05                 ` Bob Rossi
2006-05-15 20:09                   ` Daniel Jacobowitz
2006-05-15 20:20                     ` Bob Rossi
2006-05-15 21:02                       ` Daniel Jacobowitz
2006-05-15 21:08                         ` Bob Rossi
2006-05-15 21:31                           ` Daniel Jacobowitz
2006-05-15 21:33                             ` Bob Rossi
2006-05-15 20:11                   ` PAUL GILLIAM
2006-05-15 20:33                     ` Bob Rossi
2006-05-15 21:52                       ` Joel Brobecker
2006-05-15 22:40                     ` Bob Rossi
2006-05-16  3:32                       ` Nick Roberts
2006-05-18  1:40                     ` Bob Rossi
2006-05-18 12:32                       ` Jim Blandy
2006-05-18  7:28       ` Bob Rossi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt27j4jkz1r.fsf@theseus.home. \
    --to=jimb@codesourcery.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox