Commit Graph

422 Commits

Author SHA1 Message Date
15003d43d0 Fix build on systems where libc relies on <linux/signal.h>
Commit v4.23~10 has broken the build with Android's libc because it
relies on the UAPI headers (such as <linux/signal.h>) to define various
types, rather than copying them into the libc headers (such as <signal.h>)
like most other Linux C libraries.

* linux/linux/signal.h: Rename to linux/signal.h.in.
* Makefile.am (strace_SOURCES): Remove linux/linux/signal.h.
(EXTRA_DIST): Add linux/signal.h.in.
(DISTCLEANFILES): Add linux/linux/signal.h.
* configure.ac (AC_CACHE_CHECK): Check whether <linux/signal.h>
can be used along with <signal.h>, install linux/linux/signal.h
workaround if they cannot be used together.

Reported-by: Elliott Hughes <enh@google.com>
Closes: https://github.com/strace/strace/issues/72
2018-06-18 22:59:38 +00:00
Eugene Syromyatnikov
8f996fc157 Implement io_pgetevents syscall decoding
Introduced by Linux commit v4.17-rc3-7-g7a074e9.

* print_aio_sigset.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* aio.c (print_io_getevents): Rename from SYS_FUNC(io_getevents), add
has_usig flag, print user sigset on exiting if has_usig is set to true.
(SYS_FUNC(io_getevents), SYS_FUNC(io_pgetevents)): New functions,
wrappers for print_io_getevents.
* linux/32/syscallent.h ([292]): Wire up io_pgetevents.
* linux/64/syscallent.h ([292]): Likewise.
* linux/i386/syscallent.h ([385]): Likewise.
* linux/x32/syscallent.h ([333]): Likewise.
* linux/x86_64/syscallent.h ([333]): Likewise.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-13 16:18:38 +00:00
b27397a7d2 Workaround incompatibility between <linux/signal.h> and libc headers
Override <linux/signal.h> with <signal.h> so that those few linux
headers that include <linux/signal.h> could be included along with libc
headers.

* linux/linux/signal.h: New file.
* Makefile.am (strace_SOURCES): Add it.
2018-06-13 16:18:38 +00:00
Eugene Syromyatnikov
7adb5a2f9e Implement PERF_EVENT_IOC_* decoding
* perf.c (fetch_perf_event_attr, print_perf_event_attr): Remove "static"
qualifier.
* defs.h (fetch_perf_event_attr, print_perf_event_attr): New
declarations.
* perf_event_struct.h (struct perf_event_query_bpf): New type
definition.
* perf_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/perf_ioctl_cmds.in: New file.
* xlat/perf_ioctl_flags.in: Likewise.
* ioctl.c (ioctl_decode) <case '$'>: Call perf_ioctl.
* tests/gen_tests.in (ioctl_perf): New test.
* tests/ioctl_perf.c: New file.
* tests/pure_executables.list: ioctl_perf.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-28 17:34:50 +00:00
Eugene Syromyatnikov
07a4f1954a ioctl: implement INOTIFY_IOC_SETNEXTWD decoding
* inotify_ioctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (DECL_IOCTL(inotify)): New declaration.
* ioctl.c (ioctl_decode) <case 'I'>: Call inotify_ioctl.
* tests/ioctl_inotify.c: New file.
* tests/.gitignore: Add ioctl_inotify.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (ioctl_inotify): New test.
2018-05-25 09:15:03 +00:00
df9ddd8632 Simplify errnoent and signalent
Remove personality support for errnoent and signalent as
there is nothing personality-specific in these files.

