From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91070 invoked by alias); 7 Apr 2015 10:10:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 91054 invoked by uid 89); 7 Apr 2015 10:10:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Apr 2015 10:10:34 +0000 Received: by patj18 with SMTP id j18so73928428pat.2 for ; Tue, 07 Apr 2015 03:10:32 -0700 (PDT) X-Received: by 10.70.101.65 with SMTP id fe1mr35525777pdb.54.1428401432662; Tue, 07 Apr 2015 03:10:32 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id x9sm7403507pbt.68.2015.04.07.03.10.30 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 07 Apr 2015 03:10:31 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 8/8] add non-stop test that stresses thread starvation issues References: <1419625871-28848-1-git-send-email-palves@redhat.com> <1419625871-28848-9-git-send-email-palves@redhat.com> <551D57CC.9050403@gmail.com> <55226D5D.3020200@redhat.com> Date: Tue, 07 Apr 2015 10:10:00 -0000 In-Reply-To: <55226D5D.3020200@redhat.com> (Pedro Alves's message of "Mon, 06 Apr 2015 12:26:21 +0100") Message-ID: <86d23gxn8r.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00192.txt.bz2 Pedro Alves writes: > Yes, the test runs forever otherwise. See: > > https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Don.27t_write_tests= _that_run_forever > > How about fixing this like attach-many-short-lived-threads.exp was > fixed here: > > https://sourceware.org/ml/gdb-patches/2015-02/msg00152.html > > ? > OK, how about the patch below? >> It causes some fails on >> arm-linux, that is, the board is slow, and alarm is triggered. >> Then thread is disappeared and current_thread is set to NULL. >> GDB/GDBserver doesn't know about that. When the inferior memory is >> accessed, current_thread is dereferenced, and GDBserver is crashed. > > Sounds like we should have a test that explicitly covers that. > GDBserver shouldn't crash. Yes, let me think about a test case to cover that. --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi Subject: [PATCH] Properly set alarm value in gdb.threads/non-stop-fair-even= ts.exp Nowadays, the alarm value is 60, and alarm is generated on some slow boards. This patch is to pass DejaGNU timeout value to the program, and move the alarm call before going to infinite loop. If any thread has activities, the alarm is reset. gdb/testsuite: 2015-04-07 Yao Qi * gdb.threads/non-stop-fair-events.c (SECONDS): New macro. (child_function): Call alarm. (main): Move call to alarm into the loop. * gdb.threads/non-stop-fair-events.exp: Build program with -DTIMEOUT=3D$timeout. diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.c b/gdb/testsui= te/gdb.threads/non-stop-fair-events.c index 6a9d31d..f82c366 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.c +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.c @@ -22,6 +22,9 @@ =20 #define NUM_THREADS 10 const int num_threads =3D NUM_THREADS; +/* Allow for as much timeout as DejaGnu wants, plus a bit of + slack. */ +#define SECONDS (TIMEOUT + 20) =20 pthread_t child_thread[NUM_THREADS]; volatile pthread_t signal_thread; @@ -53,6 +56,8 @@ child_function (void *arg) =20 while (1) { + /* Reset the timer before going to INF_LOOP. */ + alarm (SECONDS); INF_LOOP; /* set thread breakpoint here */ loop_broke (); } @@ -64,8 +69,6 @@ main (void) int res; int i; =20 - alarm (60); - signal (SIGUSR1, handler); =20 for (i =3D 0; i < NUM_THREADS; i++) @@ -76,6 +79,8 @@ main (void) while (1) { pthread_kill (signal_thread, SIGUSR1); /* set kill breakpoint here */ + /* Reset the timer before going to INF_LOOP. */ + alarm (SECONDS); INF_LOOP; loop_broke (); } diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/tests= uite/gdb.threads/non-stop-fair-events.exp index 9b7b9ca..e2d3f7d 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp @@ -24,7 +24,8 @@ if [target_info exists gdb,nosignals] { return -1 } =20 -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pth= reads}] =3D=3D -1} { +set options { "additional_flags=3D-DTIMEOUT=3D$timeout" debug pthreads } +if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] = =3D=3D -1} { return -1 } =20