From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16765 invoked by alias); 2 May 2016 18:18:13 -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 16701 invoked by uid 89); 2 May 2016 18:18:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=Hx-languages-length:1802, our X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 02 May 2016 18:18:10 +0000 Received: from EUSAAHC007.ericsson.se (Unknown_Domain [147.117.188.93]) by usplmg20.ericsson.net (Symantec Mail Security) with SMTP id D0.23.09012.66297275; Mon, 2 May 2016 19:46:14 +0200 (CEST) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.93) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 2 May 2016 14:18:05 -0400 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 1/2] Introduce procedure use_gdb_stub Date: Mon, 02 May 2016 18:18:00 -0000 Message-ID: <1462213080-22823-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00018.txt.bz2 This patch introduces the use_gdb_stub procedure, which allows getting the right value of the use_gdb_stub variable/property in any all situations. When calling it before the $use_gdb_stub global variable has been set, it will return the value of the use_gdb_stub property from the board file. This happens when tests want to bail out early (even before gdb has been started) when the current test setup is a stub. Otherwise, it returns the value of the $use_gdb_stub global. It's possible for these two to differ when a test file overrides the value of the global. gdb/testsuite/ChangeLog: * lib/gdb.exp (use_gdb_stub): New procedure. --- gdb/testsuite/lib/gdb.exp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 5a5a8fb..6d25b0c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3053,6 +3053,26 @@ proc gdb_is_target_remote {} { return [gdb_is_target_remote_prompt "$gdb_prompt $"] } +# Return the effective value of use_gdb_stub. +# +# If the use_gdb_stub global has been set (it is set when the gdb process is +# spawned), return that. Otherwise, return the value of the use_gdb_stub +# property from the board file. +# +# This is the preferred way of checking use_gdb_stub, since it allows to check +# the value before the gdb has been spawned and it will return the correct value +# even when it was overriden by the test. + +proc use_gdb_stub {} { + global use_gdb_stub + + if [info exists use_gdb_stub] { + return $use_gdb_stub + } + + return [target_info exists use_gdb_stub] +} + # Return 1 if the current remote target is an instance of our GDBserver, 0 # otherwise. Return -1 if there was an error and we can't tell. -- 2.8.2