7156 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
8783cd8119 ioctl: print ioctl code in accordance with xlat verbosity
* ioctl.c (ioctl_print_code): Format in accrordance with xlat verbosity
setting.
2018-09-24 00:06:08 +02:00
Eugene Syromyatnikov
aeb343b726 Implement sysfs syscall decoding
* Makefile.am (strace_SOURCES): New file.
* linux/dummy.h (sys_sysfs): Remove macro definition.
* sysfs.c: New file.
* tests/gen_tests.in: Add sysfs test definition.
* tests/.gitignore: add sysfs.
* tests/pure_executables.list: Add sysfs.
* tests/sysfs.c: New file.
2018-09-23 12:35:53 +02:00
Eugene Syromyatnikov
8a7ba35d04 msghdr: decode IP_RECVFRAGSIZE control message
Added in v4.10-rc1~202^2~340^2~2.

* xlat/ip_cmsg_types.in (SCM_SECURITY): Provide fallback message,
reorder.
(IP_RECVFRAGSIZE): New constant.
* msghdr.c (print_cmsg_int): New function.
(cmsg_ip_printers) <IP_RECVFRAGSIZE>: New printer.
2018-09-19 23:00:30 +02:00
Eugene Syromyatnikov
156777f967 Fix old_getrlimit handling
On some historic 32-bit platforms (and 64-bit SuperH), __NR_getrlimit
corresponds to a non-SuS-compatible version that uses a hardcoded value
of 0x7fffffff as infinity. Moreover, in order to provide a backwards
compatibility with that behaviour, some architectures (mips, sparc, and
alpha, with latter being especially peculiar in its ways) just defined
RLIM_INFINITY to that value (with alpha defining RLIM_INFINITY to 2^63-1)
instead of employing sys_old_getrlimit syscall and providing
__NR_ugetrlimit with proper implementation, as other arches did.

Overall, that led to conclusion that printing "RLIM_INFINITY" is never
enough and the actial value should be printed as well.

* linux/i386/syscallent.h ([76]): Changing decoder to old_getrlimit.
* linux/m68k/syscallent.h ([76]): Likewise.
* linux/microblaze/syscallent.h ([76]): Likewise.
* linux/powerpc/syscallent.h ([76]): Likewise.
* linux/s390/syscallent.h ([76]): Likewise.
* linux/sh/syscallent.h ([76]): Likewise.
* linux/sh64/syscallent.h ([76]): Likewise.
* resource.c (sprint_rlim64, sprint_rlim32, print_rlimit64,
print_rlimit32): Remove.
(STRACE_RLIM_INFINITY, STRACE_M32_RLIM_INFINITY,
STRACE_RLIM64_INFINITY, OLD_GETLIMIT_INFINITY): New macro constants.
(enum rlimit_decode_mode): New enumeration.
(struct rlimit_64): Move type definition out of print_rlimit64.
(print_rlim_t): New function, printer of an rlimit value, in accordance
with rlimit decode mode and xlat verbosity mode.
(print_rlimit): Printer of a fetched rlimit_64 structure.
(decode_rlimit): Fetches struct rlimit/rlimit64 in accordance with
current mode and personality, uses print_rlimit for printing.
(do_getrlimit): New function, decodes old_getrlimit/getrlimit syscalls.
(SYS_FUNC(getrlimit)): Call do_getrlimit with RDM_NORMAL mode.
(SYS_FUNC(old_getrlimit)): New function, calls do_getrlimit with
RDM_OLD_GETRLIMIT mode.
(SYS_FUNC(setrlimit)): Call decode_rlimit with RDM_NORMAL mode.
(SYS_FUNC(prlimit64)): Call decode_rlimit with RDM_PRLIMIT64 mode
instead of print_rlimit64.
* tests/xgetrlimit.c (sprint_rlim): Rename to...
(print_rlim): ...this, print to terminal instead of string buffer in
accordance with the output format expected.
(main): Accomodate sprint_rlim -> print_rlim change, use sprintrc.
* tests/getrlimit.c (INFINITY, INFINITY_STR): New macros.
* tests/setrlimit.c: Likewise.
* tests/ugetrlimit.c: Likewise.
2018-09-17 20:12:02 +02:00
Eugene Syromyatnikov
719d1f8986 linux/ia64: use shuffle_scno, since syscallent table starts from 1024
* linux/ia64/shuffle_scno.c: New file
* Makefile.am (EXTRA_DIST): Add it.
* linux/ia64/arch_regs.h (IA64_SCNO_BASE): New macro.
* linux/ia64/syscallent.h: Decrease all indices by IA64_SCNO_BASE.
2018-09-17 02:59:15 +02:00
Eugene Syromyatnikov
2d89ff7096 xlat: add generation of flags-related fields
Generate known flags mask and maximum string length.

