]> granicus.if.org Git - strace/log
strace
6 years agoMove README to dist subdirectory
Eugene Syromyatnikov [Wed, 14 Mar 2018 16:53:04 +0000 (17:53 +0100)]
Move README to dist subdirectory

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

6 years agoREADME: synchronise with README.md
Eugene Syromyatnikov [Wed, 14 Mar 2018 16:51:13 +0000 (17:51 +0100)]
README: synchronise with README.md

* README: Extend description, reference COPYING.

6 years agopoll.c: remove special INFTIM handling
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:27:21 +0000 (06:27 +0100)]
poll.c: remove special INFTIM handling

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.

6 years agobuild: do not hardcode -lrt
Dmitry V. Levin [Wed, 14 Mar 2018 21:15:55 +0000 (21:15 +0000)]
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).

6 years agotests: do not link with -lrt unnecessarily
Dmitry V. Levin [Wed, 14 Mar 2018 21:15:55 +0000 (21:15 +0000)]
tests: do not link with -lrt unnecessarily

* tests/Makefile.am (attach_f_p_LDADD): Remove -lrt.
(clock_xettime_LDADD, mq_sendrecv_LDADD, mq_sendrecv_read_LDADD,
mq_sendrecv_write_LDADD): Remove.

6 years agoOptimize pid2tcb
Dmitry V. Levin [Tue, 1 Mar 2016 14:42:58 +0000 (14:42 +0000)]
Optimize pid2tcb

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

6 years agoEnable USE_SEIZE code unconditionally
Dmitry V. Levin [Tue, 13 Mar 2018 20:54:25 +0000 (20:54 +0000)]
Enable USE_SEIZE code unconditionally

It is by no means an experimental code.

* defs.h (USE_SEIZE): Remove.
* strace.c [!USE_SEIZE]: Remove.

6 years agoci: clone musl from the local server
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: clone musl from the local server

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.

6 years agoci: refactor cloning of additional repositories
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: refactor cloning of additional repositories

* ci/install-dependencies.sh (clone_repo): New function.
Use it instead of direct invocations of git clone.

6 years agoci: extend error diagnostics when configure invocation fails
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: extend error diagnostics when configure invocation fails

* ci/run-build-and-tests.sh: Include $CC -dumpspecs output in addition
to config.log when ./configure fails.

6 years agoci: rename travis-build.sh and travis-install.sh scripts
Dmitry V. Levin [Tue, 13 Mar 2018 13:19:02 +0000 (13:19 +0000)]
ci: rename travis-build.sh and travis-install.sh scripts

* 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.

6 years agotests: extend ioctl.test libc protection to -y output
Dmitry V. Levin [Tue, 13 Mar 2018 01:53:04 +0000 (01:53 +0000)]
tests: extend ioctl.test libc protection to -y output

* tests/ioctl.test: Extend the filter of ioctl calls with standard
descriptor arguments to -y output.

6 years agoptp.c: print field names and use macros form print_fields.h
Harsha Sharma [Sat, 10 Mar 2018 06:21:59 +0000 (11:51 +0530)]
ptp.c: print field names and use macros form print_fields.h

* ptp.c: Include "print_fields.h".
(ptp_ioctl): Print field names with field values for PTP_PEROUT_REQUEST,
use macros from print_fields.h.

6 years agotests: add check for decoding of netfilter subsystem
Chen Jingpiao [Sun, 11 Mar 2018 12:14:57 +0000 (20:14 +0800)]
tests: add check for decoding of netfilter subsystem

* tests/netlink_netfilter.c(test_nfgenmsg): Add check for decoding
of netfilter subsystem.

6 years agonfnetlink: introduce generic netfilter subsystem decoder
Chen Jingpiao [Sun, 11 Mar 2018 12:14:56 +0000 (20:14 +0800)]
nfnetlink: introduce generic netfilter subsystem decoder

* netlink_netfilter.c: Include "nlattr.h".
(decode_netlink_netfilter): Call decode_nlattr.

6 years agoMove nl_netfilter_msg_types definition from netlink.c to netlink_netfilter.c
Chen Jingpiao [Sat, 10 Mar 2018 01:44:35 +0000 (09:44 +0800)]
Move nl_netfilter_msg_types definition from netlink.c to netlink_netfilter.c

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.

6 years agotests: add check for NETLINK_NETFILTER parser
Chen Jingpiao [Thu, 8 Mar 2018 14:53:45 +0000 (22:53 +0800)]
tests: add check for NETLINK_NETFILTER parser

* 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.

6 years agonetlink: introduce NETLINK_NETFILTER parser
Chen Jingpiao [Thu, 8 Mar 2018 14:53:44 +0000 (22:53 +0800)]
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.

6 years agoxlat: remove NFNL_SUBSYS_COUNT constant
Chen Jingpiao [Sun, 11 Mar 2018 12:16:01 +0000 (20:16 +0800)]
xlat: remove NFNL_SUBSYS_COUNT constant

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.

6 years agoinject_data: make room for more injection features
Dmitry V. Levin [Sat, 10 Mar 2018 00:13:04 +0000 (00:13 +0000)]
inject_data: make room for more injection features

* defs.h (struct inject_data): Squeeze flags and signo fields from
uint16_t to uint8_t to make room for more injection features.

6 years agoxlat: sort v4l2_pix_fmts.in and v4l2_sdr_fmts.in
Eugene Syromyatnikov [Wed, 7 Mar 2018 14:18:55 +0000 (15:18 +0100)]
xlat: sort v4l2_pix_fmts.in and v4l2_sdr_fmts.in

* xlat/v4l2_pix_fmts.in: Sort by value, add a comment about sorting.
* xlat/v4l2_sdr_fmts.in: Likewise.

6 years agoxlat: add comments to all sorted xlat files
Dmitry V. Levin [Fri, 9 Mar 2018 02:48:30 +0000 (02:48 +0000)]
xlat: add comments to all sorted xlat files

Add a short comment describing the method used to sort entries.

