]>
granicus.if.org Git - strace/log
Dmitry V. Levin [Sun, 14 Jan 2018 00:43:12 +0000 (00:43 +0000)]
filter_qualify: move memory allocation from parse_inject_expression
* filter_qualify.c (parse_inject_expression): Replace "s" and "buf"
arguments with "str" argument, use it instead of "s" and "*buf".
(qualify_inject_common): Rename "buf" to "copy", initialize it to a copy
of "str", pass "copy" to parse_inject_expression instead of "str" and
"buf".
Eugene Syromyatnikov [Sun, 14 Jan 2018 07:45:05 +0000 (08:45 +0100)]
xlat: update NT_* constants
Update NT_* descriptor types with the values borrowed from
kernel's include/uapi/linux/elf.h and glibc's elf.h.
* xlat/nt_descriptor_types.in (NT_PRSTATUS, NT_FPREGSET, NT_PRPSINFO,
NT_PRXREG, NT_TASKSTRUCT, NT_PLATFORM, NT_AUXV, NT_GWINDOWS, NT_ASRS,
NT_PSTATUS, NT_PSINFO, NT_PRCRED, NT_UTSNAME, NT_LWPSTATUS,
NT_LWPSINFO, NT_PRFPXREG, NT_PRXFPREG, NT_PPC_VMX, NT_PPC_SPE,
NT_PPC_VSX, NT_386_TLS, NT_386_IOPERM, NT_X86_XSTATE): Add fallback
definitions.
(NT_SIGINFO, NT_FILE, NT_PPC_*, NT_S390_*, NT_ARM_*, NT_METAG_*,
NT_ARC_V2): New constants.
* NEWS: Mention this.
Dmitry V. Levin [Sat, 13 Jan 2018 13:46:45 +0000 (13:46 +0000)]
configure: use AC_MSG_ERROR and AC_MSG_FAILURE consistently
* configure.ac [$arch = mips]: Use AC_MSG_FAILURE instead of
AC_MSG_ERROR when _MIPS_SIM cannot be determined. Use AC_MSG_ERROR
instead of AC_MSG_FAILURE when syscallent stubs cannot be generated.
Eugene Syromyatnikov [Wed, 10 Jan 2018 02:43:41 +0000 (03:43 +0100)]
configure: add --disable-mpers and --enable-mpers=check options
On architectures supporting multiple personalities, multiple
personalities support in strace is required for proper decoding of
structures used by tracees with personalities that differ from the
personality of strace.
New configure options control whether multiple personalities support
in strace is mandatory, optional, or disabled.
The default is changed from what is now equivalent of
--enable-mpers=check (automatically detect whether required mpers
support could be enabled) to --enable-mpers (terminate the build
if required mpers support could not be enabled).
* configure.ac (AC_ARG_ENABLE([mpers])): New option.
* m4/mpers.m4 (st_MPERS): Use enable_mpers. Terminate the build
if mpers could not be enabled and enable_mpers==yes.
* strace.spec.in: Specify --enable-mpers=check to %configure.
* debian/rules (build/Makefile, build64/Makefile): Specify
--enable-mpers=check to configure.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Suggested-by: DJ Delorie <dj@redhat.com>
Gleb Fotengauer-Malinovskiy [Thu, 11 Jan 2018 19:03:34 +0000 (22:03 +0300)]
Update ioctl entries from linux v4.15-rc7
* linux/32/ioctls_inc_align16.h: Update from linux v4.15-rc7 using ioctls_gen.sh.
* linux/32/ioctls_inc_align32.h: Likewise.
* linux/32/ioctls_inc_align64.h: Likewise.
* linux/64/ioctls_inc.h: Likewise.
* linux/x32/ioctls_inc0.h: Likewise.
* NEWS: Mention this.
Eugene Syromyatnikov [Wed, 10 Jan 2018 02:53:54 +0000 (03:53 +0100)]
Issue a warning when strace lacks tracee personality support
* defs.h (HAVE_PERSONALITY_1_MPERS, HAVE_PERSONALITY_2_MPERS): New
macros.
* syscall.c (update_personality): Add need_mpers_warning array
initialized with mpers support data. Use it for printing the mpers
unavailability warning once per personality.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Eugene Syromyatnikov [Wed, 10 Jan 2018 04:31:15 +0000 (05:31 +0100)]
tests: add more checks of reboot syscall decoding
In particular, check for the recent fixes in reboot syscall decoder.
* tests/gen_tests.in (reboot): Provide -s 256 option.
* tests/reboot.c (STR32, STR128): New macros.
(main): Add more checks.
Eugene Syromyatnikov [Wed, 10 Jan 2018 04:30:27 +0000 (05:30 +0100)]
tests: use sprintrc in reboot.test
* test/reboot.c (main): Use sprintrc instead of old-style manual
printing of return code.
Eugene Syromyatnikov [Wed, 10 Jan 2018 04:27:49 +0000 (05:27 +0100)]
reboot.c: limit printing of the fourth argument to 255 bytes
The size of kernel buffer is 256 bytes and the last byte is always zero.
* reboot.c (SYS_FUNC(reboot)): Replace printstr call with printstr_ex
with size of 255 and style flag QUOTE_0_TERMINATED.
Eugene Syromyatnikov [Wed, 10 Jan 2018 04:25:40 +0000 (05:25 +0100)]
reboot.c: use printxval instead of printflags
Numeric arguments of reboot syscall are not flags but magic values.
* reboot.c (SYS_FUNC(reboot)): Replace printflags with printxval.
Eugene Syromyatnikov [Tue, 9 Jan 2018 19:23:01 +0000 (20:23 +0100)]
Search for <libiberty/demangle.h> in addition to <demangle.h>
This is the location where this header is installed on Debian-based
systems.
* configure.ac: Check for libiberty/demangle.h in addition to
demangle.h.
* unwind.c [USE_DEMANGLE]: Include either <demangle.h> or
<libiberty_demangle.h> based on the presence of HAVE_DEMANGLE_H and
HAVE_LIBIBERTY_DEMANGLE_H macros.
Dmitry V. Levin [Wed, 10 Jan 2018 01:57:53 +0000 (01:57 +0000)]
strace.1: fix typo
* strace.1.in (.SH NOTES): Replace prlimit with prlimit64.
Eugene Syromyatnikov [Tue, 9 Jan 2018 19:09:19 +0000 (20:09 +0100)]
Document multiple personalities support
* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): New section.
Eugene Syromyatnikov [Tue, 9 Jan 2018 19:09:05 +0000 (20:09 +0100)]
Add indication of mpers support to strace -V output
* strace.c (print_version): Append information about m32 and mx32
decoding support.
* tests/strace-V.test: Update expected output.
Eugene Syromyatnikov [Tue, 9 Jan 2018 19:04:30 +0000 (20:04 +0100)]
Provide strace's native arch to the test framework
* configure.ac (arch_native): New variable, set to arch.
* tests/Makefile.am (NATIVE_ARCH): New variable, set to @arch_native@.
(AM_TEST_LOG_FLAGS): Pass NATIVE_ARCH as STRACE_NATIVE_ARCH environment
variable.
Eugene Syromyatnikov [Tue, 9 Jan 2018 19:00:27 +0000 (20:00 +0100)]
Add indication of optional demangle feature strace -V output
* strace.c (print_version) [USE_DEMANGLE]: Append " stack-demangle"
to the features string.
* tests/strace-V.test: Update expected output.
Eugene Syromyatnikov [Tue, 9 Jan 2018 18:14:11 +0000 (19:14 +0100)]
configure.ac: check for mpers support on RISC-V
* confgure.ac (st_MPERS([m32])): Add riscv.
Eugene Syromyatnikov [Mon, 8 Jan 2018 20:03:24 +0000 (21:03 +0100)]
Use xappendstr instead of xsnprintf where suitable
Replace occurrences of
outptr += xsnprintf(outptr, sizeof(outstr) - (outptr - outstr), ...)
with much more sleek
outptr = xappendstr(outstr, outptr, ...)
* desc.c (decode_select): Replace xsnprintf with xappendstr.
* open.c (sprint_open_modes): Likewise.
* poll.c (decode_poll_exiting): Likewise.
* signal.c (sprintsigmask_n): Likewise.
* xlat.c (sprintflags): Likewise.
Eugene Syromyatnikov [Mon, 8 Jan 2018 20:00:39 +0000 (21:00 +0100)]
xstring.h: add xappendstr
Introduce a macro for handling common case of partial writes
to a character array.
* xstring.h (get_pos_diff_): New function.
(xappendstr): New macro.
Eugene Syromyatnikov [Mon, 8 Jan 2018 18:52:23 +0000 (19:52 +0100)]
Update perf-related flags
- PERF_SAMPLE_BRANCH_TYPE_SAVE, added in v4.14-rc1~173^2~33^2~6
- PERF_SAMPLE_PHYS_ADDR, added in v4.14-rc1~173^2~2
* xlat/perf_branch_sample_type.in (PERF_SAMPLE_BRANCH_TYPE_SAVE): New
flag.
* xlat/perf_event_sample_format.in (PERF_SAMPLE_PHYS_ADDR): Likewise.
* tests/perf_event_open.c: Update expected output.
Eugene Syromyatnikov [Mon, 8 Jan 2018 18:48:42 +0000 (19:48 +0100)]
perf.c: add support for struct perf_event_attr.namespaces
This field was introduced by linux kernel commit v4.12-rc1~152^2~42^2~10.
* configure.ac (AC_CHECK_MEMBERS): Add perf_event_attr.namespaces.
* perf_event_struct.h (struct perf_event_attr): Add namespaces field.
* perf.c (print_perf_event_attr): Print namespaces field.
Update comment for __reserved_1 field.
* tests/perf_event_open.c (struct pea_flags): Add namespaces field.
(print_event_attr): Update expected output.
Eugene Syromyatnikov [Mon, 8 Jan 2018 17:48:48 +0000 (18:48 +0100)]
tests: check decoding of [gs]et_thread_area syscalls on x86
* tests/xet_thread_area_x86.c: New file.
* tests/xet_thread_area_x86.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add it.
* tests/.gitignore: Add xet_thread_area_x86.
* tests/pure_executables.list: Likewise.
Eugene Syromyatnikov [Mon, 8 Jan 2018 17:46:32 +0000 (18:46 +0100)]
tests: check decoding of modify_ldt with for 4-byte-available user_desc
Since there is possibility now that strace read only entry_number field
of the user_desc struct, let's check that it doesn't do it with
modify_ldt syscall.
* tests/modify_ldt.c (main): Add 4-byte-sized tail_alloc'ed variable.
Try to provide it as an argument to modify_ldt.
Eugene Syromyatnikov [Mon, 8 Jan 2018 17:41:30 +0000 (18:41 +0100)]
Allow separate printing of struct user_desc.entry_number
Kernel reads only entry_number field in the beginning of the
get_thread_area syscall handler. Let's replicate this behaviour.
* defs.h (enum user_desc_print_filter): New enumeration.
(print_user_desc): Add an argument for signalling which part of the
structure should be printed.
* clone.c (print_tls_arg): Update print_user_desc call.
* ldt.c (print_user_desc): Add filter argument. Print entry_number on
entering and the rest on exiting. Store entering value of the
entry_number field in order to print the updated value in the impossible
case of changed entry_number value.
(SYS_FUNC(modify_ldt), SYS_FUNC(set_thread_area)): Update
print_user_desc call.
(SYS_FUNC(get_thread_area)): Call print_user_desc with
USER_DESC_ENTERING format argument on entering and with
USER_DESC_EXITING on exiting.
Eugene Syromyatnikov [Mon, 8 Jan 2018 17:38:17 +0000 (18:38 +0100)]
tests: move struct user_desc printing function into a separate file
As part of preparation for the introduction of [gs]et_thread_area test.
* tests/modify_ldt.c (print_user_desc): Move it ...
* tests/print_user_desc.c: ... to new file.
* tests/Makefile.am (EXTRA_DIST): Add print_user_desc.c.
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:11:26 +0000 (21:11 +0100)]
tests: check decoding of modify_ldt syscall
* tests/modify_ldt.c: New file.
* tests/gen_tests.in: Add modify_ldt test.
* tests/pure_executables.list: Add modify_ldt.
* tests/.gitignore: Likewise.
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:09:48 +0000 (21:09 +0100)]
ldt.c: manually set modify_ldt's error code
* ldt.c (modify_ldt): Move parsing under entering(tcp). Check whether
return code is erroneous and set tcp->u_error appropriately along with
RVAL_PRINT_ERR_VAL flag.
Eugene Syromyatnikov [Sun, 7 Jan 2018 02:53:53 +0000 (03:53 +0100)]
syscall.c: add support for printing return value and error code
Some weird syscalls (like modify_ldt) return value that doesn't indicate
an error (less than -4096), but it is, in fact, erroneous (because they
decide to clip the return value to 32-bit, for example).
Add a flag to print decoded error code along with syscall return value.
* defs.h (RVAL_PRINT_ERR_VAL): New rval flag.
* syscall.c (syscall_exiting_trace): Handle it.
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:08:25 +0000 (21:08 +0100)]
ldt.c: print the first argument of modify_ldt as int
* ldt.c (SYS_FUNC(modify_ldt)): Print the first argument as %d.
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:06:10 +0000 (21:06 +0100)]
ldt.c: print lm field for 64-bit tracees
* configure.ac (AC_CHECK_MEMBERS): Add struct user_desc.lm.
* ldt.c (print_user_desc) [HAVE_STRUCT_USER_DESC_LM]: Print lm field
for non-compat tracees (it is ignored for compat ones).
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:05:38 +0000 (21:05 +0100)]
ldt.c: make struct user_desc output more structured
Also, while we are here, let's fix print qualifiers (which should be %u
and not %d).
* ldt.c (print_user_desc): Use PRINT_FIELD_* macros for printing
structure.
(SYS_FUNC(set_thread_area)): Change field key-value separator from ":"
to "=", change print format qualifier from %d to %u.
Eugene Syromyatnikov [Fri, 5 Jan 2018 19:59:04 +0000 (20:59 +0100)]
print_fields.h: add PRINT_FIELD_U_CAST
Add a macro for printing fields explicitly casted to specific type.
This is useful for bit fields, as otherwise the magic of *_extend_to_*
macros breaks.
* print_field.h (PRINT_FIELD_U_CAST): New macro.
Eugene Syromyatnikov [Fri, 5 Jan 2018 19:57:57 +0000 (20:57 +0100)]
print_fields.h: rename PRINT_FIELD_UID to PRINT_FIELD_ID
As uid is not the only thing that has a special treatment of the -1
value (and, as a result, needs special care), let's rename
PRINT_FIELD_UID to PRINT_FIELD_ID and make PRINT_FIELD_UID its alias.
* print_fields.h (PRINT_FIELD_ID): Rename from PRINT_FIELD_UID.
(PRINT_FIELD_UID): Define to PRINT_FIELD_ID.
Dmitry V. Levin [Sun, 7 Jan 2018 23:23:01 +0000 (23:23 +0000)]
Fix build on systems without linux/genetlink.h
* socketutils.c [!HAVE_LINUX_GENETLINK_H] (genl_families_xlat): Add
tcp argument.
Fixes: v4.20-134-gc46fefc ("Add tcp arguments to netlink calls")
Eugene Syromyatnikov [Fri, 5 Jan 2018 03:07:09 +0000 (04:07 +0100)]
count.c: whitespace
Eugene Syromyatnikov [Fri, 5 Jan 2018 03:06:58 +0000 (04:06 +0100)]
count.c: cleanup types and sizeof usage
* count.c (call_summary_pers): Change the type of sorted_count
to "unsigned int *". Replace sizeof(int) with sizeof(sorted_count[0]).
Change the type of idx to unsigned int.
Eugene Syromyatnikov [Fri, 5 Jan 2018 03:06:37 +0000 (04:06 +0100)]
count.c: collect definitions of format strings in one place
In an attempt to make it more readable.
* count.c (call_summary_pers): Put all format strings in static
constants. Use them.
Eugene Syromiatnikov [Mon, 25 Dec 2017 23:14:14 +0000 (00:14 +0100)]
Add tcp arguments to netlink calls
Since they call tracee-specific socket/sendmsg/recvmsg, we'd like to
pass tcp there.
* defs.h (genl_families_xlat): Add tcp argument.
* netlink.c (decode_nlmsg_type_default, decode_nlmsg_type_generic,
decode_nlmsg_type_netfilter, typedef nlmsg_types_decoder_t): Likewise.
(decode_nlmsg_type): Add tcp argument. Pass tcp to decoder call.
(print_nlmsghdr): Pass tcp to the decode_nlmsg_type call.
* socketutils.c (send_query, receive_responses): Add tcp argument.
(inet_send_query, unix_send_query, netlink_send_query, ): Add tcp argument.
Pass tcp to the send_query call.
(unix_get): Add tcp argument. Pass tcp to the unix_send_query and
receive_responses calls.
(inet_get): Add tcp argument. Pass tcp to the inet_send_query and
receive_responses calls.
(tcp_v4_get, udp_v4_get, tcp_v6_get, udp_v6_get): Add tcp argument. Pass
tcp to the inet_get call.
(netlink_get): Add tcp argument. Pass tcp to the netlink_send_query and
receive_responses calls.
(protocols): Add tcp argument to the get field.
(get_sockaddr_by_inode_uncached): Add tcp argument. Pass tcp to
the protocols[].get calls.
(print_sockaddr_by_inode_uncached): Add tcp argument. Pass tcp to
the get_sockaddr_by_inode_uncached call.
(get_sockaddr_by_inode): Pass tcp to the get_sockaddr_by_inode_uncached
call.
(print_sockaddr_by_inode): Pass tcp to the
print_sockaddr_by_inode_uncached call.
(genl_send_dump_families): Add tcp argument. Pass tcp to the send_query
call.
(genl_families_xlat): Add tcp argument. Pass tcp to the
genl_send_dump_families and receive_responses calls.
Eugene Syromiatnikov [Mon, 25 Dec 2017 23:09:41 +0000 (00:09 +0100)]
Add tcp argument to clear_regs
* defs.h (clear_regs): Add argument struct tcb *tcp.
* syscall.c (clear_regs): Likewise.
* strace.c (next_event): Pass tcp to clear_regs() call.
Eugene Syromiatnikov [Mon, 25 Dec 2017 22:55:22 +0000 (23:55 +0100)]
Pass tcp argument to get_optmem_max/read_int_from_file
In preparation to passing tcp to all tracee-related syscalls.
* defs.h (read_int_from_file): Add "struct tcb *" as the first argument.
* util.c (read_int_from_file): Likewise.
* msghdr.c (get_optmem_max): Add "struct tcb *tcp" as the first
argument, pass it to read_int_from_file call.
(decode_msg_control): Pass tcp to get_optmem_max.
Eugene Syromiatnikov [Fri, 15 Dec 2017 11:38:59 +0000 (12:38 +0100)]
Include paths.h if it is available
Use the OS definition of _PATH_BSHELL macro if it is available.
* configure.ac (AC_CHECK_HEADERS): Add paths.h.
* strace.c [HAVE_PATHS_H]: Include paths.h.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:52:27 +0000 (08:52 +0200)]
strace.c: avoid duplication of a format string in attach_tcb
* strace.c (attach_tcb): Add task_path variable with the output format.
Use it for the procdir declaration and xsprintf format string argument.
Elvira Khabirova [Sun, 7 Jan 2018 02:38:46 +0000 (05:38 +0300)]
Move syscall_tampered to defs.h
* syscall.c (syscall_tampered): Move ...
* defs.h: ... here.
Elvira Khabirova [Sun, 7 Jan 2018 02:38:45 +0000 (05:38 +0300)]
strace.c: rename set_sigaction to set_sighandler
Since set_sigaction() actually specifies sa_handler and not sa_sigaction,
rename set_sigaction() to set_sighandler() for future definition of
set_sigaction() function as specifying sa_sigaction.
* strace.c (set_sigaction): Rename to set_sighandler.
All callers updated.
Elvira Khabirova [Sun, 7 Jan 2018 02:38:44 +0000 (05:38 +0300)]
.gitignore: ignore "gnu" directory created by st_MPERS m4 macro
Elvira Khabirova [Sun, 7 Jan 2018 02:38:49 +0000 (05:38 +0300)]
Update .mailmap
* .mailmap (Elvira Khabirova): Add @altlinux.org.
Chen Jingpiao [Sat, 18 Nov 2017 15:48:52 +0000 (23:48 +0800)]
.mailmap: add canonical name for Chen Jingpiao
* .mailmap: Add canonical name for Chen Jingpiao.
Dmitry V. Levin [Sun, 7 Jan 2018 00:05:42 +0000 (00:05 +0000)]
personality.c: use sprintxval
* personality.c (SYS_FUNC(personality)): Use sprintxval instead of local
implementation.
Eugene Syromiatnikov [Sat, 5 Aug 2017 14:19:15 +0000 (16:19 +0200)]
xlat.c: add sprintxval for printing xval to string
* defs.h (sprintxval): New declaration.
(sprintxval): New function.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
desc.c: use xsnprintf instead of sprintf
* desc.c: Include "xstring.h".
(decode_select): Replace sprintf with xsnprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
xlat.c: use xsnprintf instead of sprintf
* xlat.c: Include "xstring.h".
(sprintflags): Replace sprintf with xsnprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
open.c: use xsnprintf instead of sprintf
* open.c: Include "xstring.h".
(sprint_open_modes): Replace sprintf with xsnprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
poll.c: use xs*printf instead of sprintf
* poll.c: Include "xstring.h".
(decode_poll_exiting): Replace sprintf with xsnprintf and xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
signal.c: use xs*printf instead of sprintf
* signal.c: Include "xstring.h".
(signame): Replace sprintf with xsprintf.
(sprintsigmask_n): Replace sprintf with xsnprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
print_timeval.c: use xsprintf instead of snprintf
* print_timeval.c: Include "xstring.h".
(sprint_timeval, sprint_timeval32): Replace snprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
print_timespec.c: use xsprintf instead of snprintf
* print_timespec.c: Include "xstring.h".
(sprint_timespec): Replace snprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
mmsghdr.c: use xsprintf instead of snprintf
* mmsghdr.c: Include "xstring.h".
(SYS_FUNC(recvmmsg)): Replace snprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
socketutils.c: use xsprintf instead of snprintf
* socketutils.c: Include "xstring.h".
(unix_parse_response): Replace snprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
alpha.c: use xsprintf instead of snprintf
* alpha.c: Include "xstring.h".
(decode_getxxid): Replace snprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
v4l2.c: use xsprintf instead of sprintf
* v4l2.c: Include "xstring.h".
(print_v4l2_create_buffers): Replace sprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
util.c: use x*sprintf instead of s*printf
* util.c: Include "xstring.h".
(sprinttime_ex): Replace snprintf with xsnprintf.
(getfdproto): Replace sprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
unwind.c: use xsprintf instead of sprintf
* unwind.c: Include "xstring.h".
(build_mmap_cache): Replace sprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
syscall.c: use xsprintf instead of sprintf
* syscall.c: Include "xstring.h".
(get_scno): Replace sprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
resource.c: use xsprintf instead of sprintf
* resource.c: Include "xstring.h".
(sprint_rlim64, sprint_rlim32): Replace sprintf with xsprintf.
Dmitry V. Levin [Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)]
pathtrace.c: use xsprintf instead of sprintf
* pathtrace.c: Include "xstring.h".
(getfdpath): Replace sprintf with xsprintf.
Eugene Syromyatnikov [Fri, 5 Jan 2018 20:03:21 +0000 (21:03 +0100)]
ldt.c: replace sprintf with xsprintf
* ldt.c: Include "xstring.h".
(SYS_FUNC(set_thread_area)): Replace sprintf with xsprintf.
Dmitry V. Levin [Fri, 5 Jan 2018 01:18:05 +0000 (01:18 +0000)]
strace.c: use xsprintf instead of sprintf
* strace.c: Include "xstring.h".
(strerror, newoutf, attach_tcb, print_debug_info): Replace sprintf
with xsprintf.
Eugene Syromyatnikov [Fri, 5 Jan 2018 02:51:19 +0000 (03:51 +0100)]
ioprio.c: use xsprintf instead of sprintf
* ioprio.c: Include "xstring.h".
(sprint_ioprio): Replace sprintf with xsprintf.
Eugene Syromyatnikov [Fri, 5 Jan 2018 01:18:05 +0000 (02:18 +0100)]
Introduce hardened xsprintf/xsnprintf macros
Let's try to future/fool-proof code a bit by introducing variants
of sprintf/snprintf that die if an overflow (or an error) occurs.
They are deemed to be the default choice for printing to some local
string buffer where no sensible error handling is implemented.
* xstring.h: New file.
* Makefile.am (strace_SOURCES): Add it.
Eugene Syromyatnikov [Fri, 5 Jan 2018 02:18:13 +0000 (03:18 +0100)]
count.c: use %9.u conversion specification
Instead of printing to a temporary string. This also fixes a subtle bug
when the output for a billion errors and more is cut and shown
incorrectly.
* count.c (struct call_counts): Change type of calls and errors fields
to unsigned int since they are used and printed as unsigned anyway.
(call_summary_pers): Remove error_str. Print cc->errors
and error_cum using %9.u conversion specification.
Eugene Syromyatnikov [Fri, 5 Jan 2018 02:00:45 +0000 (03:00 +0100)]
count.c: use personality_names in call_summary report caption
Otherwise the title is quite misleading for x32 personality.
* count.c (call_summary): Use personality_names.
Victor Krapivensky [Fri, 5 Jan 2018 01:57:52 +0000 (02:57 +0100)]
Move personality names to a global variable
This is a part of "Prepare for adding support for Lua scripting"
commit.
* defs.h (personality_names): New external constant declaration.
* syscall.c: (personality_names): New global variable.
(update_personality): Use personality_names for reporting personality
name.
Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
Lubomir Rintel [Wed, 22 Nov 2017 12:04:35 +0000 (13:04 +0100)]
strace.spec.in: include Bluetooth headers for AF_BLUETOOTH sockets decoding
* strace.spec.in (BuildRequires): Add pkgconfig(bluez).
Dmitry V. Levin [Thu, 4 Jan 2018 10:52:07 +0000 (10:52 +0000)]
Lift artificial limit on output file names in -ff mode
Starting with commit v4.5.19~88 strace imposed an artificial limit
on output file names in -ff mode, leading to the following absurd
behaviour:
$ strace -ff -o"$(perl -e 'print "/" x 510')/$PWD/log" /bin/true
strace: Can't fopen '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////.12345': Permission denied
* strace.c (newoutf): Raise buffer size to PATH_MAX.
(init) <followfork >= 2>: Check output file name prefix length.
* tests/options-syntax.test: Check it.
Dmitry V. Levin [Thu, 4 Jan 2018 00:23:04 +0000 (00:23 +0000)]
configure.ac: fix typo
* configure.ac: Replace CPPFALGS with CPPFLAGS.
Fixes: v4.20-85-gf9c8e8a ("unwind: demangle symbol names")
Eugene Syromiatnikov [Mon, 25 Dec 2017 22:52:48 +0000 (23:52 +0100)]
Change the first argument of upeek from pid to tcp
All users were changed automatically by:
for i in `git grep -l 'upeek(tcp->pid'`; do \
sed -i 's/upeek(tcp->pid/upeek(tcp/g' "$i"; \
done
* upeek.c (upeek): Change the first argument from pid_t pid to struct
tcb *tcp. Use tcp->pid instead of pid in the function's body.
* defs.h (upeek): Update declaration.
* linux/alpha/arch_getrval2.c: Pass tcp instead of tcp->pid to the
upeek calls.
* linux/alpha/arch_rt_sigframe.c: Likewise.
* linux/alpha/arch_sigreturn.c: Likewise.
* linux/alpha/get_scno.c: Likewise.
* linux/alpha/get_syscall_args.c: Likewise.
* linux/alpha/get_syscall_result.c: Likewise.
* linux/bfin/arch_rt_sigframe.c: Likewise.
* linux/bfin/get_scno.c: Likewise.
* linux/bfin/get_syscall_args.c: Likewise.
* linux/bfin/get_syscall_result.c: Likewise.
* linux/crisv10/arch_rt_sigframe.c: Likewise.
* linux/crisv10/get_scno.c: Likewise.
* linux/crisv10/get_syscall_args.c: Likewise.
* linux/crisv10/get_syscall_result.c: Likewise.
* linux/hppa/arch_rt_sigframe.c: Likewise.
* linux/hppa/get_scno.c: Likewise.
* linux/hppa/get_syscall_args.c: Likewise.
* linux/hppa/get_syscall_result.c: Likewise.
* linux/microblaze/arch_rt_sigframe.c: Likewise.
* linux/microblaze/arch_sigreturn.c: Likewise.
* linux/microblaze/get_scno.c: Likewise.
* linux/microblaze/get_syscall_args.c: Likewise.
* linux/microblaze/get_syscall_result.c: Likewise.
* linux/powerpc/getregs_old.c: Likewise.
* linux/sh/arch_getrval2.c: Likewise.
* linux/sh/arch_rt_sigframe.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/sh/get_syscall_args.c: Likewise.
* linux/sh/get_syscall_result.c: Likewise.
* linux/sh64/get_scno.c: Likewise.
* linux/sh64/get_syscall_args.c: Likewise.
* linux/sh64/get_syscall_result.c: Likewise.
* linux/xtensa/arch_rt_sigframe.c: Likewise.
* linux/xtensa/get_scno.c: Likewise.
* linux/xtensa/get_syscall_args.c: Likewise.
* linux/xtensa/get_syscall_result.c: Likewise.
* syscall.c: Likewise.
Eugene Syromiatnikov [Mon, 25 Dec 2017 22:49:40 +0000 (23:49 +0100)]
Change argument of getregs_old from pid to tcp
* linux/powerpc/getregs_old.c (getregs_old): Change the first argument
from pid_t pid to struct tcb *tcp. Replace all instances of pid with
tcp->pid.
* linux/x86_64/getregs_old.c (getregs_old): Likewise.
* linux/x86_64/getregs_old.h (getregs_old): Update declaration.
* syscall.c (get_regs) [HAVE_GETREGS_OLD]: Pass tcp to the getregs_old
call instead of tcp->pid.
Eugene Syromiatnikov [Mon, 25 Dec 2017 22:45:04 +0000 (23:45 +0100)]
Change the first argument of upoke from pid to tcp
Users were updated automatically by:
for i in `git grep -l 'upoke(tcp->pid'`; do \
sed -i 's/upoke(tcp->pid/upoke(tcp/g' "$i"; \
done
* upoke.c (upoke): Change the first argument from pid_t pid to struct
tcb *tcp. Use tcp->pid instead of pid in the function's body.
* defs.h (upoke): Update declaration.
* linux/alpha/set_error.c (arch_set_error, arch_set_success): Provide
tcp in the first argument of the upoke call instead of tcp->pid.
* linux/alpha/set_scno.c (arch_set_scno): Likewise.
* linux/bfin/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/bfin/set_scno.c (arch_set_scno): Likewise.
* linux/crisv10/set_error.c (arch_set_error, arch_set_success):
Likewise.
* linux/crisv10/set_scno.c (arch_set_scno): Likewise.
* linux/hppa/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/hppa/set_scno.c (arch_set_scno): Likewise.
* linux/i386/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/i386/set_scno.c (arch_set_scno): Likewise.
* linux/microblaze/set_error.c (arch_set_error, arch_set_success):
Likewise.
* linux/microblaze/set_scno.c (arch_set_scno): Likewise.
* linux/powerpc/set_error.c (arch_set_error, arch_set_success):
Likewise.
* linux/powerpc/set_scno.c (arch_set_scno): Likewise.
* linux/sh/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/sh/set_scno.c (arch_set_scno): Likewise.
* linux/sh64/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/sh64/set_scno.c (arch_set_scno): Likewise.
* linux/x86_64/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/x86_64/set_scno.c (arch_set_scno): Likewise.
* linux/xtensa/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/xtensa/set_scno.c (arch_set_scno): Likewise.
Eugene Syromiatnikov [Mon, 25 Dec 2017 22:39:40 +0000 (23:39 +0100)]
Move enum trace_event into a separate header
As it will have users outside strace.c in the future.
* trace_event.h (enum trace_event): Move it from...
* strace.c (enum trace_event): ...here.
(#include "trace_event.h"): New header, for enum trace_event.
* Makefile.am (strace_SOURCES): Add trace_event.h.
Eugene Syromyatnikov [Wed, 3 Jan 2018 16:36:25 +0000 (17:36 +0100)]
Call get_scno during startup_tcb only for forcibly attached processes
Otherwise it makes little sense on most arches to try to get syscall
number.
* defs.h (TCB_GRABBED): New tcb flag.
* strace.c (attach_tcb): Set TCB_GRABBED for the tcb.
(startup_tcb): Call get_scno() only if process is grabbed and its
registers may contain syscall number information.
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://github.com/strace/strace/issues/22
Eugene Syromyatnikov [Mon, 1 Jan 2018 16:33:13 +0000 (17:33 +0100)]
strace.c: sort getopt switch branches alphabetically
There's no reason to have them out of order. This also (almost) matches
their order in the getopt call argument, introduced in
v4.20-64-g61c03be .
* strace.c (init): Sort branches in the getopt switch routine.
Eugene Syromyatnikov [Sun, 31 Dec 2017 16:57:33 +0000 (17:57 +0100)]
strace.c: check for (non)zero argc instead of argv[0]
Since we can never be sure that we have NULL behind the last entry of
the argv array.
* strace.c (init): Check for non-zero argc before/instead of argv[0].
Eugene Syromyatnikov [Tue, 26 Dec 2017 12:49:05 +0000 (13:49 +0100)]
strace.1: advertise strace-log-merge
In order to raise awareness about strace-log-merge, mention it in
SEE ALSO section and -ff option description.
* strace.1.in (.SS Filtering) <.TP .B \-ff>: Mention strace-log-merge.
(.SH "SEE ALSO"): Likewise.
Dmitry V. Levin [Fri, 29 Dec 2017 17:59:29 +0000 (17:59 +0000)]
unwind: demangle function arguments
* unwind.c (print_stack_frame): Specify demangling style.
* tests/strace-k.test (result): Update regexp.
* tests/strace-k-demangle.test (expected): Update expected output.
Dmitry V. Levin [Fri, 29 Dec 2017 15:20:21 +0000 (15:20 +0000)]
tests: check strace -k symbol names demangling
* tests/strace-k-demangle.test: New test.
* tests/stack-fcall-mangled.c: New file.
* tests/stack-fcall-mangled-0.c: Likewise.
* tests/stack-fcall-mangled-1.c: Likewise.
* tests/stack-fcall-mangled-2.c: Likewise.
* tests/stack-fcall-mangled-3.c: Likewise.
* tests/stack-fcall.h [MANGLE] (f0, f1, f2, f3): New macros.
* tests/.gitignore: Add stack-fcall-mangled.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(stack_fcall_mangled_SOURCES): New variable.
(EXTRA_DIST): Add strace-k-demangle.test.
[USE_LIBUNWIND && USE_DEMANGLE] (LIBUNWIND_TESTS): Likewise.
Dmitry V. Levin [Fri, 29 Dec 2017 15:20:21 +0000 (15:20 +0000)]
tests: parametrize strace-k.test
Prepare for the check of strace -k symbol names demangling.
* tests/strace-k.test: Parametrize $test_prog and $expected.
* tests/stack-fcall.h: New file.
* tests/stack-fcall.c: Include "stack-fcall.h"
* tests/stack-fcall-0.c: Likewise.
* tests/stack-fcall-1.c: Likewise.
* tests/stack-fcall-2.c: Likewise.
* tests/stack-fcall-3.c: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add stack-fcall.h.
Masatake YAMATO [Mon, 18 Dec 2017 04:24:55 +0000 (13:24 +0900)]
unwind: demangle symbol names
Implement demangling of C++ symbol names in stack trace
using cplus_demangle function from GNU libiberty library.
This is an example demangled stack trace output:
fstat(5, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
> /usr/lib64/libc-2.25.so(__fxstat64+0x12) [0xffd62]
> /usr/lib64/libc-2.25.so(_IO_file_doallocate+0x5f) [0x717ff]
> /usr/lib64/libc-2.25.so(_IO_doallocbuf+0x79) [0x81699]
> /usr/lib64/libc-2.25.so(_IO_file_overflow+0x198) [0x807b8]
> /usr/lib64/libc-2.25.so(_IO_file_xsputn+0xbd) [0x7ed5d]
> /usr/lib64/libc-2.25.so(fwrite_unlocked+0x60) [0x7d800]
> /usr/lib64/libleveldb.so.1.18(leveldb::EnvWrapper::StartThread+0x3b6) [0x48656]
> /usr/lib64/libleveldb.so.1.18(leveldb::log::Writer::EmitPhysicalRecord+0x89) [0x28bc9]
> /usr/lib64/libleveldb.so.1.18(leveldb::log::Writer::AddRecord+0x9e) [0x28d9e]
> /usr/lib64/libleveldb.so.1.18(leveldb::DBImpl::Write+0x208) [0x1ce18]
> /usr/lib64/libleveldb.so.1.18(leveldb::DB::Put+0x59) [0x192b9]
> /usr/lib64/libleveldb.so.1.18(leveldb::DBImpl::Put+0x1d) [0x1931d]
> /home/yamato/var/leveldb/doc/a.out(main+0x120) [0x1107]
> /usr/lib64/libc-2.25.so(__libc_start_main+0xea) [0x2088a]
> /home/yamato/var/leveldb/doc/a.out(_start+0x2a) [0xf3a]
* Makefile.am [USE_DEMANGLE] (strace_CPPFLAGS, strace_LDFLAGS,
libiberty_LDADD): Append libiberty_CPPFLAGS, strace_LDFLAGS, and
libiberty_LIBS, respectively.
* configure.ac: Add --with-libiberty option. Check cplus_demangle
support in libiberty.
* unwind.c [USE_DEMANGLE]: Include <demangle.h>.
(print_stack_frame) [USE_DEMANGLE]: Use cplus_demangle.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Masatake YAMATO [Mon, 18 Dec 2017 04:24:54 +0000 (13:24 +0900)]
Define macros for renaming xmalloc and xcalloc
I'm planning to link strace with libiberty for mangling C++
symbol names in stack trace enabled with -k option.
Both names, xmalloc and xcalloc, are already defined and used
in libiberty, and they conflict with functions in strace.
Rename xmalloc and xcalloc functions defined in strace
to strace_xmalloc and strace_xcalloc, respectively,
to avoid this conflict.
* xmalloc.h (xcalloc, xmalloc): New macros.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Dmitry V. Levin [Sun, 24 Dec 2017 18:49:26 +0000 (18:49 +0000)]
syscall: move a sparc specific include to an arch specific file
* syscall.c [SPARC64]: Do not include <asm/psrcompat.h>.
[SPARC]: Do not include <asm/psr.h>.
* linux/sparc/get_error.c: Include <asm/psr.h>.
Dmitry V. Levin [Sun, 24 Dec 2017 18:49:26 +0000 (18:49 +0000)]
syscall: move all ia64 specific includes to an arch specific file
* syscall.c [IA64]: Remove.
* linux/ia64/get_syscall_args.c: Include <asm/rse.h>.
Dmitry V. Levin [Sun, 24 Dec 2017 16:07:18 +0000 (16:07 +0000)]
syscall: simplify get_syscall_result
* syscall.c [ptrace_getregset_or_getregs] (get_syscall_result_regs):
Define to get_regs.
(get_syscall_result): Use get_syscall_result_regs unconditionally.
Dmitry V. Levin [Sun, 24 Dec 2017 16:07:18 +0000 (16:07 +0000)]
syscall: change get_regs argument type
This opens the way for future changes related to get_regs.
* syscall.c (get_regs): Change argument type from "pid_t"
to "struct tcb *", all callers changed.
Dmitry V. Levin [Sun, 24 Dec 2017 16:07:18 +0000 (16:07 +0000)]
syscall: move get_regs call from syscall_exiting_decode to get_syscall_result
This make the code less confusing and opens the way for future changes
related to get_regs.
* syscall.c (syscall_exiting_decode): Move get_regs invocation ...
(get_syscall_result) [ptrace_getregset_or_getregs]: ... here.
Dmitry V. Levin [Sun, 24 Dec 2017 15:07:10 +0000 (15:07 +0000)]
syscall: rework subcall decoding on mips o32
Move syscall subcall handling to the same switch statement that
handles ipc and socket subcalls.
* linux/mips/syscallent-o32.h [LINUX_MIPSO32] (SYS_syscall_subcall):
Define.
* syscall.c (decode_mips_subcall): Rename to decode_syscall_subcall,
conditionalize on SYS_syscall_subcall instead of LINUX_MIPSO32.
(syscall_entering_decode) [LINUX_MIPSO32]: Remove.
(syscall_entering_decode) [SYS_syscall_subcall]: Handle SEN_syscall
using decode_syscall_subcall.
Dmitry V. Levin [Sun, 24 Dec 2017 15:07:10 +0000 (15:07 +0000)]
syscall: tweak shuffle_scno ifdefery
* syscall.c (shuffle_scno): Check for ARM_FIRST_SHUFFLED_SYSCALL
instead of ARM || AARCH64. This does not result to any code change
but looks more comprehensible.
Dmitry V. Levin [Sun, 24 Dec 2017 12:40:00 +0000 (12:40 +0000)]
syscall: change get_regs to return an error code
* syscall.c (get_regs_error) [!ptrace_getregset_or_getregs]: Do not
define.
(clear_regs) [!ptrace_getregset_or_getregs]: Do not set get_regs_error.
(get_regs) [ptrace_getregset_or_getregs]: Return get_regs_error, all
callers changed to test get_regs return code instead of get_regs_error
static variable, which is now internally used by get_regs() and
clear_regs() only.
(USE_GET_SYSCALL_RESULT_REGS): Do not define.
Use "#ifndef ptrace_getregset_or_getregs"
instead of "#ifdef USE_GET_SYSCALL_RESULT_REGS".
Harsha Sharma [Sun, 24 Dec 2017 07:01:36 +0000 (12:31 +0530)]
tests: enhance run.sh usage error diagnostics
* tests/run.sh: Execute timeout command only when invoked with
an argument, otherwise print an error message.
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Dmitry V. Levin [Sat, 23 Dec 2017 14:12:18 +0000 (14:12 +0000)]
tests: skip nsyscalls-d.test on mips o32
On mips o32, nsyscalls test is implemented using syscall #4000,
so nsyscalls-d cannot work there.
* tests/nsyscalls-d.test: Skip on mips o32.
Dmitry V. Levin [Sat, 23 Dec 2017 02:37:33 +0000 (02:37 +0000)]
Remove linux/ptp_clock.h
As linux kernel provides a compatible linux/ptp_clock.h header since
commit v3.8-rc1~139^2~514, there is no need for a local copy.
* linux/ptp_clock.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_TYPES): Check for struct ptp_sys_offset
in <linux/ptp_clock.h>.
* ioctl.c (ioctl_decode) <case '='>: Conditionalize
on [HAVE_STRUCT_PTP_SYS_OFFSET].
* ptp.c: Likewise.
Dmitry V. Levin [Sat, 23 Dec 2017 02:53:54 +0000 (02:53 +0000)]
Remove linux/ubi-user.h
As linux kernel provides a compatible mtd/ubi-user.h header since
commit v3.7-rc1~85^2~17, there is no need for a local copy.
* linux/ubi-user.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_MEMBERS): Check
for struct ubi_attach_req.max_beb_per1024 in <mtd/ubi-user.h>.
* ioctl.c (ioctl_decode) <case 'o', case 'O'>: Conditionalize
on HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024.
* ubi.c: Likewise.