* linux/aarch64/errnoent1.h: Remove.
* linux/aarch64/signalent1.h: Likewise.
* linux/powerpc64/errnoent1.h: Likewise.
* linux/powerpc64/signalent1.h: Likewise.
* linux/riscv/errnoent1.h: Likewise.
* linux/riscv/signalent1.h: Likewise.
* linux/s390x/errnoent1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/sparc64/errnoent1.h: Likewise.
* linux/sparc64/signalent1.h: Likewise.
* linux/tile/errnoent1.h: Likewise.
* linux/tile/signalent1.h: Likewise.
* linux/x32/errnoent1.h: Likewise.
* linux/x32/signalent1.h: Likewise.
* linux/x86_64/errnoent1.h: Likewise.
* linux/x86_64/errnoent2.h: Likewise.
* linux/x86_64/signalent1.h: Likewise.
* linux/x86_64/signalent2.h: Likewise.
* Makefile.am (EXTRA_DIST): Remove them.
* defs.h (errnoent0): Rename to errnoent.
(signalent0): Rename signalent.
(nerrnos, nsignals): Change to const variables unconditionally.
* syscall.c (errnoent0): Rename to errnoent.
(signalent0): Rename signalent.
(nerrnos, nsignals): Change to const variables unconditionally.
(nerrnos0, nsignals0): Remove.
[SUPPORTED_PERSONALITIES > 1] (errnoent1, signalent1, nerrnos1,
nsignals1): Remove.
[SUPPORTED_PERSONALITIES > 2] (errnoent2, signalent2, nerrnos2,
nsignals2): Likewise.
(set_personality): Do not assign errnoent, signalent, nerrnos,
and nsignals.
2018-05-22 01:08:31 +00:00
Eugene Syromyatnikov
dc7901f5c3 Add a common MAC address printing routine
* print_mac.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (sprint_mac_addr): New declaration.
(print_mac_addr): New function, a thin wrapper around sprint_mac_addr.
* print_fields.h (PRINT_FIELD_MAC, PRINT_FIELD_MAC_SZ): New macros.
* rtnl_link.c (decode_ifla_bridge_id): Use PRINT_FIELD_MAC for bridge
address printing.
* sock.c (print_ifreq) <case SIOCGIFHWADDR>: Use print_mac_addr for
ifr_hwaddr printing.
* sockaddr.c (print_sockaddr_data_bt): Use print_mac_addr for
{sco,rc,l2}_bdaddr field printing.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-15 21:41:47 +00:00
1d98b287a4 mmap_cache: do not activate unless requested
Do not call mmap_cache functions until mmap_cache_enable is invoked.
Change struct mmap_cache_t into a proxy structure, move all mmap_cache
data from struct tcb inside this new structure.

* Makefile.am (strace_SOURCES): Move mmap_cache.c and mmap_cache.h
to libstrace_a_SOURCES.
* defs.h (struct tcb): Remove mmap_cache_size and mmap_cache_generation
* fields.
* mmap_cache.h (struct mmap_cache_t): Rename
to struct mmap_cache_entry_t, create a new struct mmap_cache_t,
all users updated.
(mmap_cache_delete): Remove.
* mmap_cache.c (mmap_cache_delete): Rename to delete_mmap_cache,
add static qualifier.
(build_mmap_cache): Merge into mmap_cache_rebuild_if_invalid.
* strace.c (droptcb): Replace mmap_cache_delete invocation
with tcp->mmap_cache->free_fn.
2018-05-04 14:45:44 +00:00
Masatake YAMATO
f17f7e6305 mmap_notify: new subsystem for tracking the changes of memory mappings
This subsystem is a spin-off of the mmap_cache subsystem.

The mmap_cache subsystem had two features: (1) tracking the change
of memory mapping, and (2) maintaining the cache of memory mapping.

mmap_notify is a subsystem specialized to provide feature (2).
unwind-libdw itself has the feature (1).  It needs only (2).

* mmap_notify.h: New file.
* mmap_notify.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-05-03 22:01:30 +00:00
f904486a28 Introduce f_owner_ex.h
Some headers define struct f_owner_ex, some struct __kernel_f_owner_ex,
we have to support both variants.

* configure.ac (AC_CHECK_TYPES): Check for "struct f_owner_ex"
and "struct __kernel_f_owner_ex" in <linux/fcntl.h>.
* f_owner_ex.h: New file.
* Makefile.am (strace_SOURCES): Add it.
2018-05-03 00:09:53 +00:00
fc8294cbc2 build: make it even more reproducible
* Makefile.am (today): Consistently print the UTC date in C locale.
* configure.ac (RPM_CHANGELOGTIME, DEB_CHANGELOGTIME): Likewise.
* maint/update_copyright_years.sh: Likewise.
* copyright-year-gen: Likewise.  When $SOURCE_DATE_EPOCH is non-empty,
use it as fallback date before the current system date.

References: https://github.com/strace/strace/pull/68
2018-04-20 13:15:38 +00:00
Masatake YAMATO
ddb5a4ba73 unwind: add libdw as an unwinder
Implement alternative libdw-based unwinder for stack tracing.
Add --with-libdw configure option to control whether libdw can be used
as an unwinder.

* m4/st_libdw.m4: New file.
* m4/st_stacktrace.m4 (st_STACKTRACE): Invoke st_ARG_LIBDW and st_LIBDW,
check for mutually exclusive configure options,
(AM_CONDITIONAL): Add USE_LIBDW.
* unwind-libdw.c: New file.
* Makefile.am [USE_LIBDW] (strace_SOURCES): Append unwind-libdw.c.
[USE_LIBDW] (strace_CPPFLAGS): Append $(libdw_CPPFLAGS).
[USE_LIBDW] (strace_CFLAGS): Append $(libdw_CFLAGS).
[USE_LIBDW] (strace_LDFLAGS): Append $(libdw_LDFLAGS).
[USE_LIBDW] (strace_LDADD): Append $(libdw_LIBS).
* NEWS: Mention this improvement.

