From patchwork Wed Apr 15 09:16:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6225 Received: (qmail 100075 invoked by alias); 15 Apr 2015 09:17:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 100065 invoked by uid 89); 15 Apr 2015 09:17:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 15 Apr 2015 09:16:59 +0000 Received: by pabtp1 with SMTP id tp1so44250200pab.2 for ; Wed, 15 Apr 2015 02:16:57 -0700 (PDT) X-Received: by 10.68.230.137 with SMTP id sy9mr44386382pbc.111.1429089417677; Wed, 15 Apr 2015 02:16:57 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id ha5sm3481116pbb.34.2015.04.15.02.16.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 15 Apr 2015 02:16:56 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH] Increase timeout in watch-bitfields.exp for software watchpoint References: <1429023644-13403-1-git-send-email-qiyaoltc@gmail.com> <552D31E4.1080503@redhat.com> <86a8yau0qb.fsf@gmail.com> <552D48C5.2050002@redhat.com> Date: Wed, 15 Apr 2015 10:16:48 +0100 In-Reply-To: <552D48C5.2050002@redhat.com> (Pedro Alves's message of "Tue, 14 Apr 2015 18:05:09 +0100") Message-ID: <86618xu4xr.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > gdb_test etc. always take the max of local, global and board > timeouts. In your current patch, the factor is applied after > selecting the max of global and board timeouts. So I think that it > should be simplest to say that the the factor is applied after determining > the maximum between local, global and board timeouts. OK, I see. You suggested we should do more than what Maciej's patch does. In Maciej's patch, local timeout variable isn't considered, and we don't have to. After moving code to a proc, and in order to be align with gdb_expect, we need to consider local timeout variable additionally. How about the patch below? diff --git a/gdb/testsuite/gdb.base/watch-bitfields.exp b/gdb/testsuite/gdb.base/watch-bitfields.exp index 9d5293b..4f97043 100644 --- a/gdb/testsuite/gdb.base/watch-bitfields.exp +++ b/gdb/testsuite/gdb.base/watch-bitfields.exp @@ -54,7 +54,14 @@ proc test_watch_location {} { expect_watchpoint "q.e" 0 5 expect_watchpoint "q.a" 1 0 expect_watchpoint "q.e" 5 4 - gdb_continue_to_end + + # It'll execute a large amount of code with software watchpoint + # enabled, which means GDB will single stepping all the way + # through til the inferior exits. Increase the timeout by a + # factor of 4. + with_timeout_factor 4 { + gdb_continue_to_end + } } } @@ -73,7 +80,14 @@ proc test_regular_watch {} { expect_watchpoint "q.d + q.f + q.g" 3 2 expect_watchpoint "q.d + q.f + q.g" 2 1 expect_watchpoint "q.d + q.f + q.g" 1 0 - gdb_continue_to_end + + # It'll execute a large amount of code with software watchpoint + # enabled, which means GDB will single stepping all the way + # through til the inferior exits. Increase the timeout by a + # factor of 4. + with_timeout_factor 4 { + gdb_continue_to_end + } } } diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp index 85e83f7..9475b37 100644 --- a/gdb/testsuite/gdb.base/watchpoint-solib.exp +++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp @@ -75,17 +75,8 @@ gdb_test "watch g" "atchpoint 3: g" "set watchpoint on g" gdb_test "continue" ".*New value = 1.*" "continue to watchpoint hit" rerun_to_main -set savedtimeout $timeout -if { [target_info exists gdb,timeout] - && $timeout < [target_info gdb,timeout] } { - set oldtimeout [target_info gdb,timeout] -} else { - set oldtimeout $timeout +with_timeout_factor 30 { + gdb_test "continue" ".*Breakpoint 2.*foo.*" "continue to foo again" } -set timeout [expr $oldtimeout * 30] - -gdb_test "continue" ".*Breakpoint 2.*foo.*" "continue to foo again" - -set timeout $savedtimeout gdb_test "continue" ".*New value = 1.*" "continue to watchpoint hit again" diff --git a/gdb/testsuite/gdb.reverse/sigall-reverse.exp b/gdb/testsuite/gdb.reverse/sigall-reverse.exp index 69152d4..065eea7 100644 --- a/gdb/testsuite/gdb.reverse/sigall-reverse.exp +++ b/gdb/testsuite/gdb.reverse/sigall-reverse.exp @@ -251,18 +251,11 @@ gdb_test "continue" \ "get signal TERM" gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM" -set savedtimeout $timeout -if { [target_info exists gdb,timeout] - && $timeout < [target_info gdb,timeout] } { - set oldtimeout [target_info gdb,timeout] -} else { - set oldtimeout $timeout +with_timeout_factor 2 { + gdb_test "continue" "\[process \[0-9\]+ .*" "continue to signal exit" \ + "The next instruction is syscall exit_group.* program...y. or n. " \ + "yes" } -set timeout [expr $oldtimeout * 2] -gdb_test "continue" "\[process \[0-9\]+ .*" "continue to signal exit" \ - "The next instruction is syscall exit_group.* program...y. or n. " \ - "yes" -set timeout $savedtimeout foreach sig [lreverse $signals] { test_one_sig_reverse $sig diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp index 1684645..640839f 100644 --- a/gdb/testsuite/gdb.reverse/until-precsave.exp +++ b/gdb/testsuite/gdb.reverse/until-precsave.exp @@ -49,22 +49,17 @@ gdb_test "break $end_of_main" \ "BP at end of main" # This can take awhile. -set savedtimeout $timeout -if { [target_info exists gdb,timeout] - && $timeout < [target_info gdb,timeout] } { - set oldtimeout [target_info gdb,timeout] -} else { - set oldtimeout $timeout +with_timeout_factor 15 { + gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main" } -set timeout [expr $oldtimeout * 15] -gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main" # So can this, against gdbserver, for example. -set timeout [expr $oldtimeout * 3] -gdb_test "record save $precsave" \ - "Saved core file $precsave with execution log\." \ - "save process recfile" -set timeout $savedtimeout + +with_timeout_factor 3 { + gdb_test "record save $precsave" \ + "Saved core file $precsave with execution log\." \ + "save process recfile" +} gdb_test "kill" "" "Kill process, prepare to debug log file" \ "Kill the program being debugged\\? \\(y or n\\) " "y" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 1448fba..25fcae3 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1919,6 +1919,54 @@ proc with_target_charset { target_charset body } { } } +# Select the largest timeout from all the timeouts: +# - the local "timeout" variable of the scope two levels above, +# - the global "timeout" variable, +# - the board variable "gdb,timeout", + +proc get_largest_timeout {} { + upvar #0 timeout gtimeout + upvar 2 timeout timeout + + set tmt 0 + if [info exists timeout] { + set tmt $timeout + } + if { [info exists gtimeout] && $gtimeout > $tmt } { + set tmt $gtimeout + } + if { [target_info exists gdb,timeout] + && [target_info gdb,timeout] > $tmt } { + set tmt [target_info gdb,timeout] + } + if { $tmt == 0 } { + # Eeeeew. + set tmt 60 + } + + return $tmt +} + +# Run tests in BODY with timeout increased by factor of FACTOR. When +# BODY is finished, restore timeout. + +proc with_timeout_factor { factor body } { + global timeout + + set savedtimeout $timeout + + set timeout [expr [get_largest_timeout] * $factor] + set code [catch {uplevel 1 $body} result] + + set timeout $savedtimeout + if {$code == 1} { + global errorInfo errorCode + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result + } else { + return -code $code $result + } +} + # Return 1 if _Complex types are supported, otherwise, return 0. gdb_caching_proc support_complex_tests { @@ -3291,26 +3339,10 @@ proc gdb_expect { args } { # A timeout argument takes precedence, otherwise of all the timeouts # select the largest. - upvar #0 timeout gtimeout - upvar timeout timeout if [info exists atimeout] { set tmt $atimeout } else { - set tmt 0 - if [info exists timeout] { - set tmt $timeout - } - if { [info exists gtimeout] && $gtimeout > $tmt } { - set tmt $gtimeout - } - if { [target_info exists gdb,timeout] - && [target_info gdb,timeout] > $tmt } { - set tmt [target_info gdb,timeout] - } - if { $tmt == 0 } { - # Eeeeew. - set tmt 60 - } + set tmt [get_largest_timeout] } global suppress_flag