* xlat.h (struct xlat): Add fields flags_strsz and flags_mask.
* xlat/gen.sh (print_xlat, print_xlat_pair): Add generation of
XLAT_VAL_n and XLAT_STR_n macros.
(gen_header): Generate flags_strsz and flags_mask fields' values using
the generated XLAT_VAL_n and XLAT_STR_n macros, undefine them
afterwards.
2018-09-17 02:49:00 +02:00
Eugene Syromyatnikov
06bb2018c7 uname: decode olduname and oldolduname syscalls
* linux/dummy.h (sys_oldolduname, sys_olduname): Remove.
* tests/.gitignore: Add oldolduname, oldolduname-v, olduname,
olduname-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (oldolduname, oldolduname-v, olduname,
olduname-v): New tests.
* tests/oldolduname-v.c: New file.
* tests/oldolduname.c: Likewise.
* tests/olduname-v.c: Likewise.
* tests/olduname.c: Likewise.
* uname.c: Include <linux/uname.h> instead of <sys/uname.h>.
(DECODE_UTSNAME_COMMON): New macro.
(SYS_FUNC(oldolduname), SYS_FUNC(olduname)): New decoders.
(SYS_FUNC(uname)): Rewrite using DECODE_UTSNAME_COMMON.
2018-09-11 20:00:20 +02:00
Eugene Syromyatnikov
1abb9c7b21 get_rboust_list: update get_robust_list and set_robust_list decoders
Decode struct robust_list_head.

* linux/dummy.h (sys_set_robust_list): Remove.
* get_robust_list.c (DEF_MPERS_TYPE(struct_robust_list_head)): Add mpers
type definition.
Include <linux/futex.h>.
(struct_robust_list_head): New type definition.
Include MPERS_DEFS, "print_fields.h".
(decode_robust_list): New function.
(SYS_FUNC(set_robust_list)): New decoder.
(SYS_FUNC(get_robust_list)): Decode second argument.
* tests/xet_robust_list.c: Include <string.h>, <linux/futex.h>.
(sprintaddr): Remove.
(print_rlh): New function.
(main): Add get_robust_list/set_robust_list checks.
2018-09-11 19:45:10 +02:00
Eugene Syromyatnikov
9f7da75206 Print signal name strace killed with
As of now, there's no visible indication that strace itself
has been signalled: it exits with exit code 0 and without any messages.
Let's add a message, at least.

* gcc_compat.h (CMPXCHG): New macro
* strace.c (interrupt): set interrupted signal only once.
(print_signalled): Add support for calling with tcp == NULL.
(terminate): Call print_signalled is qflag is not set and strace
has been interrupted.
2018-09-11 16:52:52 +02:00
Eugene Syromyatnikov
895a68db41 socketutils: add fallback inode protocol cache
For the cases when we hit a race between sock_diag request for a socket
and its addition to the socket list. It collects information about
sockets that created via socket(2) syscall and is used when not protocol
information data is available via normal means.

* defs.h (set_netlink_family_cache_entry,
get_netlink_family_cache_entry, invalidate_netlink_family_cache_entry):
New delcarations.
* desc.c (SYS_FUNC(call)): Call invalidate_netlink_family_cache_entry
for inode being closed.
* net.c (SYS_FUNC(socket)): Call set_netlink_family_cache_entry for
AF_NETLINK sockets, do not return RVAL_DECODED on entering for them.
* socketutils.c: New enumeration for cache-related constants.
(NLF_CACHE_KEY_MASK): Cache key mask constant.
(netlink_cache): Fallback cache for netlink protocol numbers.
(set_netlink_family_cache_entry, get_netlink_family_cache_entry,
invalidate_netlink_family_cache_entry): New functions.
(netlink_get): Request protocol via get_netlink_family_cache_entry if
not information has been obtained.
2018-09-11 07:51:46 +02:00
Eugene Syromyatnikov
399a2d8849 userfaultfd: enhance UFFDIO_API ioctl decoder
It may return API and features even with errno set to EINVAL.

