IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
wait.c does it already, now strace.c also does.
* wait.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* strace.c: Replace <sys/wait.h> with "wait.h".
[!WCOREDUMP]: Remove.
* wait.c: Replace <sys/wait.h> with "wait.h".
[!WCOREFLAG] (WCOREFLAG), [!WCOREDUMP] (WCOREDUMP): Move to wait.h,
rework.
[!W_STOPCODE] (W_STOPCODE), [!W_EXITCODE] (W_EXITCODE),
[!W_CONTINUED] (W_CONTINUED): Move to wait.h.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
The result of this check is going to be used by subsequent commits.
* ptrace_syscall_info.c: New file.
* ptrace_syscall_info.h: Likewise.
* Makefile.am (strace_SOURCES): Add them.
* strace.c: Include "ptrace_syscall_info.h".
(init): Call test_ptrace_get_syscall_info.
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.
As PTRACE_POKEUSER is crippled on x32 by design from the very first
linux kernel commit v3.4-rc1~33^2~2 when it was introduced,
workaround this by using the raw x86_64 syscall instead.
* linux/ptrace_pokeuser.c: New file.
* linux/x32/ptrace_pokeuser.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* upoke.c: Include "ptrace_pokeuser.c".
(upoke): Use ptrace_pokeuser instead of ptrace.
This function is going to be used outside strace.c,
so make it globally available and move it to a separate header file.
* strace.c (kill_save_errno): Add "inline" keyword, change return type
from "void" to "int", move the function ...
* kill_save_errno.h: ... to this new file.
* Makefile.am (strace_SOURCES): Add it.
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
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>
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.
* 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>
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.
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>
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.
* 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
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.
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>
* 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.
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.
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.
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.
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>
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.
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>
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.