]>
granicus.if.org Git - strace/log
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.
Dmitry V. Levin [Sat, 23 Dec 2017 02:10:13 +0000 (02:10 +0000)]
Remove linux/mtd-abi.h
As linux kernel provides a compatible mtd/mtd-abi.h header since
commit v3.2-rc1~14^2~33, there is no need for a local copy.
* linux/mtd-abi.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* configure.ac (AC_CHECK_TYPES): Check for struct mtd_write_req
in <mtd/mtd-abi.h>.
* ioctl.c (ioctl_decode) <case 'M'>: Conditionalize
on [HAVE_STRUCT_MTD_WRITE_REQ].
* mtd.c: Likewise.
* tests/ioctl_mtd.c: Likewise.
* tests/ioctl.c (main): Likewise.
Dmitry V. Levin [Sat, 23 Dec 2017 01:51:29 +0000 (01:51 +0000)]
Remove linux/personality.h
* linux/personality.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* personality.c: Do not include <linux/personality.h>, include
"xlat/personality_flags.h" before "xlat/personality_types.h".
* xlat/personality_flags.in: Provide fallback definitions.
* xlat/personality_types.in: Likewise.
Dmitry V. Levin [Sat, 23 Dec 2017 01:26:17 +0000 (01:26 +0000)]
travis: switch from clang-3.8 to clang
As travis provides a relatively fresh clang by default nowadays,
it makes sense to use default clang in clang-based test builds.
* .travis.yml (matrix): Change clang-3.8 to clang.
Eugene Syromyatnikov [Thu, 21 Dec 2017 13:11:47 +0000 (14:11 +0100)]
strace.1.in: mention perf and ftrace in SEE ALSO
* strace.1.in (.SH SEE ALSO): Add references to perf-trace(1) and
trace-cmd(1).
Eugene Syromyatnikov [Thu, 21 Dec 2017 13:10:49 +0000 (14:10 +0100)]
strace.1.in: clarify -F option behaviour
* strace.1.in <.TP \-F>: Extend deprecation warning. Describe behaviour
of multiple instances of -F and interoperability of -F and -f.
Dmitry V. Levin [Wed, 20 Dec 2017 22:58:42 +0000 (22:58 +0000)]
tests: consistently use $STRACE_EXE instead of local alternatives
* tests/get_regs.test: Replace "${STRACE##* }" with "$STRACE_EXE".
* tests/options-syntax.test: Replace "$strace_exp" with "$STRACE_EXE".
* tests/syntax.sh: Likewise.
Eugene Syromyatnikov [Wed, 20 Dec 2017 15:25:20 +0000 (16:25 +0100)]
strace.c: inform the user about -F option obsolescence
* strace.c (init): Print an error message if the option is used.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Eugene Syromyatnikov [Wed, 20 Dec 2017 14:45:55 +0000 (15:45 +0100)]
strace.c: sort option arguments alphabetically
Except for the ones that enabled by configure options.
While we are here, let's also change the indentation of while expression
continuation in order to separate it from the following switch clause.
* strace.c (init): Reorder options in getopt() call.
Eugene Syromiatnikov [Fri, 4 Aug 2017 07:38:50 +0000 (09:38 +0200)]
strace.c: use _exit() instead of exit() in child's die()
Let's keep child's death routine as minimalistic as possible for the
cases when vfork() is used instead of fork() on systems that lack MMU.
* strace.c (die) <!(strace_tracer_pid == getpid())>: Call _exit().
Harsha Sharma [Wed, 20 Dec 2017 17:33:01 +0000 (23:03 +0530)]
syscall: replace if (debug_flag) ... with debug_msg macro
* syscall.c (get_scno): Use debug_msg instead of
"if (debug_flag) error_msg".
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Eugene Syromyatnikov [Wed, 20 Dec 2017 19:11:05 +0000 (20:11 +0100)]
tests: check (some) debugging output generated during nsyscalls test
* tests/nsyscalls-d.c: New file.
* tests/.gitignore: Add it.
* tests/nsyscalls-d.test: New test, variant of nsyscalls.test with debug
output check.
* tests/nsyscalls-nd.test: Likewise.
* tests/nsyscalls.c: Add expected debug output.
* tests/Makefile.am (check_PROGRAMS): Add nsyscalls-d.
(DECODER_TESTS): Add nsyscalls-d.test and nsyscalls-nd.test.
Eugene Syromiatnikov [Wed, 13 Dec 2017 12:52:59 +0000 (13:52 +0100)]
pathtrace.c: use xgrowarray
* defs.h <struct path_set>: Change type of num_selected field to size_t.
Add size field.
* pathtrace.c (storepath): Rewrite to utilise xgrowarray.
Dmitry V. Levin [Thu, 14 Dec 2017 00:05:04 +0000 (00:05 +0000)]
dyxlat: use xgrowarray
* dyxlat.c (dyxlat_alloc): Use xgrowarray instead of xcalloc.
(dyxlat_add_pair): Use xgrowarray instead of xreallocarray.
Dmitry V. Levin [Thu, 14 Dec 2017 00:05:04 +0000 (00:05 +0000)]
unwind: use xgrowarray
* unwind.c (get_symbol_name): Use xgrowarray instead of manual
dynamic array management using xreallocarray.
Eugene Syromiatnikov [Tue, 8 Aug 2017 14:37:39 +0000 (16:37 +0200)]
strace.c: use xgrowarray
* strace.c (tcbtabsize): Change type to size_t.
(expand_tcbtab): Rewrite in order to utilise xgrowarray
instead of manual dynamic array management.
Eugene Syromiatnikov [Tue, 8 Aug 2017 14:37:01 +0000 (16:37 +0200)]
unwind: use xgrowarray
* unwind.c (build_mmap_cache): Use xgrowarray instead of manual dynamic
array management.
Eugene Syromiatnikov [Tue, 8 Aug 2017 14:36:40 +0000 (16:36 +0200)]
xmalloc.c: introduce xgrowarray helper function
In order to simplify dynamic array management code.
* xmalloc.h (xgrowarray): New declaration.
* xmalloc.c (xgrowarray): New function.
Dmitry V. Levin [Wed, 13 Dec 2017 01:47:33 +0000 (01:47 +0000)]
tests: check error diagnostics when exec file name is too long
* tests/options-syntax.test: Check error diagnostics when
exec file name length equals to PATH_MAX.
Eugene Syromiatnikov [Fri, 4 Aug 2017 07:01:47 +0000 (09:01 +0200)]
strace.c: minor style fixes
* strace.c (test_ptrace_seize): Remove excess braces.
(init): Wrap overly long string literal. Add braces
to the else if branch.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:55:35 +0000 (08:55 +0200)]
strace.c: use *_func_* message printing macros where appropriate
In order to provide some additional bits of information in weird error
cases or just replace existing usages of __func__/literal function name.
* strace.c (detach): Use perror_func_msg() instead of perror_msg().
(startup_attach, open_dummy_desc, startup_child, test_ptrace_seize): Use
perror_func_msg_and_die() instead of perror_msg_and_die().
(test_ptrace_seize): Use error_func_msg_and_die() instead of
error_msg_and_die().
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:44:01 +0000 (08:44 +0200)]
unwind.c: more verbose mapping overlapping diagnostic message
* unwind.c (build_mmap_cache): Change error_msg() to debug_msg(), add
information about region names and the respective start and end
addresses.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:43:16 +0000 (08:43 +0200)]
unwind.c: non-fatal handling of asprintf error
An error returned by asprintf is a poor excuse for dying.
* unwind.c (asprintf_error_str): New string constant.
(sprint_call_or_error): Replace error_msg_and_die() with
perror_func_msg() and usage of asprintf_error_str for a return value.
(queue_print): Free tmp->output line only if it is not
asprintf_error_str.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:41:49 +0000 (08:41 +0200)]
unwind.c: eliminate DPRINTF
Since DPRINTF is simply a macro that provides debugging information
along with some information about printing routine call site, now standard
debug_func_* macros are deemed to be a suitable replacement.
* unwind.c (DPRINTF): Remove.
(build_mmap_cache, delete_mmap_cache, unwind_cache_invalidate,
unwind_print_stacktrace, unwind_captiure_stacktrace): Replace
DPRINTF(fmt, str, ...) with debug_func_msg(fmt, ...)/
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:11:02 +0000 (08:11 +0200)]
strace.c: replace if (debug_flag) ... with suitable debug printing macros
* strace.c (alloc_tcb, droptcb, detach, attach_tcb, test_ptrace_seize,
init, startup_tcb): Replace if (debug_flag) error_msg(...) occurrences
with debug_error_msg(...).
(attach_tcb): Replace if (debug_flag) perror_msg(...) with
debug_perror_msg(...).
(cleanup, startup_tcb): Replace if (debug_flag) error_msg(...)
occurrences with debug_func_msg() in attempt to provide additional
information.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:03:34 +0000 (08:03 +0200)]
error_prints.h: add *_func_* printing macros
In order to reduce boilerplate for the cases when __func__ is desired
to be printed.
* error_prints.h (error_func_msg, perror_func_msg, debug_func_msg,
debug_func_perror_msg, error_func_msg_and_die, perror_func_msg_and_die):
New macro definitions.
Eugene Syromiatnikov [Fri, 4 Aug 2017 06:03:03 +0000 (08:03 +0200)]
error_prints.h: add debug print macros
* defs.h (debug_flag): Move the declaration...
* error_prints.h (debug_flag): ... here.
(debug_msg, debug_perror_msg): New macro definitions.
Include <stdbool.h> for the debug_flag declaration.
Masatake YAMATO [Mon, 4 Dec 2017 13:08:17 +0000 (22:08 +0900)]
tests: check decoding of KVM ioctl commands
* tests/ioctl_kvm_run.c: New file.
* tests/ioctl_kvm_run.test: New test.
* tests/Makefile.am (DECODER_TESTS): Add ioctl_kvm_run.test.
* tests/pure_executables.list: Add ioctl_kvm_run.
* tests/.gitignore: Likewise.
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>