Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] gdb could leave inferior running as a background process
@ 2008-04-22 16:12 Paul Pluzhnikov
  2008-04-22 17:40 ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Pluzhnikov @ 2008-04-22 16:12 UTC (permalink / raw)
  To: gdb-patches

[-- 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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-04-22 22:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-22 16:12 [RFC] gdb could leave inferior running as a background process Paul Pluzhnikov
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox