From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 483 invoked by alias); 18 Nov 2003 23:00:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 400 invoked from network); 18 Nov 2003 23:00:03 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (209.53.17.87) by sources.redhat.com with SMTP; 18 Nov 2003 23:00:03 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id C59DC481D5; Tue, 18 Nov 2003 15:00:02 -0800 (PST) Date: Tue, 18 Nov 2003 23:00:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA/testsuite] attach.exp: Add small delay in busy loop... Message-ID: <20031118230002.GG1319@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2003-11/txt/msg00385.txt.bz2 --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1431 Hello, The attach.exp sometimes fails on certain platforms (eg mips-irix), and causes an attach process to be left behind. Since it is doing a busy loop, this runaway process left behind consumes 99.9% of the CPU, and considerably slows down the execution of the rest of the testsuite. I suggest the following change to add a small delay at each iteration of the busy loop. I had to make some adjustments to attach.exp: a. Line number 19 became line 32. Just like Elena recently upgraded a test to avoid hard-coded line number, we should probably clean this up, someday. This can be a separate patch, however. b. The program was attached to while inside the busy loop, so the test was expecting the debugger to report that the inferior was inside function main() after the attach command was performed. This is no longer the case, since the inferior is most likely inside a system call, doing the delay. I felt that it was not a necessity to checke where the debugger thought the inferior was stopped, so removed that part of the expected output. What I can do is add an extra test that does a backtrace and verifies that it contains a frame for function main(). 2003-11-18 J. Brobecker * gdb.base/attach.c: Add small delay in busy loop. * gdb.base/attach.exp: Make some associated adjustments. OK to apply? Thanks, -- Joel --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="attach.diff" Content-length: 3486 Index: attach.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/attach.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 attach.c --- attach.c 28 Jun 1999 23:02:40 -0000 1.1.1.1 +++ attach.c 18 Nov 2003 22:51:12 -0000 @@ -5,15 +5,28 @@ exit unless/until gdb sets the variable to non-zero.) */ #include +#include int should_exit = 0; +/* Wait for 0.1 sec. */ + +void +small_delay () +{ + const struct timespec ts = { 0, 1000000 }; /* 0.1 sec */ + nanosleep (&ts, NULL); +} + int main () { int local_i = 0; while (! should_exit) { + /* Insert a small delay in order to avoid consuming all the CPU + while waiting for the debugger to take control. */ + small_delay (); local_i++; } return 0; Index: attach.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/attach.exp,v retrieving revision 1.12 diff -u -p -r1.12 attach.exp --- attach.exp 7 Aug 2003 17:55:41 -0000 1.12 +++ attach.exp 18 Nov 2003 22:51:13 -0000 @@ -173,7 +173,7 @@ proc do_attach_tests {} { send_gdb "attach $testpid\n" gdb_expect { - -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\ + -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $"\ {pass "attach1, after setting file"} -re "$gdb_prompt $" {fail "attach1, after setting file"} timeout {fail "(timeout) attach1, after setting file"} @@ -236,7 +236,7 @@ proc do_attach_tests {} { # send_gdb "attach $testpid\n" gdb_expect { - -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ + -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*$gdb_prompt $"\ {pass "attach2"} -re "$gdb_prompt $" {fail "attach2"} timeout {fail "(timeout) attach2"} @@ -253,16 +253,16 @@ proc do_attach_tests {} { # Verify that the modification really happened. # - send_gdb "tbreak 19\n" + send_gdb "tbreak 32\n" gdb_expect { - -re "Breakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\ + -re "Breakpoint .*at.*$srcfile, line 32.*$gdb_prompt $"\ {pass "after attach2, set tbreak postloop"} -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"} timeout {fail "(timeout) after attach2, set tbreak postloop"} } send_gdb "continue\n" gdb_expect { - -re "main.*at.*$srcfile:19.*$gdb_prompt $"\ + -re "main.*at.*$srcfile:32.*$gdb_prompt $"\ {pass "after attach2, reach tbreak postloop"} -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"} timeout {fail "(timeout) after attach2, reach tbreak postloop"} @@ -337,7 +337,7 @@ proc do_attach_tests {} { send_gdb "attach $testpid\n" gdb_expect { - -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\ + -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*$gdb_prompt $"\ {pass "attach when process' a.out not in cwd"} -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"} timeout {fail "(timeout) attach when process' a.out not in cwd"} --HcAYCG3uE/tztfnV--