]> granicus.if.org Git - strace/log
strace
6 years agoxlat: fix MCL_* fallback definitions on alpha, ppc, ppc64, and sparc
Dmitry V. Levin [Sun, 29 Apr 2018 21:59:55 +0000 (21:59 +0000)]
xlat: fix MCL_* fallback definitions on alpha, ppc, ppc64, and sparc

On these architectures, MCL_* constants are different.

* xlat/socketlayers.in [__alpha__ || __powerpc__ || __powerpc64__
|| __sparc__] (MCL_CURRENT, MCL_FUTURE, MCL_ONFAULT): Define to 0x2000,
0x4000, and 0x8000, respectively.

6 years agoxlat: fix SOL_SOCKET fallback definition on alpha, hppa, mips, and sparc
Eugene Syromyatnikov [Fri, 20 Apr 2018 13:19:18 +0000 (15:19 +0200)]
xlat: fix SOL_SOCKET fallback definition on alpha, hppa, mips, and sparc

On these architectures, SOL_SOCKET is 0xffff and not 1.

* xlat/socketlayers.in [__alpha__ || __hppa__ || __mips__ || __sparc__]
(SOL_SOCKET): Define to 0xffff.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add more mount checks
Eugene Syromyatnikov [Wed, 4 Apr 2018 21:25:19 +0000 (23:25 +0200)]
tests: add more mount checks

* tests/gen_tests.in (mount, mount-Xabbrev, mount-Xraw, mount-Xverbose):
Add -a33 option.
* tests/mount.c: Check printing of flags and pointers.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: use sprintrc in mount test
Dmitry V. Levin [Sat, 28 Apr 2018 20:48:52 +0000 (20:48 +0000)]
tests: use sprintrc in mount test

* tests/mount.c (main): Use sprintrc.

6 years agotests: add mount variants with different xlat verbosity levels
Eugene Syromyatnikov [Wed, 4 Apr 2018 21:03:26 +0000 (23:03 +0200)]
tests: add mount variants with different xlat verbosity levels

* tests/mount-Xabbrev.c: New file.
* tests/mount-Xraw.c: Likewise.
* tests/mount-Xverbose.c: Likewise.
* tests/mount.c: Add handling of XLAT_RAW and XLAT_VERBOSE macros.
* tests/pure_executables.list: Add mount-Xabbrev, mount-Xraw,
and mount-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (mount-Xabbrev, mount-Xraw, mount-Xverbose): New
tests.

6 years agotests: add old_mmap variants with different xlat verbosity levels
Eugene Syromyatnikov [Wed, 4 Apr 2018 16:44:44 +0000 (18:44 +0200)]
tests: add old_mmap variants with different xlat verbosity levels

* tests/old_mmap-Xabbrev.c: New file.
* tests/old_mmap-Xraw.c: Likewise.
* tests/old_mmap-Xverbose.c: Likewise.
* tests/old_mmap.c (main): Add handling of XLAT_RAW and XLAT_VERBOSE
macros.
* tests/pure_executables.list: Add old_mmap-Xabbrev, old_mmap-Xraw,
and old_mmap-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (old_mmap-Xabbrev, old_mmap-Xraw,
old_mmap-Xverbose): New tests.

6 years agotests: add mmap/mmap64 variants different xlat verbosity levels
Eugene Syromyatnikov [Wed, 4 Apr 2018 15:38:53 +0000 (17:38 +0200)]
tests: add mmap/mmap64 variants different xlat verbosity levels

* tests/tests.h [!XLAT_RAW] (XLAT_RAW): Define.
[!XLAT_VERBOSE] (XLAT_VERBOSE): Likewise.
* tests/mmap-Xabbrev.c: New file.
* tests/mmap-Xraw.c: Likewise.
* tests/mmap-Xverbose.c: Likewise.
* tests/mmap64-Xabbrev.c: Likewise.
* tests/mmap64-Xraw.c: Likewise.
* tests/mmap64-Xverbose.c: Likewise.
* tests/mmap.c (main): Add handling of XLAT_RAW and XLAT_VERBOSE macros.
* tests/mmap.test: Add handling of optional test arguments that set
alignment and xlat verbosity options.
* tests/Makefile.am (mmap64_Xabbrev_CPPFLAGS, mmap64_Xraw_CPPFLAGS,
mmap64_Xverbose_CPPFLAGS): New variables, analogous to mmap64_CPPFLAGS.
* tests/pure_executables.list: Add mmap-Xabbrev, mmap-Xraw,
mmap-Xverbose, mmap64-Xabbrev, mmap64-Xraw, and mmap64-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (mmap-Xabbrev, mmap-Xraw, mmap-Xverbose,
mmap64-Xabbrev, mmap64-Xraw, mmap64-Xverbose): New tests.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoFix fallback definition of MSG_ZEROCOPY
Dmitry V. Levin [Fri, 27 Apr 2018 07:19:52 +0000 (07:19 +0000)]
Fix fallback definition of MSG_ZEROCOPY

* xlat/msg_flags.in (MSG_ZEROCOPY): Set fallback definition to 0x4000000.

Fixes: v4.21~316 ("Update MSG_* constants")
6 years agobuild: try to use _Static_assert if static_assert is not available
Dmitry V. Levin [Fri, 27 Apr 2018 07:19:52 +0000 (07:19 +0000)]
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.

6 years agoprintmode: add xlat style support to print_symbolic_mode_t
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:32:05 +0000 (15:32 +0200)]
printmode: add xlat style support to print_symbolic_mode_t

* printmode.c (print_symbolic_mode_t): Set ifmt to an empty string,
print raw and decoded values based on current xlat_verbosity setting.

6 years agoevdev: remove XT_NORMAL
Eugene Syromyatnikov [Mon, 2 Apr 2018 19:13:42 +0000 (21:13 +0200)]
evdev: remove XT_NORMAL

It is no longer used.

* evdev.c (enum xlat_type) <XT_NORMAL>: Remove.
(printxval_dispatch) <case XT_NORMAL>: Remove.

6 years agoSwitch to use of value-indexed xlats for evdev constants
Eugene Syromyatnikov [Mon, 2 Apr 2018 19:09:15 +0000 (21:09 +0200)]
Switch to use of value-indexed xlats for evdev constants

