Commit Graph

389 Commits

Author SHA1 Message Date
b93d52fe3d Change the license of strace to LGPL-2.1-or-later
strace is now provided under the terms of the GNU Lesser General
Public License version 2.1 or later, see COPYING for more details.

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.
2018-12-10 00:00:00 +00:00
Eugene Syromyatnikov
b4b01268bb Remove HAVE_LINUX_GENETLINK_H ifdefs
<linux/netlink.h> is available since Linux 2.6.15 (commit
v2.6.15-rc1~53^2).

* configure.ac (AC_CHECK_HEADERS): Remove linux/genetlink.h.
* socketutils.c [!HAVE_LINUX_GENETLINK_H]: Remove.
* tests/netlink_generic.c [!HAVE_LINUX_GENETLINK_H]: Likewise.
2018-11-24 01:22:13 +00:00
Eugene Syromyatnikov
9b5d56054c Decode BLKGETSIZE64 unconditionally
It is available on all supported kernel versions.

* block.c (block_ioctl): Remove #ifdef HAVE_BLKGETSIZE64.
* configure.ac: Remove BLKGETSIZE64 check.
2018-09-01 14:38:12 +00:00
Eugene Syromyatnikov
197014937c s390x: fix build with old kernel headers
Avoid defining psw_compat_t and s390_compat_regs if their definitions
are provided by kernel.  Before Linux commit v3.10-rc1~201^2~11,
these definition were available in <asm/ptrace.h>.

* configure.ac (AC_CHECK_TYPES): Check for s390_compat_regs.
* linux/s390x/arch_regs.c [HAVE_S390_COMPAT_REGS]: Do not define
psw_compat_t and s390_compat_regs.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-08-05 11:49:04 +00:00
Pierre Marsais
546181b267 kvm: decode the argument of KVM_SET_CPUID2 and KVM_GET_*_CPUID ioctl commands
* configure.ac (AC_CHECK_TYPES): Add struct kvm_cpuid2.
* xlat/kvm_cpuid_flags.in: New file.
* kvm.c [HAVE_STRUCT_KVM_CPUID2]: Include "xlat/kvm_cpuid_flags.h".
[HAVE_STRUCT_KVM_CPUID2] (print_kvm_cpuid_entry, kvm_ioctl_decode_cpuid2):
New functions.
(kvm_ioctl) [HAVE_STRUCT_KVM_CPUID2]: Use kvm_ioctl_decode_cpuid2.
* NEWS: Mention this improvement.

Signed-off-by: Pierre Marsais <pierre.marsais@lse.epita.fr>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-07-07 10:29:02 +00:00
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
2cc81216cb tests: check decoding of io_pgetevents syscall
* configure.ac (AC_CHECK_TYPES): Check for struct __aio_sigset
in <linux/aio_abi.h>.
* tests/aio_pgetevents.c: New file.
* tests/.gitignore: Add aio_pgetevents.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (aio_pgetevents): New test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-13 16:18:38 +00:00
e3e4a524a1 configure.ac: fix the check for struct tc_sizespec on old kernel headers
* configure.ac (AC_CHECK_TYPES): Include <linux/types.h> before
<linux/pkt_sched.h> to check for struct tc_sizespec on linux kernel
headers without v2.6.29-rc4~77^2~26 fix.
2018-06-07 14:01:24 +00:00
Eugene Syromyatnikov
4f652c1ec4 tests: check decoding of IFLA_AF_SPEC netlink attribute
* configure.ac (AC_CHECK_TYPES): Check for struct ifla_cacheinfo in
<linux/rtnetlink.h>
(AC_CHECK_DECLS): Check for IFLA_AF_SPEC in <linux/rtnetlink.h>.
* tests/nlattr_ifla_af_spec.c: New file.
* tests/pure_executables.list: Add nlattr_ifla_af_spec.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (nlattr_ifla_af_spec): New test.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
6229d93cb2 tests: add TEST_NESTED_NLATTR_ARRAY_EX to test_nlattr.h
An ability to specify custom depth is going to be needed later to check
IFLA_AF_SPEC decoding.

