This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Introduce procedure use_gdb_stub
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 4 May 2016 13:35:09 -0000
- Subject: [binutils-gdb] Introduce procedure use_gdb_stub
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8929ad8bbca9a8b036eba0397992d6f3b4d1966b
commit 8929ad8bbca9a8b036eba0397992d6f3b4d1966b
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Wed May 4 09:27:19 2016 -0400
Introduce procedure use_gdb_stub
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.
Diff:
---
gdb/testsuite/ChangeLog | 4 ++++
gdb/testsuite/lib/gdb.exp | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bbb5262..e3830b6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-05-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * lib/gdb.exp (use_gdb_stub): New procedure.
+
2016-05-03 Yunlian Jiang <yunlian@google.com>
Doug Evans <dje@google.com>
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.