* xlat/evdev_abs.in: Add "#value_indexed" directive.
* xlat/evdev_autorepeat.in: Likewise.
* xlat/evdev_ff_status.in: Likewise.
* xlat/evdev_keycode.in: Likewise.
* xlat/evdev_leds.in: Likewise.
* xlat/evdev_misc.in: Likewise.
* xlat/evdev_prop.in: Likewise.
* xlat/evdev_relative_axes.in: Likewise.
* xlat/evdev_snd.in: Likewise.
* xlat/evdev_switch.in: Likewise.
* xlat/evdev_sync.in: Likewise.
* xlat/evdev_ff_types.in: Add a comment about sorting.
* evdev.c (keycode_ioctl, keycode_V2_ioctl): Use printxval_index
instead of printxval.
(bit_ioctl): Use XT_SORTED for evdev_ff_types, use XT_INDEXED
for other xlats.
(evdev_read_ioctl): Use XT_INDEXED for all xlats.
* ioctl.c (evdev_decode_number): Use printxval_indexn instead of
printxval for evdev_abs.

6 years agoevdev: support various types of xlats in decode_bitset
Eugene Syromyatnikov [Mon, 2 Apr 2018 18:32:19 +0000 (20:32 +0200)]
evdev: support various types of xlats in decode_bitset

* evdev.c (enum xlat_type): New enumeration.
(printxval_dispatch): New function.
(decode_bitset_): Rename from decode_bitset, add decode_nr_size
and xt arguments, call printxval_dispatch instead of printxval.
(decode_bitset): Add a decode_bitset_ wrapper that derives
decode_nr_size from the ARRAY_SIZE of decode_nr.
(bit_ioctl, evdev_read_ioctl): Update decode_bitset calls.

6 years agoMove xlat/evdev_abs.h inclusion from ioctl.c to evdev.c
Eugene Syromyatnikov [Mon, 2 Apr 2018 18:16:00 +0000 (20:16 +0200)]
Move xlat/evdev_abs.h inclusion from ioctl.c to evdev.c

Also introduce evdev_abs_size constant, which will be needed later.

* defs.h (evdev_abs_size): New declaration.
* ioctl.c: Move xlat/evdev_abs.h inclusion ...
* evdev.c: ... here.
(evdev_abs_size): New constant variable.

6 years agoAdd support for value-indexed xlats
Eugene Syromyatnikov [Mon, 2 Apr 2018 18:01:56 +0000 (20:01 +0200)]
Add support for value-indexed xlats

There are quite a few xlats that start from 0 and not too sparse,
we can push the search time for them down to O(1).

* defs.h (printxval_indexn_ex): New declaration.
(printxval_indexn, printxval_index, printxval_index_ex): New macros.
* xlat.c (printxval_sized): Rename from printxval_searchn_ex,
add fn argument, call it instead of xlat_search.
(printxval_searchn_ex): Implement as a thin wrapper around
printxval_sized using xlat_search as a search function.
(xlat_idx): New function.
(printxval_indexn_ex): New function, a thin wrapper around
printxval_sized using xlat_idx as a search function.
* xlat/gen.sh: Add support for "#value_indexed" directive.

6 years agosocketcall: use printxval_d for printing call argument
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:52:36 +0000 (15:52 +0200)]
socketcall: use printxval_d for printing call argument

* socketcall.c (SYS_FUNC(socketcall)): Use printxval_d instead of manual
call argument decoding.

6 years agosignal: use print_xlat_ex in print_sa_handler
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:51:36 +0000 (15:51 +0200)]
signal: use print_xlat_ex in print_sa_handler

* signal.c (print_sa_handler): Call print_xlat_ex instead of tprints
in order to respect current xlat style setting.

6 years agos390: use printxvals_ex for command printing in s390_runtime_instr
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:42:00 +0000 (15:42 +0200)]
s390: use printxvals_ex for command printing in s390_runtime_instr

* s390.c (SYS_FUNC(s390_runtime_instr)): Replace manual command argument
decoding with a printxvals_ex call.

6 years agoprintsiginfo: use print_xlat_ex in print_si_code
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:36:29 +0000 (15:36 +0200)]
printsiginfo: use print_xlat_ex in print_si_code

In order to respect current xlat style setting.

* printsiginfo.c (print_si_code): Use print_xlat_ex instead of manual
string/value printing.

6 years agoopen: use print_xlat_ex for printing open modes
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:54:06 +0000 (14:54 +0200)]
open: use print_xlat_ex for printing open modes

In order to respect xlat style setting.

* open.c (tprint_open_modes): Use print_xlat_ex instead of
tprint_open_modes.

6 years agonetlink: use print_xlat_ex in decode_nlmsg_type_netfilter
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:39:42 +0000 (14:39 +0200)]
netlink: use print_xlat_ex in decode_nlmsg_type_netfilter

In order to respect current xlat style setting.

* netlink.c (decode_nlmsg_type_netfilter): Use print_xlat_ex
instead of tprints.

6 years agonet: use print_xlat_ex in tprint_sock_type
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:38:22 +0000 (14:38 +0200)]
net: use print_xlat_ex in tprint_sock_type

In order to respect current xlat style setting.

* next.c (tprint_sock_type): Use print_xlat_ex instead of tprints
for socket type printing.

6 years agokeyctl: use printxval_d for printing keyring serial number
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:31:09 +0000 (14:31 +0200)]
keyctl: use printxval_d for printing keyring serial number

* keyctl.c (print_keyring_serial_number): Use printxval_d instead of
looking up and printing xlat value manually.
* xlat/key_spec.in: Add "#val_type int" so the xlat values have sign
bit propagated.

6 years agoipc: use printxval_u instead of manual xlat value printing
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:28:34 +0000 (14:28 +0200)]
ipc: use printxval_u instead of manual xlat value printing

* ipc.c (SYS_FUNC(ipc)): Decode call argument using printxval_u.

6 years agoioprio: use sprintxval instead of xlookup and string/value printing
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:19:50 +0000 (14:19 +0200)]
ioprio: use sprintxval instead of xlookup and string/value printing

In order to respect current xlat style.

* ioprio.c (sprint_ioprio): Use sprintxval for producing string
representation of ioprio class, use the produced string representation
in resulting xsprintf.

6 years agoxlat: handle NULL str in print_xlat_ex
Eugene Syromyatnikov [Wed, 4 Apr 2018 11:29:58 +0000 (13:29 +0200)]
xlat: handle NULL str in print_xlat_ex

It allows to use the following code pattern:

print_xlat_ex(val, xlookup(xlat, val), XLAT_STYLE_FMT_D);