* configure.ac (AC_CHECK_DECLS): Check for TCA_STAB_DATA in
<linux/pkt_sched.h>.
* tests/test_nlattr.h (TEST_NESTED_NLATTR_ARRAY_EX): Rename from
TEST_NESTED_NLATTR_ARRAY, add depth_ argument, perform padding and
output accordingly.
(TEST_NESTED_NLATTR_ARRAY): New macro, a thin wrapper around
TEST_NESTED_NLATTR_ARRAY_EX.
* tests/nlattr_tca_stab.c [!HAVE_DECL_TCA_STAB_DATA] (TCA_STAB_DATA):
New enumeration declaration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
e62b6a5e92 tests: move common ifinfomsg boilerplate into a separate header
* configure.ac (AC_CHECK_DECLS): Check for IFLA_PORT_SELF, IFLA_PROTINFO, and
IFLA_XDP in <linux/rtnetlink.h>.
* tests/nlattr_ifla.h: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/nlattr_ifla_brport.c [!HAVE_DECL_IFLA_PROTINFO] (IFLA_PROTINFO):
New declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_PROTINFO.
Include nlattr_ifla.h.
* tests/nlattr_ifla_port.c [!HAVE_DECL_IFLA_PORT_SELF] (IFLA_PORT_SELF):
New declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_PORT_SELF.
Include nlattr_ifla.h.
* tests/nlattr_ifla_xdp.c
* tests/nlattr_ifla_xdp.c [!HAVE_DECL_IFLA_XDP] (IFLA_XDP): New
declaration.
(hdrlen, init_ifinfomsg, print_ifinfomsg): Remove.
(IFLA_ATTR): Define to IFLA_XDP.
Include nlattr_ifla.h.
2018-06-06 15:10:37 +00:00
Eugene Syromyatnikov
93ef3d32ab tests: check BPF_OBJ_GET_INFO_BY_FD decoding
* tests/bpf-obj_get_info_by_fd-prog-v.c: New file.
* tests/bpf-obj_get_info_by_fd-prog.c: Likewise.
* tests/bpf-obj_get_info_by_fd-v.c: Likewise.
* tests/bpf-obj_get_info_by_fd.c: Likewise.
* configure.ac (AC_CHECK_HEADERS): Check for struct bpf_insn,
struct bpf_map_info, and struct bpf_prog_info.
* tests/pure_executables.list: Add bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog, and
bpf-obj_get_info_by_fd-prog-v.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (bpf-obj_get_info_by_fd,
bpf-obj_get_info_by_fd-v, bpf-obj_get_info_by_fd-prog,
bpf-obj_get_info_by_fd-prog-v): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-06-04 01:11:05 +00:00
Eugene Syromyatnikov
5c84cf7ddb configure.ac: include <sys/socket.h> before <linux/rtnetlink.h>
This is needed for old Linux UAPI headers that do no contain commit
v3.1-rc2~19^2~29.

* configure.ac: Include <sys/socket.h> before <linux/rtnetlink.h>
in AC_CHECK_* invocations.
2018-06-01 13:37:12 +00:00
Eugene Syromyatnikov
45049d4a4d configure.ac: check for linux/rtnetlink.h instead of linux/if_link.h for declarations
Historically, type definitions and declarations related to netlink route
interface attributes were in linux/rtnetlink.h, later they were moved
elsewhere (first linux/if.h, then linux/if_link.h) with the inclusion
of the corresponding header file in linux/rtnetlink.h.

* configure.ac: Use <linux/rtnetlink.h> instead of <linux/if_link.h>
in checks for interface netlink attributes-related declarations
and definitions.
2018-06-01 13:37:12 +00:00
Eugene Syromyatnikov
245df3c44b tests: check decoding of new FRA_* netlink attributes
* configure.ac (AC_CHECK_TYPES): Check for struct fib_rule_port_range
in <linux/fib_rules.h>.
* tests/nlattr_fib_rule_hdr.c: Include <linux/in.h>.
(FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE, FRA_DPORT_RANGE): New
macro constants.
[!HAVE_STRUCT_FIB_RULE_PORT_RANGE] (struct fib_rule_port_range): New
type.
(main): Check decoding of new FRA_* netlink attributes.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-30 20:50:29 +00:00
Eugene Syromyatnikov
7ff51ab3d8 sockaddr: add support for sockaddr_l2 without l2_bdaddr_type
Apparently, struct sockaddr_l2 changed over time: the l2_bdaddr_type
field was added only by commit v3.5-rc1~35^2~3^2~18^2^2~39.