* xlat/ethernet_protocols.in: Update the comment about sorting.
* xlat/fsmagic.in: Likewise.
* xlat/evdev_keycode.in: Add a comment about sorting.
* xlat/hw_breakpoint_type.in: Likewise.
* xlat/perf_hw_cache_id.in: Likewise.
* xlat/perf_hw_cache_op_id.in: Likewise.
* xlat/perf_hw_cache_op_result_id.in: Likewise.
* xlat/perf_hw_id.in: Likewise.
* xlat/perf_sw_ids.in: Likewise.
* xlat/perf_type_id.in: Likewise.

6 years agobpf: remove page size caching
Eugene Syromyatnikov [Mon, 5 Mar 2018 09:17:44 +0000 (10:17 +0100)]
bpf: remove page size caching

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.

6 years agobpf_filter: fix indentation of the switch clause
Eugene Syromyatnikov [Thu, 22 Feb 2018 05:30:54 +0000 (06:30 +0100)]
bpf_filter: fix indentation of the switch clause

* bpf_filter.c (print_bpf_filter_code): Fix switch clause indentation.

6 years agoxlat: provide fallback definitions for arch-independent mmap flags
Dmitry V. Levin [Thu, 8 Mar 2018 22:27:26 +0000 (22:27 +0000)]
xlat: provide fallback definitions for arch-independent mmap flags

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")
6 years agobpf: print kern_version in the form of KERNEL_VERSION macro
Eugene Syromyatnikov [Thu, 22 Feb 2018 01:44:04 +0000 (02:44 +0100)]
bpf: print kern_version in the form of KERNEL_VERSION macro

* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print
union bpf_attr.kern_version in the form of KERNEL_VERSION macro call.
* tests/bpf.c: Update expected output.

6 years agotests: fix remap_file_pages.test breakage on hppa
Eugene Syromyatnikov [Mon, 5 Mar 2018 03:15:53 +0000 (04:15 +0100)]
tests: fix remap_file_pages.test breakage on hppa

Apparently, hppa is the only architecture that has MAP_TYPE
defined to 0x3 instead of 0xf, and the tests hit that corner case.

* tests/remap_file_pages.c (main) [MAP_HUGETLB]: Print the value
of mapping type depending on the architecture (MAP_SHARED_VALIDATE
for hppa and unknown value for other architectures).

Fixes: v4.21~59 ("xlat: update MAP_* constants")
6 years agoSort Ethernet protocols xlat
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:01:24 +0000 (19:01 +0100)]
Sort Ethernet protocols xlat

* defs.h (ethernet_protocols_size): New declaration.
* netlink_packet_diag.c (decode_packet_diag_req): Use
printxval_searchnn to print Ethernet protocols.
* sockaddr.c (ethernet_protocols_size): New constant, item count
in ethernet_protocols array.
(print_sockaddr_data_ll): Use printxval_search instead of
printxval to print Ethernet protocols.
* xlat/ethernet_protocols.in: Sort it by value, add comment
about the fact.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoChange sorted arrays to be terminated with XLAT_END like unsorted arrays
Eugene Syromyatnikov [Wed, 7 Mar 2018 18:07:59 +0000 (19:07 +0100)]
Change sorted arrays to be terminated with XLAT_END like unsorted arrays

It is quite unwieldy to have this distinction between sorted and
unsorted arrays when we can just decrement the size in a wrapper.