Closes: https://github.com/strace/strace/issues/12
Closes: https://github.com/strace/strace/issues/13
Co-Authored-by: Mark Wielaard <mjw@redhat.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-04-11 22:01:37 +00:00
Harsha Sharma
c9694f85ed netlink: decode libudev netlink header
* defs.h (decode_netlink_kobject_uevent): New prototype.
* netlink.c (decode_netlink): Decode family kobject_uevent.
* netlink_kobject_uevent.h: New file.
* netlink_kobject_uevent.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
2018-04-11 22:01:37 +00:00
2713444cb7 unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether
-k option support is compiled in, --with-libunwind option remains
available to control whether libunwind can be used as an unwinder.

* m4/st_demangle.m4: New file.
* m4/st_libunwind.m4: Likewise.
* m4/st_stacktrace.m4: Likewise.
* configure.ac: Replace all libunwind and libiberty checks
with a single st_STACKTRACE invocation.
* Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE
on ENABLE_STACKTRACE.
[ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h.
* strace.1.in: Replace libunwind with an unwinder-agnostic wording.
* defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* strace.c: Likewise.
(print_version): Print stack-trace instead of stack-unwind.
* syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* tests/Makefile.am: Likewise.  Replace LIBUNWIND_TESTS
with STACKTRACE_TESTS.
* tests/strace-V.test: Update expected output.
2018-04-08 22:01:12 +00:00
Masatake YAMATO
dd7e62f1e7 unwind: split unwind code into front-end and back-end
This opens the way for alternative unwinder back-ends.

* unwind.h: New file, defines the unwinder back-end interface.
* unwind.c: Move all libunwind related code ...
* unwind-libunwind.c: ... here.
* Makefile.am [USE_LIBUNWIND] (strace_SOURCES): Add unwind.h
and unwind-libunwind.c.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-05 01:40:00 +00:00
1802fe1ea6 Check that structures defined by bpf_attr.h match system union bpf_attr
* gen_bpf_attr_check.sh: New file.
* Makefile.am (EXTRA_DIST): Add it.
(strace_SOURCES_check): New variable.
(strace_SOURCES): Add $(strace_SOURCES_check).
(BUILT_SOURCES, CLEANFILES): Add bpf_attr_check.c.
(bpf_attr_check.c): New rule.
(sys_func_h_sources): New variable.
(sys_func.h): Use it instead of strace_SOURCES_c.
* .gitignore: Add /bpf_attr_check.c.
2018-04-04 12:24:19 +00:00
b93c952ba5 bpf: move definitions of bpf_attr structures to separate header file
This also unifies decoders of bpf commands by moving common code
to new macros.

* bpf_attr.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* bpf.c: Include it.
(DEF_BPF_CMD_DECODER): Rename to BEGIN_BPF_CMD_DECODER, add code common
to all decoders.  All users updated.
(END_BPF_CMD_DECODER): New macro, add its invocation to all users
of BEGIN_BPF_CMD_DECODER macro.
2018-04-04 12:24:19 +00:00
a781408bd4 Introduce static_assert
We are going to use static_assert provided by <assert.h> or,
if it doesn't work, our cheap imitation that doesn't display
the message specified as the second argument of static_assert.

* configure.ac (AC_CACHE_CHECK): Check for static_assert in <assert.h>,
define HAVE_STATIC_ASSERT if it is available.
* static_assert.h: New file.
* Makefile.am (strace_SOURCES): Add it.
2018-04-04 12:24:19 +00:00
6905f5d2bf Move delay interface from defs.h to delay.h
* defs.h (alloc_delay_data, fill_delay_data, is_delay_timer_armed,
delay_timer_expired, arm_delay_timer, delay_tcb): Move...
* delay.h: ... to new file.
* Makefile.am (strace_SOURCES): Add it.
* filter_qualify.c: Include it.
* strace.c: Likewise.
* syscall.c: Likewise.
2018-03-28 04:29:22 +00:00
33c725f817 Turn struct inject_data.rval into an index
Add one level of indirection to decrease the size of struct inject_data
as hundreds of these structures are created for each process when
injection mechanism is activated.

* retval.h: New file.
* retval.c: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* defs.h (struct inject_data): Replace rval field with rval_idx.
* filter_qualify.c: Include "retval.h".
(parse_inject_token, qualify_inject_common): Initialize
struct inject_data.rval_idx using retval_new.
* syscall.c: Include "retval.h".
(tamper_with_syscall_exiting): Obtain the value that has to be injected
using retval_get.
2018-03-28 04:29:22 +00:00
Eugene Syromyatnikov
b46d5b8caf sparc, sparc64: implement kern_features decoder
* sparc.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
* linux/sparc/syscallent.h ([340]): Remove NF flag, set kern_features
decoder.
* linux/sparc64/syscallent.h ([340]): Likewise.
* xlat/sparc_kern_features.in: New file.
* NEWS: Mention this enhancement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-27 22:22:23 +00:00
dfc59e7061 evdev: move mpers-specific parsers to a separate file
This change reduces binary code duplication on mpers platforms
and prepares evdev parsers to use printxval_bsearch.

* defs.h (evdev_ioctl, print_evdev_ff_type): New prototypes.
* evdev.c (evdev_ioctl): Un-mpersify.
(evdev_write_ioctl) Remove EVIOCSFF case, forward default case
to evdev_write_ioctl_mpers.
(decode_envelope, ff_effect_ioctl): Move to...
* evdev_mpers.c: ... new file.
* Makefile.am (strace_SOURCES): Add evdev_mpers.c.
2018-03-27 01:57:00 +00:00
dcfb3c0d47 Introduce raw syscall invocation wrappers
Unfortunately, syscall(3) provided by libc is too smart
for some of our needs.

* linux/raw_syscall.h: New file.
* linux/aarch64/raw_syscall.h: Likewise.
* linux/alpha/raw_syscall.h: Likewise.
* linux/arc/raw_syscall.h: Likewise.
* linux/arm/raw_syscall.h: Likewise.
* linux/avr32/raw_syscall.h: Likewise.
* linux/bfin/raw_syscall.h: Likewise.
* linux/hppa/raw_syscall.h: Likewise.
* linux/i386/raw_syscall.h: Likewise.
* linux/ia64/raw_syscall.h: Likewise.
* linux/m68k/raw_syscall.h: Likewise.
* linux/metag/raw_syscall.h: Likewise.
* linux/microblaze/raw_syscall.h: Likewise.
* linux/mips/raw_syscall.h: Likewise.
* linux/nios2/raw_syscall.h: Likewise.
* linux/or1k/raw_syscall.h: Likewise.
* linux/powerpc/raw_syscall.h: Likewise.
* linux/powerpc64/raw_syscall.h: Likewise.
* linux/riscv/raw_syscall.h: Likewise.
* linux/s390/raw_syscall.h: Likewise.
* linux/s390x/raw_syscall.h: Likewise.
* linux/sh/raw_syscall.h: Likewise.
* linux/sh64/raw_syscall.h: Likewise.
* linux/sparc/raw_syscall.h: Likewise.
* linux/sparc64/raw_syscall.h: Likewise.
* linux/tile/raw_syscall.h: Likewise.
* linux/x32/raw_syscall.h: Likewise.
* linux/x86_64/raw_syscall.h: Likewise.
* linux/xtensa/raw_syscall.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
2018-03-23 13:43:13 +00:00
Elvira Khabirova
ba8e768a80 Implement delay injection
Add -e inject=SET:delay_enter= and -e inject=SET:delay_exit= options.

* configure.ac (AC_SEARCH_LIBS): Check for timer_create -lrt.
* delay.c: New file.
* Makefile.am (strace_SOURCES): Add it.
(strace_LDADD): Add $(timer_LIBS).
* defs.h (INJECT_F_DELAY_ENTER, INJECT_F_DELAY_EXIT,
TCB_INJECT_DELAY_EXIT, TCB_DELAYED, inject_delay_exit, syscall_delayed):
New macros.
(alloc_delay_data, fill_delay_data, is_delay_timer_created,
arm_delay_timer, delay_tcb): New prototypes.
(struct inject_data): Replace reserved field with delay_idx.
(struct tcb): Add delay_expiration_time field.
* filter_qualify.c (parse_delay_token): New function.
(parse_inject_token): Use it.
(qualify_inject_common): Initialize struct inject_opts.data.delay_idx.
* strace.c: Include <setjmp.h>
(timer_jmp_buf, timer_set): New static variables.
(timer_sighandler, restart_delayed_tcb, restart_delayed_tcbs): New
functions.
(init): Block SIGALRM, set SIGALRM handler.
(dispatch_event): Do not restart delayed syscalls.
(next_event): Unblock SIGALRM during wait4 invocation.
* syscall.c (tamper_with_syscall_entering): Arm delay timer if
INJECT_F_DELAY_ENTER injection flag is set, set TCB_INJECT_DELAY_EXIT
flag if INJECT_F_DELAY_EXIT injection flag is set.
tamper_with_syscall_exiting): Arm delay timer if inject_delay_exit.
(syscall_exiting_trace): Call tamper_with_syscall_exiting in case of
inject_delay_exit.
(syscall_exiting_finish): Clear TCB_INJECT_DELAY_EXIT flag.
* strace.1.in: Document delay injection.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-22 06:23:25 +00:00
17935497e2 Replace struct timeval with struct timespec in time measurements
This is required to implement more precise time measurements.

