From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id D1E853858D33 for ; Wed, 13 Jan 2021 07:05:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1E853858D33 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10D75Vnl018581 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Jan 2021 02:05:36 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10D75Vnl018581 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 651041E590; Wed, 13 Jan 2021 02:05:31 -0500 (EST) Subject: Re: [PATCH 12/12] Testcase for detaching while stepping over breakpoint To: Pedro Alves , gdb-patches@sourceware.org References: <20210113011543.2047449-1-pedro@palves.net> <20210113011543.2047449-13-pedro@palves.net> From: Simon Marchi Message-ID: Date: Wed, 13 Jan 2021 02:05:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210113011543.2047449-13-pedro@palves.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 13 Jan 2021 07:05:31 +0000 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 07:05:40 -0000 On 2021-01-12 8:15 p.m., Pedro Alves wrote: > +# The test proper. See description above. > +proc test {condition_eval target_non_stop non_stop displaced} { > + global binfile srcfile > + global gdb_prompt > + global decimal > + global bp_lineno > + global GDBFLAGS > + > + # Number of threads started by the program. > + set n_threads 10 > + > + save_vars { GDBFLAGS } { > + append GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\"" > + append GDBFLAGS " -ex \"set non-stop $non_stop\"" > + append GDBFLAGS " -ex \"set displaced $displaced\"" > + append GDBFLAGS " -ex \"set schedule-multiple on\"" > + clean_restart $binfile > + } > + > + set test_spawn_id [spawn_wait_for_attach $binfile] > + set testpid [spawn_id_get_pid $test_spawn_id] > + > + set any "\[^\r\n\]*" > + > + gdb_test "add-inferior" "Added inferior 2.*" > + gdb_test "inferior 2" "Switching to .*" > + > + gdb_load $binfile > + if ![runto setup_done] then { > + fail "can't run to setup_done" > + kill_wait_spawned_process $test_spawn_id > + return > + } > + > + gdb_test_no_output "set breakpoint condition-evaluation $condition_eval" > + > + # Get the PID of the test process. > + set pid_inf2 "" > + gdb_test_multiple "p mypid" "get pid of inferior 2" { > + -re " = ($decimal)\r\n$gdb_prompt $" { > + set pid_inf2 $expect_out(1,string) > + pass $gdb_test_name > + } > + } > + > + set attempts 3 > + for {set attempt 1} { $attempt <= $attempts } { incr attempt } { > + with_test_prefix "iter $attempt" { > + gdb_test "inferior 1" "Switching to .*" > + > + set attached 0 > + set eperm 0 > + set test "attach" > + gdb_test_multiple "attach $testpid" $test { > + -re "new threads in iteration" { > + # Seen when "set debug libthread_db" is on. > + exp_continue > + } > + -re "is a zombie - the process has already terminated.*$gdb_prompt " { > + fail $gdb_test_name > + } > + -re "Unable to attach: .*$gdb_prompt " { > + fail $gdb_test_name > + } > + -re "Attaching to program.*process $testpid.*$gdb_prompt " { > + pass $test > + set attached 1 > + } > + } > + > + if {!$attached} { > + kill_wait_spawned_process $test_spawn_id > + return > + } > + > + if {$non_stop} { > + # In non-stop, we will see one stop per thread after > + # the prompt. > + set stops 0 > + set tid_re "$::decimal\.$::decimal" > + set test "seen all stops" > + for {set thread 1} { $thread <= $n_threads } { incr thread } { > + if {[gdb_test_multiple "" $test { > + -re "Thread ${tid_re} ${any} stopped" { > + incr stops > + } > + }] != 0} { > + break > + } > + } > + > + # This we haven't seen all stops, then the This sentence misses something, like in the other test. I am running it in a loop here and it's passing so far :). Really, congrats and thanks for this series, that looked like some hardcore debugging. Simon