* defs.h (printxval_search): Decrement array size.
* xlat/fsmagic.in (#unterminated): Remove.
* xlat/hw_breakpoint_type.in (#unterminated): Remove.
* xlat/perf_hw_cache_id.in (#unterminated): Remove.
* xlat/perf_hw_cache_op_id.in (#unterminated): Remove.
* xlat/perf_hw_cache_op_result_id.in (#unterminated): Remove.
* xlat/perf_hw_id.in (#unterminated): Remove.
* xlat/perf_sw_ids.in (#unterminated): Remove.
* xlat/perf_type_id.in (#unterminated): Remove.
* xlat/gen.sh (gen_header): Remove #unterminated support.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agostrace.1.in: add a note about tracing of scripts without shebang
Eugene Syromyatnikov [Wed, 28 Feb 2018 17:17:26 +0000 (18:17 +0100)]
strace.1.in: add a note about tracing of scripts without shebang

* strace.1.in (.SH NOTES): Note that tracing of scripts without shebang
won't work.

Reported-by: Mike Parker
Closes: https://github.com/strace/strace/issues/46
6 years agostrace.1.in: mention that -c suppresses regular output
Eugene Syromyatnikov [Wed, 28 Feb 2018 16:25:31 +0000 (17:25 +0100)]
strace.1.in: mention that -c suppresses regular output

As the note that -C makes strace "also print regular output" can be
easily overlooked.

* strace.1.in (.SS Statistics) <.TP .B \-c>: Mention that -c supresses
regular output.

6 years agoerrnoent.h: add ERECALLCONFLICT
Eugene Syromyatnikov [Wed, 28 Feb 2018 16:12:04 +0000 (17:12 +0100)]
errnoent.h: add ERECALLCONFLICT

* linux/errnoent.h ([530]): Add ERECALLCONFLICT error introduced by
Linux commit v4.7-rc1~40^2~6.
* linux/alpha/errnoent.h ([530]): Likewise.
* linux/hppa/errnoent.h ([530]): Likewise.
* linux/mips/errnoent.h ([530]): Likewise.
* linux/sparc/errnoent.h ([530]): Likewise.

6 years agoxlat: add BPF_F_ALLOW_MULTI constant
Eugene Syromyatnikov [Thu, 1 Mar 2018 19:19:16 +0000 (20:19 +0100)]
xlat: add BPF_F_ALLOW_MULTI constant

* xlat/bpf_attach_flags.in (BPF_F_ALLOW_MULTI): New constant, introduced
by Linux commit v4.15-rc1~84^2~558^2~7.

6 years agoxlat: add BPF_MAP_TYPE_CPUMAP constant
Eugene Syromyatnikov [Thu, 1 Mar 2018 18:50:39 +0000 (19:50 +0100)]
xlat: add BPF_MAP_TYPE_CPUMAP constant

* xlat/bpf_map_types.in (BPF_MAP_TYPE_CPUMAP): New constant, introduced
by Linux commit v4.15-rc1~84^2~427^2~4.

6 years agotests/test_printstrn.c: do not declare i again
Eugene Syromyatnikov [Fri, 2 Mar 2018 05:19:03 +0000 (06:19 +0100)]
tests/test_printstrn.c: do not declare i again

6 years agotests/s390_sthyi.c: make utility functions inline
Eugene Syromyatnikov [Thu, 1 Mar 2018 05:28:05 +0000 (06:28 +0100)]
tests/s390_sthyi.c: make utility functions inline

When built with --enable-gcc-Werror, s390_sthyi test build fails
with the following error:

s390_sthyi.c:63:1: error: ‘print_u8’ defined but not used [-Werror=unused-function]
 print_u8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
 ^~~~~~~~

Apparently, after some back and forth, all occurrences of printing u8
values landed under verbose printing, so this function is no longer
used in non-verbose mode.  Let's avoid this in the future by inlining
all the utility functions in this test.

* tests/s390_sthyi.c (print_0x8, print_u8, print_u16, print_x32,
print_weight, ebcdic2ascii, is_empty, print_ebcdic): Add inline
qualifier.
[!VERBOSE] (is_empty): Remove "# if VERBOSE" guard.

6 years agobtrfs: print struct btrfs_ioctl_logical_ino_args.flags field
Eugene Syromyatnikov [Wed, 21 Feb 2018 23:18:10 +0000 (00:18 +0100)]
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.

6 years agobtrfs.c: print __u64 fields with pointer semantics using printaddr64
Eugene Syromyatnikov [Wed, 21 Feb 2018 22:20:46 +0000 (23:20 +0100)]
btrfs.c: print __u64 fields with pointer semantics using printaddr64

* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_INO_PATHS>: Print fspath field
with printaddr64.
(btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print inodes field with
printaddr64.
* tests/btrfs.c: Add checks for NULL in fspath and inodes fields.
* NEWS: Mention it.

6 years agoutil.c: introduce printaddr64
Eugene Syromyatnikov [Wed, 21 Feb 2018 22:15:54 +0000 (23:15 +0100)]
util.c: introduce printaddr64

Sometimes, 64-bit value is expected to be interpreted as an address
(in BTRFS ioctl interface, for example).

* defs.h (printaddr64): New declaration.
* util.c (printaddr64): Rename from printaddr, change argument type
to uint64_t.
(printaddr): Turn into a thin wrapper around printaddr64.
(printnum_addr_int, printnum_addr_int64): Use printaddr64 instead of
printaddr.  printnum_addr_int64 is not used outside the cases where
kernel_long is less or equal than 64 bit currently, so this change
should be safe.

6 years agoprctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands
Eugene Syromyatnikov [Wed, 21 Feb 2018 19:57:16 +0000 (20:57 +0100)]
prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands

These commands were introduced in Linux commit v4.15-rc1~110^2~9.

* xlat/pr_sve_vl_flags.in: New file.
* xlat/prctl_options.in: Likewise.
* prctl.c: Include "xstring.h" and "xlat/pr_sve_vl_flags.h".
[!PR_SVE_VL_LEN_MASK] (PR_SVE_VL_LEN_MASK): New macro constant.
(sprint_sve_val): New function.
(SYS_FUNC(prctl)): Add decoding for PR_SVE_GET_VL and PR_SVE_SET_VL
commands.
* NEWS: Mention it.

6 years agoImplement PTRACE_SECCOMP_GET_METADATA ptrace request decoding
Eugene Syromyatnikov [Wed, 21 Feb 2018 18:20:54 +0000 (19:20 +0100)]
Implement PTRACE_SECCOMP_GET_METADATA ptrace request decoding

* defs.h (seccomp_filter_flags): New declaration.
* process.c (SYS_FUNC(ptrace)): Implement PTRACE_SECCOMP_GET_METADATA
request decoding.
* ptrace.h [!PTRACE_SECCOMP_GET_METADATA] (PTRACE_SECCOMP_GET_METADATA):
New macro constant.
* xlat/ptrace_cmds.in (PTRACE_SECCOMP_GET_METADATA): New constant.
* tests/ptrace.c (main): Add some checks for PTRACE_SECCOMP_GET_METADATA
request decoding.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobuild: prepare for -Wimplicit-fallthrough=5
Dmitry V. Levin [Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)]
build: prepare for -Wimplicit-fallthrough=5

* gcc_compat.h (ATTRIBUTE_FALLTHROUGH): New macro.
* block.c (block_ioctl): Use it instead of "fall through" comment.
* btrfs.c (btrfs_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl): Likewise.
* rtc.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* dm.c (dm_decode_values): Likewise.
* process.c (SYS_FUNC(ptrace)): Likewise.
* quota.c (decode_cmd_data): Likewise.
* ucopy.c (umovestr): Likewise.
* unwind.c (unwind_print_stacktrace, unwind_capture_stacktrace)):
Likewise.
* term.c (term_ioctl): Add ATTRIBUTE_FALLTHROUGH.
* ioctl.c (ioctl_decode) [ALPHA || POWERPC]: Likewise.
* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Wimplicit-fallthrough=5.
* tests/ioctl_v4l2.c (init_v4l2_format): Reorganize the switch statement
without implicit fallthrough.

6 years agoxlat: add eBPF-based device controller constants
Eugene Syromyatnikov [Tue, 20 Feb 2018 18:48:08 +0000 (19:48 +0100)]
xlat: add eBPF-based device controller constants

Add new BPF_PROG_TYPE_CGROUP_DEVICE eBPF program type and new
BPF_CGROUP_DEVICE eBPF program attach type, added in Linux commit
v4.15-rc1~84^2~120^2~2.

* xlat/bpf_attach_type.in (BPF_CGROUP_DEVICE): New constant.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_CGROUP_DEVICE): Likewise.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for input event constants
Eugene Syromyatnikov [Mon, 19 Feb 2018 18:25:44 +0000 (19:25 +0100)]
xlat: provide fallback definitions for input event constants

Values added using the following pair of commands:

$ cat xlat/evdev_keycode.in |
while read r; do [ -n "$r" ] &&
sed -rn 's/^#define[[:space:]]+('$r'[[:space:]]+[^[:space:]]+).*/\1/p' \
~/dev/linux/include/uapi/linux/input-event-codes.h || echo;
done > xlat/evdev_keycode.in.new
$ sort -s -n -k1,1 \
<(awk '{if (NF>1) {last = strtonum($2)}; printf("%d %s\n", last, $0)}' \
xlat/evdev_keycode.in.new) \
| sed 's/^[0-9]* //'  > xlat/evdev_keycode.in

It also verifies that the values are sorted and bsearch-ready.

* xlat/evdev_keycode.in: Add constant values.

6 years agoxlat: update the list of input event constants
Eugene Syromyatnikov [Mon, 19 Feb 2018 17:53:24 +0000 (18:53 +0100)]
xlat: update the list of input event constants

Remove some duplicating definitions and add the new ones.

* xlat/evdev_keycode.in (KEY_HANGUEL): Remove, an alternative name for
KEY_HANGEUL.
(KEY_DIRECTION): Remove, an alternative name for KEY_ROTATE_DISPLAY.
(KEY_BRIGHTNESS_ZERO): Remove, an alternative name for
KEY_BRIGHTNESS_AUTO.
(KEY_WIMAX): Remove, an alternative name for KEY_WWAN.
(BTN_A): Remove, an alternative name for BTN_SOUTH.
(BTN_B): Remove, an alternative name for BTN_EAST.
(BTN_X): Remove, an alternative name for BTN_NORTH.
(BTN_Y): Remove, an alternative name for BTN_WEST.
(BTN_STYLUS3): New constant, added in Linux commit v4.15-rc1~114^2^2~1.
(KEY_BRIGHTNESS_TOGGLE): Remove, an alternative name for
KEY_DISPLAYTOGGLE.
(KEY_ROTATE_LOCK_TOGGLE): New constant, added in Linux commit
v4.16-rc1~54^2~67.
(KEY_DATA): New constant, added in Linux commit v4.9-rc8~12^2.
(KEY_ONSCREEN_KEYBOARD): New constant, added in Linux commit
v4.12-rc1~126^2~2^12~5.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for SCTP socket option constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:36:07 +0000 (19:36 +0100)]
xlat: provide fallback definitions for SCTP socket option constants

Values for SCTP_GET_PEER_ADDRS_NUM_OLD, SCTP_GET_PEER_ADDRS_OLD,
SCTP_GET_LOCAL_ADDRS_NUM_OLD, SCTP_GET_LOCAL_ADDRS_OLD are reconstructed
from Linux commit v2.6.33-rc1~388^2~167^2~7.

xlat/socksctpoptions.in: Add constant values.

6 years agoxlat: update the list of SCTP socket option constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:26:02 +0000 (19:26 +0100)]
xlat: update the list of SCTP socket option constants

* xlat/socksctpoptions.in (SCTP_DELAYED_ACK): Rename to...
(SCTP_DELAYED_SACK): ...this, per Linux commit v2.6.38-rc2~33^2.
(SCTP_SOCKOPT_PEELOFF_FLAGS): New constant, introduced in Linux commit
v4.13-rc1~157^2~39.
(SCTP_STREAM_SCHEDULER): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~3.
(SCTP_STREAM_SCHEDULER_VALUE): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~2.
(SCTP_INTERLEAVING_SUPPORTED): New constant, introduced in Linux commit
 v4.16-rc1~123^2~384^2~11.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for Ethernet protocol constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 17:44:42 +0000 (18:44 +0100)]
xlat: provide fallback definitions for Ethernet protocol constants

As those are not architecture-specific.

* xlat/ethernet_protocols.in: Add values to constants.

6 years agoxlat: update the list of Ethernet protocol constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 17:28:44 +0000 (18:28 +0100)]
xlat: update the list of Ethernet protocol constants

* xlat/ethernet_protocols.in (ETH_P_ERSPAN2): New constant, introduced
in Linux commit v4.16-rc1~123^2~355^2~2.
(ETH_P_IBOE): New constant, introduced in commit v4.11-rc1~73^2~74.
* NEWS: Mention it.

6 years agov4l2: print known pixel/SDR formats
Eugene Syromyatnikov [Thu, 15 Feb 2018 20:16:15 +0000 (21:16 +0100)]
v4l2: print known pixel/SDR formats

* xlat/v4l2_pix_fmts.in: New file.
* xlat/v4l2_sdr_fmts.in: Likewise.
* v4l2.c [!v4l2_fourcc_be] (v4l2_fourcc_be): New macro.
(print_pixelformat): Add xlat parameter, print constant name
as a comment if it has been found in xlat.
(print_v4l2_fmtdesc, print_v4l2_frmivalenum): Pass v4l2_pix_fmts
to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_VIDEO_CAPTURE, case
V4L2_BUF_TYPE_VIDEO_OUTPUT, case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, case V4L2_BUF_TYPE_VBI_CAPTURE,
case V4L2_BUF_TYPE_VBI_OUTPUT>: Pass v4l2_pix_fmts to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_SDR_OUTPUT, case
V4L2_BUF_TYPE_SDR_CAPTURE>: Pass v4l2_sdr_fmts to print_pixelformat.
* tests/v4l2.c: Test it, update expected output.
* NEWS: Mention it.

6 years agov4l2: v4l2_fourcc is endianness-agnostic
Eugene Syromyatnikov [Thu, 1 Mar 2018 23:45:16 +0000 (00:45 +0100)]
v4l2: v4l2_fourcc is endianness-agnostic

v4l2_fourcc(a, b, c, d) is defined as (a | (b << 8) | (c << 16) | (d << 24)
regardless of endianness (no mnemonic on big-endian architectures),
so we don't need special handling for WORDS_BIGENDIAN both in decoder
and in the test.

* v4l2.c (print_pixelformat): Change initialisation to a simple
assignment of character array.
* tests/ioctl_v4l2.c [WORDS_BIGENDIAN]: Remove.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.10~371 "Implement Video4Linux video-input ioctls decoder"
6 years agotests: do not include <stdbool.h> in files that include "tests.h"
Dmitry V. Levin [Thu, 1 Mar 2018 01:00:24 +0000 (01:00 +0000)]
tests: do not include <stdbool.h> in files that include "tests.h"

Starting with commit v4.21-37-g4f63bc70ca95012d72e288fc3c1eeb3ba26068a4,
<stdbool.h> is included by tests.h, so all tests that already include
"tests.h" do not need to include <stdbool.h>.

* tests/btrfs.c: Do not include <stdbool.h>.
* tests/file_handle.c: Likewise.
* tests/futex.c: Likewise.
* tests/ioctl_dm.c: Likewise.
* tests/ioctl_loop.c: Likewise.
* tests/ioctl_sock_gifconf.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/perf_event_open.c: Likewise.
* tests/s390_guarded_storage.c: Likewise.
* tests/s390_pci_mmio_read_write.c: Likewise.
* tests/s390_sthyi.c: Likewise.
* tests/xet_thread_area_x86.c: Likewise.

6 years agotests: check printing of block/char device numbers in -yy mode
Eugene Syromyatnikov [Mon, 29 Jan 2018 17:50:09 +0000 (18:50 +0100)]
tests: check printing of block/char device numbers in -yy mode

* tests/dev-yy.c: New file.
* tests/pure_executables.list: Add dev-yy.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (dev-yy): New test.

6 years agoprintfd: print character/block device number in -yy mode
Eugene Syromyatnikov [Thu, 25 Jan 2018 16:53:23 +0000 (17:53 +0100)]
printfd: print character/block device number in -yy mode

* util.c: Include <sys/stat.h>, <sys/sysmacros.h>,
and "largefile_wrappers.h".
(printsocket, printdev): New functions.
(printfd): Move socket matching/printing logic to printsocket.  Check
also for printdev.  Escape opening angle bracket in addition to closing angle
bracket as it can show up as a separator in printdev.
* tests/fsync-y.c: Update expected output.
* strace.1.in: Mention this.
* NEWS: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoutil.c: escape closing angle bracket in printfd
Eugene Syromyatnikov [Fri, 2 Feb 2018 18:06:31 +0000 (19:06 +0100)]
util.c: escape closing angle bracket in printfd

* util.c (printfd): Use print_quoted_string_ex instead of
print_quoted_string, specify ">" as escape_chars argument.
* tests/fsync-y.c (main): Update expected output.
* NEWS: Mention it.

6 years agoutil.c: add support for additional escape characters in string_quote
Eugene Syromyatnikov [Fri, 2 Feb 2018 17:46:29 +0000 (18:46 +0100)]
util.c: add support for additional escape characters in string_quote

Quotes are not always used to denote string limits; printfd uses angle
brackets for that, for example.  As result, mechanism for supplying
set of additional characters in order to avoid ambiguities regarding
the end of the quoted string is needed.

* defs.h (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): New function prototype.
* util.c (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): Rename from print_quoted_string, add
escape_chars parameter, pass it to string_quote call.
(print_quoted_string): Turn into a thin wrapper around
print_quoted_string_ex.
(printstr_ex): Pass NULL as escape_chars argument of string_quote call.
* socketutils.c (unix_parse_response): Pass NULL as escape_chars
argument of string_quote call.
* tests/print_quoted_string.c (print_octal): New function.
print_quoted_memory_ex): Use it.  Add escape_chars parameter.
(print_quoted_memory): Pass NULL as escape_chars argument
of print_quoted_memory_ex call.
* tests/tests.h (print_quoted_string_ex, print_quoted_memory_ex): Add
escape_chars parameter.
* tests/fsync-y.c: Pass NULL as escape_chars argument of
print_quoted_string_ex call.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: check file name printing in strace -y mode
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:21:22 +0000 (17:21 +0100)]
tests: check file name printing in strace -y mode

* tests/fsync-y.c: New file.
* tests/.gitignore: Add fsync-y.
* tests/Makefile.am (check_PROGRAMS): Likewise.
* tests/gen_tests.in (fsync-y): New test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add print_quoted_string_ex and print_quoted_memory_ex functions
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:58:18 +0000 (17:58 +0100)]
tests: add print_quoted_string_ex and print_quoted_memory_ex functions