* Makefile.am (strace_LDADD): Add $(clock_LIBS).
* defs.h (struct tcb): Change the type of stime, dtime, and etime fields
from struct timeval to struct timespec, all users updated.
(syscall_exiting_decode, syscall_exiting_trace, count_syscall): Change
the type of "struct timeval *" argument to "struct timespec *", all
users updated.
(tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul): Rename to
ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.  Change
the type of all "struct timeval *" arguments to "struct timespec *",
all users updated.
* util.c (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul):
Rename to ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.
Change the type of all "struct timeval *" arguments to "struct timespec *".
* count.c (struct call_counts): Change the type of "time" field
from struct timeval to struct timespec, all users updated.
(overhead): Change type from struct timeval to struct timespec, all
users updated.
(count_syscall): Change the type of "struct timeval *" argument to
"struct timespec *".
* strace.c (printleader): Change the type of struct timeval variables
to struct timespec, call clock_gettime instead of gettimeofday.
(next_event, trace_syscall): Change the type of struct timeval variables
to struct timespec.
* syscall.c (syscall_entering_finish, syscall_exiting_decode): Call
clock_gettime instead of gettimeofday.
2018-03-20 02:30:24 +00:00
Chen Jingpiao
106731a96c netlink: introduce NETLINK_NETFILTER parser
* netlink_netfilter.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_netfilter): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_NETFILTER.
* xlat/netfilter_versions.in: New file.
2018-03-11 14:49:25 +00:00
bbeee0be62 Introduce mmap_cache.h
Let's avoid bloating defs.h and introduce a separate header for
mmap_cache.

