From e6359af3fdda6b9265565ecbd213763244ed8594 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 30 Mar 2016 16:36:51 +0100 Subject: [PATCH] Simplify gdb.reverse/until-reverse.c Nowadays, functions fprintf, printf and malloc are executed in gdb.reverse/until-reverse.c, so that it takes much time to record instructions inside them. This may cause timeout, and we had several fixes to bump the timeout, https://sourceware.org/ml/gdb-patches/2012-02/msg00038.html https://sourceware.org/ml/gdb-patches/2015-08/msg00186.html also I still see this on arm-linux, continue Continuing. Do you want to auto delete previous execution log entries when record/replay buffer becomes full (record full stop-at-limit)?([y] or n) n Process record: stopped by user. Program stopped. 0xf77021e6 in __linkin_atfork (newp=0xf7751748 ) at ../nptl/sysdeps/unix/sysv/linux/register-atfork.c:117 117 ../nptl/sysdeps/unix/sysv/linux/register-atfork.c: No such file or directory. (gdb) FAIL: gdb.reverse/until-precsave.exp: run to end of main (got interactive prompt) however, I can't figure out how these functions (fprintf, printf and malloc) are related to the test itself. marker1 is a function from shared library too so we don't need these complicated libc functions at all. IMO, recording the instructions in these libc functions has nothing to do with the test itself except slow down the test. This patch is to remove the usage of fprintf and printf, and also move malloc to a dead code path. gdb/testsuite: 2016-03-30 Yao Qi * gdb.reverse/until-precsave.exp: Match function name only. * gdb.reverse/until-reverse.c (main): Don't call fprintf nor printf. Move malloc to a condition block. * gdb.reverse/until-reverse.exp: Match function name only. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.reverse/until-precsave.exp | 2 +- gdb/testsuite/gdb.reverse/until-reverse.c | 15 ++++++++------- gdb/testsuite/gdb.reverse/until-reverse.exp | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1fac1e3aad..57583c23a2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-03-30 Yao Qi + + * gdb.reverse/until-precsave.exp: Match function name only. + * gdb.reverse/until-reverse.c (main): Don't call fprintf nor printf. + Move malloc to a condition block. + * gdb.reverse/until-reverse.exp: Match function name only. + 2016-03-29 Marcin Koƛcielnicki * gdb.trace/ftrace.exp: Set arg0exp for s390. diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp index b5afa52272..f06b6622d0 100644 --- a/gdb/testsuite/gdb.reverse/until-precsave.exp +++ b/gdb/testsuite/gdb.reverse/until-precsave.exp @@ -91,7 +91,7 @@ gdb_test "until $bp_location19" \ # Finish out to main scope # gdb_test "finish" \ - " in main .*$srcfile:$bp_location1.*" \ + "main .*$srcfile:.*" \ "finish to main" # Advance to a function called by main (marker2) diff --git a/gdb/testsuite/gdb.reverse/until-reverse.c b/gdb/testsuite/gdb.reverse/until-reverse.c index 51f949e6e7..d3311b7827 100644 --- a/gdb/testsuite/gdb.reverse/until-reverse.c +++ b/gdb/testsuite/gdb.reverse/until-reverse.c @@ -33,19 +33,20 @@ int factorial(int); int main (int argc, char **argv, char **envp) { - if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ - fprintf (stderr, "usage: factorial \n"); - return 1; + if (argc == 12345) + { + /* We're used by a test that requires malloc, so make sure it is + in the executable. */ + (void) malloc (1); + return 1; } - printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */ + + factorial (atoi ("6")); /* set breakpoint 1 here */ /* set breakpoint 12 here */ marker1 (); /* set breakpoint 11 here */ marker2 (43); /* set breakpoint 20 here */ marker3 ("stack", "trace"); /* set breakpoint 21 here */ marker4 (177601976L); - /* We're used by a test that requires malloc, so make sure it is - in the executable. */ - (void)malloc (1); argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */ return argc; /* set breakpoint 10 here */ diff --git a/gdb/testsuite/gdb.reverse/until-reverse.exp b/gdb/testsuite/gdb.reverse/until-reverse.exp index 07193a82a4..07870f672b 100644 --- a/gdb/testsuite/gdb.reverse/until-reverse.exp +++ b/gdb/testsuite/gdb.reverse/until-reverse.exp @@ -64,7 +64,7 @@ gdb_test "until $bp_location19" \ # Finish out to main scope # gdb_test "finish" \ - " in main .*$srcfile:$bp_location1.*" \ + "main .*$srcfile:.*" \ "finish to main" # Advance to a function called by main (marker2)