Files
binutils-gdb/gdb/testsuite/gdb.reverse/time-reverse.c
Pedro Alves 4097906672 gdb.reverse/time-reverse.exp: test both time syscall and C time function
Instead of only testing this on systems that have a SYS_time syscall,
test it everywhere using the time(2) C function, and in addition, run
the tests again using the SYS_time syscall.

The C variant ensures that if some platform uses some syscall we are
not aware of yet, we'll still exercise it, and likely fail, at which
point we should teach GDB about the syscall.

The explicit syscall variant is useful on platforms where the C
function does not call a syscall at all by default, e.g., on some
systems the C time function wraps an implementation provided by the
vDSO.

Approved-By: Tom de Vries <tdevries@suse.de>
Change-Id: Id4b755d76577d02c46b8acbfa249d9c31b587633
2023-02-22 18:09:08 +00:00

49 lines
1.1 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2008-2023 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/>. */
#define _GNU_SOURCE
#include <time.h>
#include <sys/syscall.h>
#include <unistd.h>
#ifdef USE_SYSCALL
# define my_time(TLOC) syscall (SYS_time, TLOC)
#else
# define my_time(TLOC) time (TLOC)
#endif
void
marker1 (void)
{
}
void
marker2 (void)
{
}
time_t time_global = -1;
int
main (void)
{
marker1 ();
my_time (&time_global);
marker2 ();
return 0;
}