* defs.h (struct mmap_cache_t, enum mmap_cache_protection,
enum mmap_cache_rebuild_result, mmap_cache_enable, mmap_cache_is_enabled,
mmap_cache_invalidate, mmap_cache_delete, mmap_cache_rebuild_if_invalid,
mmap_cache_search): Move ...
* mmap_cache.h: ... to this new file.
* Makefile.am (strace_SOURCES): Add mmap_cache.h.
* mmap_cache.c: Include mmap_cache.h.
* strace.c: Likewise.
* syscall.c: Likewise.
* unwind.c: Likewise.
2018-02-26 23:22:24 +00:00
Masatake YAMATO
8fd4ef9bef mmap_cache: new subsystem derived from unwind.c
For making mmap cache code reusable from other areas in strace than
unwind, mmap cache related code and unwind related code should be
separated.

This change moves the most of mmap cache code from unwind.c
to mmap_cache.c, a new file.

* unwind.c: Move mmap_cache implementation ...
* mmap_cache.c: ... to this new file.
* Makefile.am (strace_SOURCES): add mmap_cache.c.
* defs.h (struct tcb): Move mmap_cache, mmap_cache_size, and
mmap_cache_generation fields out of [USE_LIBUNWIND] condition.
(mmap_cache_invalidate, mmap_cache_delete,
mmap_cache_rebuild_if_invalid): New function prototypes.
(struct mmap_cache_t, enum mmap_cache_rebuild_result): Move from
unwind.c.
* syscall.c (syscall_exiting_decode): Replace unwind_cache_invalidate
with mmap_cache_invalidate.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00
daaf8ab7fe Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-02-13 22:00:00 +00:00
Eugene Syromyatnikov
3e97bf63fc Remove old and unused maintenance scripts
Firewell, last witnesses of bygone era.

* linux/sparc/gen.pl: Remove.
* linux/x86_64/gentab.pl: Likewise.
* xlate.el: Likewise.
* Makefile.am (EXTRA_DIST): Remove them.

Suggested-by: Elvira Khabirova <lineprinter@altlinux.org>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-02-13 21:36:08 +00:00
Eugene Syromyatnikov
b06199a8b9 Mark architectures that indicate syscall error in a dedicated register
* linux/alpha/arch_defs_.h (HAVE_ARCH_DEDICATED_ERR_REG): New macro,
define to 1.
* linux/ia64/arch_defs_.h: Likewise.
* linux/mips/arch_defs_.h: Likewise.
* linux/powerpc/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/arch_defs_.h [!HAVE_ARCH_DEDICATED_ERR_REG]
(HAVE_ARCH_DEDICATED_ERR_REG): New macro, define to 0.
* linux/nios2/arch_defs_.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
2018-02-10 02:15:35 +00:00
Eugene Syromyatnikov
7b6e926641 Handle very special __ARM_NR_-prefixed syscalls
* linux/aarch64/nr_prefix.c: New file.
* linux/arm/nr_prefix.c: Likewise.
* linux/nr_prefix.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* printsiginfo.c: Include nr_prefix.c
(print_si_info): Use nr_prefix.
2018-02-10 00:01:01 +00:00
Eugene Syromyatnikov
0f60aba412 Use shuffle_scno for x32 syscall numbers
This changes behaviour of printing of unknown syscall.

* linux/x32/shuffle_scno.c: New file.
* linux/x86_64/shuffle_scno.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* linux/x86_64/get_scno.c (arch_get_scno): Do not clear
__X32_SYSCALL_BIT.
* tests/nsyscalls.c: Update expected output.
2018-02-09 22:11:50 +00:00
Eugene Syromyatnikov
c2c35ae227 Move shuffle_scno to arch-specific file
While we are here, let's fix AArch64 by limiting scno shuffling
to compat personality only.

