Support catch syscall on aarch64 linux
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / catch-syscall.c
CommitLineData
fbbe92c5
SDJ
1/* This file is used to test the 'catch syscall' feature on GDB.
2
3 Please, if you are going to edit this file DO NOT change the syscalls
4 being called (nor the order of them). If you really must do this, then
5 take a look at catch-syscall.exp and modify there too.
6
7 Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
8 September, 2008 */
9
10#include <unistd.h>
2e0d821f 11#include <sys/syscall.h>
fbbe92c5
SDJ
12#include <fcntl.h>
13#include <sys/stat.h>
14
2e0d821f
SDJ
15/* These are the syscalls numbers used by the test. */
16
2abc3f8d
DB
17int close_syscall = SYS_close;
18int chroot_syscall = SYS_chroot;
4924df79
GKB
19/* GDB had a bug where it couldn't catch syscall number 0 (PR 16297).
20 In most GNU/Linux architectures, syscall number 0 is
21 restart_syscall, which can't be called from userspace. However,
22 the "read" syscall is zero on x86_64. */
2abc3f8d 23int read_syscall = SYS_read;
f68f11b7 24#ifdef SYS_pipe
2abc3f8d 25int pipe_syscall = SYS_pipe;
f68f11b7
YQ
26#else
27int pipe2_syscall = SYS_pipe2;
28#endif
2abc3f8d
DB
29int write_syscall = SYS_write;
30int exit_group_syscall = SYS_exit_group;
2e0d821f 31
fbbe92c5
SDJ
32int
33main (void)
34{
4924df79
GKB
35 int fd[2];
36 char buf1[2] = "a";
37 char buf2[2];
38
fbbe92c5
SDJ
39 /* A close() with a wrong argument. We are only
40 interested in the syscall. */
41 close (-1);
42
43 chroot (".");
44
4924df79
GKB
45 pipe (fd);
46
47 write (fd[1], buf1, sizeof (buf1));
48 read (fd[0], buf2, sizeof (buf2));
49
fbbe92c5
SDJ
50 /* The last syscall. Do not change this. */
51 _exit (0);
52}
This page took 0.667811 seconds and 4 git commands to generate.