* userfaultfd.c (print_uffdio_api_start): New function.
(uffdio_ioctl): Decode api and features fields on exiting if errno
is EINVAL.
2018-09-11 06:05:08 +02:00
Eugene Syromyatnikov
22ec7c5edb ioctl: sort entries in ioctl_decode switch statement
* ioctl.c (ioctl_decode): Sort case branches in the switch statement.
2018-09-11 02:01:21 +02:00
Eugene Syromyatnikov
1ef81b4b74 fixup! Avoid mixing error messages and trace output 2018-09-11 01:46:49 +02:00
Eugene Syromyatnikov
b7d8794dbf xlat: add FAN_ENABLE_AUDIT to fan_init_flags xlat
* xlat/fan_init_flags.in (FAN_ENABLE_AUDIT): New constant, introduced by
Linux commit v4.15-rc1~130^2^2~11.
* tests/fanotify_init.c: Update expected output.
2018-09-11 01:45:30 +02:00
Eugene Syromyatnikov
4544b3f554 Avoid mixing error messages and trace output
Handle error_msg output similarly to the output from another tcb.

* Makefile.am (strace_CPPFLAGS): Add -DHAVE_DEFS_H.
* error_prints.c [HAVE_DEFS_H]: Include "defs.h" instead of "config.h".
(verror_msg): Call finish_line before fflush().
* error_prints.h (finish_line): New declaration.
* strace.c (finish_line): New function.
2018-09-11 01:32:52 +02:00
Eugene Syromyatnikov
2df7898efb Makefile.am: provide MPERS_WORDSIZE and MPERS_KLONGSIZE definitions
* Makefile.am (strace_CFLAGS, $(mpers_m32_targets): mpers_CC_FLAGS,
$(mpers_mx32_targets): mpers_CC_FLAGS): Add -DMPERS_WORDSIZE and
-DMPERS_KLONGSIZE.
2018-09-10 21:38:06 +02:00
Eugene Syromyatnikov
00c56292a1 Makefile.am: quote mpers_CC_FLAGS in mpers.sh call
Otherwise additional flags are recognised as file names.

* Makefile.am (mpers-m%.stamp): Quote mpers.sh arguments.
2018-09-10 21:37:42 +02:00
Eugene Syromyatnikov
25f71c5488 ioctl: fix indentation in switch clauses
* ioctl.c: Fix indentation in switch clauses, no code changes.
2018-09-06 20:00:00 +02:00
Eugene Syromyatnikov
33ea6a9bb0 xlat: provide fallback values for schedulers
* xlat/schedulers.in: Provide fallback values, add #value_indexed.
(SCHED_ISO): Comment out, not currently used in Linux.
2018-09-06 19:58:27 +02:00
Eugene Syromyatnikov
f4e7b1e740 Revert "netlink_diag: move constant definitions to xlats"
This reverts commit bfbdf336ec301578fe5ab80b3271f8f6ade71466.
2018-09-06 11:24:58 +02:00
Eugene Syromyatnikov
bfbdf336ec netlink_diag: move constant definitions to xlats
In order to avoid duplication.

* linux/netlink_diag.h (NETLINK_DIAG_MEMINFO, NETLINK_DIAG_GROUPS,
NETLINK_DIAG_RX_RING, NETLINK_DIAG_TX_RING, NETLINK_DIAG_FLAGS,
NDIAG_SHOW_MEMINFO, NDIAG_SHOW_GROUPS, NDIAG_SHOW_RING_CFG,
NDIAG_SHOW_FLAGS, NDIAG_FLAG_CB_RUNNING, NDIAG_FLAG_PKTINFO,
NDIAG_FLAG_BROADCAST_ERROR, NDIAG_FLAG_NO_ENOBUFS,
NDIAG_FLAG_LISTEN_ALL_NSID, NDIAG_FLAG_CAP_ACK): Remove.
* xlat/netlink_diag_attrs.in: Add fallback values.
* xlat/netlink_diag_show.in: Likewise.
* xlat/netlink_socket_flags.in: Likewise.
2018-09-05 00:45:35 +02:00
Eugene Syromyatnikov
08c045c3ac Work around possible post-execve-SIGTRAP when PTRACE_ATTACH is used 2018-09-04 22:14:03 +02:00
Eugene Syromyatnikov
68d33a311a fixup! syscall: track syscall system time a bit more explicitly 2018-09-04 22:12:13 +02:00
Eugene Syromyatnikov
d055196eb4 count: add information about minimum and maximum call duration
* count.c (struct call_counts): Add time_min, time_max fields.
(max_ts): New constant.
(enum count_summary_columns): Add CSC_TIME_MIN, CSC_TIME_MAX.
(count_syscall): Fill time_min field with max_ts in counts
initialisation, update time_min and time_max.
(min_time_cmp, max_time_cmp): New functions.
(set_sortby): Add keys for them.
(set_count_summary_columns): Add support for time_min and time_max
fields printing.
* strace.1.in (.SH OPTIONS) <-S, -U>: Document it.

Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=240945
Closes: https://github.com/strace/strace/issues/32
2018-09-04 20:36:08 +02:00
Eugene Syromyatnikov
dd1061290f strace.1.in: variaous fixes 2018-09-04 20:30:56 +02:00
Eugene Syromyatnikov
1cf06bb8df strace.1.in: consistently use CTRL-combinations 2018-09-04 20:30:30 +02:00
Eugene Syromyatnikov
33e9a736b1 strace.1: more bold 2018-09-04 20:29:34 +02:00
Eugene Syromyatnikov
e369424a58 count: add ability to select columnt being shown
* count.c (set_count_summary_columns): New function.
* defs.h (set_count_summary_columns): New declaration.
* strace.c (init) <-U>: Pass option argument to
set_count_summary_columns.
* strace.1.in (.SH OPTIONS): Document it.
2018-09-04 20:28:38 +02:00
Eugene Syromyatnikov
cd6e2d27f8 strace.1: more fixes 2018-09-04 19:54:09 +02:00
Eugene Syromyatnikov
90320f4ce4 fixup! strace.1.in: print names of entities in bold, provide man page sections 2018-09-04 19:53:51 +02:00
Eugene Syromyatnikov
3ef3477891 count: add ability to sort on avg_time and errors fields
For completeness.