* xlat.c (print_xlat_ex): Handle str being NULL: print val instead.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agostrace.1.in: fix typo (Ronald -> Roland)
Eugene Syromyatnikov [Thu, 26 Apr 2018 15:26:22 +0000 (17:26 +0200)]
strace.1.in: fix typo (Ronald -> Roland)

A very unfortunate one, though.

6 years agoNEWS: mention that -X option addresses Debian bug #692915
Eugene Syromyatnikov [Tue, 24 Apr 2018 15:19:19 +0000 (17:19 +0200)]
NEWS: mention that -X option addresses Debian bug #692915

6 years agoioctl: do not include linux/input.h
Eugene Syromyatnikov [Mon, 2 Apr 2018 18:13:37 +0000 (20:13 +0200)]
ioctl: do not include linux/input.h

All the ABS_* and EV_* values are now available internally,
there's no need to include the header.

* ioctl.c [HAVE_LINUX_INPUT_H]: Do not include linux/input.h.

6 years agotests: add more evdev ioctl checks
Eugene Syromyatnikov [Mon, 2 Apr 2018 18:09:02 +0000 (20:09 +0200)]
tests: add more evdev ioctl checks

tests/ioctl_evdev.c (TEST_NULL_ARG_EX): Rename from TEST_NULL_ARG, add
str argument, print it instead of #cmd.
(TEST_NULL_ARG): Implement as a TEST_NULL_ARG_EX wrapper.
(main): Add checks for EVIOCSABS and EVIOCGBIT ioctls.

6 years agoevdev: decode EV_SW unconditionally
Eugene Syromyatnikov [Fri, 30 Mar 2018 20:20:24 +0000 (22:20 +0200)]
evdev: decode EV_SW unconditionally

* evdev.c (bit_ioctl): Remove [EV_SW] check.
* tests/ioctl_evdev.c [!EV_SW] (EV_SW): Define.
(main): Remove [EV_SW] check.

6 years agoxlat: provide fallback definitions for arch-independent evdev constants
Eugene Syromyatnikov [Mon, 2 Apr 2018 00:44:55 +0000 (02:44 +0200)]
xlat: provide fallback definitions for arch-independent evdev constants

* xlat/evdev_abs.in: Add constant values.
* xlat/evdev_autorepeat.in: Likewise.
* xlat/evdev_ev.in: Likewise.
* xlat/evdev_ff_status.in: Likewise.
* xlat/evdev_ff_types.in: Likewise.
* xlat/evdev_leds.in: Likewise.
* xlat/evdev_misc.in: Likewise.
* xlat/evdev_prop.in: Likewise.
* xlat/evdev_relative_axes.in: Likewise.
* xlat/evdev_snd.in: Likewise.
* xlat/evdev_switch.in: Likewise.
* xlat/evdev_sync.in: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoxlat/evdev_switch.in: update
Eugene Syromyatnikov [Fri, 30 Mar 2018 20:22:52 +0000 (22:22 +0200)]
xlat/evdev_switch.in: update

* xlat/evdev_switch.in (SW_RADIO): Remove, as it was renamed to
SW_RFKILL_ALL and marked as deprecated by Linux commit v2.6.26-rc5~32^2.
(SW_PEN_INSERTED): New constant, was added by Linux commit v4.7~11^2~7.

6 years agoutil.c: make "Out of memory" messages a bit more informative
Eugene Syromyatnikov [Mon, 9 Apr 2018 08:19:01 +0000 (10:19 +0200)]
util.c: make "Out of memory" messages a bit more informative

Since these are emitted in multiple places and are not expected during
any normal operation, it makes sense to report the caller name.

* util.c (print_quoted_string_ex, print_quoted_string_ex, dumpiov_upto,
dumpstr): Replace error_msg with error_func_msg.

6 years agoci: reorder travis jobs
Eugene Syromyatnikov [Sat, 7 Apr 2018 00:45:09 +0000 (02:45 +0200)]
ci: reorder travis jobs

Run coverage check first as it is the longest one.

* .travis.yml (matrix): Reorder.

6 years agoxlat: add MS_SUBMOUNT constant
Eugene Syromyatnikov [Wed, 4 Apr 2018 21:24:23 +0000 (23:24 +0200)]
xlat: add MS_SUBMOUNT constant

* xlat/mount_flags.in (MS_SUBMOUNT): New constant, introduced
by Linux commit v4.11-rc1~82^2~7.

6 years agofcntl: replace combinations of xlookup and printxval with printxvals
Eugene Syromyatnikov [Wed, 4 Apr 2018 12:12:08 +0000 (14:12 +0200)]
fcntl: replace combinations of xlookup and printxval with printxvals

After all, that's what printxvals for.

* fcntl.c (SYS_FUNC(fcntl), SYS_FUNC(fcntl64)): Use printxvals for
printing value with multiple xlat tables as constant sources.

6 years agoMove xlat_verbose and xlat_format from xlat.c to defs.h
Eugene Syromyatnikov [Wed, 4 Apr 2018 11:28:51 +0000 (13:28 +0200)]
Move xlat_verbose and xlat_format from xlat.c to defs.h

As it will be used elsewhere.

* xlat.c (xlat_verbose, xlat_format): Move...
* defs.h: ...here.

6 years agobtrfs: use printxval_u for error types printing
Eugene Syromyatnikov [Wed, 4 Apr 2018 13:56:52 +0000 (15:56 +0200)]
btrfs: use printxval_u for error types printing

* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case
BTRFS_IOC_GET_DEV_STATS>: Use printxval_u for error type printing.
* tests/btrfs.c (btrfs_test_get_dev_stats_ioctl): Update expected output.

6 years agobtrfs: print device IDs using PRINT_FIELD_DEV
Eugene Syromyatnikov [Mon, 26 Mar 2018 04:45:36 +0000 (06:45 +0200)]
btrfs: print device IDs using PRINT_FIELD_DEV

* btrfs.c (btrfs_print_balance_args): Print devid field using
PRINT_FIELD_DEV.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_INFO,
case BTRFS_IOC_GET_DEV_STATS, case BTRFS_IOC_SCRUB,
case BTRFS_IOC_SCRUB_PROGRESS>: Likewise.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_REPLACE>: Print
start.srcdevid field using PRINT_FIELD_DEV.
* tests/btrfs.c: Update expected output.

6 years agobtrfs: print cont_reading_from_srcdev_mode as xlat
Eugene Syromyatnikov [Sun, 25 Mar 2018 16:28:47 +0000 (18:28 +0200)]
btrfs: print cont_reading_from_srcdev_mode as xlat