* syscall.c: Include shuffle_scno.c.
(shuffle_scno): Move it to a...
* linux/arm/shuffle_scno.c: New file.
* linux/aarch64/shuffle_scno.c: New file, define arm's shuffle_scno
as arm_shuffle_scno and call it only for personality 1.
* linux/shuffle_scno.c: New file, fallback trivial shuffle_scno
definition.
* Makefile.am (EXTRA_DIST): Add them.
2018-02-09 22:11:50 +00:00
Eugene Syromyatnikov
1f77138867 Makefile.am: minor EXTRA_DIST formatting changes 2018-02-06 02:56:14 +01:00
Eugene Syromyatnikov
eae4643b0f Move large file-related wrappers to a separate header
* strace.c [_LARGEFILE64_SOURCE]: Move the definitions under it to a...
* largefile_wrappers.h: ... new file.
* Makefile.am (strace_SOURCES): Add it.
2018-02-06 02:56:14 +01:00
Eugene Syromyatnikov
876e77a785 Introduce s390_sthyi system call decoder
* s390.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/s390/syscallent.h ([380]): Change decoder to s390_sthyi.
* linux/s390x/syscallent.h: Likewise.
* xlat/s390_sthyi_function_codes.in: New file.
2018-01-29 14:10:10 +01:00
832e2ac13e Drop non-functional CRIS architecture support
From the very first commit when CRIS architecture support was introduced
and up to this comment that ends the agony of this non-functional code,
this support was incomplete and could never be compiled.

* Makefile.am (EXTRA_DIST): Remove linux/crisv*.
* clone.c: Remove CRISV* checks.
* configure.ac ($host_cpu == cris*): Remove.
* linux/crisv10: Remove.
* linux/crisv32: Likewise.

Fixes: v4.5.18-77-gea0e6e8 ("CRIS support by Hinko Kocevar ...")
2018-01-25 01:55:08 +00:00
Eugene Syromyatnikov
5b5e9a7620 Implement decoding of riscv_flush_icache syscall
* linux/riscv/syscallent.h ([259]): Add riscv_flush_icache entry.
* riscv.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/riscv_flush_icache_flags.in: New file.
* NEWS: Mention it.
2018-01-25 01:55:08 +00:00
7494f63faa Rework decoding and pathtrace of old select syscall
* linux/arch_defs_.h [!HAVE_ARCH_OLD_SELECT] (HAVE_ARCH_OLD_SELECT): New
macro.
* linux/aarch64/arch_defs_.h (HAVE_ARCH_OLD_SELECT): Likewise.
* linux/arm/arch_defs_.h: Likewise.
* linux/bfin/arch_defs_.h: Likewise.
* linux/i386/arch_defs_.h: Likewise.
* linux/m68k/arch_defs_.h: Likewise.
* linux/microblaze/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/powerpc/arch_defs_.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* desc.c (SYS_FUNC(oldselect)): Rewrite using
fetch_indirect_syscall_args, move under [HAVE_ARCH_OLD_SELECT].
* pathtrace.c (match_xselect_args): New function.
(pathtrace_match_set): Use it.
2018-01-23 23:17:02 +00:00
f03d67cfd9 Transform fetch_old_mmap_args into fetch_indirect_syscall_args
As there are more than one old style syscall that take their arguments
via array, generalize fetch_old_mmap_args into a function that could
fetch variable number of arguments.

* mem.c (fetch_old_mmap_args): Transform into ...
* fetch_indirect_syscall_args.c: ... fetch_indirect_syscall_args
in this new file.
* Makefile.am (libstrace_a_SOURCES): Add it.
* defs.h [HAVE_ARCH_OLD_MMAP] (fetch_old_mmap_args): Remove.
(fetch_indirect_syscall_args): New prototype.
* pathtrace.c (pathtrace_match_set) [HAVE_ARCH_OLD_MMAP]: Use
fetch_indirect_syscall_args instead of fetch_old_mmap_args.
2018-01-23 23:17:02 +00:00
af955678b9 Move decoder of getpagesize syscall to libstrace
As only five architectures have getpagesize syscall, moving the decoder
to libstrace allows to get rid of getpagesize related ifdefs and check
build of getpagesize decoder on other architectures.

* mem.c (SYS_FUNC(getpagesize)): Move ...
* getpagesize.c: ... to this new file.
* Makefile.am (libstrace_a_SOURCES): Add it.
2018-01-21 20:19:53 +00:00
Eugene Syromyatnikov
ac8241cd4f Move definition of personality macros to arch_defs_.h
* supported_personalities.h: Remove.
* defs.h: Do not include it.
* linux/arch_defs_.h [!DEFAULT_PERSONALITY] (DEFAULT_PERSONALITY): New
macro.
[!SUPPORTED_PERSONALITIES] (SUPPORTED_PERSONALITIES): Likewise.
* linux/aarch64/arch_defs_.h (SUPPORTED_PERSONALITIES): New macro.
* linux/riscv/arch_defs_.h: Likewise.
* linux/s390x/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: New file.
* linux/tile/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
(strace_SOURCES): Remove supported_personalities.h.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-01-21 01:46:04 +00:00
Eugene Syromyatnikov
bf23036873 Introduce HAVE_ARCH_SA_RESTORER
In order to simplify HAVE_SA_RESTORER logic a bit.

