public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: fix default behavior of runto
@ 2021-12-08 19:45 Simon Marchi
  2021-12-09 10:47 ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2021-12-08 19:45 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

The documented behavior of proc runto is to not emit a PASS when
succeeding to to run to the specified location, but emit a FAIL when
failing to do so.  I suppose the intent is that it won't pollute the
results normally passing tests (although I don't see why we would care),
but make visible any problems.

However, it seems like the implementation makes it default to never
print anything.  "no-message" is prependend to "args", so if "message"
is not passed, we will always take the   path that sets print_fail to 0,
which will silence any failure.

This unfortunately means that tests relying on runto_main won't emit a
FAIL if failing to run to main.  And since commit 4dfef5be6812
("gdb/testsuite: make runto_main not pass no-message to runto"), tests
don't emit a FAIL themselves when failing to run to main.  This means
that tests failing to run to main just fail silently, and that's bad.

This can be reproduced by hacking gdb.base/template.exp like so:

    diff --git a/gdb/testsuite/gdb.base/template.c b/gdb/testsuite/gdb.base/template.c
    index bcf39c377d92..052be5b79d73 100644
    --- a/gdb/testsuite/gdb.base/template.c
    +++ b/gdb/testsuite/gdb.base/template.c
    @@ -15,6 +15,14 @@
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

    +#include <stdlib.h>
    +
    +__attribute__((constructor))
    +static void c (void)
    +{
    +  exit (1);
    +}
    +
     int
     main (void)
     {

Running the modified gdb.base/template.exp shows that it exits without
printing any result.

Remove the line that prepends no-message to args, that should make
runto's behavior match its documentation.

This patch will appear to add many failures, but in reality they already
existed, they were just silenced.

Change-Id: I2a730d5bc72b6ef0698cd6aad962d9902aa7c3d6
---
 gdb/testsuite/lib/gdb.exp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 70fa2b3a8013..6f8fffffd0b6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -628,9 +628,6 @@ proc runto { function args } {
 
     delete_breakpoints
 
-    # Default to "no-message".
-    set args "no-message $args"
-
     set print_pass 0
     set print_fail 1
     set no_message_loc [lsearch -exact $args no-message]
-- 
2.26.2


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

* Re: [PATCH] gdb/testsuite: fix default behavior of runto
  2021-12-08 19:45 [PATCH] gdb/testsuite: fix default behavior of runto Simon Marchi
@ 2021-12-09 10:47 ` Tom de Vries
  2021-12-09 19:04   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2021-12-09 10:47 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 12/8/21 8:45 PM, Simon Marchi via Gdb-patches wrote:
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 70fa2b3a8013..6f8fffffd0b6 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -628,9 +628,6 @@ proc runto { function args } {
>  
>      delete_breakpoints
>  
> -    # Default to "no-message".
> -    set args "no-message $args"
> -
>      set print_pass 0
>      set print_fail 1
>      set no_message_loc [lsearch -exact $args no-message]

I would also remove this line:
...
# The default is no-message.
...
from the proc documentation.

Otherwise, LGTM.

Thanks,
- Tom

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

* Re: [PATCH] gdb/testsuite: fix default behavior of runto
  2021-12-09 10:47 ` Tom de Vries
@ 2021-12-09 19:04   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2021-12-09 19:04 UTC (permalink / raw)
  To: Tom de Vries, Simon Marchi, gdb-patches

On 2021-12-09 5:47 a.m., Tom de Vries via Gdb-patches wrote:
> On 12/8/21 8:45 PM, Simon Marchi via Gdb-patches wrote:
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 70fa2b3a8013..6f8fffffd0b6 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -628,9 +628,6 @@ proc runto { function args } {
>>  
>>      delete_breakpoints
>>  
>> -    # Default to "no-message".
>> -    set args "no-message $args"
>> -
>>      set print_pass 0
>>      set print_fail 1
>>      set no_message_loc [lsearch -exact $args no-message]
> 
> I would also remove this line:
> ...
> # The default is no-message.
> ...
> from the proc documentation.
> 
> Otherwise, LGTM.

Done and pushed, thanks.

Simon

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

end of thread, other threads:[~2021-12-09 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 19:45 [PATCH] gdb/testsuite: fix default behavior of runto Simon Marchi
2021-12-09 10:47 ` Tom de Vries
2021-12-09 19:04   ` Simon Marchi

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).