From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15530 invoked by alias); 22 Apr 2008 14:41:58 -0000 Received: (qmail 15518 invoked by uid 22791); 22 Apr 2008 14:41:57 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 22 Apr 2008 14:41:30 +0000 Received: from zps77.corp.google.com (zps77.corp.google.com [172.25.146.77]) by smtp-out.google.com with ESMTP id m3MEfNbv029024 for ; Tue, 22 Apr 2008 15:41:24 +0100 Received: from gv-out-0910.google.com (gvei36.prod.google.com [10.16.160.36]) by zps77.corp.google.com with ESMTP id m3MEfLfW012825 for ; Tue, 22 Apr 2008 07:41:22 -0700 Received: by gv-out-0910.google.com with SMTP id i36so240949gve.15 for ; Tue, 22 Apr 2008 07:41:21 -0700 (PDT) Received: by 10.150.229.16 with SMTP id b16mr311062ybh.115.1208875280722; Tue, 22 Apr 2008 07:41:20 -0700 (PDT) Received: by 10.151.39.20 with HTTP; Tue, 22 Apr 2008 07:41:20 -0700 (PDT) Message-ID: <8ac60eac0804220741g6b830620h6f83c627fb00474b@mail.gmail.com> Date: Tue, 22 Apr 2008 16:12:00 -0000 From: "Paul Pluzhnikov" To: gdb-patches@sourceware.org Subject: [RFC] gdb could leave inferior running as a background process MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_11950_11109326.1208875280711" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00471.txt.bz2 ------=_Part_11950_11109326.1208875280711 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1789 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 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 * gdb/infrun.c (wait_for_inferior): Call target_terminal_inferior before blocking. ------=_Part_11950_11109326.1208875280711 Content-Type: text/plain; name=patch.txt Content-Transfer-Encoding: base64 X-Attachment-Id: f_ffcl1gdf0 Content-Disposition: attachment; filename=patch.txt Content-length: 1054 MjAwOC0wNC0yMSAgUGF1bCBQbHV6aG5pa292ICA8cHBsdXpobmlrb3ZAZ29v Z2xlLmNvbT4KCiAgICAgICAqIGdkYi9pbmZydW4uYyAod2FpdF9mb3JfaW5m ZXJpb3IpOiBDYWxsCiAgICAgICB0YXJnZXRfdGVybWluYWxfaW5mZXJpb3Ig YmVmb3JlIGJsb2NraW5nLgoKCi0tLSBnZGIvaW5mcnVuLmMub3JpZwkyMDA4 LTA0LTIxIDE4OjAwOjE1LjE1OTU2NzAwMCAtMDcwMAorKysgZ2RiL2luZnJ1 bi5jCTIwMDgtMDQtMjEgMjM6MTk6MTYuODAyMjA2MDAwIC0wNzAwCkBAIC0x MDIzLDEyICsxMDIzLDE0IEBAIHdhaXRfZm9yX2luZmVyaW9yIChpbnQgdHJl YXRfZXhlY19hc19zaWcKICAgICAgc3RhdHVzIG1lY2hhbmlzbS4gKi8KIAog ICByZWdpc3RlcnNfY2hhbmdlZCAoKTsKIAogICB3aGlsZSAoMSkKICAgICB7 CisgICAgICAvKiBNYWtlIHN1cmUgdGVybWluYWwgaXMgc3dpdGNoZWQgdG8g aW5mZXJpb3IgYmVmb3JlIHdhaXRpbmcgZm9yIGl0LiAgKi8KKyAgICAgIHRh cmdldF90ZXJtaW5hbF9pbmZlcmlvciAoKTsKICAgICAgIGlmIChkZXByZWNh dGVkX3RhcmdldF93YWl0X2hvb2spCiAJZWNzLT5wdGlkID0gZGVwcmVjYXRl ZF90YXJnZXRfd2FpdF9ob29rIChlY3MtPndhaXRvbl9wdGlkLCBlY3MtPndw KTsKICAgICAgIGVsc2UKIAllY3MtPnB0aWQgPSB0YXJnZXRfd2FpdCAoZWNz LT53YWl0b25fcHRpZCwgZWNzLT53cCk7CiAKICAgICAgIGlmICh0cmVhdF9l eGVjX2FzX3NpZ3RyYXAgJiYgZWNzLT53cy5raW5kID09IFRBUkdFVF9XQUlU S0lORF9FWEVDRCkK ------=_Part_11950_11109326.1208875280711--