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!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
While in debian/control we use libunwind-dev in Build-Depends, in case
of ci we have to be more conservative and use the name portable across
different ci implementations.
* ci/install-dependencies.sh (common_packages): Add libunwind8-dev.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fix the following use case:
$ sh -uc '. tests/init.sh; kernel_version_code 4.5'
tests/init.sh: line 242: 3: unbound variable
* tests/init.sh (kernel_version_code): Fix potentially unbound variable.
Do not unblock the delay signal handler unless the delay timer is armed.
* defs.h (is_delay_timer_created): Remove.
(is_delay_timer_armed, delay_timer_expired): New prototypes.
* delay.c (delay_timer_is_armed): New static variable.
(is_delay_timer_created): Add static qualifier.
(is_delay_timer_armed, delay_timer_expired): New functions.
(arm_delay_timer): Set delay_timer_is_armed.
* strace.c (next_event): Use is_delay_timer_armed instead of
is_delay_timer_created to check whether the delay signal handler
has to be unblocked.
(timer_sighandler): Invoke delay_timer_expired.
Further simplify and optimize error handling of the delay signal handler
by replacing sigsetjmp/siglongjmp mechanism with an error flag.
* strace.c: Do not include <setjmp.h>.
(restart_failed): New volatile variable.
(timer_jmp_buf): Remove.
(next_event): Cache is_delay_timer_created() return value,
remove sigsetjmp invocation, check restart_failed instead.
(timer_sighandler): Replace siglongjmp with setting restart_failed.
As sigsetjmp costs a syscall, do not call it unless a delay timer
is already created and its signal handler is going to be unblocked.
* strace.c (next_event): Move sigsetjmp invocation under
is_delay_timer_created() condition.
Optimizes: v4.21-108-gba8e768 ("Implement delay injection")
As it looks like there's no compelling reason to keep it as a macro and
leaving it so quite complicates modification of the routine and makes
them error-prone.
* tests/bpf.c (TEST_BPF_): Convert it to...
(test_bpf): ...this. Rename cmd_ to cmd, cmd_str_ to cmd_str,
init_first_ to init_first, print_first_ to print_first, init_attr_
to init_attr, print_attr_ to print_attr.
(TEST_BPF): Call test_bpf_ instead of TEST_BPF_.
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>
Let these signals be handled asynchronously as they are acted on
only when waiting for process state changes.
* strace.c (start_set, blocked_set): Remove.
(set_sighandler): Do not update blocked_set.
(startup_attach, init, next_event): Remove all sigprocmask calls.
As program attributes have been added gradually over kernel versions,
attribute size less than expected should be printed accordingly.
* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Do not print structure
fields if their size is less than the initially introduced (in Linux
commit v3.18-rc1~52^2~1^2~7) version. Print fields of union bpf_attr
introduced in various kernel versions when the length is big enough
(new fields were introduced in Linux commits v3.18-rc1~52^2~1^2~4,
v4.1-rc1~84^2~50, and v4.12-rc2~34^2~29^2~2).
* tests/bpf.c (print_BPF_PROG_LOAD_first): Update expected output.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print
struct btrfs_ioctl_logical_ino_args.reserved field if it is not zero.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Check it.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Make generated empty gnu stub files available for mpers_test.sh check.
* m4/mpers.m4 (st_MPERS): Add $IFLAG to CPPFLAGS for mpers_test.sh
invocation.
Complements: v4.11~223 ("mpers.m4: workaround missing gnu/stubs-*.h files")
* bootstrap: Install README before invoking autoreconf to get README
included into distributed tarball.
Fixes: v4.21-93-g4bb8454 ("Move README to dist subdirectory")
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.
Fast syscalls usually take less than a microsecond of system cpu time
nowadays, making -O option almost useless.
* count.c (call_summary_pers): Avoid negative time counts.
* tests/count.test: Check it.
* NEWS: Mention it.
* count.c (shortest): Remove.
(overhead): Initialize to zero.
(call_summary_pers): Remove shortest handling.
(count_syscall): Remove dead code. The remaining code does the same
wrong calculations as before the change, though.
* README-hacking (Requirements): Enhance phrasing.
(Commit log requirements): Rename to "Commit requirements",
describe "absence of whitespace errors" requirement, add references
to the Linux kernel coding style and scripts/checkpatch.pl script.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
README was originally written for users of distribution tarballs.
Nowadays it appears to be confusing for those who build strace
using a GIT version of strace source code.
* README: Move...
* dist/README: ...here.
* bootstrap: Copy README from dist subdirectory to the toplevel
directory after successful autoreconf.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
References: https://github.com/strace/strace/issues/56
On Linux, poll syscall interprets any negative timeout value as an
infinite timeout, so no need to handle BSD-specific INFTIM.
* poll.c (SYS_FUNC(poll)): Remove INFTIM handling.
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).
Introduce an internal cache of pid2tcb translations.
This can save more than 80% of CPU user time spent by strace.
Tested using the following setup:
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
int main()
{
int i;
sleep(1);
for (i = 1; i < 1000; ++i) {
pid_t pid = fork();
if (pid < 0)
return 2;
if (pid)
return wait(&i) != pid || i;
}
sleep(1);
for (i = 0; i < 10000000; ++i)
umask(0777);
return 0;
}
old$ ./set_ptracer_any ./pid2tcb >pid2tcb.wait & \
while [ ! -s pid2tcb.wait ]; do sleep 0.1; done; \
time -f '%Uuser %Ssystem %eelapsed %PCPU' \
../strace -qq -enone -esignal=none -f -p $!
5.51user 104.90system 122.45elapsed 90%CPU
new$ ./set_ptracer_any ./pid2tcb >pid2tcb.wait & \
while [ ! -s pid2tcb.wait ]; do sleep 0.1; done; \
time -f '%Uuser %Ssystem %eelapsed %PCPU' \
../strace -qq -enone -esignal=none -f -p $!
1.29user 102.78system 114.97elapsed 90%CPU
Assume that strace project on the local server contains an appropriate
musl repository, use this repository instead of hardcoded github
location.
* ci/install-dependencies.sh (clone_repo): Use local server by default.
(musl-gcc): Un-hardcode the location of musl repository.
* travis-build.sh: Rename to ci/run-build-and-tests.sh, all callers
updated.
* travis-install.sh: Rename to ci/install-dependencies.sh, all callers
updated.
The side effect of #include "xlat/nl_netfilter_msg_types.h" is
NFNL_MSG_BATCH_* constants properly defined in that header file.
While netlink.c does not use these constants itself,
netlink_netfilter.c is going to need them soon.
* defs.h (nl_netfilter_msg_types): New xlat prototype.
* netlink.c: Move inclusion of "xlat/nl_netfilter_msg_types.h" ...
* netlink_netfilter.c: ... here.
* tests/netlink_netfilter.c: Include <netinet/in.h>, <arpa/inet.h>
and <linux/netfilter/nf_tables.h>.
Replace "netlink.h" with "test_netlink.h".
(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWTABLE): New macros.
(test_nlmsg_done, test_nfgenmsg): New functions.
(main): Use them.
NFNL_SUBSYS_COUNT is not a symbol with some constant value, it changes
with time, just print it as an unrecognized number.
* xlat/nl_netfilter_subsys_ids.in (NFNL_SUBSYS_COUNT): Remove.
get_pagesize() has a static cache anyway, no need to duplicate it.
* bpf.c (SYS_FUNC(bpf)): Remove static size_t page_size and its
initialisation, use get_pagesize() as the size of buf directly.
This is important for recently introduced MAP_SHARED_VALIDATE flag.
* xlat/mmap_flags.in (MAP_SHARED, MAP_PRIVATE, MAP_SHARED_VALIDATE):
Add constant values.
Fixes: v4.21-67-g8c209d1 ("tests: fix remap_file_pages.test breakage on hppa")