From: Elena Zannoni <ezannoni@redhat.com>
To: Michael Elizabeth Chastain <mec@shout.net>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [rfc/testsuite/mi/thread] fix call to sleep in pthreads.c
Date: Wed, 05 Nov 2003 19:21:00 -0000 [thread overview]
Message-ID: <16297.19877.371819.187468@localhost.redhat.com> (raw)
In-Reply-To: <200311051756.hA5HuKXP018763@duracef.shout.net>
Michael Elizabeth Chastain writes:
> This patch changes gdb.mi/pthreads.c so that it gives repeatable results
> under gdb.
>
> Currently, the gdb.mi/mi*-pthreads.exp tests give irregular results
> because the call to sleep() will often return prematurely. Thus, many
> of the threads exit before the test script can see them. All the
> results are PASS, but there are different PASSes on different test runs.
>
> With this patch, all the threads live as long as they are intended to
> live, so that the test script sees all the threads.
Thank you! I love this.
>
> This patch has a disadvantage. gdb is supposed to work with all kinds
> of inferior programs, not just well-written inferior programs.
> Arguably, I should live pthreads.c alone, and change the *.exp files to
> be more flexible about what they recognize.
>
Nah, the purpose of the testsuite is to find regressions, and for that
you need repeatable test results.
> I thought about that approach and decided that I like it better if the
> test program covers what it is intended to cover (thread backtraces)
> even at the expense of other coverage (of nothing particularly useful).
> Also, gdb.threads/pthreads.c still has the broken call to sleep()
> with no return value checking, so we do still have an instance of this
> programming idiom in the test corpus.
>
> My motivation for doing this is that I'm processing two million
> test results on every spin, so the more uniform and regular they are,
> the less work I have to do. This also helps anyone who compares
> test runs with 'diff' or with Andrew's script.
>
> Testing: I'm in the process of testing this. So far it looks okay
> but I won't say anything until the test bed finishes.
>
> Anyways ... comments?
I like the comment. ;-)
elena
>
> Michael C
>
> 2003-11-05 Michael Chastain <mec@shout.net>
>
> * gdb.mi/pthreads.c (routine): Handle early return from sleep.
>
> Index: pthreads.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/pthreads.c,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 pthreads.c
> *** pthreads.c 24 Oct 2003 19:55:09 -0000 1.4
> --- pthreads.c 5 Nov 2003 17:43:00 -0000
> *************** static pthread_attr_t null_attr;
> *** 42,48 ****
> void *
> routine (void *arg)
> {
> ! sleep (9);
> printf ("hello thread\n");
> }
>
> --- 42,55 ----
> void *
> routine (void *arg)
> {
> ! /* When gdb is running, it sets hidden breakpoints in the thread
> ! library. The signals caused by these hidden breakpoints can
> ! cause system calls such as 'sleep' to return early. Pay attention
> ! to the return value from 'sleep' to get the full sleep. */
> ! int unslept = 9;
> ! while (unslept > 0)
> ! unslept = sleep (unslept);
> !
> printf ("hello thread\n");
> }
>
next prev parent reply other threads:[~2003-11-05 19:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-05 17:56 Michael Elizabeth Chastain
2003-11-05 19:21 ` Elena Zannoni [this message]
2003-11-05 19:25 ` Michael Snyder
2003-11-05 18:04 Michael Elizabeth Chastain
2003-11-06 2:16 Michael Elizabeth Chastain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16297.19877.371819.187468@localhost.redhat.com \
--to=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=mec@shout.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox