From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9676 invoked by alias); 7 Jul 2014 17:20:35 -0000 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 Received: (qmail 9657 invoked by uid 89); 7 Jul 2014 17:20:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 07 Jul 2014 17:20:32 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 06.11.05330.6B48AB35; Mon, 7 Jul 2014 13:29:59 +0200 (CEST) Received: from [142.133.110.254] (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.96) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 7 Jul 2014 13:20:29 -0400 Message-ID: <53BAD6DC.2010003@ericsson.com> Date: Mon, 07 Jul 2014 17:20:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Joel Brobecker CC: GDB Patches Subject: Re: [PATCH 1/2] Add dprintf and detach test (PR breakpoints/17012) References: <1403101571-1190-1-git-send-email-simon.marchi@ericsson.com> <53B40946.3080102@ericsson.com> <20140707150614.GG6038@adacore.com> In-Reply-To: <20140707150614.GG6038@adacore.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00128.txt.bz2 On 14-07-07 11:06 AM, Joel Brobecker wrote: > Hello Simon, > >> 2014-06-18 Simon Marchi simon.marchi@ericsson.com >> >> PR breakpoints/17012 >> gdb.base/dprintf-detach.c: New file. >> gdb.base/dprintf-detach.exp: New file. > > Sorry for the delay in answering this. > >> diff --git a/gdb/testsuite/gdb.base/dprintf-detach.c b/gdb/testsuite/gdb.base/dprintf-detach.c >> new file mode 100644 >> index 0000000..91f49ce >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/dprintf-detach.c >> @@ -0,0 +1,18 @@ >> +#include > > This file needs a copyright notice, please. I checked a few other test files and they didn't have the copyright notice, that's why I didn't add it. I have no problem adding it if it should be there. >> diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp >> new file mode 100644 >> index 0000000..18ba154 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/dprintf-detach.exp >> @@ -0,0 +1,80 @@ >> +# Copyright 2003-2014 Free Software Foundation, Inc. > > Can you confirm that 2003 is the correct year for the start > of the range? Oops, just 2014. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . */ >> + >> +# This test checks that inserting a dprintf and detaching does not crash >> +# the program. >> +# >> +# Related bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17012 >> + >> +# Only GNU/Linux is known to support (dprintf and detach). >> +if { ! [istarget "*-*-linux*"] } { >> + return 0 >> +} >> + >> +# Are we on a target board? >> +if [is_remote target] then { >> + return 0 >> +} >> + >> +standard_testfile >> +set escapedbinfile [string_to_regexp ${binfile}] >> + >> +if [prepare_for_testing "failed to prepare for dprintf-detach" \ >> + ${testfile} ${srcfile} {debug}] { >> + return -1 >> +} >> + >> +# The problem was showing up in non-stop mode, since it enables >> +# "breakpoint always-inserted", so this could also be >> +# "set breakpoint always-inserted on". >> +gdb_test_no_output "set non-stop on" >> + >> +if ![runto_main] { >> + fail "Can't run to main" >> + return -1 >> +} >> + >> +# Get PID of test program. >> +set inferior_pid -1 >> +set test "get inferior process ID" >> +gdb_test_multiple "call getpid ()" $test { >> + -re ".* = ($decimal).*$gdb_prompt $" { >> + set inferior_pid $expect_out(1,string) >> + pass $test >> + } >> +} >> + >> +# Add a dprintf and detach. >> +gdb_test "dprintf function, \"hello\"" "Dprintf .*" "dprintf insertion" >> +gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach program" >> + >> +# Exit gdb. Until we do that, the process will exist as a zombie. > > Two spaces after the period. > >> +gdb_exit >> + >> +# Give some time for the ex-inferior to run and hopefully not crash. >> +sleep 1 >> + >> +# Check that the process still exists. >> +set test "detached process should continue to exist" >> +if {[catch {exec kill -0 $inferior_pid}]} { >> + # Process does not exist. >> + fail "$test" >> +} else { >> + # Process exists. >> + pass "$test" >> +} >> + >> +# Clean up. >> +catch {exec kill -9 $inferior_pid} > > I am not quite sure about how well how the above would work in practice. > How about restarting GDB, and do an "attach" gdb_test? That way, we > can kill the inferior process from GDB as well. (it's a good thing > you used a 30-times loops as well to make sure the process eventually > terminates on its own as well). It "works", as in "it runs fine on my machine". Your suggestion to attach the process with a new gdb seems more portable, as it doesn't rely on kill. I will try to make a version based on that.