]> granicus.if.org Git - strace/log
strace
9 years agosysmips.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:35:41 +0000 (21:35 +0000)]
sysmips.c: make use of RVAL_DECODED

* sysmips.c [MIPS] (sys_sysmips): Update for RVAL_DECODED.

9 years agotime.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:07:06 +0000 (21:07 +0000)]
time.c: make use of RVAL_DECODED

* time.c (sys_settimeofday, sys_osf_settimeofday, sys_clock_settime,
sys_timerfd, sys_timerfd_create, sys_timerfd_settime): Update
for RVAL_DECODED.
(timerfd_gettime): Decode struct itimerspec argument on exiting syscall.

9 years agotime.c: use printaddr, printnum_int, and umoven_or_printaddr
Dmitry V. Levin [Thu, 16 Jul 2015 18:18:09 +0000 (18:18 +0000)]
time.c: use printaddr, printnum_int, and umoven_or_printaddr

* time.c (sys_nanosleep): Use printaddr.
(printitv_bitness, tprint_timex32, tprint_timex, printsigevent32,
printsigevent): Use umoven_or_printaddr.
(sys_timer_create): Use printnum_int.
(sys_getitimer, sys_osf_getitimer, sys_setitimer, sys_osf_setitimer,
do_adjtimex, sys_timer_settime, sys_timer_gettime): Remove
redundant checks for syserror.

9 years agosprinttv: do not fetch data in case of syserror
Dmitry V. Levin [Thu, 16 Jul 2015 16:22:07 +0000 (16:22 +0000)]
sprinttv: do not fetch data in case of syserror

* time.c (sprinttv): Do not fetch data in case syserror.
Print address instead of {...} in case of umove failure.
(sys_gettimeofday, sys_osf_gettimeofday, sys_adjtime, sys_clock_gettime,
clock_nanosleep): Remove now redundant checks for syserror.

9 years agotruncate.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:29:28 +0000 (21:29 +0000)]
truncate.c: make use of RVAL_DECODED

* truncate.c (sys_truncate, sys_truncate64, sys_ftruncate,
sys_ftruncate64): Update for RVAL_DECODED.

9 years agoumask.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:27:12 +0000 (21:27 +0000)]
umask.c: make use of RVAL_DECODED

* umask.c (sys_umask): Update for RVAL_DECODED.

9 years agoumount.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:13:27 +0000 (21:13 +0000)]
umount.c: make use of RVAL_DECODED

* umount.c (sys_umount2): Update for RVAL_DECODED.

9 years agoutimes.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 21:21:09 +0000 (21:21 +0000)]
utimes.c: make use of RVAL_DECODED

* utimes.c (decode_utimes): Change to return void.
Update for RVAL_DECODED.
(sys_utimes, sys_futimesat, sys_utimensat, sys_osf_utimes):
Update callers.  Update for RVAL_DECODED.

9 years agotests/uid.test: adopt for alpha
Dmitry V. Levin [Thu, 16 Jul 2015 09:09:11 +0000 (09:09 +0000)]
tests/uid.test: adopt for alpha

Make the test work on alpha that has getxuid syscall instead of getuid.

* tests/uid.awk (BEGIN): Update getuid regexp to match both getuid
and getxuid syscalls.
* tests/uid.c (main): Allow __NR_getxuid as an alternative
to __NR_getuid.
* tests/uid.test: If getuid syscall is not available, probe for
getxuid syscall.

9 years agouid.c: make use of RVAL_DECODED
Dmitry V. Levin [Thu, 16 Jul 2015 00:01:25 +0000 (00:01 +0000)]
uid.c: make use of RVAL_DECODED

* uid.c (sys_setuid, sys_setreuid, sys_setresuid, sys_chown, sys_fchown,
sys_setgroups): Update for RVAL_DECODED.

9 years agouid.c: use printaddr and umoven_or_printaddr
Dmitry V. Levin [Wed, 15 Jul 2015 23:37:31 +0000 (23:37 +0000)]
uid.c: use printaddr and umoven_or_printaddr

* uid.c (get_print_uid): Use umoven_or_printaddr.
(sys_getresuid): Do not check for syserror, get_print_uid now does
the right thing.
(sys_setgroups, sys_getgroups): Add const qualifier to local variables
that are assigned once.  Use printaddr.

9 years agoia64: wire up utimensat syscall
Dmitry V. Levin [Wed, 15 Jul 2015 23:03:15 +0000 (23:03 +0000)]
ia64: wire up utimensat syscall

* linux/ia64/syscallent.h (utimensat): New entry.

9 years agodecode_utimes: enclose timespec array in square brackets
Dmitry V. Levin [Wed, 15 Jul 2015 14:52:47 +0000 (14:52 +0000)]
decode_utimes: enclose timespec array in square brackets

* utimes.c (decode_utimes): enclose timespec array in square brackets
instead of curly brackets.

9 years agouname.c: use umove_or_printaddr
Dmitry V. Levin [Wed, 15 Jul 2015 09:25:34 +0000 (09:25 +0000)]
uname.c: use umove_or_printaddr

* uname.c (sys_uname): Use umove_or_printaddr.

9 years agotests: add utime.test
Dmitry V. Levin [Wed, 15 Jul 2015 09:02:17 +0000 (09:02 +0000)]
tests: add utime.test

* tests/utime.c: New file.
* tests/utime.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add utime.
(TESTS): Add utime.test.
* tests/.gitignore: Add utime.

9 years agoutime.c: make use of RVAL_DECODED
Dmitry V. Levin [Wed, 15 Jul 2015 08:29:56 +0000 (08:29 +0000)]
utime.c: make use of RVAL_DECODED

* utime.c (sys_utime): Update for RVAL_DECODED.

9 years agoutime.c: use umoven_or_printaddr
Dmitry V. Levin [Wed, 15 Jul 2015 08:27:18 +0000 (08:27 +0000)]
utime.c: use umoven_or_printaddr

* utime.c (sys_utime): Use umoven_or_printaddr.

9 years agowait.c: use printaddr and umove_or_printaddr
Dmitry V. Levin [Wed, 15 Jul 2015 00:36:20 +0000 (00:36 +0000)]
wait.c: use printaddr and umove_or_printaddr

* wait.c (waitid): Do not check for NULL the address passed
to printrusage.
(printwaitn): Likewise.
Use printaddr and umove_or_printaddr for fetching wait status.

9 years agowait: move fallback definitions of wait options to xlat/
Dmitry V. Levin [Wed, 15 Jul 2015 00:33:20 +0000 (00:33 +0000)]
wait: move fallback definitions of wait options to xlat/

* wait.c: Move definitions of __W* flags ...
* xlat/wait4_options.in: ... here.

9 years agotests: add xattr.test
Dmitry V. Levin [Wed, 15 Jul 2015 00:09:08 +0000 (00:09 +0000)]
tests: add xattr.test

* tests/xattr.c: New file.
* tests/xattr.expected: Likewise.
* tests/xattr.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add xattr.
(TESTS): Add xattr.test.
(EXTRA_DIST): Add xattr.expected.
* tests/.gitignore: Add xattr.

9 years agoxattr.c: make use of RVAL_DECODED
Dmitry V. Levin [Tue, 14 Jul 2015 23:38:58 +0000 (23:38 +0000)]
xattr.c: make use of RVAL_DECODED

* xattr.c (sys_setxattr, sys_fsetxattr, sys_removexattr,
sys_fremovexattr): Update for RVAL_DECODED.

9 years agoprint_xattr_val: do not fetch data in case of !verbose || syserror
Dmitry V. Levin [Tue, 14 Jul 2015 23:34:06 +0000 (23:34 +0000)]
print_xattr_val: do not fetch data in case of !verbose || syserror

* xattr.c (print_xattr_val): Do not fetch data in case
of !verbose || syserror.   Use printaddr.

9 years agoprint_xattr_list: use printaddr
Dmitry V. Levin [Tue, 14 Jul 2015 23:31:35 +0000 (23:31 +0000)]
print_xattr_list: use printaddr

* xattr.c (print_xattr_list): Use printaddr.

9 years agoprint_xattr_val: remove unused argument
Dmitry V. Levin [Tue, 14 Jul 2015 23:25:15 +0000 (23:25 +0000)]
print_xattr_val: remove unused argument

* xattr.c (print_xattr_val): Remove unused "failed" argument.
(sys_setxattr, sys_fsetxattr, sys_getxattr, sys_fgetxattr): Update
all callers.

9 years agoprint_xattr_list: remove redundant address check
Dmitry V. Levin [Tue, 14 Jul 2015 23:27:21 +0000 (23:27 +0000)]
print_xattr_list: remove redundant address check

* xattr.c (print_xattr_list): Do not check for NULL the address passed
to printstr.

9 years agoipc.c: make use of RVAL_DECODED
Dmitry V. Levin [Mon, 13 Jul 2015 21:06:48 +0000 (21:06 +0000)]
ipc.c: make use of RVAL_DECODED

* ipc.c (sys_mq_notify, sys_mq_open, sys_mq_timedreceive,
sys_mq_timedsend, sys_msgctl, sys_msgget, sys_msgsnd, sys_semctl,
sys_semget, sys_semop, sys_semtimedop, sys_shmctl, sys_shmdt,
sys_shmget): Update for RVAL_DECODED.
(sys_shmat): Decode all arguments on entering syscall.

9 years agoumoven_or_printaddr: do not fetch data if not in verbose mode
Dmitry V. Levin [Tue, 14 Jul 2015 22:03:55 +0000 (22:03 +0000)]
umoven_or_printaddr: do not fetch data if not in verbose mode

After this change, umoven_or_printaddr and its callers, including
printnum_* and printpair_*, will not fetch data in !verbose mode.

* util.c (umoven_or_printaddr): Do not call umoven if !verbose.

9 years agoChange printnum_* printers to honor syserror
Dmitry V. Levin [Mon, 13 Jul 2015 20:44:01 +0000 (20:44 +0000)]
Change printnum_* printers to honor syserror

With this change, printnum_* printers will not attempt to fetch data
in case of exiting(tcp) && syserror(tcp).
All "at exiting" decoders that call these printers have been made
ready for this change in previous commits.

* util.c (DEF_PRINTNUM, DEF_PRINTPAIR): Use umove_or_printaddr.
* prctl.c (prctl_exit): Use printnum_int and printnum_long.
(sys_arch_prctl): Do not check for syserror.

9 years agoterm.c: enhance tty ioctl parser
Dmitry V. Levin [Mon, 13 Jul 2015 20:10:20 +0000 (20:10 +0000)]
term.c: enhance tty ioctl parser

Decode as much data on entering syscall as possible.

* term.c (decode_termios, decode_termio, decode_winsize, decode_ttysize,
decode_modem_flags): New functions.
(term_ioctl): Use them.  Update for RVAL_DECODED.

9 years agoChange comparisons with function pointers to comparisons with SENs
Elvira Khabirova [Fri, 10 Jul 2015 19:24:58 +0000 (22:24 +0300)]
Change comparisons with function pointers to comparisons with SENs

* pathtrace.c (pathtrace_match): Change all comparisons with function
pointers to a single SEN based switch.
* syscall.c (dumpio, trace_syscall_entering): Change all comparisons
with function pointers to comparisons with SENs.
* ipc.c (sys_ipc): Remove.
* sock.c (sys_socketcall): Likewise.
* linux/dummy.h (sys_ipc, sys_socketcall): New aliases.