* linux/ia64/arch_defs_.h (HAVE_ARCH_SA_RESTORER): New macro.
* linux/m68k/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/hppa/arch_defs_.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* signal.c [HAVE_ARCH_SA_RESTORER]: Define HAVE_SA_RESTORER to it.
[!HAVE_ARCH_SA_RESTORER && SA_RESTORER]: Define HAVE_SA_RESTORER to 1.
[!HAVE_ARCH_SA_RESTORER && !SA_RESTORER]: Define HAVE_SA_RESTORER to 0.
2018-01-21 01:46:04 +00:00
2880a927a6 Replace NEED_UID16_PARSERS with HAVE_ARCH_UID16_SYSCALLS
* linux/arch_defs_.h [!HAVE_ARCH_UID16_SYSCALLS]
(HAVE_ARCH_UID16_SYSCALLS): New macro.
* linux/aarch64/arch_defs_.h (HAVE_ARCH_UID16_SYSCALLS): New macro.
* linux/arm/arch_defs_.h: Likewise.
* linux/i386/arch_defs_.h: Likewise.
* linux/ia64/arch_defs_.h: Likewise.
* linux/m68k/arch_defs_.h: Likewise.
* linux/s390/arch_defs_.h: Likewise.
* linux/s390x/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* linux/syscall.h: Likewise.
* linux/x32/arch_defs_.h: Likewise.
* linux/x86_64/arch_defs_.h: Likewise.
* linux/bfin/arch_defs_.h: New file.
* linux/microblaze/arch_defs_.h: Likewise.
* linux/riscv/arch_defs_.h: Likewise.
* linux/sh64/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h (NEED_UID16_PARSERS): Remove.
* linux/syscall.h: Check for HAVE_ARCH_UID16_SYSCALLS instead of
NEED_UID16_PARSERS.
* uid.c: Likewise.
2018-01-21 01:46:04 +00:00
a9b7fb4f73 Replace HAVE_GETRVAL2 with HAVE_ARCH_GETRVAL2
* linux/arch_defs_.h [!HAVE_ARCH_GETRVAL2] (HAVE_ARCH_GETRVAL2): New
macro.
* linux/alpha/arch_defs_.h: New file.
* linux/ia64/arch_defs_.h: Likewise.
* linux/mips/arch_defs_.h: Likewise.
* linux/sh/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
* linux/sparc64/arch_defs_.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h (HAVE_GETRVAL2): Remove.
(getrval2): Check for HAVE_ARCH_GETRVAL2 instead of arch checks.
* net.c (SYS_FUNC(pipe)): Check for HAVE_ARCH_GETRVAL2 instead of
HAVE_GETRVAL2.
* syscall.c: Likewise.
2018-01-21 01:46:04 +00:00
8baf8f4a37 Rename arch-specific arch_defs.h files to arch_defs_.h
Introduce a new arch_defs.h header that includes the corresponding
arch-specific arch_defs_.h file followed by generic arch_defs_.h file.

* linux/arch_defs.h: Rename to linux/arch_defs_.h.
* linux/aarch64/arch_defs.h: Rename to linux/aarch64/arch_defs_.h.
* linux/arm/arch_defs.h: Rename to linux/arm/arch_defs_.h.
* linux/i386/arch_defs.h: Rename to linux/i386/arch_defs_.h.
* linux/m68k/arch_defs.h: Rename to linux/m68k/arch_defs_.h.
* linux/s390/arch_defs.h: Rename to linux/s390/arch_defs_.h.
* linux/s390x/arch_defs.h: Rename to linux/s390x/arch_defs_.h.
* linux/x32/arch_defs.h: Rename to linux/x32/arch_defs_.h.
* linux/x86_64/arch_defs.h: Rename to linux/x86_64/arch_defs_.h.
* arch_defs.h: New file.
* Makefile.am (strace_SOURCES): Add it.
(EXTRA_DIST): Rename linux/*/arch_defs.h to linux/*/arch_defs_.h.
2018-01-21 01:46:04 +00:00
Eugene Syromyatnikov
d9f6166f0c Add compat support for s390x
By very popular demand.

While we are here, let's refactor the condition for old_mmap_pgoff into
an arch-specific one, as it is used more than in one place.