* xlat/btrfs_cont_reading_from_srcdev_mode.in: New file.
* btrfs.c: Include "xlat/btrfs_cont_reading_from_srcdev_mode.h".
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_DEV_REPLACE>: Print
named values for the
struct btrfs_ioctl_dev_replace_args.start.cont_reading_from_srcdev_mode
field.
* tests/btrfs.c: Include "xlat/btrfs_cont_reading_from_srcdev_mode.h".
(btrfs_test_dev_replace_ioctl): Update expected output.

6 years agobtrfs: use PRINT_FIELD_*
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:49:05 +0000 (05:49 +0100)]
btrfs: use PRINT_FIELD_*

* btrfs.c (btrfs_print_balance_args, btrfs_print_balance,
btrfs_print_features, btrfs_print_qgroup_limit,
btrfs_print_data_container_header,
print_btrfs_data_container_logical_ino, btrfs_print_qgroup_inherit,
btrfs_print_tree_search, print_btrfs_ioctl_space_info, btrfs_ioctl):
Use PRINT_FIELD_* macros for printing structure fields.

6 years agobtrfs: make BTRFS_IOC_GET_DEV_STATS error statistics output more structured
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:48:22 +0000 (05:48 +0100)]
btrfs: make BTRFS_IOC_GET_DEV_STATS error statistics output more structured

* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case
BTRFS_IOC_GET_DEV_STATS>: Print array index in square brackets before
the value in order to avoid confusion.
* tests/btrfs.c (btrfs_test_get_dev_stats_ioctl): Update expected output.

6 years agoioctl: print ioctl number in accordance with xlat verbosity setting
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:27:41 +0000 (05:27 +0100)]
ioctl: print ioctl number in accordance with xlat verbosity setting

* ioctl.c (SYS_FUNC(ioctl)): Print ioctl command name in accordance
with the current xlat_verbosity setting.
* tests/btrfs.c (sprint_xlat_): New function.
(ioc): New macro, a wrapper for sprint_xlat_.
Update expected output.

6 years agofile_ioctl: make abbreviated output more structured
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:24:16 +0000 (05:24 +0100)]
file_ioctl: make abbreviated output more structured

* file_ioctl.c (file_ioctl): Print fm_extents field name only in case
of non-abbreviated output.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Update expected output.

6 years agobtrfs: fix printing of struct btrfs_ioctl_quota_ctl_args
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:22:42 +0000 (05:22 +0100)]
btrfs: fix printing of struct btrfs_ioctl_quota_ctl_args

For some reason, he decoder of BTRFS_IOC_QUOTA_CTL command didn't print
opening curly brace and field name, only the closing curly brace.

* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_QUOTA_CTL>:
Print "{cmd=".
* tests/btrfs.c (btrfs_test_quota_ctl_ioctl): Update expected output.

Fixes: v4.12~100 "ioctl: add decoding support for btrfs ioctls"
6 years agobtrfs: consistently use PRINT_FIELD_U64
Eugene Syromyatnikov [Tue, 13 Mar 2018 22:47:37 +0000 (23:47 +0100)]
btrfs: consistently use PRINT_FIELD_U64

* btrfs.c (print_u64, print_member_u64, print_key_value_internal,
print_key_value): Remove.
(btrfs_print_balance_args): Use PRINT_FIELD_U64 instead of
print_member_u64.
(btrfs_print_tree_search): Use PRINT_FIELD_U64 instead of
print_key_value.
(MPERS_PRINTER_DECL(btrfs_ioctl)): Use PRINT_FIELD_U64 instead of manual
UINT64_MAX printing.
* tests/btrfs.c: Update expected output in order to account fields that
are now affected by xlat_verbosity setting.

6 years agobtrfs: print {min,max}_{offset,transid} unconditionally
Eugene Syromyatnikov [Sat, 17 Mar 2018 09:32:59 +0000 (10:32 +0100)]
btrfs: print {min,max}_{offset,transid} unconditionally

As it looks like there's no reason to skip their printing.

* btrfs.c (print_key_value_internal): Do not check value argument
for holding non-zero value.
* tests/btrfs.c (btrfs_print_search_key): Update expected output.

6 years agotests/btrfs.c: accept possible failure of BTRFS_IOC_BALANCE_V2
Eugene Syromyatnikov [Mon, 19 Mar 2018 02:14:20 +0000 (03:14 +0100)]
tests/btrfs.c: accept possible failure of BTRFS_IOC_BALANCE_V2

BTRFS_IOC_BALANCE_V2 ioctl might fail sometimes (for example, if it
decides that it doesn't have enough free space).

* tests/btrfs.c (btrfs_test_balance_ioctls): Print expected output for
the BTRFS_IOC_BALANCE_V2 call based on its return code.

6 years agotests/btrfs.c: support volumes with mixed data/metadata in BTRFS_IOC_BALANCE_V2
Eugene Syromyatnikov [Mon, 19 Mar 2018 02:13:56 +0000 (03:13 +0100)]
tests/btrfs.c: support volumes with mixed data/metadata in BTRFS_IOC_BALANCE_V2

For these volumes, pend/vend should be the same for data and meta.

* tests/btrfs.c (btrfs_test_balance_ioctls): Set args.meta.pend and
args.meta.vend to the same values as args.data.pend and args.data.vend,
respectively.

6 years agotests/btrfs.c: check BTRFS_IOC_SUBVOL_CREATE_V2 result
Eugene Syromyatnikov [Mon, 19 Mar 2018 01:45:31 +0000 (02:45 +0100)]
tests/btrfs.c: check BTRFS_IOC_SUBVOL_CREATE_V2 result

Otherwise the subsequent openat call fails with a cryptic message.

* tests/btrfs.c (btrfs_test_subvol_ioctls): Check return code of the
BTRFS_IOC_SUBVOL_CREATE_V2 ioctl call that is supposed to be successful.

6 years agotests/btrfs.c: add pid suffix to the created directory, remove it on exit
Eugene Syromyatnikov [Sun, 18 Mar 2018 06:56:52 +0000 (07:56 +0100)]
tests/btrfs.c: add pid suffix to the created directory, remove it on exit

If multiple tests are running simultaneously in the same directory,
conflicts (and test failures) may happen.

* tests/btrfs.c (path, dir_name_fmt, dir_name): New variables.
(btrfs_test_ino_path_ioctls): Use dir_name for printing directory name.
(rm_test_dir): New function.
(main): Generate dir_name, use it instead of fixed name, add rm_test_dir
as an atexit handler.

6 years agobtrfs: duplicate printing of opening braces on entering/exiting
Eugene Syromyatnikov [Sat, 17 Mar 2018 05:38:08 +0000 (06:38 +0100)]
btrfs: duplicate printing of opening braces on entering/exiting

* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)): Print opening bracket
on entering and exiting separately.