9 years agoAdd unique syscall entry numbers (SENs)
Elvira Khabirova [Fri, 10 Jul 2015 19:24:54 +0000 (22:24 +0300)]
Add unique syscall entry numbers (SENs)

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sen.h.
(syscallent_names, syscallent_patterns, syscallent_files): New variables.
(sen.h): New rule.
* defs.h (struct sysent): Add sen field.
* generate_sen.sh: New file.
* linux/syscall.h: Include "sen.h".
* syscall.c (SEN_NAME): New temporary macro.
(SEN): Use it to prepend syscall entry number.

9 years agoIntroduce SEN macro
Elvira Khabirova [Fri, 10 Jul 2015 19:24:48 +0000 (22:24 +0300)]
Introduce SEN macro

* syscall.c (SEN): New temporary macro.
* linux/dummy.h (sys_printargs): New macro.
* linux/subcall.h: Wrap all sys_func entries using SEN.
* linux/*/syscallent*.h: Likewise.

9 years agoscsi.c: enhance SG_IO ioctl parser
Dmitry V. Levin [Tue, 7 Jul 2015 18:38:07 +0000 (21:38 +0300)]
scsi.c: enhance SG_IO ioctl parser

Fix SG_IO ioctl output in case of failed umove

* scsi.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
Update for RVAL_DECODED.
(print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): Do not print address in case of failed umove.
(scsi_ioctl): Use printaddr.

9 years agoptp.c: enhance ptp ioctl parser
Dmitry V. Levin [Tue, 7 Jul 2015 09:47:18 +0000 (12:47 +0300)]
ptp.c: enhance ptp ioctl parser

* ptp.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
Update for RVAL_DECODED.
(ptp_ioctl): Use umove_or_printaddr.

9 years agomtd.c: enhance mtd and ubi ioctl parsers
Dmitry V. Levin [Tue, 7 Jul 2015 01:12:12 +0000 (04:12 +0300)]
mtd.c: enhance mtd and ubi ioctl parsers

Decode as much data on entering syscall as possible.

* xlat/mtd_file_mode_options.in: New file.
* mtd.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
Include "xlat/mtd_file_mode_options.h".
Update for RVAL_DECODED.
(mtd_ioctl, ubi_ioctl): Use printnum_int and umove_or_printaddr.

9 years agosock.c: enhance socket ioctl parser
Dmitry V. Levin [Sat, 4 Jul 2015 11:01:08 +0000 (14:01 +0300)]
sock.c: enhance socket ioctl parser

Decode as much data on entering syscall as possible.

* sock.c: Update for RVAL_DECODED.
(print_addr): Remove.
(print_ifreq_addr, print_ifreq, print_ifc_len, decode_ifconf): New
functions.
(sock_ioctl) Use them.  Use umove_or_printaddr.

9 years agoblock.c: enhance block ioctl parser
Dmitry V. Levin [Sun, 5 Jul 2015 12:15:03 +0000 (15:15 +0300)]
block.c: enhance block ioctl parser

* block.c: Update for RVAL_DECODED.
Define BLKROTATIONAL and BLKZEROOUT.
(block_ioctl): Decode them.  Use printnum_short, printnum_int,
printnum_long, printpair_int64, and umove_or_printaddr.
(print_blkpg_req, block_ioctl): Use umove_or_printaddr.

9 years agoblkpg_ops: add BLKPG_RESIZE_PARTITION constant
Dmitry V. Levin [Sun, 5 Jul 2015 12:15:03 +0000 (15:15 +0300)]
blkpg_ops: add BLKPG_RESIZE_PARTITION constant

* xlat/blkpg_ops.in: Add BLKPG_RESIZE_PARTITION.

Reported-by: Christian Neukirchen <chneukirchen@gmail.com>
9 years agoloop.c: enhance loop ioctl parser
Dmitry V. Levin [Sat, 4 Jul 2015 14:40:02 +0000 (17:40 +0300)]
loop.c: enhance loop ioctl parser

Decode as much data on entering syscall as possible.

* loop.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
Update for RVAL_DECODED.
(decode_loop_info, decode_loop_info64): New functions.
(loop_ioctl): Use them.  Decode LOOP_SET_STATUS, LOOP_SET_STATUS64,
LOOP_SET_FD, LOOP_CHANGE_FD, LOOP_CTL_ADD and LOOP_CTL_REMOVE on
entering syscall.
Print LOOP_SET_FD and LOOP_CHANGE_FD arguments using printfd.

9 years agortc.c: enhance rtc ioctl parser
Dmitry V. Levin [Sat, 4 Jul 2015 12:07:35 +0000 (15:07 +0300)]
rtc.c: enhance rtc ioctl parser

* rtc.c: Update for RVAL_DECODED.
(print_rtc): Rename to print_rtc_time.
(decode_rtc_time, decode_rtc_wkalrm): New functions.
(rtc_ioctl): Use them.
[RTC_VL_READ]: Decode RTC_VL_READ.
Use printnum_long for RTC_IRQP_READ and RTC_EPOCH_READ decoding.

9 years agoUse printpair_int
Dmitry V. Levin [Mon, 6 Jul 2015 22:33:39 +0000 (22:33 +0000)]
Use printpair_int

* evdev.c (repeat_ioctl): Use printpair_int.
* net.c (do_pipe, sys_socketpair): Likewise.

9 years agoAdd several generic integer pairs printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add several generic integer pairs printing functions

Add functions to fetch and print pairs of integer types.
Note that these printers do not attempt to fetch data
in case of exiting(tcp) && syserror(tcp).

printnum_* printers will follow as soon as all callers are made ready
for this change.

* defs.h (printpair_int, printpair_long, printpair_int64): New
prototypes.
* util.c (DEF_PRINTPAIR): New macro.
(printpair_int, printpair_long, printpair_int64): New functions.

9 years agoAdd two generic integer printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add two generic integer printing functions

Add printnum_short and printnum_int64 in addition to already existing
printnum_int and printnum_long.

* defs.h (printnum_short, printnum_int64): New prototypes.
* util.c (DEF_PRINTNUM): New macro.
(printnum_int, printnum_long): Use DEF_PRINTNUM.
(printnum_short, printnum_int64): New functions.

9 years agoAdd address printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add address printing functions

printaddr is a simple function implementing "print NULL or address"
idiom.
umoven_or_printaddr is a wrapper around umoven that has the same return
value semantics as umoven but also prints the address when the data
is not going to be fetched (in case of exiting(tcp) && syserror(tcp))
or cannot be fetched (umoven fails).
umove_or_printaddr is a macro wrapper around umoven_or_printaddr that
mirrors umove wrapper around umoven.

* defs.h (printaddr, umoven_or_printaddr): New prototypes.
(umove_or_printaddr): New macro.
* util.c (printaddr, umoven_or_printaddr): New functions.

9 years agoImplement RVAL_DECODED flag
Dmitry V. Levin [Wed, 8 Jul 2015 14:10:56 +0000 (14:10 +0000)]
Implement RVAL_DECODED flag

Implement a method for "on entering" parsers to return
"done with decoding" information to their callers.

If a syscall parser called from trace_syscall_entering returns a value
with RVAL_DECODED bit set, record this value in tcp->sys_func_rval
and use it in trace_syscall_exiting instead of calling the parser on
exiting syscall.

If an ioctl parser returned RVAL_DECODED, this would tell
SYS_FUNC(ioctl) that the decoding is finished but fallback printing of
the ioctl command argument is needed, while e.g. RVAL_DONE+1 would mean
that the decoding is finished and no fallback decoding is needed.

* defs.h (struct tcb): Add sys_func_rval.
(RVAL_DECODED): New macro.
* syscall.c (trace_syscall_entering): Initialize tcp->sys_func_rval
along with setting TCB_INSYSCALL flag.
(trace_syscall_exiting): Use tcp->sys_func_rval instead of calling
tcp->s_ent->sys_func when the former has RVAL_DECODED flag set.
Reset tcp->sys_func_rval along with clearing TCB_INSYSCALL flag.
* ioctl.c (sys_ioctl): Set RVAL_DECODED flag on exiting.
Print ioctl argument iff RVAL_DECODED is set and fallback decoding
is requested.

9 years agotime.c: move rtc ioctl parser to a separate file
Dmitry V. Levin [Sat, 4 Jul 2015 08:56:21 +0000 (08:56 +0000)]
time.c: move rtc ioctl parser to a separate file

* rtc.c: new file
* Makefile.am (strace_SOURCES): Add it.
* time.c (print_rtc, rtc_ioctl): Move to rtc.c.

9 years agoterm.c: fix typo
Dmitry V. Levin [Sun, 5 Jul 2015 16:30:10 +0000 (16:30 +0000)]
term.c: fix typo

* term.c: Rename TCLFLSH to TCFLSH.

9 years agoDo not include sys/filio.h
Dmitry V. Levin [Sun, 5 Jul 2015 16:18:45 +0000 (16:18 +0000)]
Do not include sys/filio.h

* configure.ac (AC_CHECK_HEADERS): Remove sys/filio.h.
* term.c: Do not include <sys/filio.h>.

9 years agoioctl: prepare ioctl_decode_command_number for future changes
Dmitry V. Levin [Thu, 2 Jul 2015 22:31:11 +0000 (22:31 +0000)]
ioctl: prepare ioctl_decode_command_number for future changes

* ioctl.c (ioctl_decode_command_number): Change 1st arg to struct tcb*.
(sys_ioctl): Update callers.

9 years agoioctl: simplify ioctl_decode signature
Dmitry V. Levin [Thu, 2 Jul 2015 22:27:51 +0000 (22:27 +0000)]
ioctl: simplify ioctl_decode signature

* ioctl.c (ioctl_decode): Remove 2nd and 3rd parameters.
(sys_ioctl): Update callers.

9 years agoioctl: consistently use name "code" for ioctl request code
Dmitry V. Levin [Thu, 2 Jul 2015 22:23:53 +0000 (22:23 +0000)]
ioctl: consistently use name "code" for ioctl request code

* ioctl.c (evdev_decode_number, hiddev_decode_number,
ioctl_decode_command_number): Rename "arg" to "code".

9 years agoMove ioctl syscall parser to ioctl.c
Dmitry V. Levin [Thu, 2 Jul 2015 21:37:23 +0000 (21:37 +0000)]
Move ioctl syscall parser to ioctl.c

* io.c (sys_ioctl): Move ...
* ioctl.c: ... here.
(ioctl_lookup, ioctl_next_match, ioctl_print_code, ioctl_decode,
ioctl_decode_command_number): Declare as static.
* defs.h (ioctl_lookup, ioctl_next_match, ioctl_print_code,
ioctl_decode, ioctl_decode_command_number): Remove.

9 years agoioctl: remove obsolete registry of ioctl characters
Dmitry V. Levin [Thu, 2 Jul 2015 21:34:39 +0000 (21:34 +0000)]
ioctl: remove obsolete registry of ioctl characters

* ioctl.c: Remove registry of ioctl characters.

9 years agoFix filtering of <unavailable> syscalls
Dmitry V. Levin [Mon, 29 Jun 2015 11:57:44 +0000 (11:57 +0000)]
Fix filtering of <unavailable> syscalls

* syscall.c (trace_syscall_exiting): Skip filtered syscalls also in case
of get_regs or get_syscall_result failure.
* tests/filter-unavailable.c: New file.
* tests/filter-unavailable.expected: Likewise.
* tests/filter-unavailable.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add filter-unavailable.
(filter_unavailable_LDFLAGS): Add -pthread.
(TESTS): Add filter-unavailable.test.
(EXTRA_DIST): Add filter-unavailable.expected.
* tests/.gitignore: Add filter-unavailable.

Reported-by: Bryan Matsuo <bryan.matsuo@gmail.com>
9 years agoFix -qq option in conjunction with -o option
Dmitry V. Levin [Mon, 29 Jun 2015 14:37:26 +0000 (14:37 +0000)]
Fix -qq option in conjunction with -o option

This change makes -qq option work in conjunction with -o option,
thus complementing commit v4.7-222-g01997cf.

* strace.c (init): Do not reset qflag.

9 years agoxtensa: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 16:31:33 +0000 (16:31 +0000)]
xtensa: wire up new syscalls

* linux/xtensa/syscallent.h (bpf, execveat): New entries.

9 years agobfin: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 16:25:10 +0000 (16:25 +0000)]
bfin: wire up new syscalls

* linux/bfin/syscallent.h (kcmp, finit_module, sched_setattr,
sched_getattr, renameat2, seccomp, getrandom, memfd_create,
bpf, execveat): New entries.

9 years agoalpha: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 15:39:46 +0000 (15:39 +0000)]
alpha: wire up new syscalls

* linux/alpha/syscallent.h (getrandom, memfd_create, execveat):
New entries.

9 years agotests: skip stat32 test if struct stat is defined incorrectly
Dmitry V. Levin [Wed, 17 Jun 2015 20:58:33 +0000 (20:58 +0000)]
tests: skip stat32 test if struct stat is defined incorrectly

If stat.st_mode returned by syscall is 0, it means that the definition
of struct stat in <asm/stat.h> is incorrect.  This is the case e.g. on
mips n32 where the only available stat syscall is 64-bit but at the same
time struct stat defined by <asm/stat.h> is 32-bit.

* tests/stat.c (main) [NR_stat]: Return 77 if st_mode is 0.

9 years agoConsistenly use #ifdef to check for AC_DEFINE'd macros
Dmitry V. Levin [Wed, 17 Jun 2015 20:09:13 +0000 (20:09 +0000)]
Consistenly use #ifdef to check for AC_DEFINE'd macros

* aio.c (print_common_flags): Use #ifdef in the check for
HAVE_STRUCT_IOCB_U_C_FLAGS.
* defs.h: Use #ifdef in the check for HAVE_LITTLE_ENDIAN_LONG_LONG.
* net.c: Use #ifdef in the check for HAVE_SENDMSG.
* syscall.c (dumpio): Likewise.
* printstat.h (DO_PRINTSTAT): Use #ifdef in checks for
HAVE_STRUCT_STAT_ST_* macros.
* util.c: Use #ifdef in checks for HAVE_SYS_XATTR_H.

9 years agoxattr: move fallback definitions of xattr flags to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:54:21 +0000 (19:54 +0000)]
xattr: move fallback definitions of xattr flags to xlat/

* xattr.c: Include <sys/xattr.h> insread of <linux/xattr.h>.
Move definitions of XATTR_* flags ...
* xlat/xattrflags.in: ... here.

9 years agolink: move fallback definitions of AT_* constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:45:26 +0000 (19:45 +0000)]
link: move fallback definitions of AT_* constants to xlat/

* link.c: Move definitions of AT_* constants ...
* xlat/at_flags.in: ... here.

9 years agonet: move fallback definitions of SOL_* constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:22:10 +0000 (19:22 +0000)]
net: move fallback definitions of SOL_* constants to xlat/

* net.c: Move definitions of SOL_* constants ...
* xlat/socketlayers.in: ... here.

9 years agofutex: move fallback definitions of futex constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:00:17 +0000 (19:00 +0000)]
futex: move fallback definitions of futex constants to xlat/

* futex.c: Move definitions of FUTEX_OP_CMP_* constants ...
* xlat/futexwakecmps.in: ... here.
* futex.c: Move definitions of other FUTEX_OP_* constants ...
* xlat/futexwakeops.in: ... here.
* futex.c: Move definitions of remaining FUTEX_* constants except
FUTEX_PRIVATE_FLAG and FUTEX_CLOCK_REALTIME flags ...
* xlat/futexops.in: ... here.

9 years agoclone: move definitions of cloning flags to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 18:36:53 +0000 (18:36 +0000)]
clone: move definitions of cloning flags to xlat/

* clone.c: Include <sched.h>.  Move definitions of CLONE_* flags ...
* xlat/clone_flags.in: ... here.

9 years agoUpdate mount flags constants
Dmitry V. Levin [Tue, 16 Jun 2015 00:31:45 +0000 (00:31 +0000)]
Update mount flags constants

* mount.c: Remove definitions of mount flags constants.
* xlat/mount_flags.in: Update from linux v4.0, add default values.

9 years agomount: update parser to match kernel behaviour
Dmitry V. Levin [Tue, 16 Jun 2015 10:53:25 +0000 (10:53 +0000)]
mount: update parser to match kernel behaviour

* mount.c (sys_mount): Do not decode type and data strings for
MS_SHARED, MS_PRIVATE, MS_SLAVE, and MS_UNBINDABLE mount flags
that do not imply valid strings.

9 years agomount: robustify MS_MGC_VAL decoding
Dmitry V. Levin [Tue, 16 Jun 2015 01:28:34 +0000 (01:28 +0000)]
mount: robustify MS_MGC_VAL decoding

* mount.c (sys_mount): When printing mount flags, do not assume that
(flags & MS_MGC_MSK) == MS_MGC_VAL.

9 years agonet: decode setsockopt() multicast arguments
Dmitry V. Levin [Mon, 8 Jun 2015 14:19:46 +0000 (14:19 +0000)]
net: decode setsockopt() multicast arguments

* configure.ac (AC_CHECK_FUNCS): Add inet_pton.
* net.c (print_mreq, print_mreq6): New functions.
(print_setsockopt): Use them to decode IP_ADD_MEMBERSHIP,
IP_DROP_MEMBERSHIP, IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP,
IPV6_JOIN_ANYCAST, and IPV6_LEAVE_ANYCAST.
* tests/ip_mreq.c: New file.
* tests/ip_mreq.expected: Likewise.
* tests/ip_mreq.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add ip_mreq.
(TESTS): Add ip_mreq.test.
(EXTRA_DIST): ip_mreq.expected.
* tests/.gitignore: Add ip_mreq.

Based on patch by Ben Noordhuis <info@bnoordhuis.nl>.

9 years agoUpdate IPV6 socket options constants
Dmitry V. Levin [Mon, 8 Jun 2015 23:01:09 +0000 (23:01 +0000)]
Update IPV6 socket options constants

* xlat/sockipv6options.in: Update from linux v4.0.

9 years agonet: factor out interface index printing code
Dmitry V. Levin [Fri, 5 Jun 2015 20:13:21 +0000 (20:13 +0000)]
net: factor out interface index printing code

* net.c (print_ifindex): New function.
(printsock) [HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID]: Use it.

9 years agoConsistently use error_msg instead of fprintf(stderr)
Dmitry V. Levin [Mon, 25 May 2015 22:51:19 +0000 (22:51 +0000)]
Consistently use error_msg instead of fprintf(stderr)

* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.

9 years agoConsistently print OOM diagnostic messages
Dmitry V. Levin [Mon, 25 May 2015 20:33:31 +0000 (23:33 +0300)]
Consistently print OOM diagnostic messages

* bjm.c (sys_query_module): Use error_msg to print OOM diagnostics.
* util.c (dumpiov, dumpstr): Likewise.

9 years agoIntroduce memory allocation wrappers
Dmitry V. Levin [Mon, 25 May 2015 20:41:02 +0000 (20:41 +0000)]
Introduce memory allocation wrappers

Introduce wrappers to the following functions that do memory allocation:
malloc, calloc, realloc, strdup.

This commit is a follow-up to the related discussions in strace-devel ML:
http://sourceforge.net/p/strace/mailman/message/33618180/
http://sourceforge.net/p/strace/mailman/message/33733470/

* defs.h (xmalloc, xcalloc, xreallocarray, xstrdup): New prototypes.
* xmalloc.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* count.c (count_syscall, call_summary_pers): Use xcalloc.
* desc.c (decode_select): Use xmalloc.
* dirent.c (sys_getdents, sys_getdents64): Likewise.
* net.c (sys_recvmmsg): Use xstrdup.
* pathtrace.c (storepath): Use xreallocarray.
(pathtrace_match): Use xmalloc.
* strace.c (die_out_of_memory): Move to xmalloc.c.
(expand_tcbtab): Use xcalloc and xreallocarray.
(startup_child): Use xstrdup.
(init): Use xmalloc, xcalloc, and xstrdup.
* syscall.c (reallocate_qual): Use xreallocarray.
(qualify): Use xstrdup.
* unwind.c (unwind_tcb_init): Use xmalloc.
(build_mmap_cache): Use xcalloc, xreallocarray, and xstrdup.
(get_symbol_name): Use xreallocarray.
(stacktrace_walk, queue_put): Use xmalloc.
* util.c (printstr): Use xmalloc.
* vsprintf.c (strace_vfprintf): Likewise.

9 years agoFix ioctl entries on 32-bit architectures with 64-bit aligned structures
Dmitry V. Levin [Thu, 21 May 2015 16:19:40 +0000 (16:19 +0000)]
Fix ioctl entries on 32-bit architectures with 64-bit aligned structures

Some ioctl constants are defined to different values on those 32-bit
architectures where structures containing a 64-bit field are aligned on
a 8-byte boundary and have a size multiple of 8 bytes, and on other
32-bit architectures.

* configure.ac: Check the size of a structure containing a 64-bit field.
* linux/32/ioctls_inc.h: Rename to ...
* linux/32/ioctls_inc_align32.h: ... this.
* linux/32/ioctls_inc_align64.h: New file.
* linux/32/ioctls_inc.h: Include either 32/ioctls_inc_align32.h
or ioctls_inc_align64.h depending on SIZEOF_STRUCT_I64_I32.
* Makefile.am (EXTRA_DIST): Add linux/32/ioctls_inc_align32.h and
* linux/32/ioctls_inc_align64.h.
* tests/ioctl.c (main): Test for VIDIOC_ENUMINPUT.
* tests/ioctl.expected: Check VIDIOC_ENUMINPUT decoding.

Reported-by: Philippe De Muyter <phdm@macqel.be>
9 years agomaint: make linux/kvm.h parseable on arm
Dmitry V. Levin [Thu, 21 May 2015 16:12:31 +0000 (16:12 +0000)]
maint: make linux/kvm.h parseable on arm

* maint/ioctls_sym.sh [AARCH64 || ARM]: Add missing definitions for
structures referenced from linux/kvm.h.

9 years agov4l2: add decoding for VIDIOC_S_CROP's arg
Philippe De Muyter [Wed, 20 May 2015 15:50:21 +0000 (17:50 +0200)]
v4l2: add decoding for VIDIOC_S_CROP's arg

* v4l2.c (v4l2_ioctl): Add decoding for VIDIOC_S_CROP's arg.

9 years agoAdd support for Altera's Nios-II softcore architecture
Ezequiel Garcia [Sat, 18 Apr 2015 20:33:27 +0000 (17:33 -0300)]
Add support for Altera's Nios-II softcore architecture

This commit adds strace support for Altera's Nios-II.  The architecture
is supported by Linux since v3.19, and it implements the generic syscall
ABI.

* configure.ac: Add nios2 support.
* cacheflush.c [NIOS2] (sys_cacheflush): New function.
* linux/nios2/*: New Nios-II specific files.
* Makefile.am (EXTRA_DIST): Add them.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
9 years agov4l2: VIDIOC_CROPCAP: add missing braces around arg printout
Philippe De Muyter [Tue, 19 May 2015 21:54:21 +0000 (23:54 +0200)]
v4l2: VIDIOC_CROPCAP: add missing braces around arg printout

* v4l2.c (v4l2_ioctl): case VIDIOC_CROPCAP: add missing braces around arg
printout.

9 years agomaint: avoid effects of locale when sorting files
Dmitry V. Levin [Tue, 19 May 2015 18:00:07 +0000 (18:00 +0000)]
maint: avoid effects of locale when sorting files

* maint/ioctls_gen.sh: Invoke sort with LC_COLLATE=C.
* maint/ioctls_hex.sh: Likewise.
* maint/ioctls_sym.sh: Likewise.

Reported-by: Philippe De Muyter <phdm@macqel.be>
9 years agov4l2: add decoding for VIDIOC_CREATE_BUFS's arg.
Philippe De Muyter [Sat, 18 Apr 2015 13:06:43 +0000 (15:06 +0200)]
v4l2: add decoding for VIDIOC_CREATE_BUFS's arg.

* v4l2.c (v4l2_ioctl): Add decoding for VIDIOC_CREATE_BUFS's arg.

9 years agomips o32: decode indirect syscall
Dmitry V. Levin [Fri, 17 Apr 2015 09:14:19 +0000 (09:14 +0000)]
mips o32: decode indirect syscall

Implement decoding of MIPS O32 specific indirect syscall.

* syscall.c [LINUX_MIPSO32] (decode_mips_subcall, sys_syscall):
New functions.
(trace_syscall_entering) [LINUX_MIPSO32]: Use decode_mips_subcall.
* linux/mips/syscallent-o32.h (4000): Change sys_func to sys_syscall.

Reported-and-tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
9 years agodebian: add gawk to Build-Depends
Dmitry V. Levin [Tue, 14 Apr 2015 17:22:54 +0000 (17:22 +0000)]
debian: add gawk to Build-Depends

* debian/control (Build-Depends): Add gawk.
Patch by Reiner Herrmann <reiner@reiner-h.de>.

This fixes Debian bug #780992.

9 years agotests: fix bexecve.test for the case of mixed personalities
Dmitry V. Levin [Tue, 14 Apr 2015 16:04:08 +0000 (16:04 +0000)]
tests: fix bexecve.test for the case of mixed personalities

Fix bexecve.test when the executable being run does not match the
native architecture.

* tests/bexecve.test: Use "set_ptracer_any" instead of "sh".
Allow for a personality switch notification in the strace output.

9 years agotests: add a test for "resuming interrupted nanosleep"
Dmitry V. Levin [Tue, 7 Apr 2015 21:18:23 +0000 (21:18 +0000)]
tests: add a test for "resuming interrupted nanosleep"

* tests/restart_syscall.test: New test.
* tests/restart_syscall.expected: New file.
* tests/restart_syscall_unknown.expected: Likewise.
* tests/Makefile.am (TESTS): Add restart_syscall.test.
(EXTRA_DIST): Add restart_syscall.expected
(TEST_LOG_COMPILER): Change to "env".
(OS, ARCH, AM_TEST_LOG_FLAGS): Define.
and restart_syscall_unknown.expected.

9 years agotests: strip executable bit from *.expected files
Dmitry V. Levin [Tue, 7 Apr 2015 21:11:50 +0000 (21:11 +0000)]
tests: strip executable bit from *.expected files

9 years agoDeclare syscall parsers using SYS_FUNC macro
Dmitry V. Levin [Tue, 7 Apr 2015 01:36:50 +0000 (01:36 +0000)]
Declare syscall parsers using SYS_FUNC macro

Introduce SYS_FUNC macro to declare and define all syscall parsers.

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sys_func.h.
(sys_func.h): New rule.
* defs.h (SYS_FUNC_NAME, SYS_FUNC): New macros.
* linux/syscall.h: Include "sys_func.h".
[NEED_UID16_PARSERS]: Use SYS_FUNC to declare uid16 syscall parsers.
Remove other declarations.
* linux/alpha/syscallent.h (160, 161): Add sys_ prefix to osf_statfs
and osf_fstatfs syscall parsers.
* *.c: Use SYS_FUNC to define syscall parsers.

9 years agoFix confusing "resuming interrupted unknown" message
Denys Vlasenko [Tue, 7 Apr 2015 10:46:59 +0000 (12:46 +0200)]
Fix confusing "resuming interrupted unknown" message

Dmitry reported seeing the following:

    $ sleep 2 & sleep 1; ./strace -erestart_syscall -p $!
    [1] 12345
    Process 12345 attached
    restart_syscall(<... resuming interrupted unknown ...>) = 0

Fixing it by replacing "unknown" with "system call".

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotests: workaround old gawk versions that do not provide @include support
Dmitry V. Levin [Mon, 6 Apr 2015 23:40:13 +0000 (23:40 +0000)]
tests: workaround old gawk versions that do not provide @include support

Some of our tests use GNU awk @include extension, but not all currently
used versions of GNU awk support it.  Skip these tests if gawk does not
provide @include support.

* tests/init.sh (check_gawk): New function.
(match_awk): Use it.

9 years agotests: rewrite umovestr2.test without using grep
Dmitry V. Levin [Mon, 6 Apr 2015 22:17:28 +0000 (22:17 +0000)]
tests: rewrite umovestr2.test without using grep

The regular expression generated by umovestr2.c on systems with large
page size is too big for GNU grep.  Rewrite the test to use diff
instead of grep.

* tests/umovestr2.test: Use match_diff instead of match_grep.
* tests/umovestr2.c (main): Convert output from regexp to plain text.

9 years agoCleanup process_vm_writev syscall decoding
Dmitry V. Levin [Tue, 31 Mar 2015 21:00:39 +0000 (21:00 +0000)]
Cleanup process_vm_writev syscall decoding

* process_vm.c (sys_process_vm_writev): Do not check for syserror,
it is not applicable on entering syscall.

9 years agoumovestr: read chunks of memory up to pagesize at a time
Dmitry V. Levin [Tue, 31 Mar 2015 19:45:08 +0000 (19:45 +0000)]
umovestr: read chunks of memory up to pagesize at a time

* defs.h (get_pagesize): New prototype.
* mem.c (get_pagesize) Make global.
* util.c (PAGMASK): Remove.
(vm_read_mem): New process_vm_readv proxy function.
(umoven, umovestr): Use it.
(umovestr): Read chunks up to pagesize at a time.

9 years agoumovestr: fix short read bug
Dmitry V. Levin [Tue, 31 Mar 2015 18:52:57 +0000 (18:52 +0000)]
umovestr: fix short read bug

* util.c (umovestr): Check the right address.
* tests/umovestr.c: New file.
* tests/umovestr2.c: Likewise.
* tests/umovestr.expected: Likewise.
* tests/umovestr.test: New test.
* tests/umovestr2.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add umovestr and umovestr2.
(TESTS): Add umovestr.test and umovestr2.test.
(EXTRA_DIST): Add umovestr.expected.
* tests/.gitignore: Add umovestr and umovestr2.

Reported-by: Josef T. Burger <bolo@cs.wisc.edu>
9 years agoWhen process_vm_readv fails with EPERM, try PTRACE_PEEKDATA
Dmitry V. Levin [Mon, 30 Mar 2015 15:21:55 +0000 (15:21 +0000)]
When process_vm_readv fails with EPERM, try PTRACE_PEEKDATA

process_vm_readv() and ptrace(PTRACE_PEEKDATA) have inconsistent access
control rules wrt traced processes: process_vm_readv() is more likely to
fail with EPERM than ptrace(PTRACE_PEEKDATA) when tracing a process that
has execve'd a privileged executable.

* util.c (umoven, umovestr): If process_vm_readv returned EPERM,
fall back to ptrace(PTRACE_PEEKDATA).

Reported-by: Andrew Guertin <lists@dolphinling.net>
9 years agoUse macros for gcc attributes
Dmitry V. Levin [Sun, 29 Mar 2015 22:45:03 +0000 (22:45 +0000)]
Use macros for gcc attributes

* defs.h (error_msg, perror_msg, error_msg_and_die, perror_msg_and_die,
die_out_of_memory, printllval, printnum_int, printnum_long, tprintf):
Use ATTRIBUTE_* macros for gcc attributes.
* file.c (struct stat64): Likewise.
* statfs.c (struct compat_statfs64): Likewise.
* strace.c (die, exec_or_die, init): Likewise.
* linux/sparc/arch_sigreturn.c: Likewise.
* linux/ubi-user.h: Likewise.

9 years agoIntroduce macros for gcc attributes
Dmitry V. Levin [Sun, 29 Mar 2015 22:42:55 +0000 (22:42 +0000)]
Introduce macros for gcc attributes

Define macros for gcc attributes that are already in use
or going to be used soon.

* defs.h (GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT,
ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC,
ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): New macros.

9 years agoInclude <linux/ioctl.h> for _IOC_* macros
Felix Janda [Sat, 28 Mar 2015 17:40:13 +0000 (18:40 +0100)]
Include <linux/ioctl.h> for _IOC_* macros

Fix a compilation failure with musl libc.

* evdev.c: Include <linux/ioctl.h>.
* ioctl.c: Include <linux/ioctl.h> instead of <asm/ioctl.h>.
* ioctlsort.c: Likewise.

Reported-by: Dima Krasner <dima@dimakrasner.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
9 years agoInclude <sys/stat.h> for S_I* macros
Felix Janda [Sat, 28 Mar 2015 17:21:09 +0000 (18:21 +0100)]
Include <sys/stat.h> for S_I* macros

Fix a compilation failure with musl libc.

* mknod.c: Include <sys/stat.h>.
* printmode.c: Likewise.

Reported-by: Dima Krasner <dima@dimakrasner.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
9 years agosignal.c: move siginfo_t parsers to a separate file
Dmitry V. Levin [Fri, 27 Mar 2015 23:28:15 +0000 (23:28 +0000)]
signal.c: move siginfo_t parsers to a separate file

* printsiginfo.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (printsiginfo): Change second argument's type from int to bool.
* signal.c: Stop defining siginfo_t related constants.
Move inclusion of xlat/sig*_codes.h files to printsiginfo.c
(printsigsource, printsigval, printsiginfo_at): Move to printsiginfo.c.
(printsiginfo): Change second argument's type from int to bool,
split, and move to printsiginfo.c.

9 years agoUpdate siginfo_t constants
Dmitry V. Levin [Fri, 27 Mar 2015 22:51:51 +0000 (22:51 +0000)]
Update siginfo_t constants

* xlat/sigbus_codes.in: Add BUS_MCEERR_AR and BUS_MCEERR_AO,
add default values.
* xlat/sigtrap_codes.in: Add TRAP_BRANCH and TRAP_HWBKPT,
add default values.
* xlat/sigsegv_codes.in: Add SEGV_BNDERR, add default values.
* xlat/sigchld_codes.in: Add default values.
* xlat/sigemt_codes.in: Likewise.
* xlat/sigfpe_codes.in: Likewise.
* xlat/sigill_codes.in: Likewise.
* xlat/siginfo_codes.in: Likewise.
* xlat/sigpoll_codes.in: Likewise.
* xlat/sigsys_codes.in: Likewise.