From 0a46d518c7565be02e544ab508f8b5a99b1b5192 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 10 Dec 2014 15:12:17 -0500 Subject: [PATCH] Introduce target_is_gdbserver 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/qtro.exp, so it replaces the code there by a call to the new function. gdb/testsuite/ChangeLog: * gdb.trace/qtro.exp: Replace gdbserver detection code by... * lib/gdb.exp (target_is_gdbserver): New procedure. --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.trace/qtro.exp | 13 +------------ gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0e973f7eb3c..4abd097aaa2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-10 Simon Marchi + + * gdb.trace/qtro.exp: Replace gdbserver detection code by... + * lib/gdb.exp (target_is_gdbserver): New procedure. + 2014-12-08 Doug Evans * gdb.python/py-objfile.exp: Add tests for objfile.owner. diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp index 22b50510bfe..d8ffc4024fd 100644 --- a/gdb/testsuite/gdb.trace/qtro.exp +++ b/gdb/testsuite/gdb.trace/qtro.exp @@ -98,18 +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 - } -} +set is_gdbserver [target_is_gdbserver] if { $is_gdbserver == -1 } { return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index a29b6614e6c..609f22fcbea 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2537,6 +2537,31 @@ proc gdb_is_target_remote {} { return 0 } +# 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. + +gdb_caching_proc target_is_gdbserver { + global gdb_prompt + + set is_gdbserver -1 + 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 $" { + set is_gdbserver 0 + } + } + + if { $is_gdbserver == -1 } { + verbose -log "Unable to tell whether we are using GDBserver or not." + } + + return $is_gdbserver +} + set compiler_info "unknown" set gcc_compiled 0 set hp_cc_compiler 0 -- 2.30.2