6 years agobtrfs: refactor timespec printing into print_btrfs_timespec
Eugene Syromyatnikov [Thu, 15 Mar 2018 22:57:25 +0000 (23:57 +0100)]
btrfs: refactor timespec printing into print_btrfs_timespec

* btrfs.c (print_btrfs_timespec): New function.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SET_RECEIVED_SUBVOL>:
Use print_btrfs_timespec for printing stime and rtime fields.
* tests/btrfs.c (btrfs_test_set_received_subvol_ioctl): Update expected
output.

6 years agobtrfs: print abbreviations and field names more consistently
Eugene Syromyatnikov [Wed, 14 Mar 2018 20:13:40 +0000 (21:13 +0100)]
btrfs: print abbreviations and field names more consistently

* btrfs.c (btrfs_print_data_container_header): Do not print ", val=".
(btrfs_print_ino_path_container): Print val field name only in case
of non-abbreviated output.
(btrfs_print_qgroup_inherit): Print qgroups field name only in case
of non-abbreviated output.
(btrfs_print_tree_search): Print buf field name only in case
of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SEND>: Print
clone_sources field name only in case of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SPACE_INFO>: Print
spaces field name only in case of non-abbreviated output.
* tests/btrfs.c: Update expected output.

6 years agobtrfs: move printing of the field name inside btrfs_print_qgroup_limit
Eugene Syromyatnikov [Wed, 14 Mar 2018 19:55:00 +0000 (20:55 +0100)]
btrfs: move printing of the field name inside btrfs_print_qgroup_limit

* btrfs.c (btrfs_print_qgroup_limit): Print ", lim=".
(btrfs_print_qgroup_inherit, MPERS_PRINTER_DECL(btrfs_ioctl)): Do not
print ", lim=" before btrfs_print_qgroup_limit call.

6 years agobtrfs: convert btrfs_print_{objectid,key_type} to PRINT_FIELD_XVAL_U
Eugene Syromyatnikov [Tue, 13 Mar 2018 22:59:22 +0000 (23:59 +0100)]
btrfs: convert btrfs_print_{objectid,key_type} to PRINT_FIELD_XVAL_U

* btrfs.c (btrfs_print_key_type, btrfs_print_objectid): Convert into
thin wrappers around PRINT_FIELD_XVAL_U.
(btrfs_print_data_container_header, btrfs_print_tree_search,
MPERS_PRINTER_DECL(btrfs_ioctl)): Update calls to btrfs_print_key_type
and btrfs_print_objectid in accordance with the new calling convention.
(print_objectid_callback): Use printxvals_ex directly instead of
btrfs_print_objectid call.
* tests/btrfs.c (btrfs_print_objectid, btrfs_print_key_type): Update
expected output.

6 years agotests: add btrfs tests with verbose xlat decoding
Eugene Syromyatnikov [Sat, 17 Mar 2018 07:33:05 +0000 (08:33 +0100)]
tests: add btrfs tests with verbose xlat decoding

* tests/btrfs-X.test: New test.
* tests/btrfs-vX.test: Likewise.
* tests/btrfs-vwX.test: Likewise.
* tests/btrfs-wX.test: Likewise.
* tests/Makefile.am (DECODER_TESTS): Add them.
* tests/btrfs.c (verbose_xlat): New static variable.
(prfl_btrfs, prxval_btrfs): New function.
(btrfs_print_qgroup_inherit, btrfs_print_vol_args_v2,
btrfs_print_balance_args, btrfs_test_balance_ioctls,
btrfs_test_clone_ioctls, btrfs_test_defrag_ioctls,
btrfs_test_space_info_ioctl, btrfs_print_defrag_range_args,
btrfs_test_scrub_ioctls, btrfs_test_ino_path_ioctls,
btrfs_test_send_ioctl, btrfs_test_send_ioctl,
btrfs_test_quota_ctl_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_get_dev_stats_ioctl, btrfs_test_dev_replace_ioctl,
btrfs_test_dev_replace_ioctl, btrfs_print_features): Use prfl_btrfs and
prxval_btrfs instead of printflags and printxval, respectively.
(btrfs_test_balance_ioctls, btrfs_test_ino_path_ioctls,
btrfs_test_quota_ctl_ioctl, btrfs_test_dev_replace_ioctl,
btrfs_test_dev_replace_ioctl): Update expected output based on
verbose_xlat setting.
(btrfs_print_defrag_range_args): Add compress_type_known arg, pass it
to prxval_btrfs.
(main): Handle -X option.

6 years agotests: check -X option syntax
Eugene Syromyatnikov [Wed, 4 Apr 2018 16:48:06 +0000 (18:48 +0200)]
tests: check -X option syntax

* tests/options-syntax.test: Add checks for -X option with invalid
arguments.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoAdd user interface for configuring xlat output style
Eugene Syromyatnikov [Sat, 10 Mar 2018 04:12:45 +0000 (05:12 +0100)]
Add user interface for configuring xlat output style

* strace.c (init): Handle -X option, set xlat_verbosity
according to -X argument.
* strace.1.in: Document -X option.
* NEWS: Mention it.

Closes: https://github.com/strace/strace/issues/27
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobpf: print fields that interpreted as pointers using printaddr64
Eugene Syromyatnikov [Mon, 26 Mar 2018 04:37:16 +0000 (06:37 +0200)]
bpf: print fields that interpreted as pointers using printaddr64

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM),
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)): Print key and value
fields using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)): Print key field using
PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)): Print key and next_key
field using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print insns and log_buf fields
using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)): Print data_in and data_out
fields using PRINT_FIELD_ADDR64.
* tests/bpf.c: Update expected output.

6 years agobuild: make it even more reproducible
Dmitry V. Levin [Fri, 20 Apr 2018 13:15:38 +0000 (13:15 +0000)]
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

6 years agounwind: move unwind_tcb_init invocation to after_successful_attach
Dmitry V. Levin [Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)]
unwind: move unwind_tcb_init invocation to after_successful_attach

There is no need to call unwind_tcb_init before the tracee is attached.

