From: "Paul Pluzhnikov" <ppluzhnikov@google.com>
To: gdb-patches@sourceware.org
Subject: [RFC] gdb could leave inferior running as a background process
Date: Tue, 22 Apr 2008 16:12:00 -0000 [thread overview]
Message-ID: <8ac60eac0804220741g6b830620h6f83c627fb00474b@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]
Greetings,
Problem:
- gdb calls target_terminal_inferior(),
- performs other stuff, which could issue warnings. warning()
switches gdb to the foreground.
- calls target_wait without switching the terminal back to inferior,
which then prevents inferior from working.
Demonstration:
$ cat pp.c
int main()
{
char buf[1];
while (0 != read(0, buf, 1))
write(1, buf, 1);
return 0;
}
$ gcc -static pp.c # -static is needed to trigger warning with
# my version of gcc and glibc
$ gdb ./a.out
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux"...
(gdb) r
warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x8048100 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x8048100 in read in psymtab, but not in symtab.)
Program received signal SIGTTIN, Stopped (tty input).
0xffffe410 in __kernel_vsyscall ()
(gdb) c
Program received signal SIGTTIN, Stopped (tty input).
0xffffe410 in __kernel_vsyscall ()
Note: the 'in psymtab, but not in symtab' warning appears to be triggered
by a separate bug in gold, but that's irrelevant: there could be any
other warning, and the effect would be the same.
Proposed patch below.
Thanks,
--
Paul Pluzhnikov
--------------------------------------------------------------------------------
2008-04-21 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb/infrun.c (wait_for_inferior): Call
target_terminal_inferior before blocking.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 777 bytes --]
2008-04-21 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb/infrun.c (wait_for_inferior): Call
target_terminal_inferior before blocking.
--- gdb/infrun.c.orig 2008-04-21 18:00:15.159567000 -0700
+++ gdb/infrun.c 2008-04-21 23:19:16.802206000 -0700
@@ -1023,12 +1023,14 @@ wait_for_inferior (int treat_exec_as_sig
status mechanism. */
registers_changed ();
while (1)
{
+ /* Make sure terminal is switched to inferior before waiting for it. */
+ target_terminal_inferior ();
if (deprecated_target_wait_hook)
ecs->ptid = deprecated_target_wait_hook (ecs->waiton_ptid, ecs->wp);
else
ecs->ptid = target_wait (ecs->waiton_ptid, ecs->wp);
if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD)
next reply other threads:[~2008-04-22 14:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-22 16:12 Paul Pluzhnikov [this message]
2008-04-22 17:40 ` Daniel Jacobowitz
2008-04-22 17:56 ` Paul Pluzhnikov
2008-04-22 18:05 ` Paul Pluzhnikov
2008-04-22 19:55 ` Daniel Jacobowitz
2008-04-22 20:29 ` Paul Pluzhnikov
[not found] ` <20080422195515.GA28506@caradoc.them.org>
2008-04-22 21:35 ` Doug Evans
2008-04-22 22:09 ` Daniel Jacobowitz
2008-04-23 2:19 ` Doug Evans
2008-04-23 3:54 ` Daniel Jacobowitz
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=8ac60eac0804220741g6b830620h6f83c627fb00474b@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=gdb-patches@sourceware.org \
/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