From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5899 invoked by alias); 15 Jul 2014 17:17:49 -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 5862 invoked by uid 89); 15 Jul 2014 17:17:47 -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,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; Tue, 15 Jul 2014 17:17:45 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6FHHfhh013488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Jul 2014 13:17:41 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FHHdK9011265; Tue, 15 Jul 2014 13:17:40 -0400 Message-ID: <53C56233.8000904@redhat.com> Date: Tue, 15 Jul 2014 17:19:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH v2 1/2] Add dprintf and detach test (PR breakpoints/17012) References: <1404760664-17289-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1404760664-17289-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-07/txt/msg00401.txt.bz2 On 07/07/2014 08:17 PM, Simon Marchi wrote: > +#include > + > +static void > +function (void) > +{ > + sleep (1); 'sleep' needs unistd.h, not stdlib.h. > +} > + > +int > +main (void) > +{ > + int i; > + > + for (i = 0; i < 30; i++) > + { > + function (); > + } Could you please make this follow the same coding standard as GDB? That is, a single statement doesn't need braces. > +} > +# Only GNU/Linux is known to support (dprintf and detach). > +if { ! [istarget "*-*-linux*"] } { > + return 0 > +} dprintf call-style should has no target dependencies, so please remove this making it run on all targets/archs. > + > +# Are we on a target board? > +if [is_remote target] then { > + return 0 > +} This should be a $use_gdb_stub check instead, and give out an explanation for why we need to skip the test: # The test relies on "detach/attach". if [$use_gdb_stub] then { return 0 } > + > +standard_testfile > +set escapedbinfile [string_to_regexp ${binfile}] Spurious double space. > + > +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" It's best to make it so then. That'll expand the coverage of the test to more targets. All targets can do always-inserted, but only a few can do non-stop. For extra coverage, I'd even make the test exercise with both always-inserted on and off. See bottom of break-unload-file.exp, for example. > + > +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: if {$inferior_pid == -1} { return } after gdb_test_multiple, so that if the test fails, we don't try to use a bogus pid. > +# Add a dprintf and detach. > +gdb_test "dprintf function, \"hello\"" "Dprintf .*" "dprintf insertion" > +gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach program" > + > +gdb_exit > + > +# Give some time for the ex-inferior to run and hopefully not crash. > +sleep 1 > + > +# Check that the process still exists by attaching a new gdb to it. > +gdb_start > +gdb_test "attach $inferior_pid" "Attaching to process $inferior_pid.*Reading symbols from $escapedbinfile.*" "re-attach to inferior" I think that as is, this fails with --target_board=native-extended-gdbserver, because with that, "attach" won't know which binary the program is running. A gdb_load/clean_restart be missing too -- I think you might get a complain about not knowing how to attach, as auto-connecting to native target is force-disabled with that board (to catch these issues exactly). Thanks, -- Pedro Alves