From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 3A4043840000 for ; Thu, 10 Jun 2021 14:47:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A4043840000 X-ASG-Debug-ID: 1623336462-0c856e6cd51733990001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 8SfscDDwylyIrGpk (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Jun 2021 10:47:42 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 2BCFD441D64; Thu, 10 Jun 2021 10:47:42 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb/testsuite: gdb.base/attach.exp: expose bug when testing with native-extended-gdbserver Date: Thu, 10 Jun 2021 10:47:40 -0400 X-ASG-Orig-Subj: [PATCH 2/2] gdb/testsuite: gdb.base/attach.exp: expose bug when testing with native-extended-gdbserver Message-Id: <20210610144740.2021125-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210610144740.2021125-1-simon.marchi@polymtl.ca> References: <20210610144740.2021125-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1623336462 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 4315 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.90548 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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: Thu, 10 Jun 2021 14:47:46 -0000 In gdb.base/attach.exp, proc do_attach_failure_tests, we attach to a process. When then try to attach to the same process in another inferior, expecting it to fail. We then come back to the first inferior and try to kill it, to clean up the test. When using the native-extended-gdbserver board, this "kill" test passes, even though it didn't actually work: add-inferior [New inferior 2] Added inferior 2 on connection 1 (extended-remote localhost:2347) (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: add empty inferior 2 inferior 2 [Switching to inferior 2 [] ()] (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: switch to inferior 2 attach 817032 Attaching to process 817032 Attaching to process 817032 failed (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: fail to attach again inferior 1 [Switching to inferior 1 [process 817032] (/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/attach/attach)] [Switching to thread 1.1 (Thread 817032.817032)] #0 main () at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/attach.c:19 19 while (! should_exit) (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: switch to inferior 1 kill Kill the program being debugged? (y or n) y Remote connection closed <==== That's unexpected (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: exit after attach failures When the second attach fails, gdbserver seems to break the connection (it hangs up on the existing remote target) and start listening again for incoming connections. This is documented in PR 19558 [1]. Make the expected output regexp for the kill command tighter (it currently accepts anything). Use "set confirm off" so we don't have to deal with the confirmation. And to be really sure the extended-remote target still works, try to run the inferior again after killing. The now tests are kfail'ed when the target is gdbserver. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=19558 gdb/testsuite/ChangeLog: * gdb.base/attach.exp (do_attach_failure_tests): Make kill regexp tighter, run inferior after killing it. Kfail when target is gdbserver. Change-Id: I99c5cd3968ce2ec962ace35b016f842a243b7a0d --- gdb/testsuite/gdb.base/attach.exp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 8b78dcc51811..d6c592275590 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -179,6 +179,10 @@ proc_with_prefix do_attach_failure_tests {} { gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2" + # Probe this before the failing attach: the failed attach against GDBserver + # currently leaves the extended-remote target in a bad state. + set do_kfail [target_is_gdbserver] + set test "fail to attach again" gdb_test_multiple "attach $testpid" "$test" { -re "Attaching to process $testpid.*warning: process .* is already traced by process .*$gdb_prompt $" { @@ -190,13 +194,24 @@ proc_with_prefix do_attach_failure_tests {} { } } + # To ensure the target is still alive and working after this, try to run + # inferior 1. + gdb_test_no_output "set confirm off" gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1" - set test "exit after attach failures" - gdb_test "kill" \ - "" \ - "$test" \ - "Kill the program being debugged.*y or n. $" \ - "y" + + if { $do_kfail } { setup_kfail "gdb/19558" "*-*-*" } + gdb_test "kill" "killed.*" "exit after attach failures" + + # This can probably be replaced with a call to runto or runto_main once + # the kfail is removed. + gdb_breakpoint "main" + gdb_run_cmd + if { $do_kfail } { setup_kfail "gdb/19558" "*-*-*" } + gdb_test_multiple "" "stop at main" { + -wrap -re "Breakpoint $::decimal, main .*" { + pass $gdb_test_name + } + } # Another "don't leave a process around" kill_wait_spawned_process $test_spawn_id -- 2.32.0