* NEWS: Mention this.
* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Likewise.
* configure.ac (case "$host_cpu" in) <s390x>: Set arch_m32 to s390, set
cc_flags_m32 to -m31.
(st_MPERS([m32])): Add s390x.
* defs.h [S390X]: Define NEED_UID16_PARSERS.
* linux/s390/arch_sigreturn.c [!S390_FRAME_PTR] (S390_FRAME_PTR): New
macro, define to s390_frame_ptr.
[!SIGNAL_FRAMESIZE] (SIGNAL_FRAMESIZE): New macro, define to
__SIGNAL_FRAMESIZE.
[!PTR_TYPE] (PTR_TYPE): New macro, define to unsigned long.
(arch_sigreturn): Use S390_FRAME_PTR, SIGNAL_FRAMESIZE, and PTR_TYPE
instead of s390_frame_ptr, __SIGNAL_FRAMESIZE, and pointer-sized type,
respectively.
* linux/s390/get_error.c [!ARCH_REGSET] (ARCH_REGSET): New macro, define
* to s390_regset.
(get_error): Use it instead of s390_regset.
* linux/s390/get_scno.c (arch_get_scno): Likewise.
* linux/s390/get_syscall_args.c (get_syscall_args): Likewise.
* linux/s390/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/s390x/arch_regs.c (psw_compat_t, s390_compat_regs,
s390x_regs_union, s390_frame_ptr, s390x_frame_ptr, s390x_io): New
variables.
(s390_regset, s390x_regset, ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET, ARCH_PC_REG, ARCH_PERSONALITY_0_IOV_SIZE,
ARCH_PERSONALITY_1_IOV_SIZE): New macros.
* linux/s390x/arch_regs.h (s390_frame_ptr, s390x_frame_ptr): New
prototypes.
* linux/s390x/arch_rt_sigframe.c: Conditionalize on tcp->currpers.
* linux/s390x/arch_sigreturn.c: Likewise.
* linux/s390x/get_error.c: Likewise.
* linux/s390x/get_scno.c: Likewise.
* linux/s390x/get_syscall_args.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/s390x/errnoent1.h: New file.
* linux/s390x/ioctls_arch1.h: Likewise.
* linux/s390x/ioctls_inc1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/s390x/syscallent1.h: Likewise.
* Makefile.am (EXTRA_DIST): Add new files added to linux/s390x.
* supported_personalities.h [S390X] (SUPPORTED_PERSONALITIES): Define
to 2.
* tests/strace-V.test: Add s390 to the list of architectures that have
m32 personality.
* linux/s390/arch_defs.h (HAVE_ARCH_OLD_MMAP_PGOFF): New macro.
* linux/s390x/arch_defs.h: Likewise.
* mem.c: Replace #ifdef S390 with #ifdef HAVE_ARCH_OLD_MMAP_PGOFF.
* pathtrace.c: Likewise.
2018-01-19 02:04:37 +01:00
Eugene Syromyatnikov
408ce203da Introduce arch-specific define HAVE_ARCH_OLD_MMAP
* linux/arch_defs.h: New file.
* linux/aarch64/arch_defs.h: New file.  Define HAVE_ARCH_OLD_MMAP.
* linux/arm/arch_defs.h: Likewise.
* linux/i386/arch_defs.h: Likewise.
* linux/m68k/arch_defs.h: Likewise.
* linux/s390/arch_defs.h: Likewise.
* linux/s390x/arch_defs.h: Likewise.
* linux/x32/arch_defs.h: Likewise.
* linux/x86_64/arch_defs.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h: Include "arch_defs.h"
* mem.c: Replace condition for SYS_FUNC(old_mmap) with #ifdef
HAVE_ARCH_OLD_MMAP.

Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
2018-01-17 04:34:49 +00:00
Eugene Syromyatnikov
558ece68c8 Add support for specifying compiler options for mpers builds
Because some architectures are very, very special.

* configure.ac (cc_flags_m32, cc_flags_mx32): New variables. AC_SUBST
them.
* m4/mpers.m4 (MPERS_CFLAGS): Use instead of CFLAG, pushdef as
$cc_flags_$1.
Use mpers_name instead of CFLAG in AC_CACHE_CHECK messages.
Pass MPERS_CFLAGS as the second argument to mpers_test.sh
* mpers.sh: Add CC_ARCH_FLAGS as the second argument (PARSER_FILE
is moved to the third one). Do not expect leading dash in ARCH_FLAG
anymore.
* mpers_test.sh (mpers_cc_flags): New variable, initialise to the second
command line argument.
Pass $mpers_name without leading dash to mpers.sh.
Pass $mpers_cc_flags as the second argument to mpers.sh ($sample is
the third argument now).
* Makefile.am (mpers-m%.stamp:): Pass $(mpers_CC_FLAGS) as the second
argument to mpers.sh ($$f is now the third argument).
($(mpers_m32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_m32@
($(mpers_mx32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_mx32@
* tests/Makefile.am (MERS_CC_FLAGS): New variable.
* bootstrap: Append @cc_flags_$1@ to MPERS_CC_FLAGS. Append
$(MPERS_CC_FLAGS) to ARCH_MFLAGS.
2018-01-16 23:02:35 +01:00