* tests/tests.h (print_quoted_string_ex, print_quoted_memory_ex): New
declarations.
* tests/print_quoted_string.c (print_quoted_string_ex): New function,
a thin wrapper around print_quoted_memory_ex wrapper.
(print_quoted_memory_ex): Rename from print_quoted_memory, add quote
argument.
(print_quoted_memory): Turn into a thin wrapper around
print_quoted_memory_ex.

6 years agotests: check escaping in string printing
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:29:36 +0000 (17:29 +0100)]
tests: check escaping in string printing

* tests/test_printstrn.c (test_print_memory): New function.
(test_printstrn): Use it.

6 years agoDo not go full octal if the next char is '8' or '9'
Eugene Syromyatnikov [Fri, 2 Feb 2018 15:15:48 +0000 (16:15 +0100)]
Do not go full octal if the next char is '8' or '9'

* util.c (string_quote): Change the upper limit for the next character
in unabbreviated octal printing from '9' to '7'.
* tests/print_quoted_string.c (print_quoted_memory): Likewise.

6 years agotests: fix abbreviated octal escape check in print_quoted_memory
Eugene Syromyatnikov [Fri, 2 Feb 2018 12:39:30 +0000 (13:39 +0100)]
tests: fix abbreviated octal escape check in print_quoted_memory

