f68f11b76d
Hi, This patch is to support catch syscall on aarch64 linux. We implement gdbarch method get_syscall_number for aarch64-linux, and add aarch64-linux.xml file, which looks straightforward, however the changes to test case doesn't. First of all, we enable catch-syscall.exp on aarch64-linux target, but skip the multi_arch testing on current stage. I plan to touch multi arch debugging on aarch64-linux later. Then, when I run catch-syscall.exp on aarch64-linux, gcc errors that SYS_pipe isn't defined. We find that aarch64 kernel only has pipe2 syscall and libc already convert pipe to pipe2. As a result, I change catch-syscall.c to use SYS_pipe if it is defined, otherwise use SYS_pipe2 instead. The vector all_syscalls in catch-syscall.exp can't be pre-determined, so I add a new proc setup_all_syscalls to fill it, according to the availability of SYS_pipe. Regression tested on {x86_64, aarch64}-linux x {native, gdbserver}. gdb: 2015-03-18 Yao Qi <yao.qi@linaro.org> PR tdep/18107 * aarch64-linux-tdep.c: Include xml-syscall.h (aarch64_linux_get_syscall_number): New function. (aarch64_linux_init_abi): Call set_gdbarch_get_syscall_number. * syscalls/aarch64-linux.xml: New file. gdb/testsuite: 2015-03-18 Yao Qi <yao.qi@linaro.org> PR tdep/18107 * gdb.base/catch-syscall.c [!SYS_pipe] (pipe2_syscall): New variable. * gdb.base/catch-syscall.exp: Don't skip it on aarch64*-*-linux* target. Remove elements in all_syscalls. (test_catch_syscall_multi_arch): Skip it on aarch64*-linux* target. (setup_all_syscalls): New proc.
52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
/* This file is used to test the 'catch syscall' feature on GDB.
|
|
|
|
Please, if you are going to edit this file DO NOT change the syscalls
|
|
being called (nor the order of them). If you really must do this, then
|
|
take a look at catch-syscall.exp and modify there too.
|
|
|
|
Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
|
|
September, 2008 */
|
|
|
|
#include <unistd.h>
|
|
#include <sys/syscall.h>
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
|
|
/* These are the syscalls numbers used by the test. */
|
|
|
|
int close_syscall = SYS_close;
|
|
int chroot_syscall = SYS_chroot;
|
|
/* GDB had a bug where it couldn't catch syscall number 0 (PR 16297).
|
|
In most GNU/Linux architectures, syscall number 0 is
|
|
restart_syscall, which can't be called from userspace. However,
|
|
the "read" syscall is zero on x86_64. */
|
|
int read_syscall = SYS_read;
|
|
#ifdef SYS_pipe
|
|
int pipe_syscall = SYS_pipe;
|
|
#else
|
|
int pipe2_syscall = SYS_pipe2;
|
|
#endif
|
|
int write_syscall = SYS_write;
|
|
int exit_group_syscall = SYS_exit_group;
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int fd[2];
|
|
char buf1[2] = "a";
|
|
char buf2[2];
|
|
|
|
/* A close() with a wrong argument. We are only
|
|
interested in the syscall. */
|
|
close (-1);
|
|
|
|
chroot (".");
|
|
|
|
pipe (fd);
|
|
|
|
write (fd[1], buf1, sizeof (buf1));
|
|
read (fd[0], buf2, sizeof (buf2));
|
|
|
|
/* The last syscall. Do not change this. */
|
|
_exit (0);
|
|
}
|