* strace.c (alloctcb) [ENABLE_STACKTRACE]: Move unwind_tcb_init
invocation ...
(after_successful_attach) [ENABLE_STACKTRACE]: ... here.
(init) [ENABLE_STACKTRACE]: Remove unwind_tcb_init invocation loop.
* unwind.c (unwind_tcb_fin): Skip if tcp->unwind_queue is NULL.

6 years agostrace: move setting of post-attach flags inside after_successful_attach
Dmitry V. Levin [Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)]
strace: move setting of post-attach flags inside after_successful_attach

* strace.c (after_successful_attach): Add "flags" argument.
Set TCB_ATTACHED, TCB_STARTUP, and "flags" in tcp->flags.
All users updated.

6 years agostrace: rename newoutf to after_successful_attach
Dmitry V. Levin [Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)]
strace: rename newoutf to after_successful_attach

This function is going to be used for other things that have to be done
right after a successful attach, hence the rename.

* strace.c (newoutf): Rename to after_successful_attach,
all users updated.

6 years agounwind: remove stray newline in error diagnostics
Dmitry V. Levin [Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)]
unwind: remove stray newline in error diagnostics

* unwind-libdw.c (tcb_init): Do not pass trailing "\n" to error_msg
as the latter prints newline itself.

6 years agobuild: make it more reproducible
Dmitry V. Levin [Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)]
build: make it more reproducible

* file-date-gen: Consistently print the UTC date in C locale.
When $SOURCE_DATE_EPOCH is non-empty, use it as fallback date
before the current system date.

Reported-by: Chris Lamb <lamby@debian.org>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896016
Closes: https://github.com/strace/strace/pull/68
6 years agounwind: initialize unwind context only if given tcb is initialized
Masatake YAMATO [Thu, 19 Apr 2018 08:49:47 +0000 (17:49 +0900)]
unwind: initialize unwind context only if given tcb is initialized

With libdw based unwinder, following warnings are reported
when -p is passed before -k:

   $ ./strace -p 1 -k
   ...
   ./strace: dwfl_linux_proc_attach returned an error for process 0: No such file or directory
   ...

It seems that commit 54c7792b, "Fix libunwind segfault when -p is
passed before -k" doesn't fix the original issue.

* strace.c (init) [ENABLE_STACKTRACE]: Initialize unwind context only
if given tcb is initialized.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agobpf: harmonize length checks
Dmitry V. Levin [Thu, 12 Apr 2018 23:00:29 +0000 (23:00 +0000)]
bpf: harmonize length checks

The rest of the decoder uses offsetof to check the length.

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_OBJ_PIN),
BEGIN_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID),
BEGIN_BPF_CMD_DECODER(BPF_PROG_GET_FD_BY_ID),
BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_FD_BY_ID)): Use offsetof instead
of offsetofend.

6 years agobpf: add support for map_name and map_ifindex fields in BPF_MAP_CREATE
Eugene Syromyatnikov [Mon, 5 Mar 2018 14:53:48 +0000 (15:53 +0100)]
bpf: add support for map_name and map_ifindex fields in BPF_MAP_CREATE

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Decode map_name
and map_ifindex fields that were added in Linux commits
v4.15-rc1~84^2~605^2~3 and v4.16-rc1~123^2~145^2~5^2~8, respectively.
* bpf_attr.h (struct BPF_MAP_CREATE_struct): Add map_name
and map_ifindex fields.
* tests/bpf.c (init_BPF_MAP_CREATE_attr7): New function.
(BPF_MAP_CREATE_checks): Remove const qualifier, add two more checks.

6 years agobpf: improve handling of various sizes of BPF_MAP_CREATE attributes
Eugene Syromyatnikov [Mon, 5 Mar 2018 14:53:08 +0000 (15:53 +0100)]
bpf: improve handling of various sizes of BPF_MAP_CREATE attributes

* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Skip printing
the rest of the structure if len is less than the offset of the end
of max_entries, map_flags, or inner_map_fd field.
* tests/bpf.c (BPF_MAP_CREATE_checks): Add two more checks.

6 years agotests: add checks for bpf BPF_MAP_CREATE arguments
Eugene Syromyatnikov [Sun, 25 Mar 2018 10:27:28 +0000 (12:27 +0200)]
tests: add checks for bpf BPF_MAP_CREATE arguments

* tests/bpf.c (BPF_MAP_CREATE_checks): Add two more checks.

6 years agobpf: print numa_node using xlat
Eugene Syromyatnikov [Fri, 2 Mar 2018 23:30:32 +0000 (00:30 +0100)]
bpf: print numa_node using xlat

As the value of -1 has a special meaning.  The issue is complicated
by the fact that this constant is not exported by UAPI.

* xlat/numa_node.in: New file.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Print numa_node field
using printxvals_ex with a special xlat style.

6 years agobtrfs: use umove_or_printaddr_ignore_syserror instead of u_error mangling
Eugene Syromyatnikov [Wed, 14 Mar 2018 20:08:34 +0000 (21:08 +0100)]
btrfs: use umove_or_printaddr_ignore_syserror instead of u_error mangling

* btrfs.c (MPERS_PRINTER_DECL(btrfs_ioctl)) <case
BTRFS_IOC_TREE_SEARCH_V2>: Use umove_or_printaddr_ignore_syserror
instead of tcp->u_error mangling around umove_or_printaddr call.

6 years agodefs.h: introduce umove_or_printaddr{,64}_ignore_syserror wrappers
Eugene Syromyatnikov [Wed, 14 Mar 2018 20:02:47 +0000 (21:02 +0100)]
defs.h: introduce umove_or_printaddr{,64}_ignore_syserror wrappers

* defs.h (umove_or_printaddr64_ignore_syserror): New macro, a thin
wrapper around umoven_or_printaddr64_ignore_syserror.
(umove_or_printaddr_ignore_syserror): New macro, a thin wrapper around
umoven_or_printaddr_ignore_syserror.

6 years agoprint_fields.h: add PRINT_FIELD_XVAL_U for printing xlat in %u format
Eugene Syromyatnikov [Tue, 13 Mar 2018 22:51:54 +0000 (23:51 +0100)]
print_fields.h: add PRINT_FIELD_XVAL_U for printing xlat in %u format

* print_fields.h (PRINT_FIELD_XVAL_U): New macro.

6 years agoprint_fields.h: add PRINT_FIELD_U64 for printing u64 with UINT64_MAX handling
Eugene Syromyatnikov [Tue, 13 Mar 2018 22:46:14 +0000 (23:46 +0100)]
print_fields.h: add PRINT_FIELD_U64 for printing u64 with UINT64_MAX handling