* tests/print_quoted_string.c (print_quoted_memory): Check the next
character after octal-escaped one instead of the first one in the
string.

6 years agoutil.c: reduce indentation in non-hexadecimal case in string_quote
Eugene Syromyatnikov [Thu, 1 Feb 2018 19:13:53 +0000 (20:13 +0100)]
util.c: reduce indentation in non-hexadecimal case in string_quote

As it is already too deep there.

* util.c (string_quote): Add string_ended label, jump there
after the loop in "if (usehex)" case.

6 years agoutil.c: fix switch statement indentation in string_quote
Eugene Syromyatnikov [Thu, 1 Feb 2018 19:08:08 +0000 (20:08 +0100)]
util.c: fix switch statement indentation in string_quote

While we are here, let's also remove unnecessary break statement
in the default case.

6 years agoReplace fopen_for_input and fopen_for_output with fopen_stream
Dmitry V. Levin [Tue, 27 Feb 2018 13:14:38 +0000 (13:14 +0000)]
Replace fopen_for_input and fopen_for_output with fopen_stream

* largefile_wrappers.h (fopen_for_input, fopen_for_output): Replace
with fopen_stream.
* mmap_cache.c (fopen_for_input) Likewise.
* strace.c (fopen_for_output): Likewise.

6 years agoUpdate the list of INET_DIAG_BC_* operators
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:55:16 +0000 (19:55 +0100)]
Update the list of INET_DIAG_BC_* operators