* count.c (avg_time_cmp, error_cmp): New functions.
(set_sortby): Add sort keys for the new fields.
* strace.1.in (.SH OPTIONS) <-S>: Document it.
2018-09-04 19:48:11 +02:00
Eugene Syromyatnikov
f0865403a2 count: refactor statistics calculation/output
In preparation to extension.

* count.c (enum count_summary_columns): New enumeration type.
(struct call_counts): Add time_avg field.
(DEF_COLUMNS): New macro.
(columns, visible): New variables.
(num_chars): New function.
(call_summary_pers): Calculate aggregate data first, then output table
based on columns configuration.
* tests/count-f.expected: Update expected output.
* tests/strace-C.expected: Likewise.
* tests/strace-S.test: Likewise.
2018-09-04 19:18:48 +02:00
Eugene Syromyatnikov
69d148d233 strace.1.in: assorted updates 2018-09-04 16:56:54 +02:00
Eugene Syromyatnikov
059568a665 strace.1.in: print names of entities in bold, provide man page sections
* strace.1.in (.SH DESCRIPTION): add man page section numbber to open,
lstat, getpwuid, id mentions.
(.SH OPTIONS): make strace mentions bold.
(.SH NOTES): It was meant setrlimit(3), not setrlimit(2).
2018-09-04 16:45:04 +02:00
Eugene Syromyatnikov
71404212b8 dist/README: add some additional links
* dist/README: Mention README-hacking, add links to repositories and
mailing list arhcive.

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
2018-09-04 16:32:25 +02:00
Eugene Syromyatnikov
86899822ba README.md: add link to new contributors guide.
* README.md: Add a link to the Guide of new contributors.

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
2018-09-04 15:54:30 +02:00
Eugene Syromyatnikov
05ae538c90 mmap_cache: simplify API
* mmap_cache.h (mmap_cache_rebuild_if_invalid_): rename from
mmap_cache_rebuild_if_invalid.
(mmap_cache_rebuild_if_invalid): New macro, a wrapper for
mmap_cache_rebuild_if_invalid_ that supplies __func__ to it.
(mmap_cache_free_): New declaration.
(mmap_cache_free): New macro, a wrapper for mmap_cache_free_ that
supplies __func__ to it.
* mmap_cache.c (mmap_cache_rebuild_if_invalid_): Rename from
mmap_cache_rebuild_if_invalid.
(mmap_cache_free_): New function.
* unwind-libunwind.c (tcb_walk): Remove __func__ argument from the
mmap_cache_rebuild_if_invalid call.
* kvm.c (vcpu_get_info): Likewise.
* strace.c (droptcb): Call mmap_cache_free.
2018-09-04 15:41:47 +02:00
Eugene Syromyatnikov
3305550ccc syscall.c: unify error printing a bit
As of now, when -e raw is set, ERESTART* return code descriptions
are not printed (generic "-1 ERESTART_RESTARTBLOCK (Unknown error 516)"
is printed instead).

