public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 1/2] Introduce procedure use_gdb_stub
Date: Mon, 02 May 2016 18:18:00 -0000	[thread overview]
Message-ID: <1462213080-22823-1-git-send-email-simon.marchi@ericsson.com> (raw)

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

             reply	other threads:[~2016-05-02 18:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02 18:18 Simon Marchi [this message]
2016-05-02 18:18 ` [PATCH 2/2] Fix solib-display.exp remote check Simon Marchi
2016-05-02 18:30   ` Pedro Alves
2016-05-04 13:37     ` Simon Marchi
2016-05-02 18:28 ` [PATCH 1/2] Introduce procedure use_gdb_stub Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462213080-22823-1-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).