Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] Introduce remote_target_is_gdbserver
@ 2014-09-05 20:21 Simon Marchi
  2014-09-05 23:30 ` Sergio Durigan Junior
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2014-09-05 20:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Oops, I had some unstaged changes when I sent this patch, so here is
an updated one with those changes. Sorry for the noise.

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.

gdb/testsuite/ChangeLog:

	* lib/gdbserver-support.exp (remote_target_is_gdbserver): New
	fonction.
---
 gdb/testsuite/gdb.trace/qtro.exp        | 14 +-------------
 gdb/testsuite/lib/gdbserver-support.exp | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp
index 22b5051..95b6b85 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 8c91e28..300c3db 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -419,3 +419,26 @@ 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 $" {
+		pass $test
+		set is_gdbserver 1
+	}
+	-re "$gdb_prompt $" {
+		pass $test
+	}
+	default {
+		pass $test
+	}
+    }
+    return $is_gdbserver
+}
-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Introduce remote_target_is_gdbserver
  2014-09-05 20:21 [PATCH v2] Introduce remote_target_is_gdbserver Simon Marchi
@ 2014-09-05 23:30 ` Sergio Durigan Junior
  2014-09-11 14:47   ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Sergio Durigan Junior @ 2014-09-05 23:30 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

On Friday, September 05 2014, Simon Marchi wrote:

> Oops, I had some unstaged changes when I sent this patch, so here is
> an updated one with those changes. Sorry for the noise.
>
> 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.

Hi Simon,

Thanks for the patch.  A few comments.

> gdb/testsuite/ChangeLog:
>
> 	* lib/gdbserver-support.exp (remote_target_is_gdbserver): New
> 	fonction.

Typo: fonction.

You also forgot to mention the change to gdb.trace/qtro.exp.

> ---
>  gdb/testsuite/gdb.trace/qtro.exp        | 14 +-------------
>  gdb/testsuite/lib/gdbserver-support.exp | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp
> index 22b5051..95b6b85 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] {

I know it's just a matter of style, but I'd prefer if you kept the
surrounding brackets in the condition:

  if { ![remote_target_is_gdbserver] } {
  ...

>      return -1
>  }
>  
> diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
> index 8c91e28..300c3db 100644
> --- a/gdb/testsuite/lib/gdbserver-support.exp
> +++ b/gdb/testsuite/lib/gdbserver-support.exp
> @@ -419,3 +419,26 @@ 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 $" {
> +		pass $test
> +		set is_gdbserver 1
> +	}
> +	-re "$gdb_prompt $" {
> +		pass $test
> +	}
> +	default {
> +		pass $test
> +	}

Do we really need these "pass"?  I'd rather we don't put it, and by
looking at lib/gdb.exp I see many tests also don't use it.

> +    }
> +    return $is_gdbserver
> +}

Otherwise, looks good to me (this is not an approval).

Cheers,

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Introduce remote_target_is_gdbserver
  2014-09-05 23:30 ` Sergio Durigan Junior
@ 2014-09-11 14:47   ` Simon Marchi
  2014-09-11 16:46     ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2014-09-11 14:47 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: gdb-patches

On 14-09-05 07:30 PM, Sergio Durigan Junior wrote:
> On Friday, September 05 2014, Simon Marchi wrote:
> 
>> Oops, I had some unstaged changes when I sent this patch, so here is
>> an updated one with those changes. Sorry for the noise.
>>
>> 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.
> 
> Hi Simon,
> 
> Thanks for the patch.  A few comments.
> 
>> gdb/testsuite/ChangeLog:
>>
>> 	* lib/gdbserver-support.exp (remote_target_is_gdbserver): New
>> 	fonction.
> 
> Typo: fonction.
> 
> You also forgot to mention the change to gdb.trace/qtro.exp.
> 
>> ---
>>  gdb/testsuite/gdb.trace/qtro.exp        | 14 +-------------
>>  gdb/testsuite/lib/gdbserver-support.exp | 23 +++++++++++++++++++++++
>>  2 files changed, 24 insertions(+), 13 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp
>> index 22b5051..95b6b85 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] {
> 
> I know it's just a matter of style, but I'd prefer if you kept the
> surrounding brackets in the condition:
> 
>   if { ![remote_target_is_gdbserver] } {
>   ...
> 
>>      return -1
>>  }
>>  
>> diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
>> index 8c91e28..300c3db 100644
>> --- a/gdb/testsuite/lib/gdbserver-support.exp
>> +++ b/gdb/testsuite/lib/gdbserver-support.exp
>> @@ -419,3 +419,26 @@ 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 $" {
>> +		pass $test
>> +		set is_gdbserver 1
>> +	}
>> +	-re "$gdb_prompt $" {
>> +		pass $test
>> +	}
>> +	default {
>> +		pass $test
>> +	}
> 
> Do we really need these "pass"?  I'd rather we don't put it, and by
> looking at lib/gdb.exp I see many tests also don't use it.

I thought so, but apparently no. I thought that each gdb_test_multiple had to be matched with one pass or fail.

>> +    }
>> +    return $is_gdbserver
>> +}
> 
> Otherwise, looks good to me (this is not an approval).
> 
> Cheers,

Thanks,

Sending v2 now.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Introduce remote_target_is_gdbserver
  2014-09-11 14:47   ` Simon Marchi
@ 2014-09-11 16:46     ` Pedro Alves
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2014-09-11 16:46 UTC (permalink / raw)
  To: Simon Marchi, Sergio Durigan Junior; +Cc: gdb-patches

On 09/11/2014 03:47 PM, Simon Marchi wrote:
> On 14-09-05 07:30 PM, Sergio Durigan Junior wrote:


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


>>> +# 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 $" {
>>> +		pass $test
>>> +		set is_gdbserver 1
>>> +	}
>>> +	-re "$gdb_prompt $" {
>>> +		pass $test
>>> +	}
>>> +	default {
>>> +		pass $test
>>> +	}
>>
>> Do we really need these "pass"?  I'd rather we don't put it, and by
>> looking at lib/gdb.exp I see many tests also don't use it.
> 
> I thought so, but apparently no. I thought that each gdb_test_multiple had to be matched with one pass or fail.

FWIW, yeah, that was the original rationale behind the "pass"es
in the original code.  The test was written in the form of
"Probing for GDBserver", and the idea is that if we find that we're
not running GDBserver but something else, the _probing_ itself was
still a success.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-11 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05 20:21 [PATCH v2] Introduce remote_target_is_gdbserver Simon Marchi
2014-09-05 23:30 ` Sergio Durigan Junior
2014-09-11 14:47   ` Simon Marchi
2014-09-11 16:46     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox