From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91201 invoked by alias); 16 Sep 2015 14:47:58 -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 91187 invoked by uid 89); 16 Sep 2015 14:47:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no 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; Wed, 16 Sep 2015 14:47:56 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A9EDD8EA37; Wed, 16 Sep 2015 14:47:55 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GElr8K001218; Wed, 16 Sep 2015 10:47:54 -0400 Message-ID: <55F98119.1000906@redhat.com> Date: Wed, 16 Sep 2015 14:47:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Sandra Loosemore CC: gdb-patches , Yao Qi Subject: Re: [RFC] fix gdb.threads/non-stop-fair-events.exp timeouts References: <55E9CCCD.7060604@codesourcery.com> <55EF0D11.2020200@redhat.com> <55F05975.4030207@codesourcery.com> <55F07D12.7090607@redhat.com> <55F7815F.1010602@codesourcery.com> In-Reply-To: <55F7815F.1010602@codesourcery.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-09/txt/msg00379.txt.bz2 On 09/15/2015 03:24 AM, Sandra Loosemore wrote: > Yes, that fixes the trouble, and the tests run OK now. I did find that > it still timed out 1 of the 5 times I ran it, though, so maybe the > timeout factor really does need to match NUM_THREADS to be safe? Indeed, just played with NUM_THREADS now, and the time it takes to complete the test depends on it. Here's what I'm pushing then. >From 7e2a5b76cc4dc2871b44792737ca02950b68c2fb Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 16 Sep 2015 15:31:48 +0100 Subject: [PATCH] non-stop-fair-events.exp slower on software single-step && !displ-step targets On software single-step targets that don't support displaced stepping, threads keep hitting each other's single-step breakpoints, and then GDB needs to pause all threads to step past those. The end result is that progress in the main thread will be slower and it may take a bit longer for the signal to be queued. This patch bumps the timeout on such targets. gdb/testsuite/ChangeLog: 2015-09-16 Pedro Alves Sandra Loosemore * gdb.threads/non-stop-fair-events.c (timeout): New global. (SECONDS): Redefine. (main): Call pthread_kill and alarm early. * gdb.threads/non-stop-fair-events.exp: Probe displaced stepping support. (test): If the target can't hardware step and doesn't support displaced stepping, increase the timeout. --- gdb/testsuite/gdb.threads/non-stop-fair-events.c | 9 ++- gdb/testsuite/gdb.threads/non-stop-fair-events.exp | 94 +++++++++++++++------- gdb/testsuite/lib/gdb.exp | 20 +++-- 3 files changed, 85 insertions(+), 38 deletions(-) diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.c b/gdb/testsuite/gdb.threads/non-stop-fair-events.c index f82c366..700676b 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.c +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.c @@ -24,7 +24,9 @@ const int num_threads = NUM_THREADS; /* Allow for as much timeout as DejaGnu wants, plus a bit of slack. */ -#define SECONDS (TIMEOUT + 20) + +volatile unsigned int timeout = TIMEOUT; +#define SECONDS (timeout + 20) pthread_t child_thread[NUM_THREADS]; volatile pthread_t signal_thread; @@ -69,6 +71,11 @@ main (void) int res; int i; + /* Call these early so that we're sure their PLTs are quickly + resolved now, instead of in the busy threads. */ + pthread_kill (pthread_self (), 0); + alarm (0); + signal (SIGUSR1, handler); for (i = 0; i < NUM_THREADS; i++) diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp index 37f5bcb..27b50c5 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp @@ -62,6 +62,21 @@ set NUM_THREADS [get_value "num_threads" "get num_threads"] # Account for the main thread. incr NUM_THREADS +# Probe for displaced stepping support. We're stopped at the main +# breakpoint. If displaced stepping is supported, we should see +# related debug output. +set displaced_stepping_enabled 0 +set msg "check displaced-stepping" +gdb_test_no_output "set debug displaced 1" +gdb_test_multiple "next" $msg { + -re "displaced pc to.*$gdb_prompt $" { + set displaced_stepping_enabled 1 + } + -re ".*$gdb_prompt $" { + } +} +gdb_test_no_output "set debug displaced 0" + # Run threads to their start positions. This prepares for a new test # sequence. @@ -127,6 +142,8 @@ proc enable_debug {enable} { proc test {signal_thread} { global gdb_prompt global NUM_THREADS + global timeout + global displaced_stepping_enabled with_test_prefix "signal_thread=$signal_thread" { restart @@ -152,42 +169,59 @@ proc test {signal_thread} { enable_debug 1 - set saw_continuing 0 - set test "continue &" - gdb_test_multiple $test $test { - -re "Continuing.\r\n" { - set saw_continuing 1 - exp_continue - } - -re "$gdb_prompt " { - gdb_assert $saw_continuing $test - } - -re "infrun:" { - exp_continue - } + # On software single-step targets that don't support displaced + # stepping, threads keep hitting each others' single-step + # breakpoints, and then GDB needs to pause all threads to step + # past those. The end result is that progress in the main + # thread will be slower and it may take a bit longer for the + # signal to be queued; bump the timeout. + if {!$displaced_stepping_enabled && ![can_hardware_single_step]} { + # The more threads we have, the longer it takes. + set factor $NUM_THREADS + } else { + set factor 1 } - - set gotit 0 - - # Wait for all threads to finish their steps, and for the main - # thread to hit the breakpoint. - for {set i 1} { $i <= $NUM_THREADS } { incr i } { - set test "thread $i broke out of loop" - set gotit 0 - gdb_test_multiple "" $test { - -re "loop_broke" { - # The prompt was already matched in the "continue - # &" test above. We're now consuming asynchronous - # output that comes after the prompt. - set gotit 1 - pass $test + with_timeout_factor $factor { + gdb_test "print timeout = $timeout" " = $timeout" \ + "set timeout in the inferior" + + set saw_continuing 0 + set test "continue &" + gdb_test_multiple $test $test { + -re "Continuing.\r\n" { + set saw_continuing 1 + exp_continue + } + -re "$gdb_prompt " { + gdb_assert $saw_continuing $test } -re "infrun:" { exp_continue } } - if {!$gotit} { - break + + set gotit 0 + + # Wait for all threads to finish their steps, and for the main + # thread to hit the breakpoint. + for {set i 1} { $i <= $NUM_THREADS } { incr i } { + set test "thread $i broke out of loop" + set gotit 0 + gdb_test_multiple "" $test { + -re "loop_broke" { + # The prompt was already matched in the "continue + # &" test above. We're now consuming asynchronous + # output that comes after the prompt. + set gotit 1 + pass $test + } + -re "infrun:" { + exp_continue + } + } + if {!$gotit} { + break + } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 56cde7a..9eaf721 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2150,15 +2150,10 @@ proc supports_get_siginfo_type {} { } } -# Return 1 if target hardware or OS supports single stepping to signal -# handler, otherwise, return 0. +# Return 1 if the target supports hardware single stepping. -proc can_single_step_to_signal_handler {} { +proc can_hardware_single_step {} { - # Targets don't have hardware single step. On these targets, when - # a signal is delivered during software single step, gdb is unable - # to determine the next instruction addresses, because start of signal - # handler is one of them. if { [istarget "arm*-*-*"] || [istarget "mips*-*-*"] || [istarget "tic6x-*-*"] || [istarget "sparc*-*-linux*"] || [istarget "nios2-*-*"] } { @@ -2168,6 +2163,17 @@ proc can_single_step_to_signal_handler {} { return 1 } +# Return 1 if target hardware or OS supports single stepping to signal +# handler, otherwise, return 0. + +proc can_single_step_to_signal_handler {} { + # Targets don't have hardware single step. On these targets, when + # a signal is delivered during software single step, gdb is unable + # to determine the next instruction addresses, because start of signal + # handler is one of them. + return [can_hardware_single_step] +} + # Return 1 if target supports process record, otherwise return 0. proc supports_process_record {} { -- 1.9.3