Simplify gdb.reverse/until-reverse.c

Message ID 1459257423-9675-1-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi March 29, 2016, 1:17 p.m. UTC
  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 <atfork_mem>) 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-29  Yao Qi  <yao.qi@linaro.org>

	* 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/gdb.reverse/until-precsave.exp |  2 +-
 gdb/testsuite/gdb.reverse/until-reverse.c    | 15 ++++++++-------
 gdb/testsuite/gdb.reverse/until-reverse.exp  |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)
  

Comments

Pedro Alves March 29, 2016, 4:45 p.m. UTC | #1
On 03/29/2016 02:17 PM, Yao Qi wrote:
> 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

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

This is fine with me.

Thanks,
Pedro Alves
  
Yao Qi March 30, 2016, 3:37 p.m. UTC | #2
Pedro Alves <palves@redhat.com> writes:

> This is fine with me.

Patch is pushed in.
  

Patch

diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp
index b5afa52..f06b662 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 51f949e..d3311b7 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 <number>\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 07193a8..07870f6 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)