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 v3] Introduce remote_target_is_gdbserver
Date: Thu, 11 Sep 2014 14:54:00 -0000	[thread overview]
Message-ID: <1410447276-21821-1-git-send-email-simon.marchi@ericsson.com> (raw)

This patch introduces a function in gdbserver-support.exp to find out
whether the current target is GDBserver.

The code was inspired from gdb.trace/qtor.exp, so it replaces the code
there by a call to the new function.

New in v3:
- Remove useless "pass" in remote_target_is_gdbserver.
- Coding style in qtro.exp (braces in condition).
- Changelog entry about qtro.exp.

gdb/testsuite/ChangeLog:

	* gdb.trace/qtro.exp: Replace gdbserver detection code by...
	* lib/gdbserver-support.exp (remote_target_is_gdbserver): New
	function.
---
 gdb/testsuite/gdb.trace/qtro.exp        | 14 +-------------
 gdb/testsuite/lib/gdbserver-support.exp | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp
index 22b5051..700c157 100644
--- a/gdb/testsuite/gdb.trace/qtro.exp
+++ b/gdb/testsuite/gdb.trace/qtro.exp
@@ -98,19 +98,7 @@ if { $traceframe_info_supported == -1 } {
 }
 
 # Check whether we're testing with our own GDBserver.
-set is_gdbserver -1
-set test "probe for GDBserver"
-gdb_test_multiple "monitor help" $test {
-    -re "The following monitor commands are supported.*debug-hw-points.*remote-debug.*GDBserver.*$gdb_prompt $" {
-	set is_gdbserver 1
-	pass $test
-    }
-    -re "$gdb_prompt $" {
-	set is_gdbserver 0
-	pass $test
-    }
-}
-if { $is_gdbserver == -1 } {
+if { ![remote_target_is_gdbserver] } {
     return -1
 }
 
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 026a937..423c729 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -436,3 +436,21 @@ proc mi_gdbserver_start_multi { } {
 
     return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 }
+
+# Return true if the current remote target is an instance of gdbserver.
+
+proc remote_target_is_gdbserver { } {
+    global gdb_prompt
+
+    set is_gdbserver 0
+    set test "Probing for GDBserver"
+
+    gdb_test_multiple "monitor help" $test {
+	-re "The following monitor commands are supported.*Quit GDBserver.*$gdb_prompt $" {
+		set is_gdbserver 1
+	}
+	-re "$gdb_prompt $" {
+	}
+    }
+    return $is_gdbserver
+}
-- 
2.1.0

             reply	other threads:[~2014-09-11 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 14:54 Simon Marchi [this message]
2014-09-11 15:57 ` Doug Evans
2014-09-11 19:26   ` Simon Marchi
2014-09-11 16:10 ` Luis Machado
2014-09-11 19:33   ` Simon Marchi
2014-09-11 19:36     ` Luis Machado

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=1410447276-21821-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).