[PATCH v4] Introduce target_is_gdbserver

Pedro Alves palves@redhat.com
Thu Dec 4 16:52:00 GMT 2014


On 09/23/2014 04:19 PM, Simon Marchi wrote:
> 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.
> 
> New in v4:
> - Return -1 on error, and check for -1 in qtro.exp.
> - Use gdb_caching_proc to cache result.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/qtro.exp: Replace gdbserver detection code by...
> 	* lib/gdbserver-support.exp (target_is_gdbserver): New
> 	fonction.

"function".  Or, "procedure".


> diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
> index 026a937..e3f421e 100644
> --- a/gdb/testsuite/lib/gdbserver-support.exp
> +++ b/gdb/testsuite/lib/gdbserver-support.exp

I don't think gdbserver-support.exp is always loaded on all
targets?  By putting the procedure here, ISTM that non-GDBserver
testing will ERROR when the procedure is called?

> @@ -436,3 +436,28 @@ proc mi_gdbserver_start_multi { } {
>  
>      return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
>  }
> +
> +# Return 1 if the current remote target is an instance of gdbserver, 0
> +# otherwise. Return -1 if there was an error and we can't tell.

s/gdbserver/our GDBserver/

Double space after period.

> +
> +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

Indentation doesn't look right here.  Should be one tab + 4 spaces?

> +	}
> +	-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
> +}


Thanks,
Pedro Alves



More information about the Gdb-patches mailing list