* print_fields.h (PRINT_FIELD_U64): New macro.

6 years agobpf_sock_filter: use print_xlat32
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:16:17 +0000 (06:16 +0100)]
bpf_sock_filter: use print_xlat32

We can't simply use print_xlat here due to the way those SKF_*_OFF
constants are defined.

* bpf_sock_filter.c (print_sock_filter_k): Use print_xlat32 for printing
SKF_AD_OFF, SKF_NET_OFF, and SKF_LL_OFF named constants.

6 years agodefs.h: add print_xlat32 macro
Eugene Syromyatnikov [Thu, 12 Apr 2018 22:57:46 +0000 (00:57 +0200)]
defs.h: add print_xlat32 macro

For those cases where inadvertent sign extension is possible.

* defs.h (print_xlat32): New macro, a wrapper for print_xlat_ex.

6 years agoopen: use print_xlat_d in print_dirfd
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:56:21 +0000 (06:56 +0100)]
open: use print_xlat_d in print_dirfd

* open.c (print_dirfd): Use print_xlat_d for printing AT_FDCWD named
constant.

6 years agofanotify: use print_xlat_d
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:17:31 +0000 (06:17 +0100)]
fanotify: use print_xlat_d

* fanotify.c (SYS_FUNC(fanotify_mark)): Use print_xlat_d for printing
FAN_NOFD named constant.

6 years agoAdd print_xlat_u and print_xlat_d shorthands
Eugene Syromyatnikov [Sat, 7 Apr 2018 00:11:07 +0000 (02:11 +0200)]
Add print_xlat_u and print_xlat_d shorthands

Add variants of print_xlat with various value printing formats.

* defs.h (print_xlat_u, print_xlat_d): New macro, a wrapper for
print_xlat_ex.

6 years agoxlat: introduce XLAT_STYLE_FMT_D
Eugene Syromyatnikov [Wed, 4 Apr 2018 11:24:54 +0000 (13:24 +0200)]
xlat: introduce XLAT_STYLE_FMT_D

As there are some possible users for it, apparently.

* defs.h (XLAT_STYLE_FORMAT_MASK): Update the value in order to
accommodate XLAT_STYLE_FMT_D.
(enum xlat_style) <XLAT_STYLE_FMT_D>: New enumeration entity.
(printxval64_d, printxval_d): New function, a shorthand for
printxvals_ex with a single xlat and XLAT_STYLE_FMT_D xlat style.
* xlat.c (sprint_xlat_val): Handle XLAT_STYLE_FMT_D.

6 years agodefs.h: add shorthands for printing xval with XLAT_STYLE_FMT_U
Eugene Syromyatnikov [Wed, 4 Apr 2018 11:22:52 +0000 (13:22 +0200)]
defs.h: add shorthands for printing xval with XLAT_STYLE_FMT_U

* defs.h (printxval_u, printxval64_u): New function, a shorthand for
printxvals_ex with a single xlat and XLAT_STYLE_FMT_U as a style.

6 years agoAdd support for various xlat formats
Eugene Syromyatnikov [Sat, 10 Mar 2018 06:20:26 +0000 (07:20 +0100)]
Add support for various xlat formats

Since xlat printing routines now have a notion of "style" that should be
used for printing xlat values, we can also employ this argument for
passing information about number printing format (unsigned decimal
or hexadecimal, so far).

* defs.h (XLAT_STYLE_FORMAT_SHIFT, XLAT_STYLE_FORMAT_MASK): New macro
constant.
(enum xlat_style) <XLAT_STYLE_FMT_X, XLAT_STYLE_FMT_U>: New enumeration
entities.
* xlat.c (xlat_verbose, xlat_format): New macro for checking specific
aspect of style argument.
(get_xlat_style): Use xlat_verbose for checking xlat verbosity style.
(sprint_xlat_val, print_xlat_val): New function, for easing printing
raw constant number with respect to printing format style.
(printxvals_ex, sprintxval_ex, printxval_searchn_ex,
printxval_searchn_ex, sprintflags_ex, printflags_ex, print_xlat_ex):
Use xlat_verbose macro for xlat verbosity style checks. Use
print_xlat_val instead of direct raw xlat value printing.

6 years agov4l2: use print_xlat in print_v4l2_queryctrl
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:56:40 +0000 (06:56 +0100)]
v4l2: use print_xlat in print_v4l2_queryctrl

* v4la.c (print_v4l2_queryctrl): Use print_xlat for printing
V4L2_CTRL_FLAG_NEXT_CTRL named constant.

6 years agoprctl: use print_xlat_ex to print PR_SET_PTRACER_ANY
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:29:41 +0000 (06:29 +0100)]
prctl: use print_xlat_ex to print PR_SET_PTRACER_ANY

We cannot simply use print_xlat as PR_SET_PTRACER_ANY is defined
differently in kernel headers.

* prctl.c (SYS_FUNC(prctl)) <case PR_SET_PTRACER>: Use print_xlat_ex
for printing PR_SET_PTRACER_ANY named constant.

6 years agonlattr: use print_xlat
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:18:51 +0000 (06:18 +0100)]
nlattr: use print_xlat

* nlattr.c (print_nlattr): Use print_xlat for printing NLA_F_NESTED and
NLA_F_NET_BYTEORDER named constants.

6 years agoipc_defs.h: use print_xlat
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:18:04 +0000 (06:18 +0100)]
ipc_defs.h: use print_xlat

* ipc_defs.h (PRINTCTL): Use print_xlat for printing IPC_64 named
constant.

6 years agofutex: use print_xlat
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:17:47 +0000 (06:17 +0100)]
futex: use print_xlat

* futex.c [!FUTEX_OP_OPARG_SHIFT] (FUTEX_OP_OPARG_SHIFT): New macro
constant.
(SYS_FUNC(futex)): Use print_xlat for printing FUTEX_OP_OPARG_SHIFT
named constant.

6 years agoipc: use printxval for printing key
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:17:11 +0000 (06:17 +0100)]
ipc: use printxval for printing key

Convert explicit constant printing logic into a printxval call in order
to account for xlat style setting.

* defs.h (ipc_private): New xlat array declaration.
* ipc_msg.c (SYS_FUNC(msgget)): Use printxval for printing IPC_PRIVATE.
* ipc_sem.c (SYS_FUNC(semtimedop)): Likewise.
* ipc_shm.c (SYS_FUNC(shmget)): Likewise.
* xlat/ipc_private.in: New file.

