From patchwork Wed Aug 1 21:24:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 28723 Received: (qmail 118362 invoked by alias); 1 Aug 2018 21:24:39 -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 118291 invoked by uid 89); 1 Aug 2018 21:24:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=me, mi_gdb_test, HX-Received:sk:c90-v6m X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Aug 2018 21:24:20 +0000 Received: by mail-wm0-f66.google.com with SMTP id y9-v6so153220wma.5 for ; Wed, 01 Aug 2018 14:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gPj5O1sFxSeYNu9HEYWiWT5MBW446gaOEc4wiVLvYjg=; b=CQSbtqONmF68y9Q2Ipvva8Z+QRSLeSOIr8jqPDROYf1C4wVODwsprD62OInozhC6Kn QSqzDHXjAadm/7DnzsC55/BjWANbiUqUfG9dXOfXocIAOq+FptA1/pTXuXdd/XlotzW1 OVIKNjvVXU1G/owepisT3fOiiUclC5vRO8ssS8wE5hwziNvZ6xTjuB1epRNi7u/kXZnF h6dyw39i/ZpHoL8h3KVQoHIFG5C2K3tlrSBjkq9HRFmprz22xXbKaVSpQTn99Z4pkED4 haIKZ33j75pcrDhlVgDUFAFEdoJCxIgOBaP+9HphVxCjBhWU6cLfDQ/vg9z4rVmgpO5Z rxkQ== Return-Path: Received: from localhost (host109-147-66-79.range109-147.btcentralplus.com. [109.147.66.79]) by smtp.gmail.com with ESMTPSA id z14-v6sm17298wrr.71.2018.08.01.14.24.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 14:24:05 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: PING! [PATCHv2] gdb: Only run scheduler-locking tests if feature is supported Date: Wed, 1 Aug 2018 22:24:03 +0100 Message-Id: <20180801212403.20076-1-andrew.burgess@embecosm.com> In-Reply-To: <20180717174646.GI2888@embecosm.com> References: <20180717174646.GI2888@embecosm.com> X-IsSubscribed: yes Ping! Patch rebased onto latest upstream/master, nothing else has changed. Thanks, Andrew --- Not all targets support scheduler-locking. Add a check to see if the taraget supports scheduler locking, and if it doesn't, don't run the scheduler-locking tests that will otherwise fail. There are actually a set of tests that try to use scheduler-locking however, in most of these cases the test will not be run on smaller targets (those that might not support threads and scheduler-locking) due to the targets lack of support for threads, or some other larger feature. In the gdb.mi/mi-cmd-param-changed.exp test though, there's no dependence on threads, or any other larger feature, and so, for the small target I was using the test would otherwise try to run, only to fail due to lack of support for scheduler-locking. gdb/testsuite/ChangeLog: * lib/gdb.exp (target_supports_scheduler_locking): New proc. * gdb.mi/mi-cmd-param-changed.exp: Only run scheduler locking tests if the target supports scheduler locking. --- gdb/testsuite/ChangeLog | 6 +++ gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp | 48 ++++++++++-------- gdb/testsuite/lib/gdb.exp | 70 +++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp index 8ffafe296f6..bbe9cf36236 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp @@ -13,6 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# Do this here before we start GDB for the test. +set scheduler_locking_supported [target_supports_scheduler_locking] + load_lib mi-support.exp set MIFLAGS "-i=mi" @@ -24,37 +27,40 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb } proc test_command_param_changed { } { + global scheduler_locking_supported + with_test_prefix "cmd param" { if [mi_gdb_start] { return } mi_run_to_main - foreach opt { "on" "off" "step" } { - mi_gdb_test "set scheduler-locking ${opt}" \ - ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ - "\"set scheduler-locking ${opt}\"" - } - foreach opt { "on" "off" "step" } { - mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \ - ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ - "interpreter-exec \"set scheduler-locking ${opt}\"" + if { $scheduler_locking_supported } { + foreach opt { "on" "off" "step" } { + mi_gdb_test "set scheduler-locking ${opt}" \ + ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ + "\"set scheduler-locking ${opt}\"" + } + foreach opt { "on" "off" "step" } { + mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \ + ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \ + "interpreter-exec \"set scheduler-locking ${opt}\"" + } + # Don't emit MI notification for request from MI. + mi_gdb_test "-gdb-set scheduler-locking on" \ + {\^done} \ + "\"set scheduler-locking on\" no event (requested by MI)" + mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \ + "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \ + "\"set scheduler-locking step\" no event (requested by MI interp)" + mi_gdb_test "set scheduler-locking step" \ + "\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \ + "\"set scheduler-locking stepr\" no event" } - # Don't emit MI notification for request from MI. - mi_gdb_test "-gdb-set scheduler-locking on" \ - {\^done} \ - "\"set scheduler-locking on\" no event (requested by MI)" + mi_gdb_test "-exec-arguments foo" {\^done} \ "\"-exec-arguments foo\" no event" - mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \ - "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \ - "\"set scheduler-locking step\" no event (requested by MI interp)" - mi_gdb_test "set scheduler-locking step" \ - "\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \ - "\"set scheduler-locking stepr\" no event" - - foreach command { "remotecache" "check type" } { # The default value of each command option may be different, so we first diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3e2f755e5b7..dd2c57cbc2d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6053,6 +6053,76 @@ gdb_caching_proc gdb_target_symbol_prefix { return $prefix } +# Return 1 if target supports scheduler locking, otherwise return 0. + +gdb_caching_proc target_supports_scheduler_locking { + global gdb_prompt + + set me "gdb_target_supports_scheduler_locking" + + set src [standard_temp_file has_schedlock[pid].c] + set exe [standard_temp_file has_schedlock[pid].x] + + gdb_produce_source $src { + int main () { + return 0; + } + } + + verbose "$me: compiling testfile $src" 2 + set compile_flags {debug nowarnings} + set lines [gdb_compile $src $exe executable $compile_flags] + file delete $src + + if ![string match "" $lines] then { + verbose "$me: testfile compilation failed, returning 0" 2 + return 0 + } + + clean_restart $exe + gdb_start_cmd + + set supports_schedule_locking -1 + set current_schedule_locking_mode "" + + set test "reading current scheduler-locking mode" + gdb_test_multiple "show scheduler-locking" $test { + -re "Mode for locking scheduler during execution is \"(\[\^\"\]*)\".*$gdb_prompt" { + set current_schedule_locking_mode $expect_out(1,string) + } + -re "$gdb_prompt $" { + set supports_schedule_locking 0 + } + timeout { + set supports_schedule_locking 0 + } + } + + if { $supports_schedule_locking == -1 } { + set test "checking for scheduler-locking support" + gdb_test_multiple "set scheduler-locking $current_schedule_locking_mode" $test { + -re "Target '\[^'\]+' cannot support this command\..*$gdb_prompt $" { + set supports_schedule_locking 0 + } + -re "$gdb_prompt $" { + set supports_schedule_locking 1 + } + timeout { + set supports_schedule_locking 0 + } + } + } + + if { $supports_schedule_locking == -1 } { + set supports_schedule_locking 0 + } + + gdb_exit + remote_file build delete $exe + verbose "$me: returning $supports_schedule_locking" 2 + return $supports_schedule_locking +} + # gdb_target_symbol returns the provided symbol with the correct prefix # prepended. (See gdb_target_symbol_prefix, above.)