* linux/inet_diag.h (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
enumeration items introduced by linux kernel commit v4.16-rc1~123^2~259.
* xlat/inet_diag_bytecodes.in (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
constants.
* NEWS: Mention it.

6 years agoxlat: update the list of SCHED_FLAG_* constants
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:41:28 +0000 (19:41 +0100)]
xlat: update the list of SCHED_FLAG_* constants

* xlat/sched_flags.in (SCHED_FLAG_RECLAIM, SCHED_FLAG_DL_OVERRUN): New
constants introduced by linux kernel commits v4.13-rc1~205^2~27 and
v4.16-rc1~164^2~8, respectively.
(SCHED_FLAG_RESET_ON_FORK): Add constant value.
* tests/sched_xetattr.c: Update expected output.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for arch-independent poll event flags
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:08:14 +0000 (19:08 +0100)]
xlat: provide fallback definitions for arch-independent poll event flags

* xlat/pollflags.in (POLLIN, POLLPRI, POLLOUT, POLLRDNORM, POLLRDBAND,
POLLERR, POLLHUP, POLLNVAL, POLL_BUSY_LOOP): Add constant values.

6 years agoxlat: update the list of poll event flags
Eugene Syromyatnikov [Thu, 15 Feb 2018 17:34:25 +0000 (18:34 +0100)]
xlat: update the list of poll event flags

POLL_BUSY_LOOP was introduced by linux kernel commit v3.11-rc1~64^2~129
as POLL_LL and then renamed in v3.11-rc1~64^2~9.  POLLRDHUP was
introduced by linux kernel commit v2.6.17-rc1~796.  POLLMSG and
POLLREMOVE predate git repository.  POLLFREE was introduced by linux
kernel commit v3.3-rc5~8 for internal use only.

* xlat/pollflags.in (POLLMSG, POLLREMOVE, POLLRDHUP, POLL_BUSY_LOOP):
New constants.
* NEWS: Mention it.

6 years agoxlat: add arch-specific si_codes constants
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:45:24 +0000 (20:45 +0100)]
xlat: add arch-specific si_codes constants

Based on Linux commits v4.16-rc1~159^2~17, v4.16-rc1~159^2~16,
v4.16-rc1~159^2~15, and v4.16-rc1~159^2~14.

* xlat/sigbus_codes.in (BUS_OPFETCH): New constant.
* xlat/sigfpe_codes.in (FPE_MDAOVF, __FPE_DECOVF, __FPE_DECDIV,
__FPE_DECERR, __FPE_INVASC, __FPE_INVDEC): New constants.
* xlat/sigill_codes.in (ILL_ILLPARAOP, ILL_ILLEXCPT, ILL_CPLB_VI,
ILL_CPLB_MISS, ILL_CPLB_MULHIT, ILL_DBLFLT, ILL_HARDWALL, ILL_BADIADDR,
__ILL_BREAK, __ILL_BNDMOD): Likewise.
* xlat/sigsegv_codes.in (SEGV_STACKFLOW, __SEGV_PSTKOVF): Likewise.
* xlat/sigtrap_codes.in (TRAP_STEP, TRAP_TRACEFLOW, TRAP_WATCHPT,
TRAP_ILLTRAP): Likewise.
* NEWS: Mention it.

6 years agortnl_tc: support new TCA_* attributes
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:26:32 +0000 (20:26 +0100)]
rtnl_tc: support new TCA_* attributes

* xlat/rtnl_tc_attrs.in (TCA_HW_OFFLOAD, TCA_INGRESS_BLOCK,
TCA_EGRESS_BLOCK): New constants introduced by linux kernel commits
v4.15-rc4~13^2~5^2~2 and v4.16-rc1~123^2~139^2~5.
* rtnl_tc.c (tcmsg_nla_decoders) <TCA_HW_OFFLOAD, TCA_INGRESS_BLOCK,
TCA_EGRESS_BLOCK>: New items.

6 years agortnl_link: add decoding of new IFLA_* attributes
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:02:58 +0000 (20:02 +0100)]
rtnl_link: add decoding of new IFLA_* attributes

* xlat/rtnl_link_attrs.in (IFLA_NEW_NETNSID, IFLA_IF_NETNSID,
IFLA_CARRIER_UP_COUNT, IFLA_CARRIER_DOWN_COUNT, IFLA_NEW_IFINDEX): New
constants introduced by linux kernel commits v4.15-rc1~84^2~557,
v4.15-rc1~84^2~133^2, v4.16-rc1~123^2~91, and v4.16-rc1~123^2~24^2.
* rtnl_link.c (ifinfomsg_nla_decoders) <IFLA_NEW_NETNSID,
IFLA_IF_NETNSID, IFLA_CARRIER_UP_COUNT, IFLA_CARRIER_DOWN_COUNT,
IFLA_NEW_IFINDEX>: New items.

6 years agortnl_link: implement IFLA_EVENT_* decoding
Eugene Syromyatnikov [Mon, 12 Feb 2018 18:58:47 +0000 (19:58 +0100)]
rtnl_link: implement IFLA_EVENT_* decoding

* rtnl_link.c (decode_ifla_event): New function.
(ifinfomsg_nla_decoders) <[IFLA_EVENT]>: Use it.
* xlat/rtnl_ifla_events.in: New file.
* NEWS: Mention it.

