From patchwork Tue Jul 3 16:02:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 28214 Received: (qmail 85475 invoked by alias); 3 Jul 2018 16:02:38 -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 85461 invoked by uid 89); 3 Jul 2018 16:02:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.0 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= X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jul 2018 16:02:35 +0000 Received: by mail-wr0-f175.google.com with SMTP id f16-v6so2523835wrm.3 for ; Tue, 03 Jul 2018 09:02:35 -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; bh=oMzT/WzL/k1iUzAXhPjstnEztFLBecM7V6ohpqO5y8g=; b=d+eMxNNzdl0uWlwc4ArS6UetMTzE47BOQ9wEQ2cAeHfAa1dSLGOTaLVQXVziyvnPfY HNM2zW8YBX0j798Nrv9jP5VCc4d5arpuNMh9GK4PDAIcjsqs80ID7JfWHSJq2n0kFUnH YAHO6YZo/ltH29KqUYltXtxyCUlTCz7iFep3lK9F2BjlOih45tPc1soS59wwfljHDSmZ 5HPB/FGGvCzSt0KkQypcNj+08raWlrReu7WckTfqfhSIm3p+j3rxK3kfnttnJh1j9H/o eG9RyOJDJh0uksNZayjfpHvt0TaoaaJCDb/dMb2zye+EMzuDEri/kchhLUvJLR6wHWNl 7Vrw== Return-Path: Received: from localhost (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id y193-v6sm2601960wmy.13.2018.07.03.09.02.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 09:02:32 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: Only run scheduler-locking tests if feature is supported Date: Tue, 3 Jul 2018 17:02:30 +0100 Message-Id: <20180703160230.25472-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes 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 aef580b04d3..f15a2f309d1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6047,6 +6047,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.)