6 years agomount: use print_xlat for printing MS_MGC_VAL
Eugene Syromyatnikov [Sat, 10 Mar 2018 04:38:39 +0000 (05:38 +0100)]
mount: use print_xlat for printing MS_MGC_VAL

* mount.c (SYS_FUNC(mount)): Use print_xlat for printing MS_MGC_VAL
named constant.

6 years agoIntroduce print_xlat and print_xlat_ex
Eugene Syromyatnikov [Sat, 10 Mar 2018 04:51:55 +0000 (05:51 +0100)]
Introduce print_xlat and print_xlat_ex

print_xlat_ex prints a named constant in accordance with xlat style
provided, print_xlat is a thin wrapper around print_xlat_ex that passes
stringified constant name as a string and XLAT_STYLE_DEFAULT as a style.

* defs.h (print_xlat_ex): New function prototype.
(print_xlat): New macro, a thin wrapper around print_xlat_ex.
* xlat.c (print_xlat_ex): New function.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoIntroduce XLAT_STYLE_DEFAULT
Eugene Syromyatnikov [Sat, 10 Mar 2018 04:12:02 +0000 (05:12 +0100)]
Introduce XLAT_STYLE_DEFAULT

This will be needed later, with the introduction of user-configurable
xlat style setting (stored in xlat_verbosity variable).

* defs.h (XLAT_STYLE_VERBOSITY_MASK): New macro constant.
(enum xlat_style) <XLAT_STYLE_DEFAULT>: New enumeration entity.
(xlat_verbosity): New external declaration.
(printxvals, printxval_searchn, printxval_search_ex, sprintxval,
sprintflags, printflags64): Use XLAT_STYLE_DEFAULT instead of
XLAT_STYLE_ABBREV.
* strace.c (xlat_verbosity): New variable.
* xlat.c (get_xlat_style): New function.
(printxvals_ex, sprintxval_ex, printxval_searchn_ex, sprintflags_ex,
printflags_ex): Use it.

6 years agoIntroduce xlat verbosity styles
Eugene Syromyatnikov [Sat, 10 Mar 2018 03:48:33 +0000 (04:48 +0100)]
Introduce xlat verbosity styles

* defs.h (printxvals_ex): Rename from printxvals, add style argument.
(enum xlat_style): New enumeration.
(printxvals): New macro, a wrapper for printxvals_ex.
(printxval_searchn_ex): Rename from printxval_searchn, add style
argument.
(printxval_searchn): New macro, a wrapper for printxval_searchn_ex.
(printxval_search_ex): New macro, a wrapper for printxval_searchn_ex.
(sprintxval_ex): Rename from sprintxval, add style argument.
(sprintxval): New macro, a wrapper for sprintxval_ex.
(printflags_ex): Add style argument.
(sprintflags_ex): Rename from sprintflags, add style argument.
(sprintflags): New macro, a wrapper for sprintflags_ex.
(printflags64): Pass XLAT_STYLE_ABBREV as a style in printflags_ex call.
* netlink.c (decode_nlmsg_flags): Pass XLAT_STYLE_ABBREV as a style in
printflags_ex call.
* xlat.c (printxvals_ex): Rename from printxvals, add style argument,
handle it.
(sprintxval_ex): Rename from sprintxval, add style argument, handle it.
(printxval_searchn_ex): Rename from printxval_searchn, add style
argument, handle it.
(sprintflags_ex): Rename from sprintflags, add style argument,
handle it.
(printflags_ex): Add style argument, handle it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
References: https://github.com/strace/strace/issues/27

6 years agotests: robustify signal delivery test against kernel bugs
Dmitry V. Levin [Wed, 11 Apr 2018 22:01:37 +0000 (22:01 +0000)]
tests: robustify signal delivery test against kernel bugs

Recent kernel siginfo changes, namely, v4.14-rc1~60^2^2~1,
v4.16-rc1~159^2~37, and v4.16-rc1~159^2~39, introduced ABI regressions
that render the whole siginfo interface unreliable.

Looks like the kernel side is not eager to fix the breakage,
so here is a workaround.

* tests/signal_receive.c (s_sig, s_code, s_pid, s_uid): New volatile
variables.
(handler): Add siginfo_t parameter, save siginfo_t fields.
(sig_print): Remove.
(main): Rewrite.  Use variables saved by handler to print expected
siginfo output. Print diagnostics in case of siginfo mismatch.
* strace.spec.in (%check): Extract the diagnostics.

Closes: https://github.com/strace/strace/issues/21
6 years agoLift experimental status from stack tracing feature
Dmitry V. Levin [Wed, 11 Apr 2018 15:41:40 +0000 (15:41 +0000)]
Lift experimental status from stack tracing feature

* strace.1.in (.SH OPTIONS) <.B \-k>: Remove " (experimental)".
* strace.c (usage) [ENABLE_STACKTRACE]: Likewise.

6 years agoEnable stack tracing in packages on all architectures
Dmitry V. Levin [Sun, 8 Apr 2018 23:07:50 +0000 (23:07 +0000)]
Enable stack tracing in packages on all architectures

The stack tracing feature used to be enabled in packages on x86_64 only.
This change enables -k option on all architectures.

* debian/control (Build-Depends) [!amd64]: Add pkg-config, libdw-dev,
and libiberty-dev.
* strace.spec.in (BuildRequires) [!x86_64]: Add
%buildrequires_stacktrace.

6 years agoUse libdw-based unwinder in ci and packages
Dmitry V. Levin [Sun, 8 Apr 2018 23:07:50 +0000 (23:07 +0000)]
Use libdw-based unwinder in ci and packages

* ci/install-dependencies.sh (common_packages): Add pkg-config,
replace libunwind8-dev with libdw-dev.
* debian/control (Build-Depends) [amd64]: Add pkg-config,
replace libunwind-dev with libdw-dev.
* debian/rules (build-udeb/Makefile): Replace --without-libunwind
with --without-stacktrace.
* strace.spec.in (buildrequires_libunwind_devel): Rename
to buildrequires_stacktrace, replace libunwind-devel with
either elfutils-devel or libdw-devel.

6 years agotests: skip -k tests on unsupported architectures
Dmitry V. Levin [Wed, 11 Apr 2018 15:41:40 +0000 (15:41 +0000)]
tests: skip -k tests on unsupported architectures

* tests/strace-k.test: When actual strace -k output doesn't match the
expected output because of limited architecture support, skip the test
on architectures that are not currently supported by libdw.