wrong inferior_process_group when attached to process in 'async mode'/'native debugging'
Pedro Alves
pedro@codesourcery.com
Fri Mar 14 08:05:00 GMT 2008
This patch is needed in async mode native debugging due to this
in terminal_inferior:
/* If attach_flag is set, we don't know whether we are sharing a
terminal with the inferior or not. (attaching a process
without a terminal is one case where we do not; attaching a
process which we ran from the same shell as GDB via `&' is
one case where we do, I think (but perhaps this is not
`sharing' in the sense that we need to save and restore tty
state)). I don't know if there is any way to tell whether we
are sharing a terminal. So what we do is to go through all
the saving and restoring of the tty state, but ignore errors
setting the process group, which will happen if we are not
sharing a terminal). */
if (job_control)
{
#ifdef HAVE_TERMIOS
result = tcsetpgrp (0, inferior_process_group);
if (!attach_flag)
OOPSY ("tcsetpgrp");
#endif
#ifdef HAVE_SGTTY
result = ioctl (0, TIOCSPGRP, &inferior_process_group);
if (!attach_flag)
OOPSY ("TIOCSPGRP");
#endif
}
Basically, if tcsetpgrp fails, when in terminal_ours_1 we go
doing this:
inferior_process_group = tcgetpgrp (0);
The process group returned is *our* process group.
When in linux async mode, we interrupt the target with -exec-interrupt,
or cli's interrupt, which calls target_stop, which in linux native ends
up calling:
static void
inf_ptrace_stop (void)
{
/* Send a SIGINT to the process group. This acts just like the user
typed a ^C on the controlling terminal. Note that using a
negative process number in kill() is a System V-ism. The proper
BSD interface is killpg(). However, all modern BSDs support the
System V interface too. */
kill (-inferior_process_group, SIGINT);
}
But since the inferior_process_group is wrong (remember we're attached):
In inf_ptrace_stop:
(top-gdb) p inferior_process_group
$1 = 30793
(top-gdb) p our_process_group
$2 = 30793
(top-gdb)
We'll send the SIGINT to ourselves...
OK?
--
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attach_inferior_terminal.diff
Type: text/x-diff
Size: 2186 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080314/650a2e71/attachment.bin>
More information about the Gdb-patches
mailing list