From patchwork Fri Oct 13 00:36:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23523 Received: (qmail 106565 invoked by alias); 13 Oct 2017 00:36:49 -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 106512 invoked by uid 89); 13 Oct 2017 00:36:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Fri, 13 Oct 2017 00:36:46 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 008CE7EBD6 for ; Fri, 13 Oct 2017 00:36:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 008CE7EBD6 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67C555D6AE for ; Fri, 13 Oct 2017 00:36:44 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] Eliminate is_remote check in gdb.base/scope.exp Date: Fri, 13 Oct 2017 01:36:43 +0100 Message-Id: <1507855003-15679-1-git-send-email-palves@redhat.com> This commit makes --target_board=native-gdbserver (and in principle all other is_remote boards) pass all the same gdb.base/scope.exp tests as native testing. I first wrote the gdb.base/scope.exp change described in the ChangeLog below and in the new comments in the patch, knowing that gdb_file_cmd was the right thing to use here. However, that revealed that the native-extended-gdbserver board should be overriding gdb_file_cmd+gdb_reload instead of gdb_load, as is hinted at by the comments on top of the default implementations in testsuite/lib/gdb.exp, because otherwise a gdb_run_cmd after gdb_file_cmd misses setting "set remote exec-file". However, if we do that and remove gdb_load, then we regress gdb.base/dbx.exp, so for now keep the gdb_load override as well. gdb/testsuite/ChangeLog: 2017-10-13 Pedro Alves * gdb.base/scope.exp: Use build_executable + clean_restart + gdb_file_cmd instead of prepare_for_testing and no longer skip "before run" tests on is_remote target boards. Update comments. * boards/native-extended-gdbserver.exp (extended_gdbserver_load_last_file): New, factored out from ... (gdb_load): ... this. Move further below and add comment. (extended_gdbserver_gdb_file_cmd, gdb_file_cmd, gdb_reload): New. --- gdb/testsuite/ChangeLog | 10 ++++++ gdb/testsuite/boards/native-extended-gdbserver.exp | 42 +++++++++++++++++----- gdb/testsuite/gdb.base/scope.exp | 31 ++++++++-------- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 06c62f4..38add6f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2017-10-13 Pedro Alves + + * gdb.base/scope.exp: Use build_executable + clean_restart + + gdb_file_cmd instead of prepare_for_testing and no longer skip + "before run" tests on is_remote target boards. Update comments. + * boards/native-extended-gdbserver.exp + (extended_gdbserver_load_last_file): New, factored out from ... + (gdb_load): ... this. Move further below and add comment. + (extended_gdbserver_gdb_file_cmd, gdb_file_cmd, gdb_reload): New. + 2017-10-12 Pedro Alves * gdb.base/attach.exp: Remove references to gdb64. diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp index 4ea210f..564ffd2 100644 --- a/gdb/testsuite/boards/native-extended-gdbserver.exp +++ b/gdb/testsuite/boards/native-extended-gdbserver.exp @@ -80,17 +80,12 @@ proc mi_gdb_start { args } { return 0 } -# Overriden in order to set the remote exec-file whenever a file is -# loaded to gdb. -# -proc gdb_load { arg } { +# Helper that runs "set remote exec-file" with the last loaded file. + +proc extended_gdbserver_load_last_file {} { global gdb_prompt global last_loaded_file - if { $arg != "" } { - if [gdb_file_cmd $arg] then { return -1 } - } - send_gdb "set remote exec-file $last_loaded_file\n" gdb_expect { -re "$gdb_prompt $" {} @@ -103,6 +98,37 @@ proc gdb_load { arg } { return 0 } +# Overriden in order to set the remote exec-file whenever a file is +# loaded to gdb. +# +if { [info procs extended_gdbserver_gdb_file_cmd] == "" } { + rename gdb_file_cmd extended_gdbserver_gdb_file_cmd +} +proc gdb_file_cmd { arg } { + if [extended_gdbserver_gdb_file_cmd $arg] { + return -1 + } + return [extended_gdbserver_load_last_file] +} + +proc gdb_reload { } { + return [extended_gdbserver_load_last_file] +} + +# With the two procedure overrides above, it shouldn't be necessary to +# override this one too. However, not doing so regresses +# gdb.base/dbx.exp. See comments above gdb.base/dbx.exp:gdb_file_cmd. +# Once testing of the "symbol-file"/"exec-file" commands is moved out +# to a separate non-dbx testcase, we should be able to remove this. +proc gdb_load { arg } { + if { $arg != "" } { + if [gdb_file_cmd $arg] then { return -1 } + } + + return [extended_gdbserver_load_last_file] +} + + # Likewise, for MI. # if { [info procs extended_gdbserver_mi_gdb_load] == "" } { diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp index 48d8245..f26775d 100644 --- a/gdb/testsuite/gdb.base/scope.exp +++ b/gdb/testsuite/gdb.base/scope.exp @@ -18,7 +18,7 @@ standard_testfile scope0.c scope1.c -if {[prepare_for_testing "failed to prepare" ${testfile} \ +if {[build_executable "failed to build" ${testfile} \ [list $srcfile $srcfile2] {debug}]} { return -1 } @@ -497,6 +497,13 @@ proc test_at_localscopes {} { gdb_stop_suppressing_tests } +# Note, we don't pass a binfile to clean_restart because we need to +# avoid gdb_load here. With remote targets, gdb_load connects to the +# remote target, and we specificaly want the following tests to run +# before the program is started. +clean_restart +gdb_file_cmd $binfile + # Test that variables in various segments print out correctly before # the program is run. @@ -505,21 +512,15 @@ setup_xfail "rs6000-*-*" gdb_test "print 'scope0.c'::filelocal_ro" "= 201" -# gdb currently cannot access bss memory on some targets if the inferior -# is not running. -# -# For PA boards using monitor/remote-pa.c, the bss test is going to -# randomly fail. We've already put remote-pa on the target stack, -# so we actually read memory from the board. Problem is crt0.o -# is responsible for clearing bss and that hasnt' happened yet. +# Check that gdb can access bss memory if the inferior is not running. # -# This is a problem for all non-native targets. -- manson -if [is_remote target] { - unsupported "print 'scope0.c'::filelocal_bss before run" -} else { - gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ - "print 'scope0.c'::filelocal_bss before run" -} +# Note the care above about avoiding gdb_load. Otherwise, for +# embedded stub-like boards, this test would randomly fail. If we'd +# already put target remote on the target stack, we'd read memory from +# the board instead of the program's binary, and we would have +# connected before crt0.o had had a chance to clear bss. +gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ + "print 'scope0.c'::filelocal_bss before run" gdb_test "print 'scope0.c'::filelocal" "= 1" \ "print 'scope0.c'::filelocal before run"