Commit Graph

310 Commits

Author SHA1 Message Date
03b4454129 ARM OABI: fix potential compilation warning
* syscall.c (get_scno) [!__ARM_EABI__ || ENABLE_ARM_OABI]: Fix
"comparison between signed and unsigned" warning reported by some
gcc versions.
2015-01-14 07:21:36 +00:00
cf7248d004 arm: rewrite shuffle_scno in a bit more readable way
* linux/arm/syscallent.h: Define ARM_FIRST_SHUFFLED_SYSCALL instead of
ARM_LAST_ORDINARY_SYSCALL.
* syscall.c [ARM || AARCH64] (shuffle_scno): Update.
2015-01-12 17:32:09 +00:00
Masatake YAMATO
a807dceca5 Add functions for dumping iovecs in mmsghdr used in sendmmsg and recvmmsg
This patch is similar to what I did in commit
02f9f6b386.
That commit was for sendmsg and recvmsg system calls.
This one is for sendmmsg and recvmmsg system calls.

* defs.h (dumpiov_in_mmsghdr): New declaration.
* net.c (extractmmsghdr): New function derived from printmmsghdr.
(printmmsghdr): Use it.
(dumpiov_in_mmsghdr): New function.
* syscall.c (dumpio) [HAVE_SENDMSG]: Call dumpiov_in_mmsghdr
for recvmmsg and sendmmsg syscalls.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-11-11 15:44:24 +00:00
Masatake YAMATO
02f9f6b386 Add a function for dumping iovec in msghdr used in sendmsg and recvmsg
Here is an example session:

    $ ./strace -e write=all ip link change dev enp0s25 mtu 1501 > /dev/null
    sendmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"(...
     * 40 bytes in buffer 0
     | 00000  28 00 00 00 10 00 05 00  d0 d9 aa 53 00 00 00 00  (..........S.... |
     | 00010  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  ................ |
     | 00020  08 00 04 00 dd 05 00 00                           ........         |
    ...

    $ ./strace -e read=all ip link show > /dev/null
    recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"...
     * 8192 bytes in buffer 0
     | 00000  34 00 00 00 02 00 00 00  00 00 00 00 ff 23 00 00  4............#.. |
     | 00010  ff ff ff ff 20 00 00 00  10 00 05 00 00 00 00 00  .... ........... |
    ...

* defs.h (dumpiov_in_msghdr): New prototype.
* net.c (extractmsghdr): New function derived from printmsghdr.
(printmsghdr): Use extractmsghdr.
(dumpiov_in_msghdr): New function.
* syscall.c (dumpio) [HAVE_SENDMSG]: Call dumpiov_in_msghdr for recvmsg
and sendmsg syscalls.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-11-01 01:46:06 +00:00
Maarten ter Huurne
40c174b38b Include <linux/ptrace.h> regardless of <sys/reg.h> existence
This fixes compilation with musl libc.
This approach was already used in process.c, so I assume it is safe.

* signal.c: Move [HAVE_LINUX_PTRACE_H] code out of [HAVE_SYS_REG_H] check.
* syscall.c: Likewise.
* util.c: Likewise.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
2014-10-31 23:04:59 +00:00
3ed5d02183 Fix compilation warnings reported by gcc -Wsign-compare
* configure.ac (gl_WARN_ADD): Add -Wsign-compare.
* defs.h (struct tcb): Change 'currpers' type to unsigned.
(struct xlat): Change 'val' type to unsigned
(signame): Add 'const' qualifier to its argument.
(xlookup, printxval): Add 'const' qualifier to the 2nd argument and
change its type to unsigned.
(printpathn): Change the 3rd argument type to unsigned.
(ioctl_lookup): Change 1st argument type to unsigned.
* count.c (call_summary_pers, call_summary): Change 'i' type to unsigned.
* file.c (print_xattr_list): Fix comparisons between signed and unsigned
long values.
* ioctl.c (compare): Fix cast.
(ioctl_lookup): Change 1st argument type to to unsigned.
(ioctl_next_match): Change 'code' type to unsigned.
* mem.c (sys_move_pages): Change 'i' type to unsigned.
* mtd.c (mtd_ioctl): Change 'i' and 'j' types to unsigned.
Print 'i' using %u format string.
* process.c (sys_prctl): Change 'i' type to unsigned.
(printargv): Change 'n' type to unsigned.
(sys_ptrace): Change 'addr' type to unsigned.
* scsi.c (print_sg_io_buffer): Add 'const' qualifier to 'len' argument
and change its type to unsigned.  Change 'i' and 'allocated' types
to unsigned.
* signal.c (signame): Add 'const' qualifier to its argument.
Fix comparisons between signed and unsigned values.
(sprintsigmask_n, printsiginfo): Fix comparisons between signed and
unsigned values.
* sock.c (sock_ioctl): Change 'i' and 'nifra' types to unsigned.
* strace.c (expand_tcbtab, alloctcb): Change 'i' type to unsigned.
(detach): Change 'sig' type to unsigned.
(startup_attach): Change 'tcbi' type to unsigned.
(startup_child): Change 'm', 'n', and 'len' types to unsigned.
(init): Use new variable to iterate 'tcbtab'.
(pid2tcb): Change 'i' type to unsigned.
(cleanup): Change 'i' and 'sig' types to unsigned.
* syscall.c (update_personality): Change 'personality' argument type
to unsigned.
(struct qual_options): Change 'bitflag' type to unsigned.
(reallocate_qual): Add 'const' qualifier to its argument and change its
type to unsigned.
(qualify_one): Change 'n' and 'bitflag' arguments types to unsigned.
Add 'const' qualifier to 'n', 'not', and 'pers' arguments.
Change 'p' type to signed int.
(qual_syscall): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'p' type to signed int.
(qual_signal): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'i' type to unsigned.
(qual_desc): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
(qualify): Change 'i' type to unsigned.
(get_scno): Change 'currpers' type to unsigned.
Fix a comparison between signed and unsigned values.
* system.c (sys_sysctl): Change 'cnt' and 'max_cnt' types to unsigned.
Fix comparisons between signed and unsigned values.
* util.c (xlookup, printxval): Add 'const' qualifier to 'val' argument
and change its type to unsigned.
(printuid): Fix a comparison between signed and unsigned values.
(printpathn): Change 'n' argument type to unsigned.
(printstr): Change 'size' type to unsigned.
Fix a comparison between signed and unsigned values.
(setbpt): Change 'i' type to unsigned.
* net.c (printsock): Silence a compilation warning.
* reboot.c (sys_reboot): Likewise.
2014-09-17 19:18:18 +00:00
Zubin Mithra
64aa1b1e2d Decode paths associated with file descriptors returned by syscalls
* defs.h (RVAL_FD): New macro.
(RVAL_MASK, RVAL_STR, RVAL_NONE): Update.
* desc.c (sys_dup, sys_delete_module): New functions.
(do_dup2, decode_open, sys_creat): Change return value to RVAL_FD.
* linux/dummy.h (sys_delete_module, sys_dup): Remove.
* linux/syscall.h (sys_delete_module, sys_dup): New prototypes.
* syscall.c (trace_syscall_exiting): Handle RVAL_FD.

Signed-off-by: Zubin Mithra <zubin.mithra@gmail.com>
2014-06-04 16:28:04 +00:00
Masatake YAMATO
ed69fc2dc3 unwind: move stacktrace capturing and mmap cache invalidating to trace_syscall_entering
Instead of handling stacktrace capturing and mmap cache invalidating in
sys_* functions, handle them uniformly in trace_syscall_entering using
new flags introduced by previous two commits.

The patch is simpler than its older version(v3).  The value of
hide_log_until_execve is just ignored.  I found the value is nothing
to do with this patch.  unwind_cache_invalidate is mentioned only
once in trace_syscall_exiting.
Both are suggested by Dmitry Levin.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2014-05-30 22:59:01 +00:00
Masatake YAMATO
1d78d22058 unwind: introduce markers specifying the needs of special care in unwinding
Some system calls require capturing the stack trace before they are
processed in kernel.  Typical one is execve.  Some system calls require
invalidating mmap cache after they are processed in kernel.

In current implementation these requirements are handled directly by
appropriate syscall handlers.  However, it is difficult to keep the
source code maintainable using this approach to cover all system calls
which have such requirements.

A more generic way to implement this is to flag all syscalls that
require special processing, and handle these flags right in
trace_syscall_entering instead of changing syscall handlers.

This patch just defines new flags: STACKTRACE_INVALIDATE_CACHE and
STACKTRACE_CAPTURE_ON_ENTER.

The names of macros are suggested by Dmitry Levin.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2014-05-30 22:57:56 +00:00
Masatake YAMATO
6141392856 unwind: give all exported functions "unwind_" prefix
* unwind.c (init_unwind_addr_space): Rename to unwind_init.
(init_libunwind_ui): Rename to unwind_tcb_init.
(free_libunwind_ui): Rename to unwind_tcb_fin.
(delete_mmap_cache): Rename to unwind_cache_invalidate.
(print_stacktrace): Rename to unwind_print_stacktrace.
* defs.h: Update prototypes.
* mem.c: All callers updated.
* process.c: Likewise.
* strace.c: Likewise.
* syscall.c: Likewise.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2014-05-30 22:40:22 +00:00
Luca Clementi
327064b637 Add -k option to print stack trace after each syscall
Print the stack trace of the traced process after each system call when
-k option is specified.  It is implemented using libunwind to unwind the
stack and to obtain the function name pointed by the IP.

Based on the code that was originally taken from strace-plus
of Philip J. Guo.

* configure.ac: Add --with-libunwind option.  Check libunwind support.
* Makefile.am: Add libunwind support.
* defs.h (struct tcb) [USE_LIBUNWIND]: Append libunwind specific fields.
[USE_LIBUNWIND] (stack_trace_enabled, alloc_mmap_cache,
delete_mmap_cache, print_stacktrace): New prototypes.
* mem.c (print_mmap, sys_munmap, sys_mprotect): Add libunwind support.
* process.c (sys_execve): Likewise.
* strace.c (usage, alloctcb, droptcb, init): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* unwind.c: New file.
* strace.1: Document -k option.
2014-05-30 22:24:31 +00:00
ac5133d0cb Constify count_syscall function
* count.c (count_syscall): Add const qualifier to timeval argument and
rename it.  Store the wall clock time spent while in syscall in separate
timeval variable.
* defs.h (count_syscall): Update prototype.
* syscall.c (trace_syscall_exiting): Update count_syscall invocation.
2014-05-29 18:10:00 +00:00
6556315493 Alias sys_vfork to sys_fork
* process.c (sys_vfork): Remove.
* linux/syscall.h (sys_vfork): Likewise.
* linux/dummy.h (sys_vfork): Alias to sys_fork.
* linux/alpha/syscallent.h: Fix vfork entry.
* util.c (setbpt): Do not check for sys_vfork.
* syscall.c (syscall_fixup_for_fork_exec): Likewise.
2014-05-12 20:26:24 +00:00
0160e16108 ARM EABI: disable OABI support by default
OABI is rarely used in ARM EABI systems nowadays, so disable its support
by default.  Add --enable-arm-oabi option to enable ARM OABI support.

* configure.ac: New option --enable-arm-oabi.
* syscall.c (get_scno) [ARM]: Check ENABLE_ARM_OABI macro defined by
configure instead of undocumented STRACE_KNOWS_ONLY_EABI macro.
2014-03-20 22:21:51 +00:00
Elliott Hughes
7a28f7f128 aarch64: fix decoding of arm syscall numbers
If an aarch64 strace is tracing a process using the arm personality, it
also needs to call the shuffle_scno function for the ARM-specific
syscalls.

* syscall.c (shuffle_scno): Define on AARCH64.
(get_scno) [AARCH64]: Call shuffle_scno when the tracee is in 32-bit mode.

Signed-off-by: Elliott Hughes <enh@google.com>
2014-03-03 23:54:14 +00:00
James Yang
a78d777c86 powerpc64: fix 64-bit process detection on embedded
* syscall.c (get_scno) [POWERPC64]: Fix 64-bit process detection
on embedded powerpc.

Signed-off-by: James Yang <james.yang@freescale.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2014-02-25 23:33:30 +00:00
Mike Frysinger
94e246ac57 Delete old PTRACE_{PEEK,POKE}USR logic
The code base has settled on PTRACE_{PEEK,POKE}USER (with an E) and has
logic in defs.h to make sure it's set sanely.  Delete this old logic as
the defs.h takes care of it now.

* process.c: Delete PTRACE_PEEKUSR/PTRACE_POKEUSR defines.
* signal.c: Likewise.
* syscall.c: Delete PTRACE_PEEKUSR define.
* util.c: Likewise.
2013-12-31 07:50:09 +00:00
Ali Polatel
0b4060f61f Work around conflict between <sys/ptrace.h> and <linux/ptrace.h>
Since glibc-2.18~39 <sys/ptrace.h> defines ptrace_peeksiginfo_args
which collides with <linux/ptrace.h>.

* configure.ac: Check for `struct ptrace_peeksiginfo_args' in
<sys/ptrace.h>.
* process.c: Work around potential conflict between <sys/ptrace.h>
and <linux/ptrace.h> by redefining ptrace_peeksiginfo_args.
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.

Signed-off-by: Ali Polatel <alip@exherbo.org>
2013-09-26 13:08:43 +00:00
Vineet Gupta
7daacbbbe7 Add support for ARC Cores from Synopsys
Take #2 on mainlining strace support for ARC (last one was 4.6 based back
in March 2011), see
http://sourceforge.net/p/strace/mailman/message/27210168/

The syscall ABI is asm-generic/unistd.h based (so no legacy syscalls),
hence very similar to metag port.

test/* all seem to work well.

* linux/arc/ioctlent.h.in: New file.
* linux/arc/syscallent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add linux/arc/ioctlent.h.in and
linux/arc/syscallent.h.
* configure.ac: Add ARC to the list of supported architectures.
* defs.h: Add ARC support.
* process.c (struct_user_offsets): Likewise.
* signal.c (sys_sigreturn): Likewise.
* syscall.c (print_pc, get_regset, get_regs, get_scno, get_syscall_args,
get_syscall_result, get_error): Likewise.
* util.c (change_syscall): Likewise.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2013-09-11 14:44:54 +00:00
Denys Vlasenko
e600ac67ee I386: fix signedness mismatch warning
&i386_regs.esp is a pointer to long, not unsigned long.
It needs a cast.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-18 17:40:45 +02:00
Denys Vlasenko
94e10354d8 ARM: remove wrong NSIG = 32 define
ARM in fact has 64 signals (1..64), and NSIG should be 65
(as usual, rememebr that NSIG_libc == NSIG_kernel+1).

I carefully reviewed all usages of NSIG. In syscall.c,
the only usage is:
        for (i = 0; i <= NSIG; i++)
                if (strcasecmp(s, signame(i) + 3) == 0)...
which is safe even if NSIG is way too big - signame(i)
returns a well-formed string for any i.

In signal.c, memcpy(&sigset, &sc.sc_mask, NSIG / 8) is used by
IA64 and TILE code, so ARM change can't affect it. And final
usage is:
 struct new_sigaction::unsigned long sa_mask[NSIG / sizeof(long)];
It will grow on ARM (and become correct in the process).
Its only use is
 memcpy(&sigset, &sa.sa_mask, NSIG / 8);
 printsigmask(&sigset, 1);
which used to copy garbage in high bits, now it will copy actual data.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-18 09:41:20 +02:00
Denys Vlasenko
b51f364c42 Improve sigreturn decoding on x86 to show RT signal bits too.
This includes decoding of 32-bit sigreturn by 64-bit strace,
which previously wasn't done.

Added a test for it.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-16 12:06:25 +02:00
Anton Blanchard
9459dfb891 powerpc: fix some compiler warnings
Fix a number of differing signedness warnings when building on
powerpc.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-12 12:24:02 +02:00
Denys Vlasenko
f5730e9614 s390[x]: get rid of syscall_mode, delete code which never triggers
Before this change, the logic was as follows:
syscall entry:
  get_scno:
    syscall_mode = GPR2
    scno = syscall_mode unless syscall_mode == -ENOSYS
    (if -ENOSYS, scn is retrieved by decoding current insn)
  fixup:
    gpr2 = GPR2
    syscall_mode = scno unless syscall_mode == -ENOSYS
    if (gpr2 != syscall_mode) stray_entry
syscall exit:
  get_res:
    gpr2 = GRP2
  fixup:
    syscall_mode = scno unless syscall_mode == -ENOSYS
    if (WAITEXECVE && gpr2 in (-ENOSYS, scno)) gpr2 = 0;
  get_error:
    gpr2 is retval

Entry fixup's if() can never trigger:
regardless whether GPR2 is -ENOSYS or not, syscall_mode is always
equal to GRP2 value there. So it can be removed.

On sysexit path, syscall mode is never used.

Therefore, syscall_mode variable is deleted. grp2 is read from
GPR2 register in get_scno, redundant read in entry fixup is removed.
As a result, entry fixup's s390 code block vanishes completely.

gpr2 variable is renamed s390_gpr2 to match the convention used
by other arches.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-07 12:56:42 +02:00
Denys Vlasenko
8b7aa2b35d ARM: add STRACE_KNOWS_ONLY_EABI define which can be used to omit OABI support
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-04 09:54:19 +02:00
Denys Vlasenko
5a2483ba25 Remove ia64-specific printing of current address on signal delivery
The address is printed anyway by printleader() if -i is active.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-01 12:49:14 +02:00
Denys Vlasenko
c09646aa9e Rename ia32 to ia64_ia32mode, and make it bool, not long
Grepping for just ia32 was turning up many false positives.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-07-01 12:28:17 +02:00
Denys Vlasenko
4793221a53 Fold is_restart_error() into its sole user
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-30 23:53:49 +02:00
Denys Vlasenko
44a6d04e5e POWERPC: get rid of "static long ppc_result"
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-28 16:47:38 +02:00
Denys Vlasenko
6b3016e435 POWERPC: read ppc_regs.nip if -i
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-28 14:51:50 +02:00
Denys Vlasenko
7eb893236c POWERPC: if GETREGS fails with EIO, don't try it again
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-28 14:41:30 +02:00
Denys Vlasenko
7f5a132c81 Get rid of powerpc_getreg(), it's a copy of upeek()
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-28 14:36:39 +02:00
Denys Vlasenko
752e5a02e6 Change upeek() to take pid, not full tcp.
This will be used by next change.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-28 14:35:47 +02:00
Anton Blanchard
14d51a6423 powerpc: Provide a fallback for old kernels without PTRACE_GETREGS
PTRACE_GETREGS was added to the ppc kernel in 2.6.23. In order to
provide backward compatibility for very old kernels, add a manual
fallback.

* syscall.c (powerpc_getreg, powerpc_getregs_old): New functions.
(get_regs): Call powerpc_getregs_old if PTRACE_GETREGS is not supported.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-26 15:57:29 +02:00
Anton Blanchard
ce6e33be1d powerpc: Use PTRACE_GETREGS to fetch all registers
* defs.h: declare ppc_regs and get_regs_error.
* signal.c (sys_sigreturn): Use ppc_regs instead of upeek.
* syscall.c: define ppc_regs.
(printcall): Use ppc_regs instead of upeek.
(get_scno): Replace multiple upeek calls with one PTRACE_GETREGS call.
(get_syscall_result): Likewise.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-06-26 15:56:53 +02:00
Denys Vlasenko
2a3d27552f Hide startup syscalls.
Tested with "./strace [-D] [-q] [-bexecve] env true",
all cases seem to work.

* defs.h: Declare new variable: bool hide_log_until_execve.
* strace.c: Define hide_log_until_execve.
Rename skip_startup_execve to skip_one_b_execve.
(startup_child): Do not set skip_one_b_execve = 1 here.
(init): If "strace PROG" case (as opposed to "strace -pPID"),
set skip_one_b_execve and hide_log_until_execve to 1.
(trace): Don't print signal messages if hide_log_until_execve == 1.
* syscall.c (trace_syscall_entering):
Skip syscall printing if hide_log_until_execve == 1.
Reset hide_log_until_execve if we enter execve syscall.
(trace_syscall_exiting): Skip syscall printing if hide_log_until_execve == 1.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2013-05-14 16:10:42 +02:00
Chris Zankel
8f636ed128 Add support for the XTENSA architecture
* configure.ac: Add XTENSA to the list of supported architectures.
* defs.h: Add XTENSA support.
* linux/xtensa/syscallent.h: New file.
* linux/xtensa/ioctlent.h.in: Likewise.
* process.c (struct_user_offsets): Add XTENSA support.
* signal.c (sys_sigreturn): Likewise.
* syscall.c (printcall, get_scno, get_syscall_args,
  get_syscall_result, get_error): Likewise.
* util.c (change_syscall): Likewise.

Signed-off-by: Chris Zankel <chris@zankel.net>
2013-03-25 17:58:57 +00:00
b787b10e16 Reorganize get_regs code, hopefully without functional changes
* syscall.c [I386 || ARM || OR1K || METAG] (ARCH_REGS_FOR_GETREGSET):
New macro.
(get_regset): Implement for AARCH64, METAG, OR1K and X32.
(get_regs) [AARCH64 || METAG || OR1K || X32]: Use it.
2013-03-18 12:01:21 +00:00
faa177e3d9 arm, i386: use PTRACE_GETREGSET if available
* syscall.c [ARM || I386 || X86_64] (get_regset): New function.
(get_regs) [ARM || I386 || X86_64]: Use it.
2013-03-18 12:00:57 +00:00
32c049a9d8 Include <sys/uio.h> and <elf.h> on all architectures
* syscall.c: Include <sys/uio.h> and <elf.h> on all architectures.
2013-03-18 11:59:37 +00:00
27e3ae973a x86-64: enhance PTRACE_GETREGSET test
* syscall.c (get_regs) [X86_64]: Check whether PTRACE_GETREGSET
works regardless of the kernel version.
2013-03-18 11:46:36 +00:00
ee348c6073 x32: use PTRACE_GETREGSET unconditionally
* syscall.c (get_regs) [X32]: Assume that PTRACE_GETREGSET always works
regardless of the kernel version.
2013-03-18 11:46:35 +00:00
0482c5a21d x86-64, x32: do not include linux/ptrace.h unnecessarily
* syscall.c [X86_64 || X32]: Stop including linux/ptrace.h.
2013-03-18 11:46:32 +00:00
Denys Vlasenko
aba6292797 Emit better message for ERESTARTNOHAND return
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-05 16:56:35 +01:00
James Hogan
5f999a869b Add support for Imagination Technologies Meta
Add support for Imagination Technologies Meta architecture (the
architecture/ABI is usually referred to as metag in code). The Meta
Linux kernel port is in the process of being upstreamed for v3.9 so it
uses generic system call numbers.

sys_lookup_dcookie writes a filename to buffer argument, so I've set
TF flag.
nfsservctl appears to be set to sys_ni_syscall in asm-generic/unistd.h
so I've left it blank.
truncate64/ftruncate64/pread64/pwrite64/readahead have unaligned 64bit
args which are packed tightly on metag, so less arguments on metag.
fchdir/llseek takes a file descriptor so s/TF/TD/
sync_file_range has 2 64bit args so uses 6 args, so s/4/6/
timerfd_create/msgget/msgctl/msgrcv/semget/segtimedop/semop/shmget/
shmctl/shmat/shmdt/recvmsg/migrate_pages have different number of args.
oldgetrlimit is just getrlimit for metag.
add TM flag to various memory syscalls.
metag doesn't directly use sys_mmap_pgoff for mmap2.
prlimit64/process_vm_readv/process_vm_writev take a pid so add TP flag.
fanotify_init doesn't appear to take a file descriptor so remove TD.
Add kcmp syscall.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Christian Svensson <blue@cmd.nu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-05 12:57:06 +01:00
7b9e45e891 Fix trace=set regression introduced by commit v4.7-111-g9cbc15b
* syscall.c (qual_syscall, qualify): Pass personality down to
qualify_one.
* tests/qual_syscall: New test.
* tests/Makefile.am (TESTS): Add qual_syscall.
2013-03-01 16:22:02 +00:00
e6f55240a1 Fix compilation errors uncovered by -Werror=enum-compare
This fixes regression introduced by commit v4.7-111-g9cbc15b.

* syscall.c: Merge all nsyscalls* enums into single enum.
Likewise merge nerrnos*, nsignals*, and nioctlents* into single enums.
2013-02-26 22:07:55 +00:00
Denys Vlasenko
905e8e0e2f Mass replace error_msg("%s", "literal") -> error_msg("literal")
There is no need to print literal strings through "%s".
Only untrusted strings such as filenames need that.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-26 12:30:09 +01:00
Denys Vlasenko
b43dacd6d1 Correct i > MAX_NSYSCALLS commparison: should be i >= MAX_NSYSCALLS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-23 18:19:28 +01:00
Denys Vlasenko
9cbc15b7e7 Eliminate MAX_QUALS, make qualifier array dynamic
MAX_QUALS was 2048, even though most arches used less than 500 entries
in it. MAX_QUALS had to be maintained by hand to be higher than syscall
count. It also limited the highest possible fd to track.

This change makes qual_flagsN[] arrays start sized to the required minimum
(number of syscalls) and grow dynamically if user requested
-e read=BIGNUM. As a precaution, BIGNUM should be < 2^15, but this limit
can be raised with no cost for normal strace invocations.

qual_flags is now a define to qual_vec[current_personality].

As a bonus, this patch aliases sysent, errnoent, signalent, ioctlent
names in one-personality arches to their corresponding <foo>0 arrays,
removing one indirection level.

  text   data    bss    dec    hex filename
244471    700  12928 258099  3f033 strace.t7/strace
244627    680  10860 256167  3e8a7 strace.t8/strace

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-22 13:37:36 +01:00