6 years agoxlat: update the list of RWF_* constants
Eugene Syromyatnikov [Mon, 12 Feb 2018 18:41:41 +0000 (19:41 +0100)]
xlat: update the list of RWF_* constants

* xlat/rwf_flags.in (RWF_APPEND): New constant introduced by linux
kernel commit v4.16-rc1~145^2~7.
* NEWS: Mention it.

6 years agotests: check decoding of ip6:port pairs associated with socket descriptors
Eugene Syromyatnikov [Thu, 8 Feb 2018 13:23:49 +0000 (14:23 +0100)]
tests: check decoding of ip6:port pairs associated with socket descriptors

* tests/net-yy-inet.c: Generalise test.
* tests/net-yy-inet6.c: New file.
* tests/pure_executables.list: Add net-yy-inet6.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (net-yy-inet6): New entry.

6 years agoPrint IPv6 addresses in brackets
Eugene Syromyatnikov [Thu, 8 Feb 2018 13:15:01 +0000 (14:15 +0100)]
Print IPv6 addresses in brackets

Follow a common practice for printing address:port pair to distinguish
address parts delimiter from address/port delimiter.

* socketutils.c (inet_parse_response) <ob, cb>: New variables,
initialise them to open/closing brackets or empty strings based
on address family.
(inet_parse_response): Print ob and cb around src_buf and dst_buf.
* NEWS: Mention this improvement.

6 years agostrace.spec.in: add gcc to build requirements
Dmitry V. Levin [Mon, 26 Feb 2018 23:22:24 +0000 (23:22 +0000)]
strace.spec.in: add gcc to build requirements

There are rumors in circulation that some rpm-based distributions
are going to exclude gcc from their default build environments.
Workaround this policy silliness by adding gcc to build requirements.

* strace.spec.in (BuildRequires): Add gcc.

6 years agoMove definitions of fopen_for_input to largefile_wrappers.h
Dmitry V. Levin [Mon, 26 Feb 2018 23:22:24 +0000 (23:22 +0000)]
Move definitions of fopen_for_input to largefile_wrappers.h

* largefile_wrappers.h (fopen_for_input): Define along with
fopen_for_output.
* mmap_cache.c: Include "largefile_wrappers.h".
(fopen_for_input): Remove.

6 years agoIntroduce mmap_cache.h
Dmitry V. Levin [Mon, 26 Feb 2018 23:22:24 +0000 (23:22 +0000)]
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.

6 years agommap_cache: record device major and minor numbers
Masatake YAMATO [Fri, 16 Feb 2018 19:37:14 +0000 (04:37 +0900)]
mmap_cache: record device major and minor numbers

* defs.h (struct mmap_cache_t): Add major and minor fields.
* mmap_cache.c (build_mmap_cache): Record device major and minor numbers.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agommap_cache: add function to enable mmap_cache
Masatake YAMATO [Fri, 16 Feb 2018 19:37:13 +0000 (04:37 +0900)]
mmap_cache: add function to enable mmap_cache

mmap_cache was enabled indirectly via unwind feature.  As now mmap_cache
can be used by other part of strace, a way to enable mmap_cache directly
is needed.

* defs.h (mmap_cache_enable, mmap_cache_is_enabled): New function
prototypes.
* mmap_cache.c (use_mmap_cache): New file local variable.
(mmap_cache_enable, mmap_cache_is_enabled): New functions.
* syscall.c (syscall_exiting_decode): Use mmap_cache_is_enabled()
instead of stack_trace_enabled.
* unwind.c (unwind_init): Invoke mmap_cache_enable.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agommap_cache, unwind: lift up mmap_cache_delete invocation from unwind.c
Masatake YAMATO [Fri, 16 Feb 2018 19:37:12 +0000 (04:37 +0900)]
mmap_cache, unwind: lift up mmap_cache_delete invocation from unwind.c

mmap_cache_delete function used to be called by destructor of unwind
related code.  Now that other parts can use mmap cache,
mmap_cache_delete is called separately from unwind_tcb_fin.

* unwind.c (unwind_tcb_fin): Move mmap_cache_delete invocation ...
* strace.c (droptcb): ... here.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agommap_cache: record protection bits
Masatake YAMATO [Fri, 16 Feb 2018 19:37:11 +0000 (04:37 +0900)]
mmap_cache: record protection bits

To make mmap_cache reusable, records protection bits of mmap entries.

* defs.h (mmap_cache_protection): New enum.
* mmap_cache.c (build_mmpa_cache): Don't ignore entries that are not
executable, just record the protection bits here.
* unwind.c (print_stack_frame): Ignore entries that are not executable.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agommap_cache: move code for searching a mmap cache from unwind
Masatake YAMATO [Fri, 16 Feb 2018 19:37:10 +0000 (04:37 +0900)]
mmap_cache: move code for searching a mmap cache from unwind

print_stack_frame function in unwind.c searches a mmap entry in mmap
cache.  The found entry is then used for unwinding.  However, a function
searching for a mmap entry may be useful for other purposes than
unwinding.

This change re-factors the function; code for searching an entry is
now defined as a stand-alone function named mmap_cache_search.

* defs.h (mmap_cache_search): New function prototype.
print_stack_frame.
* mmap_cached.c (mmap_cache_search): New function derived from
print_stack_frame.
* unwind.c (print_stack_frame): Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agommap_cache: new subsystem derived from unwind.c
Masatake YAMATO [Fri, 16 Feb 2018 19:37:09 +0000 (04:37 +0900)]
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>
6 years agounwind: lift up unw_flush_cache from mmap cache management code
Masatake YAMATO [Fri, 16 Feb 2018 19:37:08 +0000 (04:37 +0900)]
unwind: lift up unw_flush_cache from mmap cache management code

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 is one of the steps for the separation.  It moves
unw_flush_cache function call from the core of mmap cache code
to upper level code.

