Regression: GDB stopped on run with attached process (PR 17347) [Re: [pushed+7.8] Re: [PATCH] Fix "attach" command vs user input race
Message ID | 20140907192818.GA17035@host2.jankratochvil.net |
---|---|
State | Committed |
Headers |
Received: (qmail 17650 invoked by alias); 7 Sep 2014 19:28:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17640 invoked by uid 89); 7 Sep 2014 19:28:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 07 Sep 2014 19:28:27 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s87JSNV5006606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 7 Sep 2014 15:28:23 -0400 Received: from host2.jankratochvil.net (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s87JSJcQ017301 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sun, 7 Sep 2014 15:28:21 -0400 Date: Sun, 7 Sep 2014 21:28:18 +0200 From: Jan Kratochvil <jan.kratochvil@redhat.com> To: Pedro Alves <palves@redhat.com> Cc: Doug Evans <dje@google.com>, Mark Wielaard <mjw@redhat.com>, gdb-patches@sourceware.org Subject: Re: Regression: GDB stopped on run with attached process (PR 17347) [Re: [pushed+7.8] Re: [PATCH] Fix "attach" command vs user input race Message-ID: <20140907192818.GA17035@host2.jankratochvil.net> References: <1404291574.3766.35.camel@bordewijk.wildebeest.org> <53B3CDCC.9050502@redhat.com> <53B57911.10304@redhat.com> <53B6B0B8.2050702@redhat.com> <21434.52532.737427.778289@ruffy.mtv.corp.google.com> <53BC0D0B.7040001@redhat.com> <21437.28600.751354.629884@ruffy.mtv.corp.google.com> <53BD7749.5000800@redhat.com> <20140903075858.GA23492@host2.jankratochvil.net> <540775D7.7040003@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline In-Reply-To: <540775D7.7040003@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes |
Commit Message
Jan Kratochvil
Sept. 7, 2014, 7:28 p.m. UTC
On Wed, 03 Sep 2014 22:11:03 +0200, Pedro Alves wrote: > On 09/03/2014 08:58 AM, Jan Kratochvil wrote: > > > https://sourceware.org/bugzilla/show_bug.cgi?id=17347 > > Thanks Jan. > > Here's a fix, test included. Comments? In the testsuite run from the Fedora rpm packaging I get: GNU gdb (GDB) Fedora 7.8-21.fc21^M Copyright (C) 2014 Free Software Foundation, Inc.^M License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>^M This is free software: you are free to change and redistribute it.^M There is NO WARRANTY, to the extent permitted by law. Type "show copying"^M and "show warranty" for details.^M This GDB was configured as "i686-redhat-linux-gnu".^M Type "show configuration" for configuration details.^M For bug reporting instructions, please see:^M <http://www.gnu.org/software/gdb/bugs/>.^M Find the GDB manual and other documentation resources online at:^M <http://www.gnu.org/software/gdb/documentation/>.^M For help, type "help".^M Type "apropos word" to search for commands related to "word".^M Attaching to process 27028^M Reading symbols from /unsafebuild-i686-redhat-linux-gnu/gdb/testsuite.unix.-m32/outputs/gdb.base/attach/attach...done.^M Reading symbols from /lib/libm.so.6...Reading symbols from /usr/lib/debug/usr/lib/libm-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/libm.so.6^M Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/usr/lib/libc-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/libc.so.6^M Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/usr/lib/ld-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/ld-linux.so.2^M main ()^M at gdb/testsuite/gdb.base/attach.c:15^M 15 while (! should_exit)^M The program being debugged has been started already.^M Start it from the beginning? (y or n) PASS: gdb.base/attach.exp: cmdline attach run: run to prompt y^M ^M Temporary breakpoint 1 at 0x8048481: file gdb/testsuite/gdb.base/attach.c, line 13.^M Starting program: /unsafe/home/jkratoch/hammock/20140907fedorarel21-f21/fedora-2---Type <return> to continue, or q <return> to quit---ERROR: Window too small. UNRESOLVED: gdb.base/attach.exp: cmdline attach run: run to main While I do not fully understand why that happens in every run of that Fedora testsuite while it never happens during my reproducibility attempts by hand I find it understandable and the Fedora testsuite issues does get fixed by the attached patch. > --- a/gdb/testsuite/gdb.base/attach.exp > +++ b/gdb/testsuite/gdb.base/attach.exp > @@ -58,6 +58,37 @@ if [get_compiler_info] { > return -1 > } > > +# Start the program running and then wait for a bit, to be sure that > +# it can be attached to. Return the process's PID. > + > +proc spawn_test_prog { executable } { > + set testpid [eval exec $executable &] > + exec sleep 2 Unrelated to this patch - this patch only moved the code. Also the code move could be a separate patch: I do not see why the testsuite commonly uses "exec sleep" while it also uses "sleep" itself which also works fine. > + if { [istarget "*-*-cygwin*"] } { > + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be > + # different due to the way fork/exec works. > + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] > + } > + > + return $testpid > +} [...] > @@ -429,6 +427,50 @@ proc do_command_attach_tests {} { > remote_exec build "kill -9 ${testpid}" > } > > +# Test ' gdb --pid PID -ex "run" '. GDB used to have a bug where > +# "run" would run before the attach finished - PR17347. > + > +proc test_command_line_attach_run {} { > + global gdb_prompt > + global binfile > + global verbose > + global GDB > + global INTERNAL_GDBFLAGS These 3 lines are unused. > + > + if ![isnative] then { > + unsupported "commandline attach run test" > + return 0 > + } > + > + with_test_prefix "cmdline attach run" { > + set testpid [spawn_test_prog $binfile] > + > + set test "run to prompt" > + gdb_exit > + set res [gdb_spawn_with_cmdline_opts "--pid=$testpid -ex \"start\""] Here see the attachment. > + if { $res != 0} { > + fail $test > + return $res > + } > + gdb_test_multiple "" $test { > + -re {Attaching to.*Start it from the beginning\? \(y or n\) } { > + pass $test > + } > + } > + > + send_gdb "y\n" > + > + set test "run to main" > + gdb_test_multiple "" $test { > + -re "Temporary breakpoint .* main .*$gdb_prompt $" { > + pass $test > + } > + } > + > + # Get rid of the process > + remote_exec build "kill -9 ${testpid}" > + } > +} > > # Start with a fresh gdb > > @@ -453,4 +495,6 @@ do_call_attach_tests > > do_command_attach_tests > > +test_command_line_attach_run > + > return 0 > diff --git a/gdb/top.c b/gdb/top.c > index fc2b84d..ba71f8f 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -373,6 +373,21 @@ check_frame_language_change (void) > } > } > Missing: /* See top.h. */ Unless that rule from me has been abandoned. > +void > +maybe_wait_sync_command_done (int was_sync) > +{ > + /* If the interpreter is in sync mode (we're running a user > + command's list, running command hooks or similars), and we > + just ran a synchronous command that started the target, wait > + for that command to end. */ > + if (!interpreter_async && !was_sync && sync_execution) > + { > + while (gdb_do_one_event () >= 0) > + if (!sync_execution) > + break; > + } > +} > + > /* Execute the line P as a command, in the current user context. > Pass FROM_TTY as second argument to the defining function. */ > Thanks, Jan
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index c94c127..6e566a3 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -447,7 +444,8 @@ proc test_command_line_attach_run {} { set test "run to prompt" gdb_exit - set res [gdb_spawn_with_cmdline_opts "--pid=$testpid -ex \"start\""] + set res [gdb_spawn_with_cmdline_opts \ + "-iex set\\ height\\ 0 -iex set\\ width\\ 0 --pid=$testpid -ex \"start\""] if { $res != 0} { fail $test return $res