* [PATCH v3] Introduce remote_target_is_gdbserver @ 2014-09-11 14:54 Simon Marchi 2014-09-11 15:57 ` Doug Evans 2014-09-11 16:10 ` Luis Machado 0 siblings, 2 replies; 6+ messages in thread From: Simon Marchi @ 2014-09-11 14:54 UTC (permalink / raw) To: gdb-patches; +Cc: Simon Marchi 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Introduce remote_target_is_gdbserver 2014-09-11 14:54 [PATCH v3] Introduce remote_target_is_gdbserver Simon Marchi @ 2014-09-11 15:57 ` Doug Evans 2014-09-11 19:26 ` Simon Marchi 2014-09-11 16:10 ` Luis Machado 1 sibling, 1 reply; 6+ messages in thread From: Doug Evans @ 2014-09-11 15:57 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches Simon Marchi <simon.marchi@ericsson.com> writes: > 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 > +} Hi. The original code allowed for a -1 value of is_gdbserver to handle the case of "can't tell" (e.g. for a timeout or whatever, IIUC). While IWBN to not complicate the API of remote_target_is_gdbserver by requiring the caller to have to handle this, maybe it'd be best if the caller did have to watch for -1 and not just assume "not gdbserver": maybe a different test will want to handle all three cases (can't-tell, no, or yes). E.g., initialize is_gdbserver to -1, and watch for a -1 value before returning. proc remote_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 "can't tell if using gdbserver or not" # or whatever set $is_gdbserver 0 # <<<< this part I'm not sure about } return $is_gdbserver Also, I see an earlier version of the patch first did a check for [is_remote_target] before calling target_is_gdbserver, and the new version of the patch changes that to just calling remote_target_is_gdbserver. Since the function remote_target_is_gdbserver can be used regardless of whether the target is remote, let's remove "remote_" from the name. ie., go back to target_is_gdbserver. Hmmm, another thought. Since this requires an exchange with the target, IWBN to cache the result. There's support for doing this in the harness, grep for gdb_caching_proc. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Introduce remote_target_is_gdbserver 2014-09-11 15:57 ` Doug Evans @ 2014-09-11 19:26 ` Simon Marchi 0 siblings, 0 replies; 6+ messages in thread From: Simon Marchi @ 2014-09-11 19:26 UTC (permalink / raw) To: Doug Evans; +Cc: gdb-patches On 14-09-11 11:56 AM, Doug Evans wrote: > Simon Marchi <simon.marchi@ericsson.com> writes: >> 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 >> +} > > Hi. > > The original code allowed for a -1 value of is_gdbserver > to handle the case of "can't tell" (e.g. for a timeout or > whatever, IIUC). > While IWBN to not complicate the API of > remote_target_is_gdbserver by requiring the caller > to have to handle this, maybe it'd be best if the caller > did have to watch for -1 and not just assume "not gdbserver": > maybe a different test will want to handle all three cases > (can't-tell, no, or yes). > E.g., initialize is_gdbserver to -1, and watch for a -1 value > before returning. > > proc remote_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 "can't tell if using gdbserver or not" # or whatever > set $is_gdbserver 0 # <<<< this part I'm not sure about > } > return $is_gdbserver I am confused. Do you want remote_target_is_gdbserver to return -1 in case of error, or not. The paragraph seems to say yes, but the code seems to say no. > Also, I see an earlier version of the patch first > did a check for [is_remote_target] before calling > target_is_gdbserver, and the new version of the > patch changes that to just calling remote_target_is_gdbserver. > Since the function remote_target_is_gdbserver can > be used regardless of whether the target is remote, > let's remove "remote_" from the name. > ie., go back to target_is_gdbserver. Indeed, if the name is target_is_gdbserver, it would be clearer that you can call it in any situation, even if you are using native. However, in that particular case, I removed the [is_remote target] check, since there is an equivalent one earlier in the test. > Hmmm, another thought. > Since this requires an exchange with the target, > IWBN to cache the result. > There's support for doing this in the harness, > grep for gdb_caching_proc. Interesting, I will check that. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Introduce remote_target_is_gdbserver 2014-09-11 14:54 [PATCH v3] Introduce remote_target_is_gdbserver Simon Marchi 2014-09-11 15:57 ` Doug Evans @ 2014-09-11 16:10 ` Luis Machado 2014-09-11 19:33 ` Simon Marchi 1 sibling, 1 reply; 6+ messages in thread From: Luis Machado @ 2014-09-11 16:10 UTC (permalink / raw) To: Simon Marchi, gdb-patches On 09/11/2014 11:54 AM, 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/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 > +} > Just a thought but... is there a specific reason we need to check for gdbserver explicitly as opposed to checking for a remote debugging stub feature? It sounds more appropriate to leave remote stub-based testing as generic as possible, in which case "is_gdbserver" wouldn't be needed. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Introduce remote_target_is_gdbserver 2014-09-11 16:10 ` Luis Machado @ 2014-09-11 19:33 ` Simon Marchi 2014-09-11 19:36 ` Luis Machado 0 siblings, 1 reply; 6+ messages in thread From: Simon Marchi @ 2014-09-11 19:33 UTC (permalink / raw) To: lgustavo, gdb-patches > Just a thought but... is there a specific reason we need to check for > gdbserver explicitly as opposed to checking for a remote debugging stub > feature? > > It sounds more appropriate to leave remote stub-based testing as generic > as possible, in which case "is_gdbserver" wouldn't be needed. Good point, but I'd rather not address this in the current patch. I don't want to change the test itself, but just make the check available to other tests. Ultimately, I want to use it in this patch [1] where I really want to check for GDBserver. I want to KFAIL a test only when using gdbserver, due to a known bug in gdbserver. [1] https://sourceware.org/ml/gdb-patches/2014-09/msg00148.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Introduce remote_target_is_gdbserver 2014-09-11 19:33 ` Simon Marchi @ 2014-09-11 19:36 ` Luis Machado 0 siblings, 0 replies; 6+ messages in thread From: Luis Machado @ 2014-09-11 19:36 UTC (permalink / raw) To: Simon Marchi, gdb-patches On 09/11/2014 04:33 PM, Simon Marchi wrote: >> Just a thought but... is there a specific reason we need to check for >> gdbserver explicitly as opposed to checking for a remote debugging stub >> feature? >> >> It sounds more appropriate to leave remote stub-based testing as generic >> as possible, in which case "is_gdbserver" wouldn't be needed. > > Good point, but I'd rather not address this in the current patch. I don't > want to change the test itself, but just make the check available to other > tests. > Agreed. This may be something for the future. I don't want to create more work for you. > Ultimately, I want to use it in this patch [1] where I really want to check > for GDBserver. I want to KFAIL a test only when using gdbserver, due to a > known bug in gdbserver. > > [1] https://sourceware.org/ml/gdb-patches/2014-09/msg00148.html > I see. Thanks for the explanation. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-11 19:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-09-11 14:54 [PATCH v3] Introduce remote_target_is_gdbserver Simon Marchi 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
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).