* configure.ac (AC_CHECK_HEADERS): Move bluetooth/bluetooth.h check into
a separate check.
(AC_CHECK_HEADERS([bluetooth/bluetooth.h])): New check, also checks for
struct sockaddr_l2.l2_bdaddr_type member in case of success.
* sockaddr.c (print_sockaddr_data_bt) <case offsetof(struct sockaddr_l2,
l2_bdaddr_type)>: Add to sizeof(struct sockaddr_l2) case. Print
l2_bdaddr_type field only if the provided sockaddr is big enough.
* tests/net-sockaddr.c (check_l2): Put l2_bdaddr_type usage/printing
under HAVE_STRUCT_SOCKADDR_L2_L2_BDADDR_TYPE ifdef, add a check for the
sockaddr_l2 structure without the l2_bdaddr_type field.
2018-05-23 23:27:43 +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
bd9845770f build: try to use _Static_assert if static_assert is not available
* configure.ac: Check for _Static_assert if static_assert
is not available.
* static_assert.h [!HAVE_STATIC_ASSERT && HAVE__STATIC_ASSERT]
(static_assert): Define to _Static_assert.
2018-04-27 07:19:52 +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
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
3428c8b164 tests: check bpf syscall decoder unconditionally
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Check for
struct bpf_insn.
* tests/bpf.c: Remove the test guard, include "scno.h", "bpf_attr.h",
"xlat.h", and "xlat/bpf_commands.h".  Conditionalize inclusion of
<linux/bpf.h> on HAVE_LINUX_BPF_H.  Remove all HAVE_UNION_* checks.
(BPF_ATTR_DATA_FIELD): New macro.
(bpf_attr_data): New union.  Note that it is larger than modern
union bpf_attr, this allows more checks to be implemented in the future.
(sizeof_attr, test_bpf_): Replace union bpf_attr with
union bpf_attr_data.
(DEF_BPF_INIT_FIRST): Replace union bpf_attr with the corresponding
structure.
(init_BPF_MAP_CREATE_attr): Replace union bpf_attr with
struct BPF_MAP_CREATE_struct.
(init_BPF_MAP_LOOKUP_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_LOOKUP_ELEM_struct.
(init_BPF_MAP_UPDATE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_UPDATE_ELEM_struct.
(init_BPF_MAP_DELETE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_DELETE_ELEM_struct.
(init_BPF_MAP_GET_NEXT_KEY_attr): Replace union bpf_attr with
struct BPF_MAP_GET_NEXT_KEY_struct.
(init_BPF_PROG_LOAD_attr): Replace union bpf_attr with
struct BPF_PROG_LOAD_struct.
(init_BPF_OBJ_PIN_attr): Replace union bpf_attr with
struct BPF_OBJ_PIN_struct.
(init_BPF_PROG_ATTACH_attr): Replace union bpf_attr with
struct BPF_PROG_ATTACH_struct.
(init_BPF_PROG_DETACH_attr): Replace union bpf_attr with
struct BPF_PROG_DETACH_struct.
(init_BPF_PROG_GET_NEXT_ID_attr): Replace union bpf_attr with
struct BPF_PROG_GET_NEXT_ID_struct.
(sample_BPF_PROG_TEST_RUN_attr): Change type from union bpf_attr to
struct BPF_PROG_TEST_RUN_struct, all users updated.
(sample_BPF_OBJ_GET_INFO_BY_FD_attr): Change type from union bpf_attr
to struct BPF_OBJ_GET_INFO_BY_FD_struct, all users updated.
2018-04-04 12:24:19 +00:00
442560c875 build: generate all union bpf_attr checks automatically
Rather than list by hand some members of union bpf_attr that we check
for availability, automatically list all members of union bpf_attr we
are aware of.

* m4/gen_bpf_attr_m4.sh: New file.
* bootstrap: Invoke it.
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Use st_BPF_ATTR.
* m4/.gitignore: New file.
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
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
85b35818db build: do not hardcode -lrt
Depending on libc implementation, various -lrt functions can be
implemented either in -lc or in -lrt.  For example, starting with
glibc-2.17 the clock_* suite of functions is available directly in -lc.

Check whether clock_* and mq_* suites of functions are provided
by -lrt or by the main C library, do not link with -lrt unnecessarily.

This change affects only tests yet, but this is going to be
more important as soon as strace starts using clock_gettime.

* configure.ac (AC_SEARCH_LIBS): Check for clock_gettime and mq_open
in -lrt.
(AC_SUBST): Add clock_LIBS and mq_LIBS.
* tests/Makefile.am (mq_LDADD): Replace -lrt with $(mq_LIBS).
(threads_execve_LDADD, times_LDADD): Replace -lrt with $(clock_LIBS).
2018-03-14 21:15:55 +00:00
Eugene Syromyatnikov
bad2d7437c btrfs: print struct btrfs_ioctl_logical_ino_args.flags field
The field has been introduced in Linux commit v4.15-rc1~135^2~17.

* btrfs.c: Implement decoding of
struct btrfs_ioctl_logical_ino_args.flags field.
* configure.ac: Check for struct btrfs_ioctl_logical_ino_args.flags
presence in linux/btrfs.h.
* tests/btrfs.c: Update expected output, add additional checks.
* xlat/btrfs_logical_ino_args_flags.in: New file.
2018-03-06 23:52:08 +00:00
003c02745f Wipe out references to defunct sourceforge
The old location of strace-devel mailing list is defunct, it used to
lose email messages and sometimes did not deliver any mails for days.

The mailing list has been moved to strace-devel@lists.strace.io.

* CREDITS.in: Update the mailing list address.
(Zhang Le): Update email address.
* README: Update the mailing list address.
* README.md: Likewise.
* configure.ac (AC_INIT): Likewise.
* strace.1.in (.SH REPORTING BUGS): Likewise.
* strace-log-merge.1.in (.SH REPORTING BUGS): Likewise.
* sched.c (SYS_FUNC(sched_getattr)): Update the mailing list reference.
* tests/scno_tampering.sh: Likewise.
* qemu_multiarch_testing/README: Update git repository address.
* NEWS: Mention the change of the mailing list address.

Closes: https://github.com/strace/strace/issues/38
2018-02-23 23:18:56 +00:00
6ebf6c4f9e m68k: fix build
When <sys/reg.h> is included after <linux/ptrace.h>, the build fails
on m68k with the following diagnostics:

  In file included from /usr/include/linux/ptrace.h:101:0,
                   from ptrace.h:51,
                   from sigreturn.c:2:
  /usr/include/m68k-linux-gnu/sys/reg.h:26:3: error: expected identifier
  before numeric constant
     PT_D1 = 0,
     ^

Apparently, the only architecture where strace needs definitions
provided by <sys/reg.h> is x86_64, other three (m68k, tile, and x86)
are fine with definitions already provided by <linux/ptrace.h>.

Fix the issue by getting rid of <sys/reg.h> and defining necessary
macros in linux/x86_64/arch_regs.h file.

* configure.ac (AC_CHECK_HEADERS): Remove sys/reg.h.
* regs.h: Do not include <sys/reg.h>.
* linux/x86_64/arch_regs.h (R15, R14, R13, R12, RBP, RBX, R11, R10,
R9, R8, RAX, RCX, RDX, RSI, RDI, ORIG_RAX, RIP, CS, EFLAGS, RSP, SS,
FS_BASE, GS_BASE, DS, ES, FS, GS): New macros.
* NEWS: Mention this fix.

Fixes: v4.21~21 ("Include <sys/ptrace.h> early")
2018-02-21 23:03:27 +00:00
daaf8ab7fe Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-02-13 22:00:00 +00:00
4b36fd69f7 Export SIZEOF_LONG and SIZEOF_KERNEL_LONG_T to tests
* configure.ac (AC_SUBST): Add SIZEOF_LONG and SIZEOF_KERNEL_LONG_T.
* tests/Makefile.am (SIZEOF_LONG, SIZEOF_KERNEL_LONG_T): New variables.
(AM_TEST_LOG_FLAGS): Pass them.
* bootstrap: Substitute them.
2018-02-13 04:17:08 +00:00
Eugene Syromyatnikov
52970d343b tests: check s390_guarded_storage system call decoder
* configure.ac (AC_CHECK_HEADERS): Add asm/guarded_storage.h.
* tests/s390_guarded_storage-v.c: New file.
* tests/s390_guarded_storage.c: Likewise.
* tests/.gitignore: Add s390_guarded_storage, s390_guarded_storage-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_guarded_storage, s390_guarded_storage-v):
New tests.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
9437d47366 tests: check s390_sthyi system call decoder
* configure.ac (AC_CHECK_FUNCS): Add iconv_open.
(AC_CHECK_HEADERS): Add iconv.h.
* tests/s390_sthyi-v.c: New file.
* tests/s390_sthyi.c: Likewise.
* tests/.gitignore: Add s390_sthyi, s390_sthyi-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_sthyi, s390_sthyi): New tests.
2018-01-29 14:10:10 +01:00
Eugene Syromyatnikov
865d93c2ec configure.ac: sort architectures in lexicographical order
* configure.ac (case "$host_cpu"): sort architectures in alphabetical
order.
2018-01-25 07:18:38 +00: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
b2fe2a60ac Add support for --enable-mpers=m32|mx32
* configure.ac (AC_ARG_ENABLE([mpers])): Allow m32 and mx32 values
for --enable-mpers option.
* m4/mpers.m4 (st_MPERS): Check for personality support if personality
name is provided as an option.  Fail if the requested personality
support is not available.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-01-19 17:50:09 +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
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
376cf85efe configure: try to set the C compiler mode to accept ISO Standard C
* configure.ac: Use AC_PROG_CC_STDC.
* NEWS: Mention this.
2018-01-16 01:09:14 +00:00
752e6b4792 configure: use AC_MSG_ERROR and AC_MSG_FAILURE consistently
* configure.ac [$arch = mips]: Use AC_MSG_FAILURE instead of
AC_MSG_ERROR when _MIPS_SIM cannot be determined.  Use AC_MSG_ERROR
instead of AC_MSG_FAILURE when syscallent stubs cannot be generated.
2018-01-13 13:46:45 +00:00
Eugene Syromyatnikov
3eb199a29d configure: add --disable-mpers and --enable-mpers=check options
On architectures supporting multiple personalities, multiple
personalities support in strace is required for proper decoding of
structures used by tracees with personalities that differ from the
personality of strace.

New configure options control whether multiple personalities support
in strace is mandatory, optional, or disabled.

The default is changed from what is now equivalent of
--enable-mpers=check (automatically detect whether required mpers
support could be enabled) to --enable-mpers (terminate the build
if required mpers support could not be enabled).

* configure.ac (AC_ARG_ENABLE([mpers])): New option.
* m4/mpers.m4 (st_MPERS): Use enable_mpers.  Terminate the build
if mpers could not be enabled and enable_mpers==yes.
* strace.spec.in: Specify --enable-mpers=check to %configure.
* debian/rules (build/Makefile, build64/Makefile): Specify
--enable-mpers=check to configure.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Suggested-by: DJ Delorie <dj@redhat.com>
2018-01-11 23:09:56 +00:00
Eugene Syromyatnikov
843369ebe1 Search for <libiberty/demangle.h> in addition to <demangle.h>
This is the location where this header is installed on Debian-based
systems.

* configure.ac: Check for libiberty/demangle.h in addition to
demangle.h.
* unwind.c [USE_DEMANGLE]: Include either <demangle.h> or
<libiberty_demangle.h> based on the presence of HAVE_DEMANGLE_H and
HAVE_LIBIBERTY_DEMANGLE_H macros.
2018-01-11 15:54:33 +00:00
Eugene Syromyatnikov
5c3d4b631d Provide strace's native arch to the test framework
* configure.ac (arch_native): New variable, set to arch.
* tests/Makefile.am (NATIVE_ARCH): New variable, set to @arch_native@.
(AM_TEST_LOG_FLAGS): Pass NATIVE_ARCH as STRACE_NATIVE_ARCH environment
variable.
2018-01-11 15:54:33 +00:00
Eugene Syromyatnikov
54402590c3 configure.ac: check for mpers support on RISC-V
* confgure.ac (st_MPERS([m32])): Add riscv.
2018-01-11 15:54:33 +00:00
Eugene Syromyatnikov
7527de8263 perf.c: add support for struct perf_event_attr.namespaces
This field was introduced by linux kernel commit v4.12-rc1~152^2~42^2~10.

* configure.ac (AC_CHECK_MEMBERS): Add  perf_event_attr.namespaces.
* perf_event_struct.h (struct perf_event_attr): Add namespaces field.
* perf.c (print_perf_event_attr): Print namespaces field.
Update comment for __reserved_1 field.
* tests/perf_event_open.c (struct pea_flags): Add namespaces field.
(print_event_attr): Update expected output.
2018-01-11 15:54:33 +00:00
Eugene Syromyatnikov
916cb4ec13 ldt.c: print lm field for 64-bit tracees
* configure.ac (AC_CHECK_MEMBERS): Add struct user_desc.lm.
* ldt.c (print_user_desc) [HAVE_STRUCT_USER_DESC_LM]: Print lm field
for non-compat tracees (it is ignored for compat ones).
2018-01-08 00:40:22 +00:00
Eugene Syromiatnikov
cc057e03ae Include paths.h if it is available
Use the OS definition of _PATH_BSHELL macro if it is available.

* configure.ac (AC_CHECK_HEADERS): Add paths.h.
* strace.c [HAVE_PATHS_H]: Include paths.h.
2018-01-07 16:46:32 +00:00
2216f14499 configure.ac: fix typo
* configure.ac: Replace CPPFALGS with CPPFLAGS.

Fixes: v4.20-85-gf9c8e8a ("unwind: demangle symbol names")
2018-01-04 00:23:04 +00:00
Masatake YAMATO
f9c8e8a5b6 unwind: demangle symbol names
Implement demangling of C++ symbol names in stack trace
using cplus_demangle function from GNU libiberty library.

This is an example demangled stack trace output:

fstat(5, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
 > /usr/lib64/libc-2.25.so(__fxstat64+0x12) [0xffd62]
 > /usr/lib64/libc-2.25.so(_IO_file_doallocate+0x5f) [0x717ff]
 > /usr/lib64/libc-2.25.so(_IO_doallocbuf+0x79) [0x81699]
 > /usr/lib64/libc-2.25.so(_IO_file_overflow+0x198) [0x807b8]
 > /usr/lib64/libc-2.25.so(_IO_file_xsputn+0xbd) [0x7ed5d]
 > /usr/lib64/libc-2.25.so(fwrite_unlocked+0x60) [0x7d800]
 > /usr/lib64/libleveldb.so.1.18(leveldb::EnvWrapper::StartThread+0x3b6) [0x48656]
 > /usr/lib64/libleveldb.so.1.18(leveldb::log::Writer::EmitPhysicalRecord+0x89) [0x28bc9]
 > /usr/lib64/libleveldb.so.1.18(leveldb::log::Writer::AddRecord+0x9e) [0x28d9e]
 > /usr/lib64/libleveldb.so.1.18(leveldb::DBImpl::Write+0x208) [0x1ce18]
 > /usr/lib64/libleveldb.so.1.18(leveldb::DB::Put+0x59) [0x192b9]
 > /usr/lib64/libleveldb.so.1.18(leveldb::DBImpl::Put+0x1d) [0x1931d]
 > /home/yamato/var/leveldb/doc/a.out(main+0x120) [0x1107]
 > /usr/lib64/libc-2.25.so(__libc_start_main+0xea) [0x2088a]
 > /home/yamato/var/leveldb/doc/a.out(_start+0x2a) [0xf3a]

* Makefile.am [USE_DEMANGLE] (strace_CPPFLAGS, strace_LDFLAGS,
libiberty_LDADD): Append libiberty_CPPFLAGS, strace_LDFLAGS, and
libiberty_LIBS, respectively.
* configure.ac: Add --with-libiberty option.  Check cplus_demangle
support in libiberty.
* unwind.c [USE_DEMANGLE]: Include <demangle.h>.
(print_stack_frame) [USE_DEMANGLE]: Use cplus_demangle.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-26 21:36:49 +00:00
2c8036a972 Remove linux/ptp_clock.h
As linux kernel provides a compatible linux/ptp_clock.h header since
commit v3.8-rc1~139^2~514, there is no need for a local copy.

* linux/ptp_clock.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_TYPES): Check for struct ptp_sys_offset
in <linux/ptp_clock.h>.
* ioctl.c (ioctl_decode) <case '='>: Conditionalize
on [HAVE_STRUCT_PTP_SYS_OFFSET].
* ptp.c: Likewise.
2017-12-23 02:53:54 +00:00
e10a6d0d57 Remove linux/ubi-user.h
As linux kernel provides a compatible mtd/ubi-user.h header since
commit v3.7-rc1~85^2~17, there is no need for a local copy.

* linux/ubi-user.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_MEMBERS): Check
for struct ubi_attach_req.max_beb_per1024 in <mtd/ubi-user.h>.
* ioctl.c (ioctl_decode) <case 'o', case 'O'>: Conditionalize
on HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024.
* ubi.c: Likewise.
2017-12-23 02:53:54 +00:00