mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-12 03:43:33 +08:00
e6359af3fd
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-30 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.
83 lines
2.2 KiB
C
83 lines
2.2 KiB
C
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2008-2016 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
extern int marker1 (void);
|
|
extern int marker2 (int a);
|
|
extern void marker3 (char *a, char *b);
|
|
extern void marker4 (long d);
|
|
|
|
/*
|
|
* This simple classical example of recursion is useful for
|
|
* testing stack backtraces and such.
|
|
*/
|
|
|
|
int factorial(int);
|
|
|
|
int
|
|
main (int argc, char **argv, char **envp)
|
|
{
|
|
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;
|
|
}
|
|
|
|
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);
|
|
|
|
argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
|
|
return argc; /* set breakpoint 10 here */
|
|
} /* set breakpoint 10a here */
|
|
|
|
int factorial (int value)
|
|
{
|
|
if (value > 1) { /* set breakpoint 7 here */
|
|
value *= factorial (value - 1);
|
|
}
|
|
return (value); /* set breakpoint 19 here */
|
|
}
|
|
|
|
int multi_line_if_conditional (int a, int b, int c)
|
|
{
|
|
if (a /* set breakpoint 3 here */
|
|
&& b
|
|
&& c)
|
|
return 0;
|
|
else
|
|
return 1;
|
|
}
|
|
|
|
int multi_line_while_conditional (int a, int b, int c)
|
|
{
|
|
while (a /* set breakpoint 4 here */
|
|
&& b
|
|
&& c)
|
|
{
|
|
a--, b--, c--;
|
|
}
|
|
return 0;
|
|
}
|