From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by sourceware.org (Postfix) with ESMTPS id D8B8B3857030 for ; Mon, 6 Jul 2020 19:03:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D8B8B3857030 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f68.google.com with SMTP id 22so40404055wmg.1 for ; Mon, 06 Jul 2020 12:03:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+feKQ5RrhZQc6rtwaXavmK4aSmkN0cd7XF9zO580Weg=; b=DrG07Bmq+4k0SHuT7HtO466feamgxRG34L5rfIoxnXSgaOk+c+kZW8FLE5Fu1+gwx3 GwVO3HOa+lWYHklt2+JCVAHpMUTCBaW3Psf8FwGQrdRllM3z5i7hosAGpc1WQkEn4/ZO OjTWk4xGemK10mTuNgkFrGaikyk0clnUVTM6l8dipstHKsPc8wHFTfHJ8fjM7cjSyStS XF8Ik0MM91n8BR16VBNSlKqV4Jeuuc/XIhI8/4yJHAcX70qfX/0lIYW6yu+SzGsfSFHC LTwmFWMml5L0Z4TdzJfN7V2NAcIRU0w3U+05T1ENdacHAKTT2Pynq2BHdurxJkoWm9A6 BMbA== X-Gm-Message-State: AOAM53323Z2akiskviWvL3pwh66S5pgHDQyqaH9CMyGNp87z4Ui25JSf yJYs81btcOuMdv1Cxj2gcACT8CEf+yRhHQ== X-Google-Smtp-Source: ABdhPJyMeuiODPQE91buDt7S4L9c9wXV9ydn7NOKthMfiJ/fzafCBl9eKlUIeLyF//R48uVkdU11nw== X-Received: by 2002:a1c:1bc4:: with SMTP id b187mr613985wmb.105.1594062194684; Mon, 06 Jul 2020 12:03:14 -0700 (PDT) Received: from localhost ([2001:8a0:f91a:c400:8728:8fef:5b85:5934]) by smtp.gmail.com with ESMTPSA id m9sm380853wml.45.2020.07.06.12.03.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jul 2020 12:03:13 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 6/7] Testcase for previous handle_no_resumed fixes Date: Mon, 6 Jul 2020 20:02:51 +0100 Message-Id: <20200706190252.22552-7-pedro@palves.net> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20200706190252.22552-1-pedro@palves.net> References: <20200706190252.22552-1-pedro@palves.net> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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: Mon, 06 Jul 2020 19:03:17 -0000 This adds a testcase that covers the scenarios described in the previous two commits. gdb/testsuite/ChangeLog: PR gdb/26199 * gdb.multi/multi-target.c (exit_thread): New. (thread_start): Break loop if EXIT_THREAD. * gdb.multi/multi-target.exp (test_no_unwaited_for): New proc. (top level) Call test_no_resumed. --- gdb/testsuite/gdb.multi/multi-target.c | 4 +- gdb/testsuite/gdb.multi/multi-target.exp | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.multi/multi-target.c b/gdb/testsuite/gdb.multi/multi-target.c index 23ec6bd600..b337e59a11 100644 --- a/gdb/testsuite/gdb.multi/multi-target.c +++ b/gdb/testsuite/gdb.multi/multi-target.c @@ -26,12 +26,14 @@ static pthread_barrier_t barrier; +volatile int exit_thread; + static void * thread_start (void *arg) { pthread_barrier_wait (&barrier); - while (1) + while (!exit_thread) sleep (1); return NULL; } diff --git a/gdb/testsuite/gdb.multi/multi-target.exp b/gdb/testsuite/gdb.multi/multi-target.exp index b519eda4e8..d19cee6595 100644 --- a/gdb/testsuite/gdb.multi/multi-target.exp +++ b/gdb/testsuite/gdb.multi/multi-target.exp @@ -439,6 +439,77 @@ proc test_info_inferiors {multi_process} { } } +# Test that when there's a foreground execution command in progress, a +# TARGET_WAITKIND_NO_RESUMED for a particular target is ignored when +# other targets are still resumed. + +proc test_no_resumed {} { + proc test_no_resumed_infs {inf_A inf_B} { + global gdb_prompt + + if {![setup "off"]} { + untested "setup failed" + return + } + + gdb_test "thread $inf_A.2" "Switching to thread $inf_A\.2 .*" \ + "select thread of target A" + + gdb_test_no_output "set scheduler-locking on" + + gdb_test_multiple "continue &" "" { + -re "Continuing.*$gdb_prompt " { + pass $gdb_test_name + } + } + + gdb_test "thread $inf_B.2" "Switching to thread $inf_B\.2 .*" \ + "select thread of target B" + gdb_test "p exit_thread = 1" " = 1" \ + "set the thread to exit on resumption" + + # Wait 3 seconds. If we see any response from GDB, such as + # "No unwaited-for children left." it's a bug. + gdb_test_multiple "continue" "continue" { + -timeout 3 + timeout { + pass $gdb_test_name + } + } + + # Now stop the program (all targets). + send_gdb "\003" + gdb_test_multiple "" "send_gdb control C" { + -re "received signal SIGINT.*$gdb_prompt $" { + pass $gdb_test_name + } + } + + gdb_test_multiple "info threads" "all threads stopped" { + -re "\\\(running\\\).*$gdb_prompt $" { + fail $gdb_test_name + } + -re "$gdb_prompt $" { + pass $gdb_test_name + } + } + } + + # inferior 1 -> native + # inferior 2 -> extended-remote 1 + # inferior 5 -> extended-remote 2 + set inferiors {1 2 5} + foreach_with_prefix inf_A $inferiors { + foreach_with_prefix inf_B $inferiors { + if {$inf_A == $inf_B} { + continue + } + test_no_resumed_infs $inf_A $inf_B + } + } +} + + # Make a core file with two threads upfront. Several tests load the # same core file. prepare_core @@ -467,4 +538,9 @@ with_test_prefix "info-inferiors" { } } +# Test TARGET_WAITKIND_NO_RESUMED handling with multiple targets. +with_test_prefix "no-resumed" { + test_no_resumed +} + cleanup_gdbservers -- 2.14.5