* syscall.c (err_desc): New function.
(print_err_ret): Print return code if it is not a ERESTART* error.
(syscall_exiting_trace): Use print_err_ret for normal error return
string printing.
2018-09-04 15:19:20 +02:00
Eugene Syromyatnikov
57a2b0fbdd syscall.c: avoid infinite loop in subcalls parsing
clang complains about it, so it might be a good reason to refactor it
into something more linear.

* syscall.c (syscall_entering_decode): put syscall subcall decoding
before ipc/socket subcall decoding, remove loop.
2018-09-04 14:48:13 +02:00
Eugene Syromyatnikov
f71663b233 count: rewrite sort function selection using a table.
And provide some alternative names for the sorting options, as some
might be easier to remember than others.

* count.c (set_sortby): Replace nested if's with iteration over a table;
add aliases for the existing sorting options.
* strace.1.in (.SH OPTIONS) <-S>: Document new aliases.
2018-09-04 13:27:29 +02:00
Eugene Syromyatnikov
2b70434e3e strace.spec: use xz instead of gzip
As the source tarball is in xz format already, there is high chance
that xz is already required for the build environment.

* strace.spec.in (BuildRequires): Replace gzip with xz.
(%build): Comparess change logs with xz.
(%files): s/gz/xz.
2018-09-04 01:50:29 +02:00
Eugene Syromyatnikov
0685a353bf syscall: track syscall system time a bit more explicitly
Before, it relied on implicit assumptions that syscall-exit event is
right the next one after syscall-enter.  Also, there's some additional
debugging output that may be might help someone someday.

* count.c (count_syscall): Calculate system time as difference of tcp's
stime and ltime.
* defs.h (struct tcb): Add ltime, atime fields, remove dtime.
* strace.c (droptcb): Print total system time spent by a tcb.
(startup_tcb): Store initial system time in atime.
(next_event): Update stime directly.
* syscall.c (syscall_entering_finish): Store current system time in
tcb's ltime field.
(syscall_exiting_finish): Likewise.
2018-09-03 04:57:13 +02:00
Eugene Syromyatnikov
beece1ab43 fixup! delay: use parse_ts for parsing delay value 2018-09-03 00:41:41 +02:00
Eugene Syromyatnikov
8b2355f55f count: fix types in sorting comparison callbacks
* count.c (time_cmp. syscall_cmp): Change arguments type
to "const void *", Change indices cast type to "unsigned int *".
(count cmp): Likewise. Change count variables type to unsigned int.
(sortfun): Provide types of arguments.
2018-09-02 23:05:27 +02:00
Eugene Syromyatnikov
d58f4c7ee8 fixup! util.c: add parse_ts 2018-09-02 22:20:03 +02:00
Eugene Syromyatnikov
e30f3c2558 count: substract overhead per call
* count.c (zero_ts): New variable.
(count_syscall): Calculate the spent time in the wts variable, then add
it to cc->time.
(call_summary_pers): Do not perform overhead correction.
2018-09-02 22:07:07 +02:00
Eugene Syromyatnikov
0a21612184 count: use parse_ts for parsing overhead value
* count.c (set_overhead): Change argument type to const char *, call
parse_ts to parse it and set to overhead.
* defs.h (set_overhead): Update declaration.
* strace.c: (init) <case 'O'>: do not parse argument, pass optarg to
set_overhead call.
* tests/count.test (GENERIC, WALLCLOCK, HALFCLOCK): New variables with
expected patterns.
Add checks for the new -O syntax.
2018-09-02 21:56:47 +02:00
Eugene Syromyatnikov
1a28b6dba2 delay: use parse_ts for parsing delay value
* delay.c (fill_delay_data): Change intval argument to struct timespec
*val, assign val to ts.
* delay.h (fill_delay_data): Update function declaration.
* filter_qualify.c (parse_delay_token): Parse input with parse_ts,
supply the resulting struct timespec to fill_delay_data.
* tests/delay.c (check_): New function for providing diagnostic in case
of check failure.
(check_delay): Use it.
* tests/delay.test: Check new delay syntax.
2018-09-02 21:28:41 +02:00
Eugene Syromyatnikov
32e987b87a util.c: add parse_ts
* defs.h (parse_ts): New declaration.
* util.c (parse_ts): New function.
2018-09-02 20:04:27 +02:00
Eugene Syromyatnikov
7c7705fbc9 util: add ts_min and ts_max
* defs.h (ts_min, ts_max): New declarations.
* util.c (ts_min, ts_max): New functions.
2018-09-02 20:03:27 +02:00