* unwind.c (mmap_cache_rebuild_result): New enum.
(rebuild_cache_if_invalid): Return MMAP_CACHE_REBUILD_* instead of
a bool value.
(build_mmap_cache): Don't call unw_flush_cache here.
(unwind_print_stacktrace, unwind_capture_stacktrace): Call
unw_flush_cache here instead.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agodebian: sync with 4.21-1 package
Dmitry V. Levin [Sun, 25 Feb 2018 00:31:14 +0000 (00:31 +0000)]
debian: sync with 4.21-1 package

Versioned dependency on debhelper is not updated for backwards
compatibility.

* debian/changelog.in: Fix ancient changelog entries.
* debian/control (Build-Depends): Add dependency on libbluetooth-dev.
(Standards-Version): Update to 4.1.3.
(Vcs-Git, Vcs-Browser): Move from alioth to salsa.d.o.
(strace, strace-udeb) <Architecture>: Change to linux-any.
(strace64, strace-udeb) <Priority>: Change to optional.
* debian/rules: Use /usr/share/dpkg/architecture.mk instead of manually
setting build variables.
(configure): New target.
(build/Makefile, build-udeb/Makefile, build64/Makefile): Depend on it.
(binary-arch): Use build64/strace.1 for strace64 subpackage.
* debian/strace.manpages: Add build/ prefix.
* debian/strace64.manpages: Add build64/ prefix.

6 years agom4/mpers.m4: fix mpers name in comments added to config.h
Eugene Syromyatnikov [Fri, 23 Feb 2018 22:26:49 +0000 (23:26 +0100)]
m4/mpers.m4: fix mpers name in comments added to config.h

* m4/mpers.m4 (st_MPERS_STRUCT_STAT): Use mpers_name instead of
MPERS_NAME in comments generated by AC_DEFINE.

Fixes: v4.14~169 ("mpers.m4: check for struct stat64, struct stat, and their members")
6 years agompers.awk: use stdint.h instead of inttypes.h
Dmitry V. Levin [Sat, 24 Feb 2018 20:42:03 +0000 (20:42 +0000)]
mpers.awk: use stdint.h instead of inttypes.h

As <inttypes.h> is included in files generated by mpers.awk to obtain
definitions of uintNN_t types provided by <stdint.h>, replace the former
header with the latter.

* mpers.awk: Use <stdint.h> instead of <inttypes.h>.
* mpers_test.sh: Update expected output.

6 years agoWipe out references to defunct sourceforge
Dmitry V. Levin [Fri, 23 Feb 2018 23:18:56 +0000 (23:18 +0000)]
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
6 years agom68k: fix build
Dmitry V. Levin [Wed, 21 Feb 2018 23:03:27 +0000 (23:03 +0000)]
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")
6 years agoDemote sourceforge.net
Dmitry V. Levin [Thu, 15 Feb 2018 11:07:03 +0000 (11:07 +0000)]
Demote sourceforge.net

https://sourceforge.net/p/strace/code/ is defunct: it doesn't accept
new commits for too long.
Likewise, https://sourceforge.net/projects/strace/files/ doesn't accept
new files for too long.

* README.md: Remove sourceforge.net URL.
* debian/copyright: Replace the sourceforge.net based strace project URL
with a github based one.
* strace.spec.in (Source): Likewise.

6 years agoUpdate copyright headers
Dmitry V. Levin [Thu, 15 Feb 2018 11:07:03 +0000 (11:07 +0000)]
Update copyright headers

* COPYING: Update copyright year number range.
* debian/copyright: Sync with COPYING.

6 years agoPost-release administrivia
Dmitry V. Levin [Wed, 14 Feb 2018 03:00:00 +0000 (03:00 +0000)]
Post-release administrivia

* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.21-1.
* strace.spec.in: Likewise.

6 years agoPrepare for 4.21 release v4.21
Dmitry V. Levin [Tue, 13 Feb 2018 23:00:00 +0000 (23:00 +0000)]
Prepare for 4.21 release

* NEWS: Update for 4.21 release.

6 years agotests/s390_sthyi.c: skip the test if s390_sthyi returns an error
Eugene Syromyatnikov [Tue, 13 Feb 2018 22:57:27 +0000 (23:57 +0100)]
tests/s390_sthyi.c: skip the test if s390_sthyi returns an error

tests/s390_sthyi.c (main): replace error_msg_and_fail with
error_msg_and_skip if rc is non-zero.

6 years agoUpdate copyright headers
Dmitry V. Levin [Tue, 13 Feb 2018 22:00:00 +0000 (22:00 +0000)]
Update copyright headers

Headers updated automatically using maint/update_copyright_years.sh
script.

6 years agoRemove old and unused maintenance scripts
Eugene Syromyatnikov [Tue, 13 Feb 2018 21:00:46 +0000 (22:00 +0100)]
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>
6 years agoConsistently use MAX_ERRNO_VALUE
Dmitry V. Levin [Tue, 13 Feb 2018 05:05:13 +0000 (05:05 +0000)]
Consistently use MAX_ERRNO_VALUE

* filter_qualify.c (parse_inject_token): Replace 4095
with MAX_ERRNO_VALUE.
* negated_errno.h (is_negated_errno): Likewise.  Remove redundant
comment.

6 years agoExport SIZEOF_LONG and SIZEOF_KERNEL_LONG_T to tests
Dmitry V. Levin [Tue, 13 Feb 2018 04:17:08 +0000 (04:17 +0000)]
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.

6 years agotests: avoid ioctl_kvm_run test failure when built with gcc -O0
Eugene Syromyatnikov [Tue, 13 Feb 2018 01:38:54 +0000 (02:38 +0100)]
tests: avoid ioctl_kvm_run test failure when built with gcc -O0

When built with -O0, gcc (rightfully) generates function prologue, which
results in writing %rbp to the stack, causing premature KVM_EXIT_MMIO.
It could be possible to avoid such problems by "naked" attribute but,
unfortunately, the latter is not available on x86 with older GCC.
A trick suggested in [1] is used instead: assembly is moved
to the global scope.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50242#c3

* tests/ioctl_kvm_run.c (code): Remove function.
Add globally scoped __asm__ with the function code and its size.
(code, code_size): New extern symbols declarations.
(run_kvm): Remove code_size definition and initialization.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>