Compare commits

..

248 Commits

Author SHA1 Message Date
b083940210 kvm: avoid bogus vcpu_info assignment in vcpu_register
Also reformat code a bit to make nesting a bit clearer.

Reported by Clang.

* kvm.c (vcpu_register): Do not assign vcpu_alloc result to vcpu_info
as this value is not used afterwards in the function.
2018-12-18 05:37:30 +01:00
9319e0a49c rtnl_addr: decode IFA_RT_PRIORITY netlink attribute
* rtnl_addr.c (ifaddrmsg_nla_decoders): Decode IFA_RT_PRIORITY as u32.
2018-12-14 19:55:40 +01:00
eaea61a93b fixup! xlat/rtnl_addr_attrs: add IFA_TARGET_NETNSID 2018-12-14 19:53:25 +01:00
e2b7a15518 xlat: add PR_SPEC_INDIRECT_BRANCH to pr_spec_cmds
* xlat/pr_spec_cmds.in (PR_SPEC_INDIRECT_BRANCH): New constant,
introduced by Linux commit v4.20-rc5~4^2~3.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_SPECULATION_CTRL, case
PR_SET_SPECULATION_CTRL>: Add PR_SPEC_INDIRECT_BRANCH handling.
* tests/prctl-spec-inject.c: Add PR_SPEC_INDIRECT_BRANCH decoding
checks, update expected output.
2018-12-14 17:35:44 +01:00
4e854fee20 xlat: update audit_arch
* xlat/audit_arch.in: Add fallback values.
(AUDIT_ARCH_H8300, AUDIT_ARCH_TILEGX, AUDIT_ARCH_TILEGX32,
AUDIT_ARCH_TILEPRO, AUDIT_ARCH_V850): New constants.
2018-11-25 16:51:14 +01:00
ca28f1d4e7 v4l2: improve buffer flag decoding
* xlat/v4l2_buf_flags.in: Add fallback values.
* xlat/v4l2_buf_flags_masks.in: New file.
* xlat/v4l2_buf_flags_ts_src.in: Likewise.
* xlat/v4l2_buf_flags_ts_type.in: Likewise.
* v4l2.c: Include xlat/v4l2_buf_flags_ts_type.h,
xlat/v4l2_buf_flags_ts_src.h, xlat/v4l2_buf_flags_masks.h.
(print_v4l2_buffer_flags): New function.
(print_v4l2_buffer): Call print_v4l2_buffer_flags for printing flags field.
2018-11-25 16:14:11 +01:00
aa720f7306 fixup! Print ISO 8601 time for wall clock time values 2018-11-25 16:12:11 +01:00
f49fc80253 v4l: add constants introduced by Linux v4.20-rc1~51^2~4
* xlat/v4l2_control_ids.in (,V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION): New constants, introduced by
Linux commit v4.20-rc1~51^2~4.
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_MPEG2_SLICE): Likewise.
2018-11-25 15:53:17 +01:00
f5b54b38ee fixup! Add support for alternative error/signal names 2018-11-25 15:43:13 +01:00
997ce1ad8e xlat: tidy whitespace in fan_mark_flags
* xlat/fan_mark_flags.in: Align fallback values with additional
whitespace.
2018-11-25 14:29:05 +01:00
420b631687 printsiginfo: decode IA-64-specific siginfo_t fields
* xlat/ia64_siginfo_si_flags.in: New file.
* printsiginfo.c [IA64]: Include xlat/ia64_siginfo_si_flags.h.
[IA64] (print_si_info): Decode si_imm, si_flags, and si_isr fields
for fault signals.
2018-11-25 14:11:54 +01:00
a6ace08dbc printsiginfo: decode si_trapno
* xlat/alpha_gentrap.in: New file.
* configure.ac (AC_CHECK_MEMBERS): Add check for siginfo_t.si_trapno.
* printsiginfo.c [ALPHA]: Include <asm/gentrap.h>, "xlat/alpha_gentrap.h".
(print_si_info): Add SIGTRAP to the SIGILL/SIGFPE/SIGSEGV/SIGBUS/SIGEMT
case.
[HAVE_SIGINFO_T_SI_TRAPNO] (print_si_info) <case SIGTRAP>: Decode
si_trapno field.
2018-11-25 13:38:31 +01:00
e44ae68ae4 printsiginfo: decode SIGEMT the same way as SIG{ILL,FPE,SEGV,BUS}
* printsiginfo.c (print_si_info) [SIGEMT] <case SIGEMT>: Add
to the SIGILL/SIGFPE/SIGSEGV/SIGBUS case.
2018-11-25 13:25:47 +01:00
5338aecfa9 printsiginfo: use print_err for error number printing
* printsiginfo.c (print_si_info): use print_err instead of open-coding
error constant printing.
2018-11-25 12:51:23 +01:00
05de794953 fixup! printsiginfo: decode FASYNC (O_ASYNC) signals 2018-11-25 11:05:56 +01:00
9c26fb26e3 fixup! strace: use sprintsignal for converting signal number to string 2018-11-25 11:04:47 +01:00
ce76cd330d printsiginfo: decode FASYNC (O_ASYNC) signals
* printsiginfo.c (print_fasync_info): New function.
(print_si_info): Add tcp argument.
(print_si_info) <case SI_SIGIO, case SIGPOLL>: Call print_fasync_info.
(printsiginfo): Add tcp argument, pass it to the print_si_info call.
(printsiginfo_at, print_siginfo_t): Pass tcp argument to printsiginfo
calls.
* printsiginfo.h (printsiginfo): Update declaration.
2018-11-25 11:02:13 +01:00
b53717e034 printsiginfo: factor out syscall constant name printing
* printsiginfo.c (print_scconst); New function.
(print_si_info) <case SIGSYS>: Call print_scconst for si_syscall
printing.
2018-11-25 10:48:33 +01:00
7bfd2375ff printsiginfo: dispatch signal code names using an array
* printsiginfo.c (print_si_code): Consolidate xlat pointers into an
array, dispatch over it using si_code.
2018-11-25 10:40:47 +01:00
57098d88c2 xlat: add audit_arch_flags
For now, it's just a source for audit_flags fallback values.

* xlat/audit_arch_flags.in: New file.
* printsiginfo.c: Include xlat/audit_arch_flags.h.
2018-11-22 18:05:54 +01:00
ce9d5044c8 xlat: add elf_em.in
For now, it's a source of fallback values for AUDIT_ARCH_* constants.

* xlat/elf_em.in: New file.
* printsiginfo.c: Include "xlat/elf_em.h"
2018-11-22 10:45:02 +01:00
7657246b59 xlat/sock_ipv6_options: add IPV6_MULTICAST_ALL
* xlat/sock_ipv6_options.in (IPV6_MULTICAST_ALL): New constant,
introduced by Linux commit v4.19-rc3-454-g15033f0457dc.
2018-11-21 14:38:14 +01:00
76eea4699e xlat/v4l2_control_types: add V4L2_CTRL_TYPE_MPEG2_*
* xlat/v4l2_control_types.in (V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS,
V4L2_CTRL_TYPE_MPEG2_QUANTIZATION): New constants, introduced by Linux
commit v4.19-rc1-74-gc27bb30e7b6d.
2018-11-21 14:38:14 +01:00
a1d541c26a xlat/v4l2_control_types: add fallback values, #sorted
* xlat/v4l2_control_types.in: Add fallback values and "#sorted".
2018-11-21 14:38:13 +01:00
4ef7513055 xlat/v4l2_pix_fmts: add V4L2_PIX_FMT_SUNXI_TILED_NV12
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_SUNXI_TILED_NV12): New constant,
introduced by Linux commit v4.19-rc1-75-g36cf35b78640.
2018-11-21 14:38:13 +01:00
91ab71f387 xlat/evdev_abs: add ABS_RESERVED
* xlat/evdev_abs.in (ABS_RESERVED): New constant, introduced by Linux
commit v4.18-10855-gd9ca1c990a7f.
2018-11-21 14:38:13 +01:00
9e9071d615 xlat/evdev_relative_axes: add REL_RESERVED and REL_WHEEL_HI_RES
* xlat/evdev_relative_axes.in (REL_RESERVED): New constant, introduced
by Linux commit v4.18-10855-gd9ca1c990a7f.
(REL_WHEEL_HI_RES): New constant, introduced by Linux commit
v4.18-10849-gaaf9978c3c02 and updated by Linux commit
v4.18-10855-gd9ca1c990a7f.
2018-11-21 14:38:13 +01:00
d6d103b4fa xlat/fan_init_flags: add FAN_REPORT_TID
* xlat/fan_init_flags.in (FAN_REPORT_TID): New constant, introduced
by Linux commit v4.19-rc2-16-gd0a6a87e40da.
2018-11-21 14:38:13 +01:00
776043f4cc xlat/fan_init_flags: whitespace
* xlat/fan_init_flags.in: Replace spaces with tabs.
2018-11-21 14:38:13 +01:00
e7b9424cac xlat: update kvm_cap
* xlat/kvm_cap.in (KVM_CAP_PPC_NESTED_HV): New constant, introduced
by Linux commit v4.19-rc4-286-gaa069a996951.
(KVM_CAP_HYPERV_SEND_IPI): New constant, introduced by Linux commit
v4.19-rc4-328-g214ff83d4473.
KVM_CAP_COALESCED_PIO): New constant, introduced by Linux commit
v4.19-rc4-369-g0804c849f1df.
(KVM_CAP_HYPERV_ENLIGHTENED_VMCS): New constant, introduced by Linux
commit v4.19-rc4-375-g57b119da3594.
(KVM_CAP_EXCEPTION_PAYLOAD): New constant, introduced by Linux commit
v4.19-rc4-392-gc4f55198c7c2.
(KVM_CAP_ARM_VM_IPA_SIZE): New constant, introduced by Linux commit
v4.19-rc5-18-g233a7cb23531 and updated by Linux commit
v4.19-rc5-215-ge42b4a507efa.
2018-11-21 14:38:13 +01:00
d20c0c7804 xlat/sock_packet_options: add PACKET_IGNORE_OUTGOING
* xlat/sock_packet_options.in (PACKET_IGNORE_OUTGOING): New constant,
introduced by Linux commit v4.19-rc2-323-gfa788d986a3a.
2018-11-21 14:38:13 +01:00
b84f967d27 xlat/rtnl_addr_attrs: add IFA_TARGET_NETNSID
* xlat/rtnl_addr_attrs.in (IFA_TARGET_NETNSID): New constant, introduced
by Linux commit v4.19-rc2-337-g9f3c057c146f.
2018-11-21 14:38:13 +01:00
ad40a98f06 xlat: update neighbor_cache_entry_flags
* xlat/neighbor_cache_entry_flags.in (NTF_OFFLOADED): New constant,
introduced by Linux commit v4.13-rc1~157^2~252^2~13.
(NTF_STICKY): New constant, introduced by Linux commit
v4.19-rc2-432-g435f2e7cc0b7.
(NTF_USE, NTF_SELF, NTF_MASTER, NTF_PROXY, NTF_EXT_LEARNED, NTF_ROUTER):
Add fallback value.
2018-11-21 14:38:13 +01:00
8a268ad962 xlat: add flow dissector bpf program type constants
Introduced by Linux commit v4.19-rc2-341-gd58e468b1112.

* xlat/bpf_attach_type.in (BPF_FLOW_DISSECTOR): New constant.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_FLOW_DISSECTOR): Likewise.
2018-11-21 14:38:13 +01:00
161121a3d2 rtnl_tc: add TCA_STATS_BASIC_HW
* xlat/rtnl_tca_stats_attrs.in (TCA_STATS_BASIC_HW): New constant,
introduced by v4.19-rc4-670-g5e111210a443.
* rtnl_tc.c (tca_stats_nla_decoders): Add TCA_STATS_BASIC_HW.
2018-11-21 14:38:13 +01:00
6141608483 xlat/sock_netlink_options: add NETLINK_DUMP_STRICT_CHK
* xlat/sock_netlink_options.in (NETLINK_DUMP_STRICT_CHK): New constant,
introduced by Linux commit v4.19-rc6-1866-g89d35528d17d.
2018-11-21 14:38:13 +01:00
74d0cad5dd xlat/rtnl_ifla_info_data_bridge_attrs: add IFLA_BR_VLAN_STATS_PER_PORT
* xlat/rtnl_ifla_info_data_bridge_attrs.in
(IFLA_BR_VLAN_STATS_PER_PORT): New constant, introduced by Linux commit
v4.19-rc6-2094-g9163a0fc1f0c.
* rtnl_link.c (ifla_info_data_bridge_nla_decoders): Add
IFLA_BR_VLAN_STATS_PER_PORT.
2018-11-21 14:38:13 +01:00
504b43651c xlat/fsmagic: rename XFS_SB_MAGIC to XFS_SUPER_MAGIC
Per Linux commit v4.19-rc1-28-gdddde68b8f06.

* xlat/fsmagic.in (XFS_SUPER_MAGIC): Rename from XFS_SB_MAGIC.
2018-11-21 14:38:13 +01:00
b45562e897 xlat: convert fsmagic to a regular form
As xlat/gen.sh supports fallback definitions and sorted xlats now,
there's no need for raw definitions in fsmagic xlat.

* xlat/fsmagic.in: convert to a regular form.
2018-11-21 14:38:13 +01:00
e6e005f70c Decode UID/GID in -y mode
* defs.h (RVAL_UID, RVAL_GID): New macro constants.
(printgid): New function declaration.
* ipc_msgctl.c (print_msqid_ds, print_msqid_ds): Use printgid for
printing GID.
* ipc_shmctl.c (print_shmid_ds, print_shmid_ds): Likewise.
* keyctl.c (keyctl_chown_key): Likewise.
* nlattr.c (decode_nla_gid): Likewise.
* linux/dummy.h (sys_getgid, sys_getgid16, sys_getresgid,
sys_getresgid16, sys_setfsgid, sys_setfsgid16, sys_setgid, sys_setgid16,
sys_setregid, sys_setregid16, sys_setresgid, sys_setresgid16): Remove
macros.
(sys_getegid): Define to sys_getgid instead of sys_getuid.
(sys_getegid16): Define to sys_getgid16 instead of sys_geteuid16.
* linux/syscall.h (getresgid16, getgid16, setfsgid16, setresgid16,
setregid16, setgid16): New external SYS_FUNC declarations.
* msghdr.c (print_scm_creds); Use PRINT_FIELD_GID for printing GID.
* net.c (print_get_ucred): Likewise.
* netlink_inet_diag.c (decode_inet_diag_msg): Likewise.
* netlink_smc_diag.c (decode_smc_diag_msg): Likewise.
* print_fields.h (PRINT_FIELD_UID); Use printuid for printing UID.
(PRINT_FIELD_GID): New macro.
* print_struct_stat.c (print_struct_stat): Use printuid for printing
UID, printgid for printing GID.
* printsiginfo.c (printsigsource): Use printuid for printing UID.
* resource.c (print_priority_who): New function.
(SYS_FUNC(getpriority), SYS_FUNC(setpriority)): Use print_priority_who
for printing the second argument.
* statx.c (SYS_FUNC(statx)): Use PRINT_FIELD_UID for printing UID,
PRINT_FIELD_GID for printing GID.
* syscall.c (syscall_exiting_trace): Handle RVAL_UID and RVAL_GID.
* tests/overflowuid.c: Include stdio.h.
(printuid): New function.
* tests/setfsugid.c (printugid): Rename from printuid, update call
sites.
* tests/setgroups.c: Likewise.
* tests/setugid.c: Likewise.
* tests/tests.h (printuid): New declaration.
* uid.c (printgid, sys_getresgid, sys_getgid, sys_setfsgid,
sys_setresgid, sys_setregid, sys_setgid): Add SIZEIFY wrappers.
(gid_t, gid_t_, gid_t__): Define similarly to uid_t, uid_t_, uid_t__.
Include grp.h, pwd.h, sys/types.h.
(enum id_type): New enumeration.
(SYS_FUNC(getuid), SYS_FUNC(setfsuid), ): Return RVAL_UID flag.
(SYS_FUNC(getgid), SYS_FUNC(setfsgid), SYS_FUNC(setgid),
SYS_FUNC(getresgid), SYS_FUNC(setregid), SYS_FUNC(setresgid)): New
functions.
(get_print_id): Rename from get_print_uid, add idt argument, call
printuid or printgid depending on it. Update call sites.
(SYS_FUNC(chown), SYS_FUNC(fchown), print_gid): Use printgid
for printing GID.
(ID_CACHE_SIZE): New macro constant.
(print_id): New function.
(printuid): Implement using print_id.
(printgid): New function.
* xlat/priorities.in: Provide fallback values.
2018-11-21 14:38:13 +01:00
ce366255c5 loop: use XLAT_MACROS_ONLY instead of #stop
As the former allows controlling presence of xlat definitions
during the inclusion and not header generation.

* xlat/loop_cmds.in: remove #stop.
* loop.c: Wrap "xlat/loop_cmds.h" inclusion in XLAT_MACROS_ONLY.
* tests/ioctl_loop.c: Likewise.
2018-11-21 14:38:13 +01:00
826306c987 linux/mips/get_syscall_args.c: print an error message on fetch error
Instead of failing silently.

* linux/mips/get_syscall_args.c (get_syscall_args): Print an error message
when umoven fails.
2018-11-21 14:38:13 +01:00
2f46f33384 linux/hppa/syscallent.h: add a comment about old name of syscall 102
Also, remove empty definition.

* linux/hppa/syscallent.h ([102]): Remove (empty) definition, add
a comment that it was socketcall.
2018-11-21 14:38:13 +01:00
1d46db4207 linux/mips/syscallent-o32.h: entry 4221 is actually called "reserved221" 2018-11-21 14:38:13 +01:00
12f618552a fixup! ptp: update decoder 2018-11-21 14:38:13 +01:00
606a8f39e8 fcntl: decode F_GETOWNER_UIDS
* fcntl.c (print_owner_uids): New function.
(print_fcntl) <case F_GETOWNER_UIDS>: Decode command using
print_owner_uids.
2018-11-21 14:38:13 +01:00
7908a872ba netlink_inet_diag: implement INET_DIAG_MD5SIG attribute decoding
* linux/inet_diag.h (INET_DIAG_MD5SIG): New enum entity.
(TCP_MD5SIG_MAXKEYLEN): New macro.
(struct tcp_diag_md5sig): New type definition.
* netlink_inet_diag.c (decode_tcp_md5sig): New function.
(inet_diag_msg_nla_decoders) <[INET_DIAG_MD5SIG]>: New attribute,
decoded by decode_tcp_md5sig.
* xlat/inet_diag_attrs.in (INET_DIAG_MD5SIG): New constant.
* xlat/inet_diag_extended_flags.in (1<<(INET_DIAG_MD5SIG-1)): New flag.
2018-11-21 14:38:13 +01:00
d1f4b528cb fcntl: decode read/write hints commands
Introduced by Linux commit v4.13-rc1~212^2~51.

* xlat/fcntl_rw_hints.in: New file.
* fcntl.c: Include "xlat/fcntl_rw_hints.h".
(print_rwhint): New function.
(print_fcntl) <case F_SET_RW_HINT, case F_SET_FILE_RW_HINT, case
F_GET_RW_HINT, case F_GET_FILE_RW_HINT>: New fcntl command handlers.
* xlat/fcntlcmds.in (F_GET_RW_HINT, F_SET_RW_HINT, F_GET_FILE_RW_HINT,
F_SET_FILE_RW_HINT): New constants.
2018-11-21 14:38:13 +01:00
48a84accf6 fixup! Check PTP API fields 2018-11-21 14:38:13 +01:00
4a602e8962 ptp: update decoder
* xlat/ptp_ioctl_cmds.in: New file.
* xlat/ptp_pin_funcs.in: Likewise.
* xlat/ptp_flags_options.in: Add fallback values.
* ptp.c [HAVE_STRUCT_PTP_SYS_OFFSET]: Remove #ifdef.
Include "ptp_clock.h" instead of <linux/ptp_clock.h>.
Include "xlat/ptp_ioctl_cmds.h" undef XLAT_MACROS_ONLY.
Include "xlat/ptp_pin_funcs.h".
(print_ptp_clock_time): New function.
(PRINT_FIELD_PTP_CLOCK_TIME, PRINT_FIELD_RSV): New macros.
(ptp_ioctl) <case PTP_EXTTS_REQUEST>: Use struct
strace_ptp_extts_request instead of struct ptp_extts_request; print
index field as unsined, print rsv field using PRINT_FIELD_RSV.
(ptp_ioctl) <case PTP_PEROUT_REQUEST>: Use struct
strace_ptp_perout_request instead of struct ptp_perout_request; print
start and period fields using PRINT_FIELD_PTP_CLOCK_TIME; print rsv
field using PRINT_FIELD_RSV.
(ptp_ioctl) <case PTP_ENABLE_PPS>: Print arg as unsigned.
(ptp_ioctl) <case PTP_SYS_OFFSET>: Use struct strace_ptp_sys_offset
instead of struct ptp_sys_offset; print rsv field using PRINT_FIELD_RSV;
print time stamps using print_ptp_clock_time.
(ptp_ioctl) <case PTP_CLOCK_GETCAPS>: Use struct strace_ptp_clock_caps
instead of struct ptp_clock_caps; print n_pins, cross_timestamping, and
rsv fields.
(ptp_ioctl) <case PTP_SYS_OFFSET_PRECISE, case PTP_PIN_GETFUNC, case
PTP_PIN_SETFUNC>: Handle new commands.
2018-11-21 14:38:13 +01:00
8ff46440ff configure.ac: do not hard-code list of arches that have m32/mx32
As of now, it can be derived from SUPPORTED_PERSONALITIES, and this
information is provided in arch_defs.

* configure.ac: Use AC_COMPILE_IFELSE in order to call st_MPERS based
on SUPPORTED_PERSONALITIES value set for a n architecture.
2018-11-21 14:38:12 +01:00
d998972eb5 Check PTP API fields
Similarly to bpf_attr fields checks.

* ptp_clock.h: New file.
* Makefile.am (strace_SOURCES): Add it.
(strace_SOURCES_check, BUILT_SOURCES, CLEANFILES): Add ptp_clock_check.c.
(EXTRA_DIST): Add gen_ptp_clock_check.sh.
(ptp_clock_check.c): New rule.
* configure.ac (AC_CHECK_HEADERS([linux/ptp_clock.h])): Call
st_PTP_CLOCK.
* gen_ptp_clock_check.sh: New file.
* m4/gen_ptp_clock_m4.awk: Likewise.
* m4/gen_ptp_clock_m4.sh: Likewise.
2018-11-21 14:38:12 +01:00
2d2edb4654 xlat: add fallback values for notifyflags
* xlat/notifyflags.in: Add fallback values.
2018-11-21 14:38:12 +01:00
3cfdc5da72 xlat: provide fallback values to getsock_ip*_options
* xlat/getsock_ip_options.in: Provide fallback values.
* xlat/getsock_ipv6_options.in: Likewise.

Closes: https://github.com/strace/strace/issues/87
2018-11-21 14:38:03 +01:00
8cfc98ca99 sync_file_range2: remove unneeded argn assignment
clang complains about it:

         argn = printllval(tcp, "%lld", argn);
         ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sync_file_range2.c:43:2: note: Value stored to 'argn' is never read

* sync_file_range2.c (SYS_FUNC(sync_file_range2)): Do not assign
printllval result to argn second time.
2018-10-20 06:42:20 +02:00
e963559c13 linux/smc_diag.h: update struct smc_diag_req definition
In accordance with Linux commit v4.19-rc8~22^2~17^2.

* linux/smc_diag.h (struct smc_diag_req): Use a union for
diag_fallback/diag_mode.
2018-10-20 06:35:44 +02:00
cae7ddf0a3 fixup! futex: print uaddr value 2018-10-20 06:31:41 +02:00
3c068f860e net: decode SOL_CAN_RAW socket options
* xlat/sock_can_raw_options.in: New file.
* net.c: Include "xlat/sock_can_raw_options.h".
(print_sockopt_fd_level_name) <case SOL_CAN_RAW>: Print socket option
name using sock_can_raw_options xlat.
2018-10-20 06:25:22 +02:00
53bc64c795 xlat/clockflags: provide fallback values
* xlat/clockflags.in: Provide fallback values.
2018-10-20 06:20:07 +02:00
079776b9bd xlat/fdflags: provide fallback values
* xlat/fdflags.in: Provide fallback values.
2018-10-20 06:19:42 +02:00
36837ede63 xlat/loop_crypt_type_options: provide fallback values
* xlat/loop_crypt_type_options.in: Provide fallback values, add #sorted.
2018-10-20 06:18:56 +02:00
369afb0506 xlat: sort kexec_arch_values
* xlat/kexec_arch_values.in: Sort, add #sorted.
2018-10-20 06:17:14 +02:00
90337bbfe8 xlat/netlink_states: decode TCP_CLOSE
* xlat/netlink_states.in: Decode state 7 as TCP_CLOSE, since that's what
net core sets socket's initial state to.
2018-10-20 06:16:05 +02:00
dd0b8073d6 xlat: provide fallback values to lockfcmds
* xlat/lockfcmds.in: Provide fallback values.
2018-10-20 06:15:19 +02:00
616d4ed93c sock: switch to table handler dispatching 2018-10-20 06:14:49 +02:00
6b583ed1b3 fixup! sock: provide socket ioctl command ID definitions 2018-10-20 06:14:07 +02:00
d8e5ff352a fixup! sock: move specific ioctl decoding code into functions 2018-10-20 04:18:12 +02:00
231658be6b sock: provide socket ioctl command ID definitions
* xlat/sock_ioctls.in: New file.
* sock.c: Include "xlat/sock_ioctls.h". Remove #ifdef conditions for
ioctl commands.
2018-10-20 04:13:20 +02:00
016178ec9b sock: move specific ioctl decoding code into functions
* sock.c (decode_set_ifreq, decode_get_ifreq, decode_route_ioc): New
functions.
(decode_ifconf): Add "fd" and "code" arguments.
(sock_ioctl): Remove "ifr" local variable, call handlers instead of
open-coding ioctl handling.
2018-10-20 04:11:03 +02:00
66aea8089d sock.c: add missing comma 2018-10-20 03:39:15 +02:00
ed3e7e751d socketutils: pass 0 to dyxlat_alloc
As it is backed by xgrowarray that has a heuristic for the case
*nmemb == 0, we don't have to pass a hard-coded initial size anymore.

* socketutils.c (genl_get_family_name): Pass 0 to dyxlat_alloc.
2018-10-20 01:55:37 +02:00
da97767c05 Add macros for glibc version checks
Add GLIBC_PREREQ and GLIBC_OLDER macros that enable easy checks aginst
glibc vershions known to expose various quirks.

* glibc_compat.h: New file.
* tests/ipc_msg.c: Use GLIBC_OLDER for glibc version checking.
* tests/readahead.c: Likewise.
2018-10-20 01:21:37 +02:00
a8778adef2 xlat: provide fallback definitions to dirent_types
* xlat/dirent_types.in: Provide fallback definitions.
2018-10-15 17:59:36 +02:00
e3068c9791 xlat: provide fallback definitions to ptrace_events
* xlat/ptrace_events.in: Provide fallback definitions, define
PTRACE_EVENT_MIGRATE only on tile.
2018-10-15 17:58:18 +02:00
400c83337d xlat: sort and add fallback definitions to setsock_ip_options
* xlat/setsock_ip_options.in: Add fallback definitions, sort, add
"#sorted".
2018-10-15 17:57:32 +02:00
ab353ade4e xlat: add fallback definitions to setsock_ipv6_options
* xlat/setsock_ipv6_options.in: Add fallback definitions.
2018-10-15 17:56:42 +02:00
8d3ee7033f linux/dummy.h: remove unused sys_phys definition
* linux/dummy.h (sys_phys): Remove.
2018-10-15 17:55:56 +02:00
5bccbbe42b xlat: update sigact_flags
* xlat/sigact_flags.in: Add fallback definitions.
2018-10-15 17:53:22 +02:00
6888b56c80 xlat: update siginfo_codes
* xlat/siginfo_codes.in (SI_LWP): Remove, as it is not presen on Linux.
(SI_NOINFO): Define only on SPARC, provide fallback value.
2018-10-15 17:47:01 +02:00
fd02c5ea81 xlat: add fallback values to sock_ip_options
* xlat/sock_ip_options.in: Add fallback values, remove IP_RECVOPTIONS,
IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RECVIFINDEX, IP_BROADCAST_IF that are
not present in Linux, remove IP_RECVORIGDSTADDR as it is synonymous to
IP_ORIGDSTADDR, add "#value_indexed".
2018-10-15 17:43:54 +02:00
cd733e0454 xlat: add fallback values to sock_ipv6_options
* xlat/sock_ipv6_options.in: Add fallback values, remove
IPV6_RECVORIGDSTADDR as it is a synonym to IPV6_ORIGDSTADDR, add
"#value_indexed".
2018-10-15 17:36:07 +02:00
21cc88963f xlat: add SOL_CAN_* to socketlayers
* xlat/socketlayers.in (SOL_CAN_BASE): New constant, introduced by Linux
commit v2.6.25-rc1~1162^2~1414.
(SOL_CAN_RAW): New constant, introduced by Linux commit
v2.6.25-rc1~1162^2~1413.
2018-10-15 17:32:01 +02:00
7138dcec9e xlat: add fallback values to sock_packet_options
* xlat/sock_packet_options.in: Add fallback values, mark xclat as value
indexed.
2018-10-15 17:31:18 +02:00
ff18af2bb4 fixup! strace: always define WCOREDUMP 2018-10-15 17:30:16 +02:00
a475336863 arm: wire up io_pgetevents
Linux commit v4.19-rc7~24^2~1.

* linux/arm/syscallent.h ([399]): Add io_pgetevents.
2018-10-11 03:51:31 +02:00
be048f54c5 printmode: update print_symbolic_mode_t decoder
* printmode.c (print_symbolic_mode_t): Rewrite.
* xlat/modetypes.in: Add fallback values.
* xlat/modeflags.in: New file.
2018-10-07 14:31:00 +02:00
2a905d1b00 xlat: add XLAT_STYLE_FMT_O for octal output
* xlat.h (enum xlat_style): Add XLAT_STYLE_FMT_O.
* xlat.c (sprint_xlat_val): Handle XLAT_STYLE_FMT_O, reorder switch
branches in accordance with enum constant order.
2018-10-07 14:13:20 +02:00
6a44f46c7c print_dev_t: add support for xlat styles
* print_dev_t.c (print_dev_t): Print in accordance with current xlat
style setting.
2018-10-07 12:28:27 +02:00
9baa6bcc88 Print ISO 8601 time for wall clock time values
Add an argument to print_time* routines that signalises, whether
the time value is wall clock time or not.

* aio.c (print_io_getevents): Add an argument to print_timespec call.
* defs.h (print_timeval32_t, print_timeval32, print_itimerval32): Add
"bool rtc" argument.
* desc.c (decode_select): Add bool argument to print_tv_ts callback
function argument.
* futex.c (SYS_FUNC(futex)) <case FUTEX_WAIT>: Call print_timespec with
rtc=false, as the timestamp is always relative.
<case FUTEX_LOCK_PI>: Call print_timespec with rtc=true, as the timeout
is always absolute.
<case FUTEX_WAIT_BITSET, case FUTEX_WAIT_REQUEUE_PI>: Call
print_timespec with rtc set to true when op has FUTEX_CLOCK_REALTIME
flag.
* ipc_sem.c (SYS_FUNC(semtimedop)): Call print_timespec with rtc=false,
as timeout is always relative.
* linux/dummy.h (sys_clock_getres, sys_stime): Remove.
* mmsghdr.c (SYS_FUNC(recvmmsg)): Call print_timespec with rtc=false, as
timeout is relative.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Call
print_timespec with rtc=true, as timeout is absolute.
* msghdr.c (print_scm_timestamp, print_scm_timestampns,
print_scm_timestamping): Call print_struct_timeval_data_size,
print_struct_timespec_data_size, print_struct_timespec_array_data_size
with rtc=true as timestamps presumed absolute.
* poll.c (SYS_FUNC(ppoll)): Call print_timespec with rtc=false, as
timeout is relative.
* print_time.c (print_time_t): New function.
(SYS_FUNC(time)): Use print_time_t for printing time.
(SYS_FUNC(stime)): New function.
* print_timespec.c (print_timespec_t, print_struct_timespec_data_size,
print_struct_timespec_array_data_size, print_timespec): Add rtc argument,
handle it.
(print_timespec_t_utime): Call print_timespec_t with rtc=false when
xlat_style is not abbreviated, call print_timespec_t with rtc=true
instead of manual time stamp printing.
(print_itimerspec): Call print_timespec_t with rtc=false.
* print_timeval.c (print_timeval_t, print_struct_timeval_data_size,
print_timeval, print_itimerval, print_timeval32_t, print_timeval32):
Add rtc argument, handle it.
(print_timeval_t_utime, print_timeval32_t_utime): Remove.
(print_struct_timeval): New function.
(print_timeval_utimes): Use print_struct_timeval instead of
print_timeval_t_utime.
* print_timex.c (print_timex): Add rtc argument, handle it.
* printrusage.c (printrusage): Call print_struct_timeval with rtc=false.
* sched.c (sched_rr_get_interval): Call print_timespec with rtc=false.
* signal.c (rt_sigtimedwait): Call print_timespec with rtc=false.
* time.c: Include "xlat/clocknames.h" under XLAT_MACROS_ONLY.
(gettimeofday, settimeofday): Call print_timeval with rtc=true.
(osf_gettimeofday, osf_settimeofday): Call print_timeval32 with rtc=true.
(nanosleep): Call print_timespec with rtc=false.
(getitimer, setitimer): Call print_itimerval with rtc=false.
(osf_getitimer, osf_setitimer): Call print_itimerval32 wirh rtc=false.
(do_adjtimex): Add rtc argument, handle it.
(is_rtcid): New function.
(clock_settime, clock_gettime): Call print_timespec with rtc=true if 0th
argument is a real-time clock (as indicated by is_rtcid).
(SYS_FUNC(clock_getres)): New syscall decoder.
(SYS_FUNC(clock_nanosleep)): Call print_timespec with rtc=true if clock
is realtime (as indicated by is_rtcid) and TIMER_ABSTIME is set in flags.
(SYS_FUNC(clock_adjtime)): Call do_adjtimex with rtc=true if clock is
realtime.
* tests/adjtimex.c: Update expected output.
* tests/clock_nanosleep.c: Likewise.
2018-10-07 06:00:36 +02:00
3a94852d43 Add support for alternative error/signal names
There are some error and signal constants that are defined as a synonyms
for other errors/sugnals. Let's support their qualification.

* filter_qualify.c (struct alt_name): New type definition.
(alt_signames, alt_errnames): New variables.
(sigstr_to_uint): Check alt_signames for possible alternative signal
name usage.
(find_errno_by_name): Check alt_errnames for possible alternative error
name usage.
* linux/alpha/alt_errnoent.h: New file.
* linux/alpha/alt_signalent.h: Likewise.
* linux/alt_errnoent.h: Likewise.
* linux/alt_signalent.h: Likewise.
* linux/hppa/alt_errnoent.h: Likewise.
* linux/mips/alt_errnoent.h: Likewise.
* linux/mips/alt_signalent.h: Likewise.
* linux/powerpc/alt_errnoent.h: Likewise.
* linux/powerpc64/alt_errnoent.h: Likewise.
* linux/sparc/alt_errnoent.h: Likewise.
* linux/sparc/alt_signalent.h: Likewise.
* linux/sparc64/alt_signalent.h: Likewise.
* tests/qual_signal.test: Add some checks for alternative signal names.
2018-10-07 05:34:36 +02:00
323c689701 ioprio: print "who" argument according to its type
So far there's only UID that has a specific routine.

* ioprio.c (print_ioprio_who): New function.
(SYS_FUNC(ioprio_get), SYS_FUNC(ioprio_set)): Use it.
2018-10-07 05:31:12 +02:00
638b5c99b6 signal: return NULL is signal number has no string representation
* signal.c (signame): Return NULL if signal name hasn't been found.
2018-10-07 05:25:33 +02:00
d9a5b26067 strace: use sprintsignal for converting signal number to string
As signame is being converted to xlookup-like function, a separate
routine is needed in order to get string representation of signal.

* strace.c (sprintsignal): New function.
(print_debug_info, print_signalled, print_stopped): Use sprintsignal
instead of signame.
2018-10-07 05:23:09 +02:00
f6964715e3 Do not parse SIG_0
Signal 0 is not a valid signal number, so there's no reason to treat it
like it is.

* filter_qualify.c: Start iteration from 1.
* signal.c: Likewise.
2018-10-07 05:20:25 +02:00
2fc6a3647a Use printsignal instead of signame
As the former respects xlat styles.

* clone.c (SYS_FUNC(clone)): Use printflags for printing termination
signal in printflags.
* fcntl.c (print_fcntl) <case F_SETSIG>: Use printsignal.
* prctl.c (SYS_FUNC(prctl)) <case PR_GET_PDEATHSIG,
case PR_SET_PDEATHSIG>: Likewise.
* print_sigevent.c (print_sigevent): Likewise.
* s390.c (s390_runtime_instr): Likewise.
* signal.c (SYS_FUNC(kill), SYS_FUNC(tgkill)): Likewise.
2018-10-07 05:12:42 +02:00
4ebabbed7c signal.c: make printisgnal honor xlat style
* signal.c (printsignal): Respect current xlat style.
2018-10-07 05:09:09 +02:00
b43aae36d9 basic_filters: add %net as a possible designation for network syscalls
* basic_filters (lookup_class) <syscall_class>: Add "%net" as a possible
alias for TRACE_NETWORK.
2018-10-07 05:05:44 +02:00
81c9974f11 strace: always define WCOREDUMP
wait.c does it already.

* strace.c: Remove <sys/wait.h> include, add "wait.h" include.
[!WCOREDUMP]: Remove.
* wait.c: Remove <sys/wait.h> include, add "wait.h" include.
[!WCOREFLAG] (WCOREFLAG), [!WCOREDUMP] (WCOREDUMP): Move to wait.h,
rework.
[!W_STOPCODE] (W_STOPCODE), [!W_EXITCODE] (W_EXITCODE),
[!W_CONTINUED] (W_CONTINUED): Move to wait.h.
2018-10-03 10:31:30 +02:00
0e58b178e5 filter_qualify.c: refactor sigstr_to_uint
* filter_qualify.c (signame_eq): New function.
(sigstr_to_uint): Use signame_eq for comparing signame.
2018-09-27 08:00:34 +02:00
bca1b70f6b Use nsig instead of arbitrary numbers
* filter_qualify.c (sigstr_to_uint): Use nsig.
* prctl.c (SYS_FUNC(prctl)) <case PR_SET_PDEATHSIG>: Use nsig.
2018-09-27 07:56:25 +02:00
6d024c6336 signal: provide nsig constant
* defs.h (nsig): New declaration.
* signal.c (nsig): New constant.
2018-09-27 07:48:43 +02:00
1525464331 Replace direct usage of err_name/errnoent with print_err
* keyctl.c (keyctl_reject_key): Use print_err for printing error
argument.
* netlink.c (decode_nlmsgerr): Use print_err for printing errno field.
* numa.c (print_status): Use print_err for printing errno.
2018-09-27 07:42:50 +02:00
0fa594e3e8 fixup! syscall: track syscall system time a bit more explicitly 2018-09-27 07:41:33 +02:00
4ed4a2ffcc syscall: reset auxstr
Otherwise RVAL_STR may print auxstr remained from a previous syscall.

* syscall.c (syscall_entering_trace); Set tcp->auxstr to NULL.
2018-09-27 07:39:07 +02:00
07c1744c02 syscall: dump write buffer regardless of fd value
For the same reason, as with syserror(tcp).

* syscall.c (dumpio): Move "fd < 0" check after write I/O buffer
printing.
2018-09-27 07:37:35 +02:00
53ac73b04e syscall: add print_err function
Prints error number, respecting current xlat verbosity setting.

* defs.h (print_err): New declaration.
* print_fields.h (PRINT_FIELD_ERR): New macro.
* syscall.c (print_err): New function.
2018-09-27 07:35:32 +02:00
c2cc305c66 numa: use standard print_int32_array_member callback
* numa.c (print_int): Remove.
(SYS_FUNC(move_pages)): Use print_int32_array_member instead of
print_int.
2018-09-27 07:31:23 +02:00
061d0e133e fixup! syslog: do not print bufp and len for commands that ignore them 2018-09-27 07:28:37 +02:00
cfc3e07033 tests: add syslog-success test
* tests/.gitignore: Add syslog-success
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add syslog-success.test.
* tests/syslog-success.c: New file.
* tests/syslog-success.test: New test.
* tests/syslog.c: Add support for running under syscall retval
injection, add checks.
2018-09-27 07:24:03 +02:00
a26ad5c9ad syslog: decode log level in SYSLOG_ACTION_CONSOLE_LEVEL command
* xlat/syslog_console_levels.in: New file.
* syslog.c: Include "xlat/syslog_console_levels.h".
(SYS_FUNC(syslog)): Add SYSLOG_ACTION_CONSOLE_LEVEL case.
* tests/syslog.c: Add checks.
2018-09-27 07:21:10 +02:00
9ea764c377 syslog: fix argument printing
* syslog.c (SYS_FUNC(syslog)): Store conversion to int of tcp->u_arg[2]
in len; print address using printaddr64 (as syslog doesn't use compat
for x32), and third argument as int (as it has this type in the syscall
handler).
* tests/syslog.c: Add checks.
2018-09-27 07:15:30 +02:00
a6e6d0aa1f syslog: do not print bufp and len for commands that ignore them
* syslog.c (SYS_FUNC(syslog)): Defer printing of comma after the first
argument to the specific command handlers, return RVAL_DECODED without
additional printing for SYSLOG_ACTION_CLOSE, SYSLOG_ACTION_OPEN,
SYSLOG_ACTION_CLEAR, SYSLOG_ACTION_CONSOLE_OFF,
SYSLOG_ACTION_CONSOLE_ON, SYSLOG_ACTION_SIZE_UNREAD,
SYSLOG_ACTION_SIZE_BUFFER.
* tests/syslog.c: Add checks.
2018-09-27 04:37:14 +02:00
1324a28cc7 fixup! syslog: print syslog command with verbose style, as it is not in UAPI 2018-09-27 00:29:18 +02:00
394ba90034 syslog: fix switch statement indentation
* syslog.c (SYS_FUNC(syslog)): Decrease indentation level of case
clauses in the switch statement.
2018-09-27 00:27:21 +02:00
60b094103f syslog: print syslog command with verbose style, as it is not in UAPI
* syslog.c (SYS_FUNC(syslog)): Print syslog_action_type using
XLAT_STYLE_VERBOSE.
* tests/syslog.c: Update expected output.
2018-09-26 18:56:15 +02:00
c35f9466a8 syslog: move constant definitions to xlat
* syslog.c (enmu): Remove
* xlat/syslog_action_type.in: Add fallback values.
2018-09-26 18:28:55 +02:00
52981bfb48 fixup! futex: print uaddr value 2018-09-25 16:09:25 +02:00
8015a74269 inotify: implement inotify fd I/O decoding support
* defs.h (decode_inotify_read): New declaration.
* inotify.c: Include "print_fields.h".
(decode_inotify_read): New function.
* io.c (decode_readbuf) <decoders>: Add decoder for anon_inode:inotify.
2018-09-25 12:18:23 +02:00
78fd3aa2b8 fanotify: decode fanotify fd I/O
* xlat/fan_responses.in: New file.
* defs.h (decode_fanotify_read, decode_fanotify_write): New
declarations.
* fanotify.c: Include "print_fields.h".
[!FAN_AUDIT] (FAN_AUDIT): New macro definition.
Include "xlat/fan_responses.h".
(print_fanfd, decode_fanotify_read, decode_fanotify_write): New
functions.
* io.c (decode_readbuf): Add fanotify fd decoder using
decode_fanotify_read.
(decode_writebuf): Add fanotify fd decoder using decode_fanotify_write.
2018-09-25 03:17:33 +02:00
4f72de66f4 io: add I/O buffer decoding infrastructure
* defs.h (enum fileops): New enumeration definition.
(filebuf_decoder_fn): New type definition.
* io.c: Include <fnmatch.h>
(struct filebuf_decoder_desc): New type definition.
(decode_filebuf, decode_readbuf, decode_writebuf): New functions.
(SYS_FUNC(read), SYS_FUNC(write), SYS_FUNC(pread), SYS_FUNC(pwrite)):
Call decode_readbuf/decode_writebuf instead of printing I/O buffer as a
string.
2018-09-25 01:57:22 +02:00
ef330a84d9 msghdr: decode SO_RXQ_OVFL control packet
* xlat/scmvals.in (SO_RXQ_OVFL): New constant.
* msghdr.c (cmsg_socket_printers) <[SO_RXQ_OVFL]>: New socket option
decoder.
2018-09-24 20:53:16 +02:00
1090f31204 xlat: use fallback definitions syntax in scmvals
* xlat/scmvals.in: Rewrite using fallback value definition syntax.
2018-09-24 20:51:15 +02:00
1aca712d4a maint: add support for whitespace between # and define in gen_xlat_defs
* maint/gen_xlat_defs.sh: Change regular expressions for parsing common
and arch-specific files so they match macro definitions where whitespace
between "#" and "define" is present.
2018-09-24 20:39:01 +02:00
bca69f9e39 linux/arm/syscallent.h: Add a comment that __ARM_NR_cmpxchg was removed in 4.4 2018-09-24 20:35:18 +02:00
c3e1c57045 linux/arm/syscallents: replace empty definitions with comments
* linux/arm/syscallent.h ([222]): Remove definition, add a comment that
it was tux().
([223]): Remove definition, add comment that it was unused.
([254]): Remove definition, add comment that it was reserverd
for set_thread_area.
([255]): Remove definition, add comment that it was reserved
for get_thread_area.
2018-09-24 20:32:45 +02:00
a4c8986bd7 net: use already existing array item printing function
* net.c (print_uint32): Remove.
(print_getsockopt): Use print_uint32_array_member instead of
print_uint32.
2018-09-24 20:30:27 +02:00
c7436d45a8 fixup! socketutils: add fallback inode protocol cache 2018-09-24 20:29:43 +02:00
f2f91dbe8b socketutils: dynamically request unknown genl families after init
This commits adds ability to request for unknown generic netlink
families after the initial xlat initialisation. It also changes
socketutils-level interface so it returns string and not xlat.

* defs.h (genl_families_xlat): Remove.
(genl_get_family_name): New declaration.
* netlink.c (decode_nlmsg_type_generic): Use genl_get_family_name
instead of genl_families_xlat.
* socketutils.c (genl_query_families): Rename from
genl_send_dump_families, add "id" parameter, perform dump if id == -1,
request specific ID otherwise.
(genl_get_family_name): Rename from genl_families_xlat, add "id"
parameter, return const char *; request specific genetlink family name
if it is not found in the already initialised xlat.
2018-09-24 20:16:32 +02:00
49443a8c8c Remove HAVE_LINUX_GENETLINK_H ifdefs
<linux/netlink.h> is available since Linux 2.6.15 (commit
v2.6.15-rc1~53^2).

* configure.ac (AC_CHECK_HEADERS): Remove linux/genetlink.h.
* socketutils.c [!HAVE_LINUX_GENETLINK_H]: Remove
* tests/netlink_generic.c [!HAVE_LINUX_GENETLINK_H]: Likewise.
2018-09-24 19:56:08 +02:00
7f3519e4d8 fixup! xlat: add generation of flags-related fields 2018-09-24 08:08:16 +02:00
caac21a22b xlat: sort futexops
* xlat/futexops.in: Reorder, add #sorted.
2018-09-24 08:07:15 +02:00
1d5a776f63 xlat: add fallback values for ioctl_dirs
* xlat/ioctl_dirs.in: Add fallback values.
2018-09-24 08:06:42 +02:00
771a786157 inotify: decode file descriptor returned by inotify_init
* inotify.c (SYS_FUNC(inotify_init)): New function.
* linux/dummy.h (sys_inotify_init): Remove macro definition.
* tests/.gitignore: Add inotify_init, inotify_init-y, inotify_init1-y.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (inotify_init, inotify_init-y, inotify_init1-y):
New tests.
* tests/inotify_init-y.c: New file.
* tests/inotify_init.c: Likewise.
* tests/inotify_init1-y.c: Likewise.
* tests/inotify_init1.c [PRINT_PATHS]: Print inotify fd path.
2018-09-24 08:02:38 +02:00
6d4b688d38 futex: print futex(FUTEX_FD) return value as FD
Since it used to be it.

* futex.c (SYS_FUNC(futex)) <case FUTEX_FD>: Return
RVAL_DECODED|RVAL_FD.
2018-09-24 07:35:18 +02:00
342801a9dc futex: print uaddr value
As it might be of interest. Since uaddr itself is as important as the
containing value, it's alwais printed as comment.

* xlat/futexpiflags.in: New file.
* futex.c [!FUTEX_TID_MASK] (FUTEX_TID_MASK): New macro constant.
Include "xlat/futexpiflags.h".
(printaddrnum, printaddrpival): New functions.
(SYS_FUNC(futex)): Use printaddrpival/printaddrnum for printing uaddr
and uaddr2 values where appropriate.
* tests/futex.c: Update expected output.
2018-09-24 07:32:11 +02:00
56c64c0f85 netlink: always print genetlink family ID
As those are allocated dynamically.

* netlink.c (decode_nlmsg_type_generic): Use XLAT_STYLE_VERBOSE.
* tests/netlink_generic.c: Update expected output.
2018-09-24 05:06:41 +02:00
452bb1c4b9 fixup! ioctl: decode ioctl type 2018-09-24 03:58:51 +02:00
c8dc2208eb ioctl: print private SIOC* ioctl commands
* ioctl.c [!SIOCPROTOPRIVATE] (SIOCPROTOPRIVATE): New macro constant.
[!SIOCDEVPRIVATE] (SIOCDEVPRIVATE): Likewise.
[!SIOCIWFIRSTPRIV] (SIOCIWFIRSTPRIV): Likewise.
[!SIOCIWLASTPRIV] (SIOCIWLASTPRIV): Likewise.
(ioctl_decode_command_number) <SOCK_IOC_TYPE>: Handle protocol-private
and device-private ioctl command numbers.
<0x8B>: Handle device-private ioctl comamnd numbers.
* tests/ioctl.c: Add checks.
2018-09-24 03:55:01 +02:00
d7beb8d758 fixup! ioctl: decode ioctl type 2018-09-24 03:54:15 +02:00
b4e5977fee revert ioctl xlat 2018-09-24 03:38:52 +02:00
72ecb7691a xlat: update kvm_cap
* xlat/kvm_cap.in (KVM_CAP_NESTED_STATE): New constant, introduced
by Linux commit v4.19-rc1~87^2~62.
(KVM_CAP_ARM_INJECT_SERROR_ESR): New constant, introduced by Linux
commit v4.19-rc1~55^2~12^2~14, merged with its final value
in v4.19-rc1~55^2~12.
(KVM_CAP_MSR_PLATFORM_INFO): New constant, introduced by Linux commit
v4.19-rc5~8^2~2.
2018-09-24 00:43:52 +02:00
fc2d593d3d ioctl: decode ioctl type
* xlat/ioc_types.in: New file
* ioctl.c: Include "xlat/ioc_types.h"
(ioctl_type_str): New function.
(ioctl_print_code): Use ioctl_type_str for decoding _IOC_TYPE(code).
2018-09-24 00:26:01 +02:00
8783cd8119 ioctl: print ioctl code in accordance with xlat verbosity
* ioctl.c (ioctl_print_code): Format in accrordance with xlat verbosity
setting.
2018-09-24 00:06:08 +02:00
aeb343b726 Implement sysfs syscall decoding
* Makefile.am (strace_SOURCES): New file.
* linux/dummy.h (sys_sysfs): Remove macro definition.
* sysfs.c: New file.
* tests/gen_tests.in: Add sysfs test definition.
* tests/.gitignore: add sysfs.
* tests/pure_executables.list: Add sysfs.
* tests/sysfs.c: New file.
2018-09-23 12:35:53 +02:00
8a7ba35d04 msghdr: decode IP_RECVFRAGSIZE control message
Added in v4.10-rc1~202^2~340^2~2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* count.c (count_syscall): Calculate system time as difference of tcp's
stime and ltime.
* defs.h (struct tcb): Add ltime, atime fields, remove dtime.
* strace.c (droptcb): Print total system time spent by a tcb.
(startup_tcb): Store initial system time in atime.
(next_event): Update stime directly.
* syscall.c (syscall_entering_finish): Store current system time in
tcb's ltime field.
(syscall_exiting_finish): Likewise.
2018-09-03 04:57:13 +02:00
beece1ab43 fixup! delay: use parse_ts for parsing delay value 2018-09-03 00:41:41 +02:00
8b2355f55f count: fix types in sorting comparison callbacks
* count.c (time_cmp. syscall_cmp): Change arguments type
to "const void *", Change indices cast type to "unsigned int *".
(count cmp): Likewise. Change count variables type to unsigned int.
(sortfun): Provide types of arguments.
2018-09-02 23:05:27 +02:00
d58f4c7ee8 fixup! util.c: add parse_ts 2018-09-02 22:20:03 +02:00
e30f3c2558 count: substract overhead per call
* count.c (zero_ts): New variable.
(count_syscall): Calculate the spent time in the wts variable, then add
it to cc->time.
(call_summary_pers): Do not perform overhead correction.
2018-09-02 22:07:07 +02:00
0a21612184 count: use parse_ts for parsing overhead value
* count.c (set_overhead): Change argument type to const char *, call
parse_ts to parse it and set to overhead.
* defs.h (set_overhead): Update declaration.
* strace.c: (init) <case 'O'>: do not parse argument, pass optarg to
set_overhead call.
* tests/count.test (GENERIC, WALLCLOCK, HALFCLOCK): New variables with
expected patterns.
Add checks for the new -O syntax.
2018-09-02 21:56:47 +02:00
1a28b6dba2 delay: use parse_ts for parsing delay value
* delay.c (fill_delay_data): Change intval argument to struct timespec
*val, assign val to ts.
* delay.h (fill_delay_data): Update function declaration.
* filter_qualify.c (parse_delay_token): Parse input with parse_ts,
supply the resulting struct timespec to fill_delay_data.
* tests/delay.c (check_): New function for providing diagnostic in case
of check failure.
(check_delay): Use it.
* tests/delay.test: Check new delay syntax.
2018-09-02 21:28:41 +02:00
32e987b87a util.c: add parse_ts
* defs.h (parse_ts): New declaration.
* util.c (parse_ts): New function.
2018-09-02 20:04:27 +02:00
7c7705fbc9 util: add ts_min and ts_max
* defs.h (ts_min, ts_max): New declarations.
* util.c (ts_min, ts_max): New functions.
2018-09-02 20:03:27 +02:00
f73d6361c1 fixup! sockaddr: decode AX.25 socket addresses 2018-09-02 18:16:22 +02:00
53faa8304c macros: add ROUNDUP macro
* macros.h (ROUNDUP): New macro.
2018-09-02 18:16:22 +02:00
11c4fc6d99 linux: add arch definition for unaligned access support
* linux/arch_defs_.h [HAVE_ARCH_UNALIGNED_ACCESS]
(HAVE_ARCH_UNALIGNED_ACCESS): New macro constant, defined to 1.
* linux/alpha/arch_defs_.h (HAVE_ARCH_UNALIGNED_ACCESS): New macro
constant, defined to 0.
* linux/arm/arch_defs_.h: Likewise.
* linux/powerpc/arch_defs_.h: Likewise.
* linux/powerpc64/arch_defs_.h: Likewise.
* linux/sparc/arch_defs_.h: Likewise.
2018-09-01 23:41:34 +02:00
8b58aa17fb tests: check stack unwinding for signals
* tests/stack-fcall-3.c: Call etpid or kill depending on argument,
store getpid result.
* tests/stack-fcall.c: Call f0(0) and f0(1).
* tests/strace-k-demangle.expected: Updat eexpected output.
* tests/strace-k.expected: Likewise.
* tests/strace-k.test: Update matching code.
2018-09-01 00:14:26 +02:00
861f9fd7d8 Add xlat description structure.
Rename struct xlat to struct xlat_data and make struct  xlat an xlat descriptor
that contains various information about xlat. So far, it's type and number
of items.

As a result, xlookup/printxval now have enought information for handling
xlat depending on its type, so no *index/*_search APIs are needed.

* xlat.h (struct xlat_data): Rename from struct xlat.
(struct xlat): New type definition.
* xlat.c (xlat_search, printxval_sized, printxval_searchn_ex, xlat_idx,
printxval_indexn_ex, printxval_dispatch_ex, ): Remove.
(xlookup): Handle xlat_data based on xlat type.
(xlookup_le): New function, replaces xlat_search_eq_or_less and supports
all xlat types.
(sprintflags_ex, printflags_ex): Update.
* xlat/gen.sh (gen_header): Add handling for #sorted, generate new
struct xlat descriptor.
* defs.h (arp_hardware_types_size, ethernet_protocols_size,
inet_protocols_size, evdev_abs_size, xlat_search,
xlat_search_eq_or_less, xlat_idx, printxval_searchn_ex,
printxval_searchn, printxval_search, printxval_search_ex,
printxval_indexn_ex, printxval_indexn, printxval_index,
printxval_index_ex, printxval_dispatch_ex, printxval_dispatch): Remove.
(enum xlat_style_private_flag_bits): Remove PAF_INDEX_XLAT_SORTED_BIT
and PAF_INDEX_XLAT_VALUE_INDEXED_BIT.
(enum xlat_style_private_flag): Remove PAF_INDEX_XLAT_SORTED and
PAF_INDEX_XLAT_VALUE_INDEXED.
(print_array_ex): Remove index_xlat_size argument.
(xlookup_le): New declaration.
(printxval_ex): New macro.
* dyxlat.c (struct dyxlat): Remove used field (use xlat.size instead),
embed struct xlat, add pointer to struct xlat_data.
(MARK_END): Remove.
(dyxlat_alloc, dyxlat_free, dyxlat_get, dyxlat_add_pair): Update in
accordance with the structure changes.
* evdev.c (evdev_abs_size): Remove.
(keycode_ioctl): Use printxval instead of printxval_index.
(decode_bitset): Remove.
(decode_bitset_): Rename to decode_bitset, remove decode_nr_size and xt
arguments, call printxval instead of printxval_dispatch.
(bit_ioctl, evdev_read_ioctl): Do not pass xlat type to decode_bitset.
* print_fields.h (PRINT_FIELD_XVAL_SORTED_SIZED,
PRINT_FIELD_XVAL_INDEX): Remove.
* nlattr.h (struct decode_nla_xlat_opts): Remove xlat_size and xt
fields.
* nlattr.c (decode_nla_meminfo): do not pass
PAF_INDEX_XLAT_VALUE_INDEXED flag and netlink_sk_meminfo_indices size
in a print_array_ex call.
(decode_nla_xval): Call printxval_ex instead of printxval_dispatch_ex.
(decode_nla_ether_proto, decode_nla_ip_proto): Do not pass xlat_size and
xt fields in opts.
(decode_nla_flags): Remove XT_INDEXED unsupported warning.
* process.c (struct_user_offsets_data): Rename from
struct_user_offsets, change type to struct xlat_data[], remove XLAT_END.
(struct_user_offsets): New xlat description.
(print_user_offset_addr): Rewrite using xlookup_le.
* util.c (print_array_ex): Remove index_xlat_size argument, simply call
printxval_ex for index printing.
* aio.c (tprint_lio_opcode): Use printxval_ex instead of
printxval_indexn_ex.
* bpf.c: Use printxval instead of printxval_index; use PRINT_FIELD_XVAL
instead of PRINT_FIELD_XVAL_INDEX.
* bpf_filter.c (print_bpf_filter_code): Use printxval instead of
printxval_index.
* ioctl.c (evdev_decode_number): Use printxval instead of
printxval_indexn.
* kvm.c (kvm_ioctl_decode_check_extension): Use printxval instead of
printxval_index.
(kvm_ioctl_run_attach_auxstr): Use xlookup instead of xlat_idx.
* net.c: Use printxval instead of printxval_search/printxval_index, use
printxval_ex instead of printxval_searchn_ex.
* netlink_packet_diag.c (decode_packet_diag_msg): Use PRINT_FIELD_XVAL
instead of PRINT_FIELD_XVAL_SORTED_SIZED.
* netlink_smc_diag.c (decode_smc_diag_shutdown): Remove ARRSZ_PAIR
wrapper.
(decode_smc_diag_fallback): Use printxval_ex instead of
printxval_search_ex.
(decode_smc_diag_msg): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_INDEX.
* print_statfs.c (print_statfs_type): Use printxval instead of
printxval_search.
* rtnl_cachereport.c (decode_nla_ipmra_msg_type,
decode_nla_ip6mra_msg_type): Remove ARRSZ_PAIR wrappers, xt fields.
* rtnl_link.c (decode_ifla_inet6_flags, decode_ifla_inet6_agm):
Likewise.
(decode_nla_tun_type, decode_ifla_xdp_attached): Remove xlat_size,
xt fields.
(decode_ifla_inet_conf, decode_ifla_inet6_conf, decode_ifla_inet6_stats,
decode_ifla_inet6_icmp6_stats): Remove PAF_INDEX_XLAT_VALUE_INDEXED flag
and ARRSZ_PAIR wrapper in print_array_ex calls.
(decode_ifinfomsg): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_SORTED_SIZED.
* rtnl_route.c (decode_nla_rt_proto): Use printxval instead of
printxval_search.
* sock.c (print_ifreq): Use PRINT_FIELD_XVAL instead of
PRINT_FIELD_XVAL_SORTED_SIZED.
* sockaddr.c (print_sockaddr_data_ll, print_sockaddr_data_bt,
print_sockaddr): Use printxval instead of printxval_search and
printxval_index.
* time.c (getitimer, osf_getitimer, setitimer, printclockname): Use
printxval instead of printxval_index.
(do_adjtimex): Use xlookup instead of xlat_idx.
* v4l2.c (print_v4l2_cid): Use xlookup instead of xlat_search.
(print_v4l2_cid): Use xlookup_le instead of xlat_search_eq_or_less.
* tests/btrfs.c: Update xlat handling, use struct xlat_data instead of
struct xlat for XLAT() arrays.
* tests/ioctl_block.c: Likewise.
* tests/ioctl_rtc.c: Likewise.
* tests/printflags.c: Likewise.
* tests/printxval.c: Likewise.
* tests/prlimit64.c: Likewise.
* tests/setrlimit.c: Likewise.
* tests/socketcall.c: Likewise.
* tests/xgetrlimit.c: Likewise.
* tests/xstatfsx.c: Likewise.
* xlat/af_packet_versions.in: Add #value_indexed.
* xlat/arp_hardware_types.in: Add #sorted.
* xlat/ax25_protocols.in: Likewise.
* xlat/bluetooth_l2_cid.in: Likewise.
* xlat/bluetooth_l2_psm.in: Likewise.
* xlat/ethernet_protocols.in: Likewise.
* xlat/evdev_ff_types.in: Likewise.
* xlat/fsmagic.in: Likewise.
* xlat/hw_breakpoint_type.in: Likewise.
* xlat/iffflags.in: Likewise.
* xlat/inet6_if_flags.in: Likewise.
* xlat/inet_protocols.in: Likewise.
* xlat/msgctl_flags.in: Likewise.
* xlat/perf_hw_cache_id.in: Likewise.
* xlat/perf_hw_cache_op_id.in: Likewise.
* xlat/perf_hw_cache_op_result_id.in: Likewise.
* xlat/perf_hw_id.in: Likewise.
* xlat/perf_sw_ids.in: Likewise.
* xlat/perf_type_id.in: Likewise.
* xlat/routing_protocols.in: Likewise.
* xlat/semctl_flags.in: Likewise.
* xlat/shmctl_flags.in: Likewise.
* xlat/smc_decl_codes.in: Likewise.
* xlat/sock_ax25_options.in: Likewise.
* xlat/sock_bluetooth_options.in: Likewise.
* xlat/sock_dccp_options.in: Likewise.
* xlat/sock_tipc_options.in: Likewise.
* xlat/socketlayers.in: Likewise.
* xlat/v4l2_control_classes.in: Likewise.
* xlat/v4l2_pix_fmts.in: Likewise.
* xlat/v4l2_sdr_fmts.in: Likewise.
2018-08-31 23:05:03 +02:00
dea7b2d055 xlat: provide fallback definitions for open_access_modes constants
* xlat/open_access_modes.in: Add fallback values.
2018-08-31 21:11:42 +02:00
b3766e3e01 process: honor xlat style in print_user_offset_addr
* process.c (print_user_offset_addr): Print in accordance with xlat
verbosity setting.
2018-08-31 21:11:42 +02:00
6ee33f6452 time: add xlat styles support to printclockname
* time.c (printclockname): Respectl xlat_verbosity.
2018-08-31 21:11:42 +02:00
e8f456d4e1 open: implement sprint_open_modes using sprintflags_ex
* defs.h (sprintflags_ex): Add "sep" argument.
(sprintflags): Pass '\0' in "sep" argument.
* open.c (sprint_open_modes): Use sprintflags_ex for printing
open_mode_flags.
* xlat.c (sprintflags_ex): Add "sep" argument, use it as initial
separator (if not nul).
2018-08-31 21:11:42 +02:00
15090ba907 rtnl_link.c: decode hardware addresses
* rtnl_link.c (decode_nla_hwaddr): New function.
(ifinfomsg_nla_decoders) <IFLA_ADDRESS, IFLA_BROADCAST>: Use
decode_nla_hwaddr.
* decode_ifinfomsg: Pass ifinfo as opaque data.
2018-08-31 21:11:42 +02:00
aaab15665e perf: rewrite print_perf_event_attr using PRINT_FIELD_* macros
* perf.c: Include "print_fields.h".
(print_perf_event_attr): Use PRINT_FIELD_* macros.
2018-08-31 21:11:42 +02:00
398c49b48a Generalise hardware address printing
* defs.h [!MAX_ADDR_LEN] (MAX_ADDR_LEN): New macro.
(sprint_hwaddr): New declaration.
(print_hwaddr): New inline function, a wrapper for sprint_hwaddr.
* print_fields.h (PRINT_FIELD_HWADDR_SZ): New macro.
* print_mac.c: Include "xlat/arp_hardware_types.h" under
XLAT_MACROS_ONLY.
[!MAX_ADDR_LEN] (MAX_ADDR_LEN): Remove.
(sprint_hwaddr): New function.
* sock.c (print_ifreq) <SIOCSIFHWADDR, SIOCGIFHWADDR>: Print hardware
address using PRINT_FIELD_HWADDR_SZ.
2018-08-31 21:11:42 +02:00
2e9d851346 netlink: avoid parsing data that has been just retrieved
get_fd_nl_family did a weird thing: it parsed netlink socket address in
order to get netlink proto, but the address itself is constructed based
on the netlink proto number in the first place. Avoid doing so by
stashing information about netlink protocol right after nul byte of the
sockaddress and providing it on request.

* socketutils.c (cache_entry): Add has_data field.
(cache_inode_details): Add data argument, store it in has_data field.
(get_sockdata_by_inode_cached): New function.
(inet_parse_response, unix_parse_response, packet_parse_response):
Pass false in data argument of cache_inode_details call.
(netlink_parse_response): Append ndiag_protocol value to details string,
pass true to cache_inode_details call.
(unix_get, inet_get, packet_get): Add data argument, return NULL
if called with data == true.
(netlink_get): Add data argument, call get_sockdata_by_inode_cached
instead of get_sockaddr_by_inode_cached if called with data == true.
(protocols): Add data arguments to the type definition of the get field.
(get_sockaddr_by_inode_uncached): Add data argument, pass
it to protocols->get.
(print_sockaddr_by_inode_uncached): Call get_sockaddr_by_inode_uncached
with data == false.
(get_sockaddr_by_inode): Call get_sockaddr_by_inode_uncached with
data == false;
(get_sockdata_by_inode): New function.
* defs.h (get_sockdata_by_inode): New declaration.
* netlink.c (get_fd_nl_family): Use get_sockdata_by_inode.
2018-08-31 21:11:42 +02:00
653abe7a9d xlat: update resources
* xlat/resources.in: declare as #value indexed. Provide fallback values.
(RLIMIT_VMEM): Remove.
2018-08-31 21:11:42 +02:00
b821526643 futex: recoginise FUTEX_BITSET_MATCH_ANY bitmask
* xlat/futexbitset.in: New file.
* futex.c: Include "xlat/futexbitset.h".
(futex) <FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET>: Decode val3 using
futexbitset xlat.
* tests/futex.c: Add checks for 0xffffffff bitset mask printing.

Closes: Linux commit v4.16-rc1~166^2^2~2
2018-08-31 21:11:42 +02:00
a010a633cd Print stack traces on signals
I don't know why it hasn't been done earlier.

* strace.c [ENABLE_STACKTRACE] (print_stopped): Call unwind_tcb_print
if stack trace printing is enabled.
2018-08-31 21:11:42 +02:00
3960fea7f1 [wip] NFNL_SUBSYS_CTNETLINK subsystem decoding support 2018-08-31 21:11:42 +02:00
8de3d10e71 nlattr: ignore nla_type flags when selecting nlattre decoder
* nlattr.c (decode_nlattr_with_data): Apply NLA_TYPE_MASK to nla_type
before decoder selection.
2018-08-31 19:33:29 +02:00
13263abd4f aio: assorted iocb decoder updates
* xlat/aio_iocb_flags.in: New file.
* defs.h (pollflags, rwf_flags): New declarations.
* configure.ac: Check for the presence of aio_rw_flags field of the
struct iocb.
* aio.c: Include "xlat/aio_iocb_flags.h".
(AIO_RW_FLAGS_FIELD): New macro definition, defined based on the
presence of HAVE_STRUCT_IOCB_AIO_RW_FLAGS macro.
(iocb_sub): Add SUB_POLL.
(tprint_lio_opcode): Change IOCB_CMD_POLL subtype to SUB_POLL.
[!IOCB_FLAG_RESFD] (print_common_flags): Remove IOCB_FLAG_RESFD presence
check, as it is now provided via xlat.
(print_common_flags): Print aio_flags using aio_iocb_flags xlat.
(print_iocb_header): Always print aio_data. Print aio_rw_flags if it is
non-zero. Print aio_reqprio based on the presence of IOCB_FLAG_IOPRIO
flag in aio_flags (us print_ioprio if it set and print as a signed
integer otherwise).
(print_iocb): Decode SUB_POLL subtype.
* tests/aio.c: Update expected output.
2018-08-31 19:33:29 +02:00
ef560cb5d7 ioprio: add print_ioprio function
That respects xlat style settings.

* ioprio.c (print_ioprio): New function.
* defs.h (print_ioprio): New declaration.
2018-08-31 19:33:29 +02:00
ea3b724cf0 netlink_packet_diag: assorted decoding fixes
* xlat/af_packet_versions.in: New file.
* netlink_packet_diag.c: Include "xlat/af_packet_versions.h".
(decode_packet_diag_req): sdiag_protocol shouldn't be decoded as a protocol,
it's currently should be set to 0.
(decode_packet_diag_info): Decode pdi_version field using af_packet_versions
xlat; decode pdi_index field as an interface index.
(packet_diag_msg_nla_decoders) <PACKET_DIAG_UID>: Decode using
decode_nla_uid.
(decode_packet_diag_msg): Decode pdiag_num as an low-level protocol.
* tests/netlink_sock_diag.c: Update expected output.
* tests/nlattr_packet_diag_msg.c: Likewise.
2018-08-31 19:33:29 +02:00
d961fb6936 ioprio: move constant definitions to xlat
* xlat/ioprio_class.in: Add fallback values.
* xlat/ioprio_who.in: Likewise.
* ioprio.c: Remove IOPRIO_WHO_* and IOPRIO_CLASS_* enums.
2018-08-31 19:33:29 +02:00
e901b0cd05 xlat: provide fallback definitions for epollevents
* xlat/epollevents.in: Provide fallback definitions, add EPOLLNVAL
constant (introduced by Linux commit v4.16-rc1~3^2~3).
2018-08-31 19:33:29 +02:00
6d4d8e4241 xlat: provide fallback definitions to pollflags
* xlat/pollflags.in: Add fallback definitions for POLLWRNORM,
POLLWRBAND, POLLMSG, POLLREMOVE, and POLLRDHUP.
2018-08-31 19:33:29 +02:00
fa5d35f8f3 socketutils: provide socket information for AF_PACKET sockets
* socketutils.c: Include <linux/packet_diag.h>,
"xlat/ethernet_protocols.h", "xlat/socktypes.h".
(struct packet_cb_data): New type definition.
(packet_send_query, packet_parse_response, packet_get): New function.
(protocols) <SOCK_PROTO_PACKET>: Use packet_get for obtaining socket
information.
2018-08-31 19:33:29 +02:00
9964dc7dc4 net: decode AF_PACKET protocols in socket syscall
* net.c (SYS_FUNC(socket)) <AF_PACKET>: Decode using ethernet_protocols
xlat.
2018-08-31 19:33:29 +02:00
849d1ea8ac print_ifindex: add public get_ifname method
In order to be able to obtain sanitised device name internally.

* defs.h (geT_ifname): New declaration.
* print_ifindex.c (get_ifname): Refactor, leaving out addition of
if_nametoindex("") part.
(sprint_ifname): New function, adds if_nametoindex("") to
get_ifname's output.
(print_ifindex): Use sprint_ifname instead of get_ifname.
2018-08-31 19:33:29 +02:00
d573499dfc xlat: provide fallback values for socktypes
* xlat/socktypes.in: Provide fallback values.
2018-08-31 19:33:29 +02:00
7f232e50af sock: decode SIOCADDRT and SIOCDELRT commands
Those are a bit tricky, as their arguments depends on socket's address
family. So far, it's implemented for AF_INET, AF_AX25, AF_APPLETALK,
AF_NETROM, AF_X25, AF_INET6, AF_ROSE, and AF_PACKET.

* xlat/inet6_route_metrics.in: New file.
* xlat/inet6_router_pref.in: Likewise.
* xlat/netrom_route_types.in: Likewise.
* xlat/route_flags.in: Likewise.
* defs.h (route_nexthop_flags): New xlat declaration.
(sock_proto): Add SOCK_PROTO_AX25, SOCK_PROTO_DDP, SOCK_PROTO_NETROM,
SOCK_PROTO_PACKET, SOCK_PROTO_ROSE, SOCK_PROTO_X25.
* print_fields.h (PRINT_FIELD_INET6_ADDR): New macro.
* sock.c: Include <linux/ax25.h>, <linux/in_route.h>,
<linux/ipv6_route.h>, <linux/netrom.h>, <linux/rose.h>, <linux/route.h>,
<linux/x25.h>, "xlat/inet6_route_metrics.h", "xlat/inet6_router_pref.h",
"xlat/netrom_route_types.h", "xlat/route_flags.h",
"xlat/route_flags_inet6.h", "xlat/route_nexthop_flags.h",
"xlat/routing_types.h".
(decode_rtentry, print_digipeaters, decode_ax25_routes_struct,
decode_nr_route_struct, decode_x25_route_struct, print_inet6_route_pref,
decode_in6_rtmsg, decode_rose_route_struct): New function.
(sock_ioctl): Handle SIOCADDRT and SIOCDELRT.
* socketutils.c (protocols): Add address family information for
SOCK_PROTO_AX25, SOCK_PROTO_DDP, SOCK_PROTO_NETROM, SOCK_PROTO_PACKET,
SOCK_PROTO_ROSE, and SOCK_PROTO_X25.

Co-Authored-by; Olga Feiermann <charmik@users.sourceforge.net>
Closes: https://github.com/strace/strace/issues/41
2018-08-31 19:33:28 +02:00
43d076b53d socketutils: introduce get_family_by_proto.
Add a helper function that provides address family based on the internal
notion of the socket protocol (using protocols table).

* defs.h (get_family_by_proto): New declaration.
* socketutils.c (get_family_by_proto): New function.
2018-08-31 19:33:28 +02:00
c15ae06098 socketutils: add more IP/IPv6 transport protocols
* defs.h (ock_proto: Add SOCK_PROTO_UDPLITE, SOCK_PROTO_DCCP,
SOCK_PROTO_SCTP, SOCK_PROTO_L2TP_IP, SOCK_PROTO_PING, SOCK_PROTO_RAW,
SOCK_PROTO_UDPLITEv6, SOCK_PROTO_DCCPv6, SOCK_PROTO_L2TP_IPv6,
SOCK_PROTO_SCTPv6, SOCK_PROTO_PINGv6, SOCK_PROTO_RAWv6.
* socketutils.c: Include "xlat/inet_protocols.h".
(protocols): Add protocol descriptions for them.
2018-08-31 19:33:28 +02:00
977d5aed13 socketutils: store more information in protocols table
This also allows getting rid of all these *_v[46]_get calls.

* socketutils.c (unix_get, inet_get, netlink_gen): Add family, protocol,
proto_name paramteres, use them where appropriate.
(tcp_v4_get, udp_v4_get, tcp_v6_get, udp_v6_get): Remove.
(protocols): Add family and proto fields to the structure, call inet_get
for IP/IPv6 protocols.
(get_sockaddr_by_inode_uncached): Update protocols->get calls.
2018-08-31 19:33:28 +02:00
5a22df3304 sockaddr: decode ROSE socket addresses
* defs.h (print_rose_addr): New declaration.
* print_fields.h (PRINT_FIELD_ROSE_ADDR): New macro.
* sockaddr.c (print_rose_addr, print_sockaddr_data_rose): New function.
(sa_printers) <[AF_ROSE]>: New printer.
2018-08-31 19:33:28 +02:00
624d03085c xlat: provide fallback values to route_nexthop_flags
* xlat/route_nexthop_flags.in: Add fallback values.
2018-08-31 19:33:28 +02:00
98bfc2f997 sockaddr: add X.25 socket address decoding support
* sockaddr.c: Include <linux/x25.h>.
(print_sockaddr_data_x25): New function.
(sa_printers) <[AF_X25]>: New socket address handler.
* tests/net-sockaddr.c (check_x25): New function.
(main): Call check_x25 in order to check X.25 socket address decoding.
2018-08-31 19:33:28 +02:00
fc9b2b76e3 net: add support for AX.25 protocols and socket option names decoding
* xlat/ax25_protocols.in: New file.
* xlat/sock_ax25_options.in: Likewise.
* net.c: Include "xlat/ax25_protocols.h", "xlat/sock_ax25_options.h".
* (SYS_FUNC(socket)): <[AF_AX25]>: Print protocol name using
ax25_protocols xlat.
(print_sockopt_fd_level_name) <[SOL_AX25]>: Print socket option name
using sock_ax25_options xlat.
2018-08-31 19:33:28 +02:00
f12b03a7c5 sockaddr.c: whitespace cleanup, typo
* sockaddr.c (print_sockaddr_data_bt): Fix typo, remove excess
indentation from the switch statement.
2018-08-31 19:33:28 +02:00
4d575e0243 sockaddr: decode AX.25 socket addresses
* sockaddr.c: Include <linux/ax25.h>
(check_ax25_address, ax25_addr2str, print_ax25_addr_raw,
print_ax25_addr, print_sockaddr_data_ax25): New function.
(sa_printers) <[AF_AX25]>: New printer.
* tests/net-sockaddr.c (AX25_ADDR): New macro.
(check_ax25): New function.
(main): Call check_ax25 in order to check AX.25 socket address decoding.
2018-08-31 19:33:28 +02:00
6fa6d63bd1 tests: add utimensat test variants with different xlat verbosity levels
* tests/utimensat-Xabbrev.c: New file.
* tests/utimensat-Xraw.c: Likewise.
* tests/utimensat-Xverbose.c: Likewise.
* tests/utimensat.c: Add handling of XLAT_RAW and XLAT_VERBOSE flags.
* tests/pure_executables.list: Add utimensat-Xabbrev, utimensat-Xraw,
and utimensat-Xverbose.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (utimensat-Xabbrev, utimensat-Xraw, utimensat-Xverbose): New
tests.
2018-08-31 19:33:28 +02:00
cba303088d print_timespec: make print_timespec_t_utime respect xlat style setting
* print_timespec.c (print_timespec_t_utime): Print raw timespec value
in accordance with xlat style setting.
2018-08-31 19:33:28 +02:00
ff4b53baa8 netlink: honor custom xlat style setting during nlmsg flags printing
Commit v4.23~343 introduced xlat style argument to printflags_ex, but
XLAT_STYLE_DEFAULT was introduced only in the next commit v4.23~342,
which led to missing out fixing the sole external user of this
peculiar extended interface.

* netlink.c (decode_nlmsg_flags): Use XLAT_STYLE_DEFAULT instead of
XLAT_STYLE_ABBREV in printflags_ex call.

Fixes: v4.23~342 "Introduce XLAT_STYLE_DEFAULT"
2018-08-31 19:33:28 +02:00
741b34b3d1 netlink_netfilter: use xlat styles for res_id workaround printing
* netlink_netfilter.c (decode_netlink_netfilter): Call print_xlat_ex
in order to respect xlat style setting.
2018-08-31 19:33:28 +02:00
da228c39ad ubi: decode flags field of struct ubi_mkvol_req
Introduced by Linux commit v4.19-rc1~13^2~6.

* configure.ac (AC_CHECK_MEMBERS): Add check for struct
ubi_mkvol_req.flags field.
* ubi.c: Include "xlat/ubi_mkvol_req_flags.h".
(UBI_MKVOL_REQ_FLAGS_FIELD): New macro definition.
(ubi_ioctl): Decode the flags field of struct ubi_mkvol_req.
* xlat/ubi_mkvol_req_flags.in: New file.
2018-08-31 19:33:28 +02:00
044c1560f2 block: move fallback definitions for ioctl commands to xlat
* xlat/block_ioctl_cmds.in: New file.
* block.c: Include "xlat/block_ioctl_cmds.h".
(BLKPG, BLKTRACESETUP, BLKTRACESTART, BLKTRACESTOP, BLKTRACETEARDOWN,
BLKDISCARD, BLKIOMIN, BLKIOOPT, BLKALIGNOFF, BLKPBSZGET,
BLKDISCARDZEROES, BLKSECDISCARD, BLKROTATIONAL, BLKZEROOUT): Remove
fallback definitions as those are porvided by block_ioctl_cmds xlat now.
2018-08-31 19:33:28 +02:00
7e632b44d2 Remove BLKGETSIZE64 configure check, decode it unconditionally
It is available on all supported kernel versions.

* configure.ac: Remove BLKGETSIZE64 check.
* block.c (block_ioctl): Remove #ifdef HAVE_BLKGETSIZE64.
2018-08-31 19:33:28 +02:00
02ad183786 netlink_netfilter: decode netfilter netlink attribute names
* xlat/nf_acct_attr_names.in: New file.
* xlat/nf_cthelper_attr_names.in: Likewise.
* xlat/nf_ctnetlink_attr_names.in: Likewise.
* xlat/nf_ctnetlink_exp_attr_names.in: Likewise.
* xlat/nf_ctnetlink_to_attr_names.in: Likewise.
* xlat/nf_ipset_attr_names.in: Likewise.
* xlat/nf_nft_compat_attr_names.in: Likewise.
* xlat/nf_nftables_msg_types.in: Likewise.
* xlat/nf_osf_attr_names.in: Likewise.
* xlat/nf_queue_attr_names.in: Likewise.
* xlat/nf_ulog_attr_names.in: Likewise.
* xlat/nft_chain_attr_names.in: Likewise.
* xlat/nft_flow_attr_names.in: Likewise.
* xlat/nft_gen_attr_names.in: Likewise.
* xlat/nft_obj_attr_names.in: Likewise.
* xlat/nft_rule_attr_names.in: Likewise.
* xlat/nft_set_attr_names.in: Likewise.
* xlat/nft_setelem_attr_names.in: Likewise.
* xlat/nft_table_attr_names.in: Likewise.
* xlat/nft_trace_attr_names.in: Likewise.
* netlink_netfilter.c (struct nfnl_decoder): New type definition.
(nft_subsystem_decoders, nfnl_subsystems): New static constants.
(decode_netlink_netfilter): Select xlat for attribute names based
on message subsystem.
* tests/netlink_netfilter.c: Update expected output.
2018-08-31 19:33:24 +02:00
4087e34e87 strace.spec.in: fix for old distros that do not support xz 2018-08-28 13:44:50 +02:00
c31ced973c tests/init.sh: check for successful run under strace in run_prog
In some environments it's possible that syscalls behave differently when
the process is being ptrace'd.

* tests/init.sh (run_prog): Move down, rewrite using try_run_prog, add
a check for successful execution of the program under strace in the
"medicinal mode" (-qq -enone -esignal=none -o /dev/null).
2018-08-28 13:44:50 +02:00
0484e396f2 v4l2: improve control ID printing
Control ID space is hierarchical, so, higher bits provide information
about control class.

* v4l2.c (print_v4l2_cid): New function.
(print_v4l2_control): Use print_v4l2_cid for printing control ID field.
* tests/ioctl_v4l2.c: Add checks for control ID printing.
2018-08-28 13:44:50 +02:00
871c1af6c3 xlat: introduce xlat_search_eq_or_less
For the cases when it is preferable to print something like
"BASE_VAL+increment".

* defs.h (xlat_search_eq_or_less): New declaration.
* xlat.c (xlat_search_eq_or_less): New function.
2018-08-28 13:44:50 +02:00
39a77ad205 xlat: add ability to provide default string to print_xlat_ex
In order to avoid dealing with xlat verbosity styles outside xlat code
as much as possible.

* defs.h (xlat_style_private_flag_bits): Rename from
print_array_flag_bits, add PXF_DEFAULT_STR_BIT.
(xlat_style_private_flags): Rename from print_array_flags, add
FLAG_(PXF_DEFAULT_STR).
* xlat.c (print_xlat_ex): Handle PXF_DEFAULT_STR by interpreting str
as a default value (print both value and str in XLAT_STYLE_ABBREV).
2018-08-28 13:44:50 +02:00
9f25e7a911 xlat/gen.sh: generate <name>_size variable for xlats in mpers
Otherwise they are nearly unusable.

* xlat/gen.sh (gen_header): Add ${name}_size declaration and definition
if in_mpers is set.
2018-08-28 13:44:50 +02:00
f676bc701d netlink_route: implement RTM_{NEW,DEL,GET}CHAIN commands
* xlat/nl_route_types.in (RTM_NEWCHAIN, RTM_DELCHAIN, RTM_GETCHAIN): New
constant, introduced by Linux commit v4.19-rc1~140^2~279^2~9.
* netlink_route.c (route_decoders) <[RTM_NEWCHAIN - RTM_BASE],
[RTM_DELCHAIN - RTM_BASE], [RTM_GETCHAIN - RTM_BASE]>: New decoder,
calls decode_tcmsg.
2018-08-28 13:44:50 +02:00
e6c00226f4 netlink_route: implement RTM_NEWCACHEREPORT message decoding
* xlat/rtnl_family.in: New file.
* xlat/rtnl_ip6mra_creport_attr.in: Likewise.
* xlat/rtnl_ip6mra_msg_types.in: Likewise.
* xlat/rtnl_ipmra_creport_attr.in: Likewise.
* xlat/rtnl_ipmra_msg_types.in: Likewise.
* rtnl_cachereport.c: Likewise.
* Makefile.am (strace_SOURCES): Add it.
* netlink_route.c (route_decoders) <[RTM_NEWCACHEREPORT - RTM_BASE]>:
New decoder, call decode_cachereport.
* netlink_route.h (decode_cachereport): New declaration.
* xlat/nl_route_types.in (RTM_NEWCACHEREPORT): New constant, introduced
by Linux commit v4.13-rc1~157^2~129^2~3.
2018-08-28 13:44:50 +02:00
0ab4f638cd nlattr: provide common AF_INET{,6} address decoders
* nlattr.c (decode_nla_in_addr, decode_nla_in6_addr): New function.
* nlattr.h (DECL_NLA(in_addr), DECL_NLA(in6_addr)): New declaration.
* rtnl_link.c (decode_ifla_inet6_token): Remove.
(ifla_inet6_nla_decoders) <[IFLA_INET6_TOKEN]>: Use decode_nla_in6_addr.
2018-08-28 13:44:50 +02:00
d5f960204c netlink_route: implement RTM_NEWSTATS, RTM_GETSTATS message decoding
* xlat/ifstats_attr.in: New file.
* xlat/ifstats_attr_mask.in: Likewise.
* xlat/ifstats_offload_attr.in: Likewise.
* xlat/ifstats_xstats_type_attr.in: Likewise.
* xlat/nl_bridge_vlan_flags.in: Likewise.
* rtnl_stats.c: Likewise.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac: Add struct if_stats_msg type check.
* netlink_route.c (route_decoders) <[RTM_NEWSTATS - RTM_BASE],
[RTM_GETSTATS - RTM_BASE]>: New decoder, call decode_ifstatsmsg.
* netlink_route.h (decode_ifstatsmsg): New declaration.
* nlattr.h (DECL_NLA(ifla_af_spec), DECL_NLA(rtnl_link_stats64)): New
declaration.
* rtnl_link.c (decode_nla_rtnl_link_stats64): Rename from
decode_rtnl_link_stats64.
(decode_nla_ifla_af_spec): Rename from decode_ifla_af_spec.
(ifinfomsg_nla_decoders) <[IFLA_STATS64], [IFLA_AF_SPEC]>: Use new
decoder function names.
2018-08-28 13:44:50 +02:00
1694 changed files with 29149 additions and 15417 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
/* export-ignore
/README-github_gitlab-autogenerated-archives.txt -export-ignore

5
.gitignore vendored
View File

@ -12,8 +12,6 @@
/.version
/CREDITS
/ChangeLog
/INSTALL
/README
/aclocal.m4
/autom4te.cache
/bpf_attr_check.c
@ -55,14 +53,15 @@
/native_printer_decls.h
/native_printer_defs.h
/printers.h
/README
/scno.h
/sen.h
/stamp-h1
/strace
/strace-*.tar.gz
/strace-*.tar.xz
/strace-log-merge.1
/strace.1
/strace-log-merge.1
/strace.dsc
/strace.spec
/sys_func.h

30
COPYING
View File

@ -7,14 +7,24 @@ Copyright (c) 1998-2001 Wichert Akkerman <wakkerma@deephackmode.org>
Copyright (c) 2001-2018 The strace developers.
All rights reserved.
strace is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
strace is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See LGPL-2.1-or-later for more details.
strace test suite is provided under the terms of the GNU General Public License
version 2 or later, see tests/COPYING for more details.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -15,10 +15,10 @@ Basic Installation
Briefly, the shell command './configure && make && make install' should
configure, build, and install this package. The following more-detailed
instructions are generic; see the 'README' file for instructions
specific to this package. Some packages provide this 'README-configure'
file but do not implement all of the features documented below. The
lack of an optional feature in a given package is not necessarily a bug.
More recommendations for GNU packages can be found in *note Makefile
specific to this package. Some packages provide this 'INSTALL' file but
do not implement all of the features documented below. The lack of an
optional feature in a given package is not necessarily a bug. More
recommendations for GNU packages can be found in *note Makefile
Conventions: (standards)Makefile Conventions.
The 'configure' shell script attempts to guess correct values for

View File

@ -5,5 +5,5 @@ that are needed to build strace. Some of these files are generated by tools
from the GNU Autoconf and GNU Automake packages.
Note: rather than running `autoreconf` directly, please invoke `./bootstrap`
script and follow the instructions given in [INSTALL](README-configure) file for further
script and follow the instructions given in [INSTALL](INSTALL) file for further
building and installation.

View File

@ -1,501 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom
to share and change it. By contrast, the GNU General Public Licenses are
intended to guarantee your freedom to share and change free software--to
make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software
Foundation and other authors who decide to use it. You can use it too,
but we suggest you first think carefully about whether this license or
the ordinary General Public License is the better strategy to use in
any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get it
if you want it; that you can change the software and use pieces of it in
new free programs; and that you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide complete
object files to the recipients, so that they can relink them with the
library after making changes to the library and recompiling it. And you
must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there
is no warranty for the free library. Also, if the library is modified
by someone else and passed on, the recipients should know that what they
have is not the original version, so that the original author's reputation
will not be affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot effectively
restrict the users of a free program by obtaining a restrictive license
from a patent holder. Therefore, we insist that any patent license
obtained for a version of the library must be consistent with the full
freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License. This license, the GNU Lesser General
Public License, applies to certain designated libraries, and is quite
different from the ordinary General Public License. We use this license
for certain libraries in order to permit linking those libraries into
non-free programs.
When a program is linked with a library, whether statically or using a
shared library, the combination of the two is legally speaking a combined
work, a derivative of the original library. The ordinary General Public
License therefore permits such linking only if the entire combination
fits its criteria of freedom. The Lesser General Public License permits
more lax criteria for linking other code with the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to encourage
the widest possible use of a certain library, so that it becomes a
de-facto standard. To achieve this, non-free programs must be allowed
to use the library. A more frequent case is that a free library does
the same job as widely used non-free libraries. In this case, there
is little to gain by limiting the free library to free software only,
so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of free
software. For example, permission to use the GNU C Library in non-free
programs enables many more people to use the whole GNU operating system,
as well as its variant, the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is linked
with the Library has the freedom and the wherewithal to run that program
using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License"). Each
licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on
the Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code
means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of running
a program using the Library is not restricted, and output from such
a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided
that you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the Library.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of
it, thus forming a work based on the Library, and copy and distribute
such modifications or work under the terms of Section 1 above,
provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge
to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or table,
the facility still operates, and performs whatever part of its
purpose remains meaningful.
(For example, a function in a library to compute square roots
has a purpose that is entirely well-defined independent of
the application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square root
function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work
based on the Library, the distribution of the whole must be on the
terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of
who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is
to exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume
of a storage or distribution medium does not bring the other work
under the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To
do this, you must alter all the notices that refer to this License,
so that they refer to the ordinary GNU General Public License,
version 2, instead of to this License. (If a newer version than
version 2 of the ordinary GNU General Public License has appeared,
then you can specify that version instead if you wish.) Do not make
any other change in these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the
Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative
of it, under Section 2) in object code or executable form under the
terms of Sections 1 and 2 above provided that you accompany it with
the complete corresponding machine-readable source code, which must
be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange.
If distribution of object code is made by offering access to copy from
a designated place, then offering equivalent access to copy the source
code from the same place satisfies the requirement to distribute the
source code, even though third parties are not compelled to copy the
source along with the object code.
5. A program that contains no derivative of any portion of the Library,
but is designed to work with the Library by being compiled or linked
with it, is called a "work that uses the Library". Such a work, in
isolation, is not a derivative work of the Library, and therefore
falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License. Section
6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header
file that is part of the Library, the object code for the work may
be a derivative work of the Library even though the source code is
not. Whether this is true is especially significant if the work can
be linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data structure
layouts and accessors, and small macros and small inline functions
(ten lines or less in length), then the use of the object file
is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section
6. Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link
a "work that uses the Library" with the Library to produce a work
containing portions of the Library, and distribute that work under
terms of your choice, provided that the terms permit modification
of the work for the customer's own use and reverse engineering for
debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered
by this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do
one of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and
(2) will operate properly with a modified version of the library,
if the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three
years, to give the same user the materials specified in Subsection
6a, above, for a charge no more than the cost of performing this
distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you
cannot use both them and the Library together in an executable that
you distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise permitted,
and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities. This
must be distributed under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the
Library except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, link with, or distribute the
Library is void, and will automatically terminate your rights under
this License. However, parties who have received copies, or rights,
from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify
or distribute the Library or its derivative works. These actions
are prohibited by law if you do not accept this License. Therefore,
by modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on
the Library), the recipient automatically receives a license from
the original licensor to copy, distribute, link with or modify the
Library subject to these terms and conditions. You may not impose
any further restrictions on the recipients' exercise of the rights
granted herein. You are not responsible for enforcing compliance by
third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement
or otherwise) that contradict the conditions of this License, they
do not excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence
you may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you,
then the only way you could satisfy both it and this License would
be to refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended
to apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of
any such claims; this section has the sole purpose of protecting
the integrity of the free software distribution system which
is implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed
to be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time. Such
new versions will be similar in spirit to the present version, but
may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published
by the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free Software
Foundation; we sometimes make exceptions for this. Our decision will
be guided by the two goals of preserving the free status of all
derivatives of our free software and of promoting the sharing and
reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS
AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO
IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE
TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR
A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES. END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of
the ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and an idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or
your school, if any, to sign a "copyright disclaimer" for the library,
if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -7,7 +7,27 @@
# Copyright (c) 2002-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if HAVE_M32_RUNTIME
TESTS_M32 = tests-m32
@ -41,8 +61,9 @@ AM_CPPFLAGS_FOR_BUILD = $(AM_CPPFLAGS)
include xlat/Makemodule.am
strace_CPPFLAGS = $(AM_CPPFLAGS)
strace_CFLAGS = $(AM_CFLAGS)
strace_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_DEFS_H
strace_CFLAGS = $(AM_CFLAGS) -DMPERS_WORDSIZE=PERSONALITY0_WORDSIZE \
-DMPERS_KLONGSIZE=PERSONALITY0_KLONGSIZE
strace_LDFLAGS =
strace_LDADD = libstrace.a $(clock_LIBS) $(timer_LIBS)
noinst_LIBRARIES = libstrace.a
@ -127,15 +148,13 @@ strace_SOURCES = \
fetch_struct_xfs_quotastat.c \
file_handle.c \
file_ioctl.c \
filter.h \
filter_qualify.c \
filter.h \
flock.c \
flock.h \
fs_x_ioctl.c \
futex.c \
gcc_compat.h \
get_personality.c \
get_personality.h \
get_robust_list.c \
getcpu.c \
getcwd.c \
@ -160,7 +179,6 @@ strace_SOURCES = \
kexec.c \
keyctl.c \
keyctl_kdf_params.h \
kill_save_errno.h \
kvm.c \
largefile_wrappers.h \
ldt.c \
@ -168,7 +186,6 @@ strace_SOURCES = \
linux/asm_stat.h \
linux/x32/asm_stat.h \
linux/x86_64/asm_stat.h \
list.h \
listen.c \
lookup_dcookie.c \
loop.c \
@ -188,15 +205,15 @@ strace_SOURCES = \
msghdr.h \
mtd.c \
native_defs.h \
nbd_ioctl.c \
negated_errno.h \
net.c \
netlink.c \
netlink.h \
netlink_crypto.c \
netlink_inet_diag.c \
netlink_kobject_uevent.c \
netlink_kobject_uevent.h \
netlink_sock_diag.h \
netlink_inet_diag.c \
netlink_netfilter.c \
netlink_netlink_diag.c \
netlink_packet_diag.c \
@ -205,7 +222,6 @@ strace_SOURCES = \
netlink_selinux.c \
netlink_smc_diag.c \
netlink_sock_diag.c \
netlink_sock_diag.h \
netlink_unix_diag.c \
nlattr.c \
nlattr.h \
@ -228,11 +244,9 @@ strace_SOURCES = \
prctl.c \
print_aio_sigset.c \
print_dev_t.c \
print_fields.h \
print_group_req.c \
print_fields.h \
print_ifindex.c \
print_instruction_pointer.c \
print_kernel_version.c \
print_mac.c \
print_mq_attr.c \
print_msgbuf.c \
@ -251,11 +265,9 @@ strace_SOURCES = \
process.c \
process_vm.c \
ptp.c \
ptp_clock.h \
ptrace.h \
ptrace_syscall_info.c \
ptrace_syscall_info.h \
quota.c \
random_ioctl.c \
readahead.c \
readlink.c \
reboot.c \
@ -270,6 +282,7 @@ strace_SOURCES = \
rtc.c \
rtnl_addr.c \
rtnl_addrlabel.c \
rtnl_cachereport.c \
rtnl_dcb.c \
rtnl_link.c \
rtnl_mdb.c \
@ -279,6 +292,7 @@ strace_SOURCES = \
rtnl_nsid.c \
rtnl_route.c \
rtnl_rule.c \
rtnl_stats.c \
rtnl_tc.c \
rtnl_tc_action.c \
s390.c \
@ -308,14 +322,15 @@ strace_SOURCES = \
statx.c \
statx.h \
strace.c \
string_to_uint.c \
string_to_uint.h \
string_to_uint.c \
swapon.c \
syscall.c \
sysctl.c \
sysent.h \
sysent_shorthand_defs.h \
sysent_shorthand_undefs.h \
sysfs.c \
sysinfo.c \
syslog.c \
sysmips.c \
@ -349,7 +364,10 @@ strace_SOURCES = \
$(strace_SOURCES_check) \
# end of strace_SOURCES
strace_SOURCES_check = bpf_attr_check.c
strace_SOURCES_check = \
bpf_attr_check.c \
ptp_clock_check.c \
# end of strace_SOURCES_check
if ENABLE_STACKTRACE
strace_SOURCES += unwind.c unwind.h
@ -392,8 +410,6 @@ EXTRA_DIST = \
CREDITS \
ChangeLog \
ChangeLog-CVS \
LGPL-2.1-or-later \
README-configure \
README-linux-ptrace \
debian/changelog \
debian/compat \
@ -410,6 +426,7 @@ EXTRA_DIST = \
debian/strace64.manpages \
debian/watch \
gen_bpf_attr_check.sh \
gen_ptp_clock_check.sh \
generate_sen.sh \
ioctl_iocdef.c \
ioctlsort.c \
@ -421,8 +438,9 @@ EXTRA_DIST = \
linux/64/ioctls_inc.h \
linux/64/syscallent.h \
linux/aarch64/arch_defs_.h \
linux/aarch64/arch_get_personality.c \
linux/aarch64/arch_regs.c \
linux/aarch64/arch_regs.h \
linux/aarch64/arch_rt_sigframe.c \
linux/aarch64/arch_sigreturn.c \
linux/aarch64/get_error.c \
linux/aarch64/get_scno.c \
@ -441,6 +459,8 @@ EXTRA_DIST = \
linux/alpha/arch_defs_.h \
linux/alpha/arch_getrval2.c \
linux/alpha/arch_regs.c \
linux/alpha/arch_regs.h \
linux/alpha/arch_rt_sigframe.c \
linux/alpha/arch_sigreturn.c \
linux/alpha/errnoent.h \
linux/alpha/get_error.c \
@ -456,6 +476,8 @@ EXTRA_DIST = \
linux/alpha/syscallent.h \
linux/alpha/userent.h \
linux/arc/arch_regs.c \
linux/arc/arch_regs.h \
linux/arc/arch_rt_sigframe.c \
linux/arc/get_error.c \
linux/arc/get_scno.c \
linux/arc/get_syscall_args.c \
@ -468,10 +490,11 @@ EXTRA_DIST = \
linux/arch_defs_.h \
linux/arch_kvm.c \
linux/arch_regs.h \
linux/arch_rt_sigframe.c \
linux/arch_sigreturn.c \
linux/arm/arch_defs_.h \
linux/arm/arch_regs.c \
linux/arm/arch_regs.h \
linux/arm/arch_rt_sigframe.c \
linux/arm/arch_sigreturn.c \
linux/arm/get_error.c \
linux/arm/get_scno.c \
@ -486,6 +509,8 @@ EXTRA_DIST = \
linux/arm/syscallent.h \
linux/arm/userent.h \
linux/avr32/arch_regs.c \
linux/avr32/arch_regs.h \
linux/avr32/arch_rt_sigframe.c \
linux/avr32/get_error.c \
linux/avr32/get_scno.c \
linux/avr32/get_syscall_args.c \
@ -498,6 +523,7 @@ EXTRA_DIST = \
linux/avr32/userent.h \
linux/bfin/arch_defs_.h \
linux/bfin/arch_regs.c \
linux/bfin/arch_rt_sigframe.c \
linux/bfin/get_error.c \
linux/bfin/get_scno.c \
linux/bfin/get_syscall_args.c \
@ -510,12 +536,12 @@ EXTRA_DIST = \
linux/bfin/set_scno.c \
linux/bfin/syscallent.h \
linux/bfin/userent.h \
linux/check_scno.c \
linux/dummy.h \
linux/errnoent.h \
linux/getregs_old.h \
linux/hppa/arch_defs_.h \
linux/hppa/arch_regs.c \
linux/hppa/arch_regs.h \
linux/hppa/arch_rt_sigframe.c \
linux/hppa/errnoent.h \
linux/hppa/get_error.c \
@ -530,9 +556,10 @@ EXTRA_DIST = \
linux/hppa/set_scno.c \
linux/hppa/signalent.h \
linux/hppa/syscallent.h \
linux/i386/arch_defs_.h \
linux/i386/arch_kvm.c \
linux/i386/arch_defs_.h \
linux/i386/arch_regs.c \
linux/i386/arch_regs.h \
linux/i386/arch_rt_sigframe.c \
linux/i386/arch_sigreturn.c \
linux/i386/get_error.c \
@ -561,11 +588,13 @@ EXTRA_DIST = \
linux/ia64/rt_sigframe.h \
linux/ia64/set_error.c \
linux/ia64/set_scno.c \
linux/ia64/shuffle_scno.c \
linux/ia64/syscallent.h \
linux/ia64/userent.h \
linux/inet_diag.h \
linux/m68k/arch_defs_.h \
linux/m68k/arch_regs.c \
linux/m68k/arch_regs.h \
linux/m68k/arch_rt_sigframe.c \
linux/m68k/arch_sigreturn.c \
linux/m68k/get_error.c \
@ -580,6 +609,7 @@ EXTRA_DIST = \
linux/m68k/syscallent.h \
linux/m68k/userent.h \
linux/metag/arch_regs.c \
linux/metag/arch_regs.h \
linux/metag/arch_rt_sigframe.c \
linux/metag/get_error.c \
linux/metag/get_scno.c \
@ -592,6 +622,7 @@ EXTRA_DIST = \
linux/metag/syscallent.h \
linux/microblaze/arch_defs_.h \
linux/microblaze/arch_regs.c \
linux/microblaze/arch_rt_sigframe.c \
linux/microblaze/arch_sigreturn.c \
linux/microblaze/get_error.c \
linux/microblaze/get_scno.c \
@ -607,6 +638,8 @@ EXTRA_DIST = \
linux/mips/arch_defs_.h \
linux/mips/arch_getrval2.c \
linux/mips/arch_regs.c \
linux/mips/arch_regs.h \
linux/mips/arch_rt_sigframe.c \
linux/mips/arch_sigreturn.c \
linux/mips/errnoent.h \
linux/mips/genstub.sh \
@ -629,6 +662,8 @@ EXTRA_DIST = \
linux/netlink_diag.h \
linux/nios2/arch_defs_.h \
linux/nios2/arch_regs.c \
linux/nios2/arch_regs.h \
linux/nios2/arch_rt_sigframe.c \
linux/nios2/get_error.c \
linux/nios2/get_scno.c \
linux/nios2/get_syscall_args.c \
@ -640,6 +675,8 @@ EXTRA_DIST = \
linux/nios2/syscallent.h \
linux/nr_prefix.c \
linux/or1k/arch_regs.c \
linux/or1k/arch_regs.h \
linux/or1k/arch_rt_sigframe.c \
linux/or1k/get_error.c \
linux/or1k/get_scno.c \
linux/or1k/get_syscall_args.c \
@ -653,6 +690,7 @@ EXTRA_DIST = \
linux/packet_diag.h \
linux/powerpc/arch_defs_.h \
linux/powerpc/arch_regs.c \
linux/powerpc/arch_regs.h \
linux/powerpc/arch_rt_sigframe.c \
linux/powerpc/arch_sigreturn.c \
linux/powerpc/errnoent.h \
@ -669,8 +707,8 @@ EXTRA_DIST = \
linux/powerpc/syscallent.h \
linux/powerpc/userent.h \
linux/powerpc64/arch_defs_.h \
linux/powerpc64/arch_get_personality.c \
linux/powerpc64/arch_regs.c \
linux/powerpc64/arch_regs.h \
linux/powerpc64/arch_rt_sigframe.c \
linux/powerpc64/arch_sigreturn.c \
linux/powerpc64/errnoent.h \
@ -690,11 +728,11 @@ EXTRA_DIST = \
linux/powerpc64/syscallent.h \
linux/powerpc64/syscallent1.h \
linux/powerpc64/userent.h \
linux/ptrace_pokeuser.c \
linux/raw_syscall.h \
linux/riscv/arch_defs_.h \
linux/riscv/arch_get_personality.c \
linux/riscv/arch_regs.c \
linux/riscv/arch_regs.h \
linux/riscv/arch_rt_sigframe.c \
linux/riscv/get_error.c \
linux/riscv/get_scno.c \
linux/riscv/get_syscall_args.c \
@ -710,6 +748,8 @@ EXTRA_DIST = \
linux/rt_sigframe.h \
linux/s390/arch_defs_.h \
linux/s390/arch_regs.c \
linux/s390/arch_regs.h \
linux/s390/arch_rt_sigframe.c \
linux/s390/arch_sigreturn.c \
linux/s390/get_error.c \
linux/s390/get_scno.c \
@ -725,8 +765,9 @@ EXTRA_DIST = \
linux/s390/userent0.h \
linux/s390/userent1.h \
linux/s390x/arch_defs_.h \
linux/s390x/arch_get_personality.c \
linux/s390x/arch_regs.c \
linux/s390x/arch_regs.h \
linux/s390x/arch_rt_sigframe.c \
linux/s390x/arch_sigreturn.c \
linux/s390x/get_error.c \
linux/s390x/get_scno.c \
@ -745,6 +786,7 @@ EXTRA_DIST = \
linux/sh/arch_defs_.h \
linux/sh/arch_getrval2.c \
linux/sh/arch_regs.c \
linux/sh/arch_rt_sigframe.c \
linux/sh/get_error.c \
linux/sh/get_scno.c \
linux/sh/get_syscall_args.c \
@ -760,6 +802,7 @@ EXTRA_DIST = \
linux/sh64/arch_defs_.h \
linux/sh64/arch_regs.c \
linux/sh64/arch_regs.h \
linux/sh64/arch_rt_sigframe.c \
linux/sh64/get_error.c \
linux/sh64/get_scno.c \
linux/sh64/get_syscall_args.c \
@ -780,6 +823,8 @@ EXTRA_DIST = \
linux/sparc/arch_defs_.h \
linux/sparc/arch_getrval2.c \
linux/sparc/arch_regs.c \
linux/sparc/arch_regs.h \
linux/sparc/arch_rt_sigframe.c \
linux/sparc/arch_sigreturn.c \
linux/sparc/errnoent.h \
linux/sparc/get_error.c \
@ -795,9 +840,9 @@ EXTRA_DIST = \
linux/sparc/syscallent.h \
linux/sparc/userent.h \
linux/sparc64/arch_defs_.h \
linux/sparc64/arch_get_personality.c \
linux/sparc64/arch_getrval2.c \
linux/sparc64/arch_regs.c \
linux/sparc64/arch_regs.h \
linux/sparc64/arch_rt_sigframe.c \
linux/sparc64/arch_sigreturn.c \
linux/sparc64/errnoent.h \
@ -819,8 +864,9 @@ EXTRA_DIST = \
linux/subcall.h \
linux/syscall.h \
linux/tile/arch_defs_.h \
linux/tile/arch_get_personality.c \
linux/tile/arch_regs.c \
linux/tile/arch_regs.h \
linux/tile/arch_rt_sigframe.c \
linux/tile/arch_sigreturn.c \
linux/tile/get_error.c \
linux/tile/get_scno.c \
@ -840,13 +886,11 @@ EXTRA_DIST = \
linux/userent.h \
linux/userent0.h \
linux/x32/arch_defs_.h \
linux/x32/arch_get_personality.c \
linux/x32/arch_kvm.c \
linux/x32/arch_regs.c \
linux/x32/arch_regs.h \
linux/x32/arch_rt_sigframe.c \
linux/x32/arch_sigreturn.c \
linux/x32/check_scno.c \
linux/x32/get_error.c \
linux/x32/get_scno.c \
linux/x32/get_syscall_args.c \
@ -854,7 +898,6 @@ EXTRA_DIST = \
linux/x32/ioctls_arch1.h \
linux/x32/ioctls_inc0.h \
linux/x32/ioctls_inc1.h \
linux/x32/ptrace_pokeuser.c \
linux/x32/raw_syscall.h \
linux/x32/rt_sigframe.h \
linux/x32/set_error.c \
@ -864,7 +907,6 @@ EXTRA_DIST = \
linux/x32/syscallent1.h \
linux/x32/userent.h \
linux/x86_64/arch_defs_.h \
linux/x86_64/arch_get_personality.c \
linux/x86_64/arch_kvm.c \
linux/x86_64/arch_regs.c \
linux/x86_64/arch_regs.h \
@ -891,6 +933,7 @@ EXTRA_DIST = \
linux/x86_64/syscallent2.h \
linux/x86_64/userent.h \
linux/xtensa/arch_regs.c \
linux/xtensa/arch_rt_sigframe.c \
linux/xtensa/get_error.c \
linux/xtensa/get_scno.c \
linux/xtensa/get_syscall_args.c \
@ -928,6 +971,9 @@ $(srcdir)/.version:
bpf_attr_check.c: $(srcdir)/bpf_attr.h $(srcdir)/gen_bpf_attr_check.sh
$(srcdir)/gen_bpf_attr_check.sh $< > $@-t && mv $@-t $@
ptp_clock_check.c: $(srcdir)/ptp_clock.h $(srcdir)/gen_ptp_clock_check.sh
$(srcdir)/gen_ptp_clock_check.sh $< > $@-t && mv $@-t $@
strace_SOURCES_c = \
$(filter %.c,$(strace_SOURCES)) $(filter %.c,$(libstrace_a_SOURCES))
@ -1007,11 +1053,11 @@ ioctls_all%.h: $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%.h $(srcdir)/$(OS)/$(ARCH)/ioc
BUILT_SOURCES = $(ioctl_redefs_h) $(ioctlent_h) \
bpf_attr_check.c native_printer_decls.h native_printer_defs.h \
printers.h sen.h sys_func.h .version
printers.h ptp_clock_check.c sen.h sys_func.h .version
CLEANFILES = $(ioctl_redefs_h) $(ioctlent_h) $(mpers_preproc_files) \
ioctl_iocdef.h ioctl_iocdef.i \
bpf_attr_check.c native_printer_decls.h native_printer_defs.h \
printers.h sen.h sys_func.h
printers.h ptp_clock_check.c sen.h sys_func.h
DISTCLEANFILES = gnu/stubs-32.h gnu/stubs-x32.h linux/linux/signal.h
include scno.am
@ -1041,7 +1087,7 @@ mpers-m%.stamp: $(srcdir_mpers_source_files) | printers.h
CFLAGS="$(mpers_sh_opts) -DMPERS_IS_$(mpers_NAME)" \
CPP="$(CPP)" \
CPPFLAGS="$(mpers_sh_opts) -DIN_MPERS -DMPERS_IS_$(mpers_NAME)" \
$(srcdir)/mpers.sh $(mpers_NAME) $(mpers_CC_FLAGS) $$f || exit; \
$(srcdir)/mpers.sh "$(mpers_NAME)" "$(mpers_CC_FLAGS)" "$$f" || exit; \
done
> $@
@ -1112,7 +1158,9 @@ BUILT_SOURCES += $(mpers_m32_targets)
CLEANFILES += $(mpers_m32_targets)
$(mpers_m32_targets): mpers_NAME = m32
$(mpers_m32_targets): mpers_CC_FLAGS = @cc_flags_m32@
$(mpers_m32_targets): mpers_CC_FLAGS = @cc_flags_m32@ \
-DMPERS_WORDSIZE=PERSONALITY1_WORDSIZE \
-DMPERS_KLONGSIZE=PERSONALITY1_KLONGSIZE
endif # HAVE_M32_MPERS
@ -1129,7 +1177,9 @@ BUILT_SOURCES += $(mpers_mx32_targets)
CLEANFILES += $(mpers_mx32_targets)
$(mpers_mx32_targets): mpers_NAME = mx32
$(mpers_mx32_targets): mpers_CC_FLAGS = @cc_flags_mx32@
$(mpers_mx32_targets): mpers_CC_FLAGS = @cc_flags_mx32@ \
-DMPERS_WORDSIZE=PERSONALITY2_WORDSIZE \
-DMPERS_KLONGSIZE=PERSONALITY2_KLONGSIZE
endif # HAVE_MX32_MPERS

69
NEWS
View File

@ -1,75 +1,6 @@
Noteworthy changes in release ?.?? (????-??-??)
===============================================
* Improvements
* Enhanced xlat styles support configured by -X option.
* Updated lists of BPF_*, BTRFS_*, FAN_*, IFLA_*, KERN_*, KVM_CAP_*, NDA_*,
NETNSA_*, NT_*, PR_*, REL_*, SECCOMP_*, SCTP_*, UDP_*, V4L2_*, and *_MAGIC
constants.
* Bug fixes
* Fixed strace-k test on alpha.
* Fixed build on mips o32.
* Fixed build on NOMMU architectures.
Noteworthy changes in release 4.26 (2018-12-26)
===============================================
* License
* The test suite is now provided under the terms of
the GNU General Public License version 2 or later.
* All the rest of strace is now provided under the terms of
the GNU Lesser General Public License version 2.1 or later.
* Changes in behavior
* If strace is interrupted by a signal it handles (currently
one of HUP, INT, QUIT, PIPE, or TERM), strace terminates
itself with this signal.
* Improvements
* Implemented obtainment of system call information using
PTRACE_GET_SYSCALL_INFO ptrace API.
* Implemented decoding of PTRACE_GET_SYSCALL_INFO ptrace request.
* Implemented decoding of BLKGETZONESZ, BLKGETNRZONES, and RND* ioctl
commands.
* Enhanced xlat styles support configured by -X option.
* Enhanced internet address formatting in structureless contexts.
* Enhanced decoding of getsockopt SO_ERROR option.
* Enhanced error diagnostics when the first exec fails.
* Added %net as a short form of %network in syscall specifications.
* Updated lists of ABS_*, BPF_*, FAN_*, IFA_*, IFLA_*, KVM_CAP_*, NETLINK_*,
NTF_*, PR_SPEC_*, REL_*, SOL_*, TCA_*, and V4L2_* constants.
* Updated lists of ioctl commands from Linux 4.20.
* Enhanced manual page.
* Bug fixes
* Fixed "xlat_idx: Unexpected xlat value 0" warnings.
* Fixed sthyi output format on s390.
* Documented -X option in strace -h output.
Noteworthy changes in release 4.25 (2018-10-30)
===============================================
* Improvements
* Implemented decoding of KVM_CHECK_EXTENSION and NBD_* ioctl commands.
* Implemented decoding of SOL_XDP socket option names.
* Implemented decoding of AF_PACKET protocols in socket syscall.
* Implemented decoding of AF_AX25 and AF_X25 addresses, protocols,
and options.
* Implemented stack trace printing on receiving signals.
* Enhanced xlat styles support configured by -X option.
* Enhanced decoding of IFLA_*, NETCONFA_*, and SMC_DIAG_* netlink attributes.
* Wired up io_pgetevents syscall on arm, sparc, and sparc64.
* Updated lists of AF_*, AUDIT_*, BPF_*, IFLA_*, IN_*, IPSTATS_*,
IPV4_DEVCONF_*, NT_*, SCTP_*, SO_*, SOCK_*, SOL_*, and V4L2_* constants.
* Updated lists of ioctl commands from Linux 4.19.
* Bug fixes
* Fixed decoding of bit sets in evdev ioctl commands.
* Fixed decoding of EVIOCGBIT(0, ...) ioctl commands.
* Fixed test suite for the case when mlockall and unimplemented syscalls
are explicitly disabled by a seccomp filter.
Noteworthy changes in release 4.24 (2018-08-14)
===============================================

View File

@ -1,11 +0,0 @@
github/gitlab autogenerated archives are not supported
======================================================
This information applies to bundles automatically generated
by github and gitlab.
strace's program version is maintained using git-version-gen script, therefore,
building strace depends on "git describe" (a full git clone is needed for this)
or, alternatively, a .tarball-version file. Neither github nor gitlab can
provide the latter, they also do not allow to inject a .tarball-version file
during export archiving.

View File

@ -3,8 +3,7 @@ strace - the linux syscall tracer
This is [strace](https://strace.io) -- a diagnostic, debugging and instructional userspace utility with a traditional command-line interface for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as [ptrace](http://man7.org/linux/man-pages/man2/ptrace.2.html).
strace is released under the terms of [the GNU Lesser General Public License version 2.1 or later](LGPL-2.1-or-later); see the file [COPYING](COPYING) for details.
strace test suite is released under the terms of [the GNU General Public License version 2 or later](tests/GPL-2.0-or-later); see the file [tests/COPYING](tests/COPYING) for details.
strace is released under a Berkeley-style license at the request of Paul Kranenburg; see the file [COPYING](COPYING) for details.
See the file [NEWS](NEWS) for information on what has changed in recent versions.

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#include <fcntl.h>

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2002-2004 Roland McGrath <roland@redhat.com>
* Copyright (c) 2009-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2009-2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

79
aio.c
View File

@ -6,7 +6,27 @@
* Copyright (c) 1999-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -14,6 +34,13 @@
#include <linux/aio_abi.h>
#include "xlat/aio_cmds.h"
#include "xlat/aio_iocb_flags.h"
#ifdef HAVE_STRUCT_IOCB_AIO_RW_FLAGS
# define AIO_RW_FLAGS_FIELD aio_rw_flags
#else
# define AIO_RW_FLAGS_FIELD aio_reserved1
#endif
SYS_FUNC(io_setup)
{
@ -32,7 +59,7 @@ SYS_FUNC(io_destroy)
}
enum iocb_sub {
SUB_NONE, SUB_COMMON, SUB_VECTOR
SUB_NONE, SUB_COMMON, SUB_VECTOR, SUB_POLL
};
static enum iocb_sub
@ -44,14 +71,13 @@ tprint_lio_opcode(unsigned int cmd)
[IOCB_CMD_FSYNC] = SUB_NONE,
[IOCB_CMD_FDSYNC] = SUB_NONE,
[IOCB_CMD_PREADX] = SUB_NONE,
[IOCB_CMD_POLL] = SUB_NONE,
[IOCB_CMD_POLL] = SUB_POLL,
[IOCB_CMD_NOOP] = SUB_NONE,
[IOCB_CMD_PREADV] = SUB_VECTOR,
[IOCB_CMD_PWRITEV] = SUB_VECTOR,
};
printxval_indexn_ex(ARRSZ_PAIR(aio_cmds) - 1, cmd, "IOCB_CMD_???",
XLAT_STYLE_FMT_U);
printxval_ex(aio_cmds, cmd, "IOCB_CMD_???", XLAT_STYLE_FMT_U);
return cmd < ARRAY_SIZE(subs) ? subs[cmd] : SUB_NONE;
}
@ -59,14 +85,14 @@ tprint_lio_opcode(unsigned int cmd)
static void
print_common_flags(struct tcb *tcp, const struct iocb *cb)
{
/* IOCB_FLAG_RESFD is available since v2.6.22-rc1~47 */
#ifdef IOCB_FLAG_RESFD
if (cb->aio_flags)
PRINT_FIELD_FLAGS(", ", *cb, aio_flags, aio_iocb_flags,
"IOCB_FLAG_???");
if (cb->aio_flags & IOCB_FLAG_RESFD)
PRINT_FIELD_FD(", ", *cb, aio_resfd, tcp);
if (cb->aio_flags & ~IOCB_FLAG_RESFD)
PRINT_FIELD_X(", ", *cb, aio_flags);
#endif
else if (cb->aio_resfd)
PRINT_FIELD_X(", ", *cb, aio_resfd);
}
static bool
@ -82,20 +108,25 @@ print_iocb_header(struct tcb *tcp, const struct iocb *cb)
{
enum iocb_sub sub;
if (cb->aio_data){
PRINT_FIELD_X("", *cb, aio_data);
tprints(", ");
PRINT_FIELD_X("", *cb, aio_data);
if (cb->aio_key)
PRINT_FIELD_U(", ", *cb, aio_key);
if (cb->AIO_RW_FLAGS_FIELD) {
tprints(", aio_rw_flags=");
printflags(rwf_flags, cb->AIO_RW_FLAGS_FIELD, "RWF_???");
}
if (cb->aio_key) {
PRINT_FIELD_U("", *cb, aio_key);
tprints(", ");
}
tprints("aio_lio_opcode=");
tprints(", aio_lio_opcode=");
sub = tprint_lio_opcode(cb->aio_lio_opcode);
if (cb->aio_reqprio)
if (cb->aio_flags & IOCB_FLAG_IOPRIO) {
tprints(", aio_reqprio=");
print_ioprio(zero_extend_signed_to_ull(cb->aio_reqprio));
} else if (cb->aio_reqprio) {
PRINT_FIELD_D(", ", *cb, aio_reqprio);
}
PRINT_FIELD_FD(", ", *cb, aio_fildes, tcp);
@ -135,6 +166,10 @@ print_iocb(struct tcb *tcp, const struct iocb *cb)
PRINT_FIELD_D(", ", *cb, aio_offset);
print_common_flags(tcp, cb);
break;
case SUB_POLL:
PRINT_FIELD_FLAGS(", ", *cb, aio_buf, pollflags, "POLL???");
print_common_flags(tcp, cb);
break;
case SUB_NONE:
break;
}
@ -235,7 +270,7 @@ print_io_getevents(struct tcb *tcp, bool has_usig)
* whether the syscall has failed or not.
*/
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], false);
if (has_usig) {
tprints(", ");
print_aio_sigset(tcp, tcp->u_arg[5]);

22
alpha.c
View File

@ -3,7 +3,27 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,15 +1,8 @@
/*
* Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/* Architecture-specific definitions. */
#ifndef STRACE_ARCH_DEFS_H
# define STRACE_ARCH_DEFS_H
#define STRACE_ARCH_DEFS_H
# include "arch_defs_.h"
# include "linux/arch_defs_.h"
#include "arch_defs_.h"
#include "linux/arch_defs_.h"
#endif /* !STRACE_ARCH_DEFS_H */

View File

@ -3,7 +3,27 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

24
bind.c
View File

@ -3,10 +3,30 @@
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 1999-2018 The strace developers.
* Copyright (c) 1999-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

24
bjm.c
View File

@ -3,10 +3,30 @@
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 1999-2018 The strace developers.
* Copyright (c) 1999-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

26
block.c
View File

@ -4,7 +4,27 @@
* Copyright (c) 2011-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -47,7 +67,7 @@ typedef struct blk_user_trace_setup {
/* Provide fall-back definitions for BLK* ioctls */
#define XLAT_MACROS_ONLY
#include "xlat/block_ioctl_cmds.h"
# include "xlat/block_ioctl_cmds.h"
#undef XLAT_MACROS_ONLY
#include MPERS_DEFS
@ -116,8 +136,6 @@ MPERS_PRINTER_DECL(int, block_ioctl, struct tcb *const tcp,
case BLKIOMIN:
case BLKIOOPT:
case BLKDISCARDZEROES:
case BLKGETZONESZ:
case BLKGETNRZONES:
if (entering(tcp))
return 0;
tprints(", ");

View File

@ -1,11 +1,9 @@
#!/bin/sh -eu
#
# Copyright (c) 2014-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
export LANG=C
./m4/gen_bpf_attr_m4.sh
./m4/gen_ptp_clock_m4.sh
./generate_mpers_am.sh
./xlat/gen.sh
./tests/gen_pure_executables.sh
@ -31,7 +29,7 @@ for m in m32 mx32; do
done
done
for f in README INSTALL; do
for f in README; do
cp "dist/$f" .
done

57
bpf.c
View File

@ -4,7 +4,27 @@
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -130,9 +150,9 @@ print_ebpf_insn(struct tcb * const tcp, void * const elem_buf,
/* We can't use PRINT_FIELD_XVAL on bit fields */
tprints(", dst_reg=");
printxval_index(ebpf_regs, insn->dst_reg, "BPF_REG_???");
printxval(ebpf_regs, insn->dst_reg, "BPF_REG_???");
tprints(", src_reg=");
printxval_index(ebpf_regs, insn->src_reg, "BPF_REG_???");
printxval(ebpf_regs, insn->src_reg, "BPF_REG_???");
PRINT_FIELD_D(", ", *insn, off);
PRINT_FIELD_X(", ", *insn, imm);
@ -158,8 +178,8 @@ print_ebpf_prog(struct tcb *const tcp, const uint64_t addr, const uint32_t len)
BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)
{
PRINT_FIELD_XVAL_INDEX("{", attr, map_type, bpf_map_types,
"BPF_MAP_TYPE_???");
PRINT_FIELD_XVAL("{", attr, map_type, bpf_map_types,
"BPF_MAP_TYPE_???");
PRINT_FIELD_U(", ", attr, key_size);
PRINT_FIELD_U(", ", attr, value_size);
PRINT_FIELD_U(", ", attr, max_entries);
@ -228,8 +248,8 @@ BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)
PRINT_FIELD_FD("{", attr, map_fd, tcp);
PRINT_FIELD_ADDR64(", ", attr, key);
PRINT_FIELD_ADDR64(", ", attr, value);
PRINT_FIELD_XVAL_INDEX(", ", attr, flags, bpf_map_update_elem_flags,
"BPF_???");
PRINT_FIELD_XVAL(", ", attr, flags, bpf_map_update_elem_flags,
"BPF_???");
}
END_BPF_CMD_DECODER(RVAL_DECODED)
@ -250,8 +270,8 @@ END_BPF_CMD_DECODER(RVAL_DECODED)
BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
{
PRINT_FIELD_XVAL_INDEX("{", attr, prog_type, bpf_prog_types,
"BPF_PROG_TYPE_???");
PRINT_FIELD_XVAL("{", attr, prog_type, bpf_prog_types,
"BPF_PROG_TYPE_???");
PRINT_FIELD_U(", ", attr, insn_cnt);
tprints(", insns=");
print_ebpf_prog(tcp, attr.insns, attr.insn_cnt);
@ -272,8 +292,11 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
/* kern_version field was added in Linux commit v4.1-rc1~84^2~50. */
if (len <= offsetof(struct BPF_PROG_LOAD_struct, kern_version))
break;
tprints(", kern_version=");
print_kernel_version(attr.kern_version);
tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
attr.kern_version >> 16,
(attr.kern_version >> 8) & 0xFF,
attr.kern_version & 0xFF);
/* prog_flags field was added in Linux commit v4.12-rc2~34^2~29^2~2. */
if (len <= offsetof(struct BPF_PROG_LOAD_struct, prog_flags))
break;
@ -329,8 +352,7 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_ATTACH)
{
PRINT_FIELD_FD("{", attr, target_fd, tcp);
PRINT_FIELD_FD(", ", attr, attach_bpf_fd, tcp);
PRINT_FIELD_XVAL_INDEX(", ", attr, attach_type, bpf_attach_type,
"BPF_???");
PRINT_FIELD_XVAL(", ", attr, attach_type, bpf_attach_type, "BPF_???");
PRINT_FIELD_FLAGS(", ", attr, attach_flags, bpf_attach_flags,
"BPF_F_???");
}
@ -339,8 +361,7 @@ END_BPF_CMD_DECODER(RVAL_DECODED)
BEGIN_BPF_CMD_DECODER(BPF_PROG_DETACH)
{
PRINT_FIELD_FD("{", attr, target_fd, tcp);
PRINT_FIELD_XVAL_INDEX(", ", attr, attach_type, bpf_attach_type,
"BPF_???");
PRINT_FIELD_XVAL(", ", attr, attach_type, bpf_attach_type, "BPF_???");
}
END_BPF_CMD_DECODER(RVAL_DECODED)
@ -642,8 +663,8 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)
if (entering(tcp)) {
PRINT_FIELD_FD("{query={", attr, target_fd, tcp);
PRINT_FIELD_XVAL_INDEX(", ", attr, attach_type, bpf_attach_type,
"BPF_???");
PRINT_FIELD_XVAL(", ", attr, attach_type, bpf_attach_type,
"BPF_???");
PRINT_FIELD_FLAGS(", ", attr, query_flags, bpf_query_flags,
"BPF_F_QUERY_???");
PRINT_FIELD_FLAGS(", ", attr, attach_flags, bpf_attach_flags,
@ -713,7 +734,7 @@ SYS_FUNC(bpf)
int rc = RVAL_DECODED;
if (entering(tcp)) {
printxval_index(bpf_commands, cmd, "BPF_???");
printxval(bpf_commands, cmd, "BPF_???");
tprints(", ");
}

View File

@ -2,11 +2,31 @@
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_BPF_ATTR_H
# define STRACE_BPF_ATTR_H
#define STRACE_BPF_ATTR_H
/*
* The policy is that all fields of type uint64_t in this header file
@ -19,21 +39,21 @@
* v4.16-rc1~123^2~109^2~5^2~4.
*/
# ifndef BPF_OBJ_NAME_LEN
# define BPF_OBJ_NAME_LEN 16U
# else
# if BPF_OBJ_NAME_LEN != 16U
# error "Unexpected value of BPF_OBJ_NAME_LEN"
# endif
#ifndef BPF_OBJ_NAME_LEN
# define BPF_OBJ_NAME_LEN 16U
#else
# if BPF_OBJ_NAME_LEN != 16U
# error "Unexpected value of BPF_OBJ_NAME_LEN"
# endif
#endif
# ifndef BPF_TAG_SIZE
# define BPF_TAG_SIZE 8
# else
# if BPF_TAG_SIZE != 8
# error "Unexpected value of BPF_TAG_SIZE"
# endif
#ifndef BPF_TAG_SIZE
# define BPF_TAG_SIZE 8
#else
# if BPF_TAG_SIZE != 8
# error "Unexpected value of BPF_TAG_SIZE"
# endif
#endif
struct BPF_MAP_CREATE_struct {
uint32_t map_type;
@ -47,9 +67,9 @@ struct BPF_MAP_CREATE_struct {
uint32_t map_ifindex;
};
# define BPF_MAP_CREATE_struct_size \
#define BPF_MAP_CREATE_struct_size \
sizeof(struct BPF_MAP_CREATE_struct)
# define expected_BPF_MAP_CREATE_struct_size 48
#define expected_BPF_MAP_CREATE_struct_size 48
struct BPF_MAP_LOOKUP_ELEM_struct {
uint32_t map_fd;
@ -57,9 +77,9 @@ struct BPF_MAP_LOOKUP_ELEM_struct {
uint64_t ATTRIBUTE_ALIGNED(8) value;
};
# define BPF_MAP_LOOKUP_ELEM_struct_size \
#define BPF_MAP_LOOKUP_ELEM_struct_size \
sizeof(struct BPF_MAP_LOOKUP_ELEM_struct)
# define expected_BPF_MAP_LOOKUP_ELEM_struct_size 24
#define expected_BPF_MAP_LOOKUP_ELEM_struct_size 24
struct BPF_MAP_UPDATE_ELEM_struct {
uint32_t map_fd;
@ -68,18 +88,18 @@ struct BPF_MAP_UPDATE_ELEM_struct {
uint64_t ATTRIBUTE_ALIGNED(8) flags;
};
# define BPF_MAP_UPDATE_ELEM_struct_size \
#define BPF_MAP_UPDATE_ELEM_struct_size \
sizeof(struct BPF_MAP_UPDATE_ELEM_struct)
# define expected_BPF_MAP_UPDATE_ELEM_struct_size 32
#define expected_BPF_MAP_UPDATE_ELEM_struct_size 32
struct BPF_MAP_DELETE_ELEM_struct {
uint32_t map_fd;
uint64_t ATTRIBUTE_ALIGNED(8) key;
};
# define BPF_MAP_DELETE_ELEM_struct_size \
#define BPF_MAP_DELETE_ELEM_struct_size \
sizeof(struct BPF_MAP_DELETE_ELEM_struct)
# define expected_BPF_MAP_DELETE_ELEM_struct_size 16
#define expected_BPF_MAP_DELETE_ELEM_struct_size 16
struct BPF_MAP_GET_NEXT_KEY_struct {
uint32_t map_fd;
@ -87,9 +107,9 @@ struct BPF_MAP_GET_NEXT_KEY_struct {
uint64_t ATTRIBUTE_ALIGNED(8) next_key;
};
# define BPF_MAP_GET_NEXT_KEY_struct_size \
#define BPF_MAP_GET_NEXT_KEY_struct_size \
sizeof(struct BPF_MAP_GET_NEXT_KEY_struct)
# define expected_BPF_MAP_GET_NEXT_KEY_struct_size 24
#define expected_BPF_MAP_GET_NEXT_KEY_struct_size 24
struct BPF_PROG_LOAD_struct {
uint32_t prog_type;
@ -106,9 +126,9 @@ struct BPF_PROG_LOAD_struct {
uint32_t expected_attach_type;
};
# define BPF_PROG_LOAD_struct_size \
#define BPF_PROG_LOAD_struct_size \
offsetofend(struct BPF_PROG_LOAD_struct, expected_attach_type)
# define expected_BPF_PROG_LOAD_struct_size 72
#define expected_BPF_PROG_LOAD_struct_size 72
struct BPF_OBJ_PIN_struct {
uint64_t ATTRIBUTE_ALIGNED(8) pathname;
@ -116,12 +136,12 @@ struct BPF_OBJ_PIN_struct {
uint32_t file_flags;
};
# define BPF_OBJ_PIN_struct_size \
#define BPF_OBJ_PIN_struct_size \
sizeof(struct BPF_OBJ_PIN_struct)
# define expected_BPF_OBJ_PIN_struct_size 16
#define expected_BPF_OBJ_PIN_struct_size 16
# define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
# define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
#define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
#define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
struct BPF_PROG_ATTACH_struct {
uint32_t target_fd;
@ -130,9 +150,9 @@ struct BPF_PROG_ATTACH_struct {
uint32_t attach_flags;
};
# define BPF_PROG_ATTACH_struct_size \
#define BPF_PROG_ATTACH_struct_size \
sizeof(struct BPF_PROG_ATTACH_struct)
# define expected_BPF_PROG_ATTACH_struct_size 16
#define expected_BPF_PROG_ATTACH_struct_size 16
struct BPF_PROG_DETACH_struct {
uint32_t target_fd;
@ -140,9 +160,9 @@ struct BPF_PROG_DETACH_struct {
uint32_t attach_type;
};
# define BPF_PROG_DETACH_struct_size \
#define BPF_PROG_DETACH_struct_size \
sizeof(struct BPF_PROG_DETACH_struct)
# define expected_BPF_PROG_DETACH_struct_size 12
#define expected_BPF_PROG_DETACH_struct_size 12
struct BPF_PROG_TEST_RUN_struct /* test */ {
uint32_t prog_fd;
@ -155,9 +175,9 @@ struct BPF_PROG_TEST_RUN_struct /* test */ {
uint32_t duration;
};
# define BPF_PROG_TEST_RUN_struct_size \
#define BPF_PROG_TEST_RUN_struct_size \
sizeof(struct BPF_PROG_TEST_RUN_struct)
# define expected_BPF_PROG_TEST_RUN_struct_size 40
#define expected_BPF_PROG_TEST_RUN_struct_size 40
struct BPF_PROG_GET_NEXT_ID_struct {
uint32_t start_id;
@ -165,12 +185,12 @@ struct BPF_PROG_GET_NEXT_ID_struct {
uint32_t open_flags;
};
# define BPF_PROG_GET_NEXT_ID_struct_size \
#define BPF_PROG_GET_NEXT_ID_struct_size \
sizeof(struct BPF_PROG_GET_NEXT_ID_struct)
# define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
#define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
# define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
# define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
#define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
#define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
struct BPF_PROG_GET_FD_BY_ID_struct {
uint32_t prog_id;
@ -178,9 +198,9 @@ struct BPF_PROG_GET_FD_BY_ID_struct {
uint32_t open_flags;
};
# define BPF_PROG_GET_FD_BY_ID_struct_size \
#define BPF_PROG_GET_FD_BY_ID_struct_size \
sizeof(struct BPF_PROG_GET_FD_BY_ID_struct)
# define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
#define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
struct BPF_MAP_GET_FD_BY_ID_struct {
uint32_t map_id;
@ -188,9 +208,9 @@ struct BPF_MAP_GET_FD_BY_ID_struct {
uint32_t open_flags;
};
# define BPF_MAP_GET_FD_BY_ID_struct_size \
#define BPF_MAP_GET_FD_BY_ID_struct_size \
sizeof(struct BPF_MAP_GET_FD_BY_ID_struct)
# define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
#define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
uint32_t bpf_fd;
@ -198,9 +218,9 @@ struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
uint64_t ATTRIBUTE_ALIGNED(8) info;
};
# define BPF_OBJ_GET_INFO_BY_FD_struct_size \
#define BPF_OBJ_GET_INFO_BY_FD_struct_size \
sizeof(struct BPF_OBJ_GET_INFO_BY_FD_struct)
# define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
#define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
struct BPF_PROG_QUERY_struct /* query */ {
uint32_t target_fd;
@ -211,18 +231,18 @@ struct BPF_PROG_QUERY_struct /* query */ {
uint32_t prog_cnt;
};
# define BPF_PROG_QUERY_struct_size \
#define BPF_PROG_QUERY_struct_size \
offsetofend(struct BPF_PROG_QUERY_struct, prog_cnt)
# define expected_BPF_PROG_QUERY_struct_size 28
#define expected_BPF_PROG_QUERY_struct_size 28
struct BPF_RAW_TRACEPOINT_OPEN_struct /* raw_tracepoint */ {
uint64_t ATTRIBUTE_ALIGNED(8) name;
uint32_t prog_fd;
};
# define BPF_RAW_TRACEPOINT_OPEN_struct_size \
#define BPF_RAW_TRACEPOINT_OPEN_struct_size \
offsetofend(struct BPF_RAW_TRACEPOINT_OPEN_struct, prog_fd)
# define expected_BPF_RAW_TRACEPOINT_OPEN_struct_size 12
#define expected_BPF_RAW_TRACEPOINT_OPEN_struct_size 12
struct bpf_map_info_struct {
uint32_t type;
@ -241,9 +261,9 @@ struct bpf_map_info_struct {
uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* skip check */
};
# define bpf_map_info_struct_size \
#define bpf_map_info_struct_size \
sizeof(struct bpf_map_info_struct)
# define expected_bpf_map_info_struct_size 64
#define expected_bpf_map_info_struct_size 64
struct bpf_prog_info_struct {
uint32_t type;
@ -267,8 +287,8 @@ struct bpf_prog_info_struct {
uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* skip check */
};
# define bpf_prog_info_struct_size \
#define bpf_prog_info_struct_size \
sizeof(struct bpf_prog_info_struct)
# define expected_bpf_prog_info_struct_size 104
#define expected_bpf_prog_info_struct_size 104
#endif /* !STRACE_BPF_ATTR_H */

View File

@ -5,7 +5,27 @@
* Copyright (c) 2017-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -36,10 +56,8 @@ print_bpf_filter_code(const uint16_t code, bool extended)
const struct xlat *mode = extended ? ebpf_mode : bpf_mode;
uint16_t i = code & ~BPF_CLASS(code);
if (extended)
printxval_index(ebpf_class, BPF_CLASS(code), "BPF_???");
else
printxval_index(bpf_class, BPF_CLASS(code), "BPF_???");
printxval(extended ? ebpf_class : bpf_class, BPF_CLASS(code),
"BPF_???");
switch (BPF_CLASS(code)) {
case BPF_ST:
case BPF_STX:

View File

@ -1,14 +1,34 @@
/*
* Classic BPF filter block.
*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_BPF_FILTER_H
# define STRACE_BPF_FILTER_H
#define STRACE_BPF_FILTER_H
struct bpf_filter_block {
uint16_t code;

View File

@ -1,12 +1,5 @@
/*
* Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef STRACE_BPF_FPROG_H
# define STRACE_BPF_FPROG_H
#define STRACE_BPF_FPROG_H
struct bpf_fprog {
unsigned short len;

View File

@ -1,10 +1,30 @@
/*
* Decoder of seccomp filter programs.
*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -5,7 +5,27 @@
* Copyright (c) 2017-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

156
btrfs.c
View File

@ -3,17 +3,37 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#ifdef HAVE_LINUX_BTRFS_H
# include DEF_MPERS_TYPE(struct_btrfs_ioctl_dev_replace_args)
# include DEF_MPERS_TYPE(struct_btrfs_ioctl_send_args)
# include DEF_MPERS_TYPE(struct_btrfs_ioctl_received_subvol_args)
# include DEF_MPERS_TYPE(struct_btrfs_ioctl_vol_args_v2)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_dev_replace_args)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_send_args)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_received_subvol_args)
#include DEF_MPERS_TYPE(struct_btrfs_ioctl_vol_args_v2)
# include <linux/btrfs.h>
@ -32,8 +52,8 @@ typedef struct btrfs_ioctl_vol_args_v2
#ifdef HAVE_LINUX_BTRFS_H
# include "print_fields.h"
# include <linux/fs.h>
#include "print_fields.h"
#include <linux/fs.h>
/*
* Prior to Linux 3.12, the BTRFS_IOC_DEFAULT_SUBVOL used u64 in
@ -41,15 +61,15 @@ typedef struct btrfs_ioctl_vol_args_v2
*/
typedef __u64 u64;
# ifndef HAVE_STRUCT_BTRFS_IOCTL_FEATURE_FLAGS_COMPAT_FLAGS
#ifndef HAVE_STRUCT_BTRFS_IOCTL_FEATURE_FLAGS_COMPAT_FLAGS
struct btrfs_ioctl_feature_flags {
uint64_t compat_flags;
uint64_t compat_ro_flags;
uint64_t incompat_flags;
};
# endif
#endif
# ifndef HAVE_STRUCT_BTRFS_IOCTL_DEFRAG_RANGE_ARGS_START
#ifndef HAVE_STRUCT_BTRFS_IOCTL_DEFRAG_RANGE_ARGS_START
struct btrfs_ioctl_defrag_range_args {
uint64_t start;
uint64_t len;
@ -58,37 +78,37 @@ struct btrfs_ioctl_defrag_range_args {
uint32_t compress_type;
uint32_t unused[4];
};
# endif
#endif
# ifndef BTRFS_LABEL_SIZE
# define BTRFS_LABEL_SIZE 256
# endif
#ifndef BTRFS_LABEL_SIZE
# define BTRFS_LABEL_SIZE 256
#endif
# ifndef BTRFS_IOC_QUOTA_RESCAN
#ifndef BTRFS_IOC_QUOTA_RESCAN
struct btrfs_ioctl_quota_rescan_args {
uint64_t flags, progress, reserved[6];
};
# define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
# define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
struct btrfs_ioctl_quota_rescan_args)
# define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
# define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
struct btrfs_ioctl_quota_rescan_args)
# endif
#endif
# ifndef BTRFS_IOC_QUOTA_RESCAN_WAIT
# define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
# endif
#ifndef BTRFS_IOC_QUOTA_RESCAN_WAIT
# define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
#endif
# ifndef BTRFS_IOC_GET_FEATURES
# define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
#ifndef BTRFS_IOC_GET_FEATURES
# define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
struct btrfs_ioctl_feature_flags)
# define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
# define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
struct btrfs_ioctl_feature_flags[2])
# define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
# define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
struct btrfs_ioctl_feature_flags[3])
# endif
#endif
# ifndef BTRFS_IOC_TREE_SEARCH_V2
# define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
#ifndef BTRFS_IOC_TREE_SEARCH_V2
# define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
struct btrfs_ioctl_search_args_v2)
struct btrfs_ioctl_search_args_v2 {
struct btrfs_ioctl_search_key key; /* in/out - search parameters */
@ -97,34 +117,34 @@ struct btrfs_ioctl_search_args_v2 {
* to store item */
uint64_t buf[0]; /* out - found items */
};
# endif
#endif
# include "xlat/btrfs_balance_args.h"
# include "xlat/btrfs_balance_ctl_cmds.h"
# include "xlat/btrfs_balance_flags.h"
# include "xlat/btrfs_balance_state.h"
# include "xlat/btrfs_compress_types.h"
# include "xlat/btrfs_cont_reading_from_srcdev_mode.h"
# include "xlat/btrfs_defrag_flags.h"
# include "xlat/btrfs_dev_replace_cmds.h"
# include "xlat/btrfs_dev_replace_results.h"
# include "xlat/btrfs_dev_replace_state.h"
# include "xlat/btrfs_dev_stats_flags.h"
# include "xlat/btrfs_dev_stats_values.h"
# include "xlat/btrfs_features_compat.h"
# include "xlat/btrfs_features_compat_ro.h"
# include "xlat/btrfs_features_incompat.h"
# include "xlat/btrfs_key_types.h"
# include "xlat/btrfs_logical_ino_args_flags.h"
# include "xlat/btrfs_qgroup_ctl_cmds.h"
# include "xlat/btrfs_qgroup_inherit_flags.h"
# include "xlat/btrfs_qgroup_limit_flags.h"
# include "xlat/btrfs_qgroup_status_flags.h"
# include "xlat/btrfs_scrub_flags.h"
# include "xlat/btrfs_send_flags.h"
# include "xlat/btrfs_snap_flags_v2.h"
# include "xlat/btrfs_space_info_flags.h"
# include "xlat/btrfs_tree_objectids.h"
#include "xlat/btrfs_balance_args.h"
#include "xlat/btrfs_balance_ctl_cmds.h"
#include "xlat/btrfs_balance_flags.h"
#include "xlat/btrfs_balance_state.h"
#include "xlat/btrfs_compress_types.h"
#include "xlat/btrfs_cont_reading_from_srcdev_mode.h"
#include "xlat/btrfs_defrag_flags.h"
#include "xlat/btrfs_dev_replace_cmds.h"
#include "xlat/btrfs_dev_replace_results.h"
#include "xlat/btrfs_dev_replace_state.h"
#include "xlat/btrfs_dev_stats_flags.h"
#include "xlat/btrfs_dev_stats_values.h"
#include "xlat/btrfs_features_compat.h"
#include "xlat/btrfs_features_compat_ro.h"
#include "xlat/btrfs_features_incompat.h"
#include "xlat/btrfs_key_types.h"
#include "xlat/btrfs_logical_ino_args_flags.h"
#include "xlat/btrfs_qgroup_ctl_cmds.h"
#include "xlat/btrfs_qgroup_inherit_flags.h"
#include "xlat/btrfs_qgroup_limit_flags.h"
#include "xlat/btrfs_qgroup_status_flags.h"
#include "xlat/btrfs_scrub_flags.h"
#include "xlat/btrfs_send_flags.h"
#include "xlat/btrfs_snap_flags_v2.h"
#include "xlat/btrfs_space_info_flags.h"
#include "xlat/btrfs_tree_objectids.h"
static inline char
prnibble(char v)
@ -135,7 +155,7 @@ prnibble(char v)
}
/* 8-4-4-4-12 = 36 characters */
# define UUID_STRING_SIZE 36
#define UUID_STRING_SIZE 36
/* Formats uuid, returns 0 if it's all zeroes */
static int
@ -222,9 +242,9 @@ btrfs_print_qgroup_limit(const struct btrfs_qgroup_limit *lim)
tprints("}");
}
# define btrfs_print_key_type(prefix_, where_, field_) \
#define btrfs_print_key_type(prefix_, where_, field_) \
PRINT_FIELD_XVAL_U((prefix_), (where_), field_, btrfs_key_types, NULL)
# define btrfs_print_objectid(prefix_, where_, field_) \
#define btrfs_print_objectid(prefix_, where_, field_) \
PRINT_FIELD_XVAL_U((prefix_), (where_), field_, btrfs_tree_objectids, \
NULL)
@ -718,9 +738,9 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
struct btrfs_ioctl_fs_info_args args;
char uuid[UUID_STRING_SIZE+1];
uint32_t nodesize, sectorsize, clone_alignment;
# ifndef HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE
#ifndef HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE
uint32_t *reserved32;
# endif
#endif
if (entering(tcp))
return 0;
@ -729,16 +749,16 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
if (umove_or_printaddr(tcp, arg, &args))
break;
# ifdef HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE
#ifdef HAVE_STRUCT_BTRFS_IOCTL_FS_INFO_ARGS_NODESIZE
nodesize = args.nodesize,
sectorsize = args.sectorsize,
clone_alignment = args.clone_alignment;
# else
#else
reserved32 = (void *) args.reserved;
nodesize = reserved32[0];
sectorsize = reserved32[1];
clone_alignment = reserved32[2];
# endif
#endif
btrfs_unparse_uuid(args.fsid, uuid);
PRINT_FIELD_U("{", args, max_id);
@ -892,11 +912,11 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
tprintf(", flags=");
printflags64(btrfs_logical_ino_args_flags,
# ifdef HAVE_STRUCT_BTRFS_IOCTL_LOGICAL_INO_ARGS_FLAGS
#ifdef HAVE_STRUCT_BTRFS_IOCTL_LOGICAL_INO_ARGS_FLAGS
args.flags
# else
#else
args.reserved[3]
# endif
#endif
, "BTRFS_LOGICAL_INO_ARGS_???");
PRINT_FIELD_ADDR64(", ", args, inodes);
tprints("}");
@ -1262,9 +1282,9 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
case BTRFS_IOC_CLONE: /* FICLONE */
case BTRFS_IOC_CLONE_RANGE: /* FICLONERANGE */
# ifdef BTRFS_IOC_FILE_EXTENT_SAME
#ifdef BTRFS_IOC_FILE_EXTENT_SAME
case BTRFS_IOC_FILE_EXTENT_SAME: /* FIDEDUPERANGE */
# endif
#endif
/*
* FICLONE, FICLONERANGE, and FIDEDUPERANGE started out as
* btrfs ioctls and the code was kept for the generic

View File

@ -4,10 +4,30 @@
* Copyright (c) 2010 Carmelo Amoroso <carmelo.amoroso@st.com>
* Copyright (c) 2015 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
* Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2014-2018 The strace developers.
* Copyright (c) 2014-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -20,15 +40,15 @@
# include "xlat/cacheflush_scope.h"
static const struct xlat cacheflush_flags[] = {
# ifdef FLUSH_CACHE_BOTH
#ifdef FLUSH_CACHE_BOTH
XLAT(FLUSH_CACHE_BOTH),
# endif
# ifdef FLUSH_CACHE_DATA
#endif
#ifdef FLUSH_CACHE_DATA
XLAT(FLUSH_CACHE_DATA),
# endif
# ifdef FLUSH_CACHE_INSN
#endif
#ifdef FLUSH_CACHE_INSN
XLAT(FLUSH_CACHE_INSN),
# endif
#endif
XLAT_END
};
@ -72,18 +92,18 @@ SYS_FUNC(cacheflush)
#ifdef SH
static const struct xlat cacheflush_flags[] = {
# ifdef CACHEFLUSH_D_INVAL
#ifdef CACHEFLUSH_D_INVAL
XLAT(CACHEFLUSH_D_INVAL),
# endif
# ifdef CACHEFLUSH_D_WB
#endif
#ifdef CACHEFLUSH_D_WB
XLAT(CACHEFLUSH_D_WB),
# endif
# ifdef CACHEFLUSH_D_PURGE
#endif
#ifdef CACHEFLUSH_D_PURGE
XLAT(CACHEFLUSH_D_PURGE),
# endif
# ifdef CACHEFLUSH_I
#endif
#ifdef CACHEFLUSH_I
XLAT(CACHEFLUSH_I),
# endif
#endif
XLAT_END
};

View File

@ -2,10 +2,30 @@
* Copyright (c) 2000 Wichert Akkerman <wakkerma@debian.org>
* Copyright (c) 2011 Denys Vlasenko <dvlasenk@redhat.com>
* Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2014-2018 The strace developers.
* Copyright (c) 2014-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
CAP_CHOWN,
CAP_DAC_OVERRIDE,
CAP_DAC_READ_SEARCH,

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
CAP_MAC_OVERRIDE,
CAP_MAC_ADMIN,
CAP_SYSLOG,

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(chdir)

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
static void

View File

@ -1,9 +1,4 @@
#!/bin/sh -ex
#
# Copyright (c) 2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
type sudo >/dev/null 2>&1 && sudo=sudo || sudo=
common_packages='autoconf automake faketime file gawk gcc-multilib git gzip libbluetooth-dev make xz-utils'

View File

@ -1,9 +1,4 @@
#!/bin/sh -ex
#
# Copyright (c) 2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
DISTCHECK_CONFIGURE_FLAGS='--disable-dependency-tracking'
export DISTCHECK_CONFIGURE_FLAGS

22
clone.c
View File

@ -7,7 +7,27 @@
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -8,7 +8,27 @@
# Copyright (c) 2002-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AC_PREREQ(2.57)
AC_INIT([strace],
@ -335,7 +355,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>])
AC_CHECK_MEMBERS(m4_normalize([
siginfo_t.si_syscall,
siginfo_t.si_timerid,
siginfo_t.si_overrun
siginfo_t.si_overrun,
siginfo_t.si_trapno
]),,, [#include <signal.h>])
AC_CHECK_MEMBERS(m4_normalize([
@ -456,6 +477,10 @@ AC_CHECK_HEADERS([linux/bpf.h], [
st_BPF_ATTR
])
AC_CHECK_HEADERS([linux/ptp_clock.h], [
st_PTP_CLOCK
])
AC_CHECK_HEADERS([bluetooth/bluetooth.h], [
AC_CHECK_MEMBERS([struct sockaddr_l2.l2_bdaddr_type],,,
[#include <bluetooth/bluetooth.h>
@ -473,6 +498,7 @@ AC_CHECK_MEMBERS(m4_normalize([
AC_CHECK_TYPES([struct dcbmsg],,, [#include <linux/dcbnl.h>])
AC_CHECK_TYPES([struct ifaddrlblmsg],,, [#include <linux/if_addrlabel.h>])
AC_CHECK_TYPES([struct if_stats_msg],,, [#include <linux/if_link.h>])
AC_CHECK_TYPES([struct netconfmsg],,, [#include <linux/netconf.h>])
AC_CHECK_TYPES(m4_normalize([
@ -550,11 +576,10 @@ AC_CHECK_TYPES([struct blk_user_trace_setup],,, [#include <linux/blktrace_api.h>
AC_CHECK_TYPES([struct mtd_write_req],,, [#include <mtd/mtd-abi.h>])
AC_CHECK_MEMBERS([struct ubi_attach_req.max_beb_per1024],,, [#include <mtd/ubi-user.h>])
AC_CHECK_TYPES(m4_normalize([
struct ptp_sys_offset
]),,, [#include <linux/ptp_clock.h>])
AC_CHECK_MEMBERS(m4_normalize([
struct ubi_attach_req.max_beb_per1024
struct ubi_mkvol_req.flags
]),,, [#include <mtd/ubi-user.h>])
AC_CHECK_TYPES(m4_normalize([
struct kvm_cpuid2,
@ -580,6 +605,8 @@ fi
AC_CHECK_TYPES([struct __aio_sigset],,, [#include <linux/aio_abi.h>])
AC_CHECK_MEMBERS([struct iocb.aio_rw_flags],,, [#include <linux/aio_abi.h>])
CPPFLAGS="$saved_CPPFLAGS"
AC_CHECK_HEADERS([linux/btrfs.h], [
@ -645,8 +672,6 @@ AC_CHECK_DECLS(m4_normalize([
KERN_MAX_LOCK_DEPTH,
KERN_NMI_WATCHDOG,
KERN_PANIC_ON_NMI,
KERN_PANIC_ON_WARN,
KERN_PANIC_PRINT,
NET_LLC,
NET_NETFILTER,
NET_DCCP,
@ -910,8 +935,16 @@ AC_ARG_ENABLE([mpers],
esac],
[enable_mpers=yes])
st_MPERS([m32], [aarch64|powerpc64|riscv|s390x|sparc64|tile|x32|x86_64])
st_MPERS([mx32], [x86_64])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(, [[#include "linux/]]$arch[[/arch_defs_.h"
#include "linux/arch_defs_.h"
int i[SUPPORTED_PERSONALITIES > 1 ? 1 : -1];]])],
[st_MPERS([m32], ["$arch"])])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(, [[#include "linux/]]$arch[[/arch_defs_.h"
#include "linux/arch_defs_.h"
int i[SUPPORTED_PERSONALITIES > 2 ? 1 : -1];]])],
[st_MPERS([mx32], ["$arch"])])
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK

View File

@ -1,8 +1,28 @@
/*
* Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,9 +1,4 @@
#!/bin/sh
#
# Copyright (c) 2017-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
#! /bin/sh
: ${YEAR_FILE:=$1}
: ${DEFAULT_YEAR:=$2}
@ -19,7 +14,7 @@ year=
[ -f "${YEAR_FILE}" ] && year="$(cat "${YEAR_FILE}")"
[ -n "${year}" ] ||
year="$(date -u +%Y -d "$(git show -s --format=format:%cD)")"
year="$(date -u +%Y -d "$(git show --format=format:%cD --no-patch)")"
[ -n "${year}" ] ||
year="${DEFAULT_YEAR}"

464
count.c
View File

@ -11,160 +11,466 @@
* Copyright (c) 2006-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include <stdarg.h>
/* Per-syscall stats structure */
struct call_counts {
/* time may be total latency or system time */
struct timespec time;
struct timespec time_min;
struct timespec time_max;
double time_avg;
unsigned int calls, errors;
};
static struct call_counts *countv[SUPPORTED_PERSONALITIES];
#define counts (countv[current_personality])
static const struct timespec zero_ts;
static const struct timespec max_ts = {
(time_t) (long long) (zero_extend_signed_to_ull(~(((time_t) 0))) >> 1),
LONG_MAX };
static struct timespec overhead;
enum count_summary_columns {
CSC_NONE,
CSC_TIME_100S,
CSC_TIME_TOTAL,
CSC_TIME_MIN,
CSC_TIME_MAX,
CSC_TIME_AVG,
CSC_CALLS,
CSC_ERRORS,
CSC_SC_NAME,
CSC_MAX,
};
#define DEF_COLUMNS \
_(CSC_TIME_100S), \
_(CSC_TIME_TOTAL), \
_(CSC_TIME_AVG), \
_(CSC_CALLS), \
_(CSC_ERRORS), \
_(CSC_SC_NAME), \
/* End of DEF_COLUMNS definition */
#define _(x) x
static uint8_t columns[CSC_MAX] = { DEF_COLUMNS };
#undef _
#define _(x) [x] = 1
static uint8_t visible[CSC_MAX] = { DEF_COLUMNS };
#undef _
void
count_syscall(struct tcb *tcp, const struct timespec *syscall_exiting_ts)
{
if (!scno_in_range(tcp->scno))
return;
if (!counts)
if (!counts) {
counts = xcalloc(nsyscalls, sizeof(*counts));
for (size_t i = 0; i < nsyscalls; i++)
counts[i].time_min = max_ts;
}
struct call_counts *cc = &counts[tcp->scno];
cc->calls++;
if (syserror(tcp))
cc->errors++;
struct timespec wts;
if (count_wallclock) {
/* wall clock time spent while in syscall */
struct timespec wts;
ts_sub(&wts, syscall_exiting_ts, &tcp->etime);
ts_add(&cc->time, &cc->time, &wts);
} else {
/* system CPU time spent while in syscall */
ts_add(&cc->time, &cc->time, &tcp->dtime);
ts_sub(&wts, &tcp->stime, &tcp->ltime);
}
ts_sub(&wts, &wts, &overhead);
ts_max(&wts, &wts, &zero_ts);
if (ts_cmp(&wts, &cc->time_min) < 0)
cc->time_min = wts;
if (ts_cmp(&wts, &cc->time_max) > 0)
cc->time_max = wts;
ts_add(&cc->time, &cc->time, &wts);
}
static int
time_cmp(void *a, void *b)
time_cmp(const void *a, const void *b)
{
return -ts_cmp(&counts[*((int *) a)].time,
&counts[*((int *) b)].time);
return -ts_cmp(&counts[*((unsigned int *) a)].time,
&counts[*((unsigned int *) b)].time);
}
static int
syscall_cmp(void *a, void *b)
min_time_cmp(const void *a, const void *b)
{
const char *a_name = sysent[*((int *) a)].sys_name;
const char *b_name = sysent[*((int *) b)].sys_name;
return strcmp(a_name ? a_name : "", b_name ? b_name : "");
return -ts_cmp(&counts[*((unsigned int *) a)].time_min,
&counts[*((unsigned int *) b)].time_min);
}
static int
count_cmp(void *a, void *b)
max_time_cmp(const void *a, const void *b)
{
int m = counts[*((int *) a)].calls;
int n = counts[*((int *) b)].calls;
return -ts_cmp(&counts[*((unsigned int *) a)].time_max,
&counts[*((unsigned int *) b)].time_max);
}
static int
avg_time_cmp(const void *a, const void *b)
{
double m = counts[*((unsigned int *) a)].time_avg;
double n = counts[*((unsigned int *) b)].time_avg;
return (m < n) ? 1 : (m > n) ? -1 : 0;
}
static int (*sortfun)();
static int
syscall_cmp(const void *a, const void *b)
{
const char *a_name = sysent[*((unsigned int *) a)].sys_name;
const char *b_name = sysent[*((unsigned int *) b)].sys_name;
return strcmp(a_name ? a_name : "", b_name ? b_name : "");
}
static int
count_cmp(const void *a, const void *b)
{
unsigned int m = counts[*((unsigned int *) a)].calls;
unsigned int n = counts[*((unsigned int *) b)].calls;
return (m < n) ? 1 : (m > n) ? -1 : 0;
}
static int
error_cmp(const void *a, const void *b)
{
unsigned int m = counts[*((unsigned int *) a)].errors;
unsigned int n = counts[*((unsigned int *) b)].errors;
return (m < n) ? 1 : (m > n) ? -1 : 0;
}
static int (*sortfun)(const void *a, const void *b);
void
set_sortby(const char *sortby)
{
if (strcmp(sortby, "time") == 0)
sortfun = time_cmp;
else if (strcmp(sortby, "calls") == 0)
sortfun = count_cmp;
else if (strcmp(sortby, "name") == 0)
sortfun = syscall_cmp;
else if (strcmp(sortby, "nothing") == 0)
sortfun = NULL;
else {
error_msg_and_help("invalid sortby: '%s'", sortby);
static const struct {
int (*fn)(const void *a, const void *b);
const char *name;
} sort_fns[] = {
{ time_cmp, "time" },
{ time_cmp, "time_total" },
{ time_cmp, "total_time" },
{ min_time_cmp, "min_time" },
{ min_time_cmp, "time_min" },
{ max_time_cmp, "max_time" },
{ max_time_cmp, "time_max" },
{ avg_time_cmp, "avg_time" },
{ avg_time_cmp, "time_avg" },
{ count_cmp, "count" },
{ count_cmp, "calls" },
{ error_cmp, "errors" },
{ error_cmp, "error" },
{ syscall_cmp, "name" },
{ syscall_cmp, "syscall_name" },
{ syscall_cmp, "syscall" },
{ NULL, "nothing" },
{ NULL, "none" },
};
for (size_t i = 0; i < ARRAY_SIZE(sort_fns); i++) {
if (strcmp(sort_fns[i].name, sortby))
continue;
sortfun = sort_fns[i].fn;
return;
}
error_msg_and_help("invalid sortby: '%s'", sortby);
}
void set_overhead(int n)
void
set_count_summary_columns(const char *s)
{
overhead.tv_sec = n / 1000000;
overhead.tv_nsec = n % 1000000 * 1000;
static const char *cnames[] = {
[CSC_TIME_100S] = "time_percent",
[CSC_TIME_TOTAL] = "total_time",
[CSC_TIME_MIN] = "min_time",
[CSC_TIME_MAX] = "max_time",
[CSC_TIME_AVG] = "avg_time",
[CSC_CALLS] = "calls",
[CSC_ERRORS] = "errors",
[CSC_SC_NAME] = "syscall",
};
const char *pos = s;
const char *prev = s;
size_t cur = 0;
memset(columns, 0, sizeof(columns));
memset(visible, 0, sizeof(visible));
do {
bool found = false;
pos = strchr(prev, ',');
for (size_t i = 0; i < ARRAY_SIZE(cnames); i++) {
if (!cnames[i] || (pos
? ((size_t) (pos - prev) != strlen(cnames[i]))
|| strncmp(prev, cnames[i], pos - prev)
: strcmp(prev, cnames[i]))) {
continue;
}
if (visible[i])
error_msg_and_help("call summary column "
"has been provided more "
"than once: '%s' (-U option "
"residual: '%s')",
cnames[i], prev);
columns[cur++] = i;
visible[i] = 1;
found = true;
break;
}
if (!found)
error_msg_and_help("unknown column name: '%.*s'",
(int) (pos ? pos - prev : INT_MAX),
prev);
prev = pos + 1;
} while (pos);
}
void
set_overhead(const char *str)
{
if (parse_ts(str, &overhead) < 0)
error_msg_and_help("invalid -O argument: '%s'", str);
}
static size_t ATTRIBUTE_FORMAT((printf, 1, 2))
num_chars(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int ret = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
return (unsigned int) MAX(ret, 0);
}
static void
call_summary_pers(FILE *outf)
{
static const char dashes[] = "----------------";
static const char header[] = "%6.6s %11.11s %11.11s %9.9s %9.9s %s\n";
static const char data[] = "%6.2f %11.6f %11lu %9u %9.u %s\n";
static const char summary[] = "%6.6s %11.6f %11.11s %9u %9.u %s\n";
enum column_flags {
CF_L = 1 << 0, /* Left-aligned column */
};
static const struct {
const char *s;
size_t sz;
const char *fmt;
uint32_t flags;
} cdesc[] = {
[CSC_TIME_100S] = { ARRSZ_PAIR("% time"), "%*.2f" },
[CSC_TIME_TOTAL] = { ARRSZ_PAIR("seconds"), "%*.6f" },
[CSC_TIME_MIN] = { ARRSZ_PAIR("shortest"), "%*.6f" },
[CSC_TIME_MAX] = { ARRSZ_PAIR("longest"), "%*.6f" },
[CSC_TIME_AVG] = { ARRSZ_PAIR("usecs/call"), "%*lu" },
[CSC_CALLS] = { ARRSZ_PAIR("calls"), "%*" PRIu64 },
[CSC_ERRORS] = { ARRSZ_PAIR("errors"), "%*" PRIu64 },
[CSC_SC_NAME] = { ARRSZ_PAIR("syscall"), "%-*s", CF_L },
};
unsigned int i;
unsigned int call_cum, error_cum;
struct timespec tv_cum, dtv;
double float_tv_cum;
double percent;
unsigned int *sorted_count;
unsigned int *indices;
fprintf(outf, header,
"% time", "seconds", "usecs/call",
"calls", "errors", "syscall");
fprintf(outf, header, dashes, dashes, dashes, dashes, dashes, dashes);
struct timespec tv_cum = zero_ts;
struct timespec tv_min = max_ts;
struct timespec tv_max = zero_ts;
uint64_t call_cum = 0;
uint64_t error_cum = 0;
sorted_count = xcalloc(sizeof(sorted_count[0]), nsyscalls);
call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_nsec = 0;
for (i = 0; i < nsyscalls; i++) {
sorted_count[i] = i;
if (counts == NULL || counts[i].calls == 0)
double float_tv_cum;
double percent;
double ts_avg_max = 0;
size_t sc_name_max = 0;
/* sort, calculate statistics */
indices = xcalloc(sizeof(indices[0]), nsyscalls);
for (size_t i = 0; i < nsyscalls; i++) {
struct timespec dtv;
indices[i] = i;
if (counts[i].calls == 0)
continue;
ts_mul(&dtv, &overhead, counts[i].calls);
ts_sub(&counts[i].time, &counts[i].time, &dtv);
if (counts[i].time.tv_sec < 0 || counts[i].time.tv_nsec < 0)
counts[i].time.tv_sec = counts[i].time.tv_nsec = 0;
ts_add(&tv_cum, &tv_cum, &counts[i].time);
ts_min(&tv_min, &tv_min, &counts[i].time_min);
ts_max(&tv_max, &tv_max, &counts[i].time_max);
call_cum += counts[i].calls;
error_cum += counts[i].errors;
ts_add(&tv_cum, &tv_cum, &counts[i].time);
ts_div(&dtv, &counts[i].time, counts[i].calls);
counts[i].time_avg = ts_float(&dtv);
ts_avg_max = MAX(ts_avg_max, counts[i].time_avg);
sc_name_max = MAX(sc_name_max, strlen(sysent[i].sys_name));
}
float_tv_cum = ts_float(&tv_cum);
if (counts) {
if (sortfun)
qsort((void *) sorted_count, nsyscalls,
sizeof(sorted_count[0]), sortfun);
for (i = 0; i < nsyscalls; i++) {
double float_syscall_time;
unsigned int idx = sorted_count[i];
struct call_counts *cc = &counts[idx];
if (cc->calls == 0)
continue;
ts_div(&dtv, &cc->time, cc->calls);
float_syscall_time = ts_float(&cc->time);
percent = (100.0 * float_syscall_time);
if (percent != 0.0)
percent /= float_tv_cum;
/* else: float_tv_cum can be 0.0 too and we get 0/0 = NAN */
fprintf(outf, data,
percent, float_syscall_time,
(long) (1000000 * dtv.tv_sec + dtv.tv_nsec / 1000),
cc->calls, cc->errors, sysent[idx].sys_name);
if (sortfun)
qsort((void *) indices, nsyscalls, sizeof(indices[0]), sortfun);
/* calculate column widths */
#define W_(c_, v_) [c_] = MAX((cdesc[c_].sz - 1), (v_))
unsigned int cwidths[CSC_MAX] = {
W_(CSC_TIME_100S, sizeof("100.00") - 1),
W_(CSC_TIME_TOTAL, num_chars("%.6f", float_tv_cum)),
W_(CSC_TIME_MIN, num_chars("%ld.000000", tv_min.tv_sec)),
W_(CSC_TIME_MAX, num_chars("%ld.000000", tv_max.tv_sec)),
W_(CSC_TIME_AVG, num_chars("%lu", (unsigned long)
(ts_avg_max * 1e6))),
W_(CSC_CALLS, num_chars("%" PRIu64, call_cum)),
W_(CSC_ERRORS, num_chars("%" PRIu64, error_cum)),
W_(CSC_SC_NAME, sc_name_max + 1),
};
#undef W_
/* header */
for (size_t i = 0; columns[i] && i < ARRAY_SIZE(columns); i++) {
const char *fmt = cdesc[columns[i]].flags & CF_L
? "%s%-*s" : "%s%*s";
fprintf(outf, fmt, i ? " " : "", cwidths[columns[i]],
cdesc[columns[i]].s);
}
fputc('\n', outf);
for (size_t i = 0; columns[i] && i < ARRAY_SIZE(columns); i++) {
if (i)
fputc(' ', outf);
for (size_t j = 0; j < cwidths[columns[i]]; j++)
fputc('-', outf);
}
fputc('\n', outf);
/* data output */
for (size_t i = 0; i < nsyscalls; i++) {
unsigned int idx = indices[i];
struct call_counts *cc = &counts[idx];
double float_syscall_time;
if (cc->calls == 0)
continue;
float_syscall_time = ts_float(&cc->time);
percent = (100.0 * float_syscall_time);
/* else: float_tv_cum can be 0.0 too and we get 0/0 = NAN */
if (percent != 0.0)
percent /= float_tv_cum;
for (size_t i = 0; columns[i] && i < ARRAY_SIZE(columns); i++) {
const size_t c = columns[i];
if (i)
fputc(' ', outf);
#define PC_(c_, val_) \
case (c_): fprintf(outf, cdesc[c].fmt, cwidths[c], (val_)); break;
switch (c) {
PC_(CSC_TIME_100S, percent)
PC_(CSC_TIME_TOTAL, float_syscall_time)
PC_(CSC_TIME_MIN, ts_float(&cc->time_min))
PC_(CSC_TIME_MAX, ts_float(&cc->time_max))
PC_(CSC_TIME_AVG, (long) (cc->time_avg * 1e6))
PC_(CSC_CALLS, cc->calls)
case CSC_ERRORS:
if (cc->errors)
fprintf(outf, cdesc[c].fmt,
cwidths[c], cc->errors);
else
fprintf(outf, "%*s", cwidths[c], "");
break;
PC_(CSC_SC_NAME, sysent[idx].sys_name)
}
}
fputc('\n', outf);
}
free(indices);
/* footer */
for (size_t i = 0; columns[i] && i < ARRAY_SIZE(columns); i++) {
if (i)
fputc(' ', outf);
for (size_t j = 0; j < cwidths[columns[i]]; j++)
fputc('-', outf);
}
fputc('\n', outf);
/* totals */
for (size_t i = 0; columns[i] && i < ARRAY_SIZE(columns); i++) {
const size_t c = columns[i];
if (i)
fputc(' ', outf);
switch (c) {
PC_(CSC_TIME_100S, 100.0)
PC_(CSC_TIME_TOTAL, float_tv_cum)
PC_(CSC_TIME_MIN, ts_float(&tv_min))
PC_(CSC_TIME_MAX, ts_float(&tv_max))
PC_(CSC_TIME_AVG,
(unsigned long) (float_tv_cum / call_cum * 1e6))
PC_(CSC_CALLS, call_cum)
PC_(CSC_ERRORS, error_cum)
PC_(CSC_SC_NAME, "total")
}
}
free(sorted_count);
fputc('\n', outf);
fprintf(outf, header, dashes, dashes, dashes, dashes, dashes, dashes);
fprintf(outf, summary,
"100.00", float_tv_cum, "",
call_cum, error_cum, "total");
#undef PC_
}
void

12
debian/changelog.in vendored
View File

@ -4,18 +4,6 @@ strace (@PACKAGE_VERSION@-1) experimental; urgency=low
-- Strace <@PACKAGE_BUGREPORT@> @DEB_CHANGELOGTIME@
strace (4.26-1) unstable; urgency=medium
* New upstream version.
-- Dmitry V. Levin <ldv@altlinux.org> Wed, 26 Dec 2018 18:25:10 +0000
strace (4.25-1) unstable; urgency=medium
* New upstream version.
-- Dmitry V. Levin <ldv@altlinux.org> Tue, 30 Oct 2018 08:09:10 +0000
strace (4.24-1) unstable; urgency=medium
* New upstream version.

30
debian/copyright vendored
View File

@ -14,14 +14,24 @@ Copyright (c) 1998-2001 Wichert Akkerman <wakkerma@deephackmode.org>
Copyright (c) 2001-2018 The strace developers.
All rights reserved.
strace is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
strace is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See LGPL-2.1-or-later for more details.
strace test suite is provided under the terms of the GNU General Public License
version 2 or later, see tests/COPYING for more details.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

791
defs.h

File diff suppressed because it is too large Load Diff

27
delay.c
View File

@ -2,7 +2,27 @@
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -46,7 +66,7 @@ alloc_delay_data(void)
}
void
fill_delay_data(uint16_t delay_idx, int intval, bool isenter)
fill_delay_data(uint16_t delay_idx, struct timespec *val, bool isenter)
{
if (delay_idx >= delay_data_vec_size)
error_func_msg_and_die("delay_idx >= delay_data_vec_size");
@ -57,8 +77,7 @@ fill_delay_data(uint16_t delay_idx, int intval, bool isenter)
else
ts = &(delay_data_vec[delay_idx].ts_exit);
ts->tv_sec = intval / 1000000;
ts->tv_nsec = intval % 1000000 * 1000;
*ts = *val;
}
static bool

26
delay.h
View File

@ -2,14 +2,34 @@
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_DELAY_H
# define STRACE_DELAY_H
#define STRACE_DELAY_H
uint16_t alloc_delay_data(void);
void fill_delay_data(uint16_t delay_idx, int intval, bool isenter);
void fill_delay_data(uint16_t delay_idx, struct timespec *val, bool isenter);
bool is_delay_timer_armed(void);
void delay_timer_expired(void);
void arm_delay_timer(const struct tcb *);

29
desc.c
View File

@ -6,7 +6,27 @@
* Copyright (c) 1999-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -16,6 +36,9 @@ SYS_FUNC(close)
{
printfd(tcp, tcp->u_arg[0]);
uint64_t inode = getfdinode(tcp, tcp->u_arg[0]);
invalidate_netlink_family_cache_entry(inode);
return RVAL_DECODED;
}
@ -52,7 +75,7 @@ SYS_FUNC(dup3)
static int
decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
void (*const print_tv_ts) (struct tcb *, kernel_ulong_t),
void (*const print_tv_ts) (struct tcb *, kernel_ulong_t, bool),
const char * (*const sprint_tv_ts) (struct tcb *, kernel_ulong_t))
{
int i, j;
@ -105,7 +128,7 @@ decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
}
free(fds);
tprints(", ");
print_tv_ts(tcp, args[4]);
print_tv_ts(tcp, args[4], false);
} else {
static char outstr[1024];
char *outptr;

View File

@ -4,10 +4,30 @@
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2014-2018 The strace developers.
* Copyright (c) 2014-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -4,10 +4,30 @@
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 2005-2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2018 The strace developers.
* Copyright (c) 2015-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

134
dist/INSTALL vendored
View File

@ -1,134 +0,0 @@
0. BUILD REQUIREMENTS
- Sane POSIX shell.
- gcc-like compiler that supports C99 and some GNU extensions (namely, empty
structures, empty definitions, zero length arrays, ranged designated
initialisers).
- libc. GNU libc and musl are supported.
- Linux UAPI headers.
- GNU Make.
- GNU coreutils.
- For running test suite: gawk, grep, sed, runtime environment for all
personalities.
- Requirements for optional features are documented in their description.
1. CONFIGURATION AND OPTIONAL FEATURES
Configuration is done using GNU Autoconf-generated configure script.
Please refer to the README-configure file for generic information regarding
configure usage.
In addition to standard configure options, strace's configure file provides
the following options:
1.1. Additional build and testing hardening
--enable-gcc-Werror turn on gcc's -Werror option
--enable-code-coverage Whether to enable code coverage support
--with-gcov=GCOV use given GCOV for coverage (GCOV=gcov).
--enable-valgrind Whether to enable Valgrind on the unit tests
--disable-valgrind-memcheck
Whether to skip memcheck during the Valgrind tests
--disable-valgrind-helgrind
Whether to skip helgrind during the Valgrind tests
--disable-valgrind-drd Whether to skip drd during the Valgrind tests
--enable-valgrind-sgcheck
Whether to use sgcheck during the Valgrind tests
1.2. Optional features
1.2.1. Multiple personalities support
--enable-mpers=yes|no|check|m32|mx32
whether to enable multiple personalities support
required for proper decoding of structures used by
tracees with personalities that differ from the
personality of strace, default is yes.
Personality is a way system call is performed (in terms of ABI). For example,
Linux kernel on multiple 64-bit architectures that evolve from their 32-bit
counterparts have support for running 32-bit binaries with 32-bit system call
ABI, and that system call ABI constitutes a separate personality in strace's
terms. Another example is 32-on-64 bit ABI; while exploiting the same way for
performing system calls as native 64-bit system calls, this ABI has different
type sizes and, as a result, also constitutes a separate personality; the only
such ABI that is currently supported by strace is x32 on x86_64. This is
important as different ABIs use different alignments and type sizes, as a
result, fields in structures in unions have different offsets on different
ABIs. In order to be able to correctly parse all the structures used in various
system calls and ioctl commands, strace compiles these structure definitions
for these different ABI and then parses DWARF of these compiled definitions in
order to generate proper structure definitions that compiled with decoder code.
Taking the aforementioned into account, there are the following requirements:
- gawk (at least version 3)
- Ability to compile for m32 personality (on architectures where it is supported)
- On x86_64, x32, powerpc64, sparc64, riscv64, tile64: gcc -m32
- s390x: gcc -m31
- AArch64: a separate compiler for armv7 EABI
- See information about configuration in "1.3.2. AArch64: AArch32 support"
- Ability to compile for mx32 personality (on architectures where it is supported)
- On x86_64: gcc -mx32
- For tests: runtime support (linker, libc, and loader)
1.2.2. Stack unwinding (-k option)
--with-libunwind use libunwind to implement stack tracing support
--with-libiberty use libiberty to demangle symbols in stack trace
1.3. Architecture-specific features
1.3.1. ARMv7: OABI support
--enable-arm-oabi enable OABI support on ARM EABI
1.3.2. AArch64: AArch32 support
CC_FOR_M32
CPP_FOR_M32
CFLAGS_FOR_M32
CPPFLAGS_FOR_M32
1.4. Miscellanea
1.4.1. Static build configuration
For static linking, provide LDFLAGS='-static -pthread'.
1.4.2. Cross-compilation configuration
2. BUILDING
make
make V=1
3. TESTING
make check
TESTS='list of tests'
VALGRIND_FLAGS
TIMEOUT_DURATION
BTRFS_MOUNTPOINT
4. ADDITIONAL TARGETS
make code-coverage-capture
make code-coverage-capture CODE_COVERAGE_BRANCH_COVERAGE=
5. INSTALLATION
make install
6. PACKAGING
6.1. Distribution tarball
./make-dist
Requires git
6.2. dpkg package
6.3. RPM package

6
dist/README vendored
View File

@ -4,10 +4,8 @@ and tamper with interactions between processes and the Linux kernel, which
include system calls, signal deliveries, and changes of process state.
The operation of strace is made possible by the kernel feature known as ptrace.
strace is released under the terms of the GNU Lesser General Public License
version 2.1 or later; see the file COPYING for details.
strace test suite is released under the terms of the GNU General Public License
version 2 or later; see the file tests/COPYING for details.
strace is released under a Berkeley-style license at the request
of Paul Kranenburg; see the file COPYING for details.
See the file CREDITS for a list of authors and other contributors.
See the file INSTALL for compilation and installation instructions.

24
dm.c
View File

@ -8,7 +8,27 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -98,7 +118,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code,
}
}
# include "xlat/dm_flags.h"
#include "xlat/dm_flags.h"
static void
dm_decode_flags(const struct dm_ioctl *ioc)

View File

@ -1,32 +1,47 @@
/*
* Copyright (c) 2017-2018 The strace developers.
* Copyright (c) 2017 The strace developers.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
struct dyxlat {
size_t used;
size_t allocated;
struct xlat *xlat;
struct xlat xlat;
struct xlat_data *data;
};
#define MARK_END(xlat) \
do { \
(xlat).val = 0; \
(xlat).str = 0; \
} while (0)
struct dyxlat *
dyxlat_alloc(const size_t nmemb)
{
struct dyxlat *const dyxlat = xmalloc(sizeof(*dyxlat));
dyxlat->used = 1;
dyxlat->xlat.type = XT_NORMAL;
dyxlat->xlat.size = 0;
dyxlat->allocated = nmemb;
dyxlat->xlat = xgrowarray(NULL, &dyxlat->allocated, sizeof(struct xlat));
MARK_END(dyxlat->xlat[0]);
dyxlat->xlat.data = dyxlat->data = xgrowarray(NULL, &dyxlat->allocated,
sizeof(struct xlat_data));
return dyxlat;
}
@ -36,20 +51,20 @@ dyxlat_free(struct dyxlat *const dyxlat)
{
size_t i;
for (i = 0; i < dyxlat->used - 1; ++i) {
free((void *) dyxlat->xlat[i].str);
dyxlat->xlat[i].str = NULL;
for (i = 0; i < dyxlat->xlat.size; ++i) {
free((void *) dyxlat->data[i].str);
dyxlat->data[i].str = NULL;
}
free(dyxlat->xlat);
dyxlat->xlat = NULL;
free(dyxlat->data);
dyxlat->xlat.data = NULL;
free(dyxlat);
}
const struct xlat *
dyxlat_get(const struct dyxlat *const dyxlat)
{
return dyxlat->xlat;
return &dyxlat->xlat;
}
void
@ -58,24 +73,24 @@ dyxlat_add_pair(struct dyxlat *const dyxlat, const uint64_t val,
{
size_t i;
for (i = 0; i < dyxlat->used - 1; ++i) {
if (dyxlat->xlat[i].val == val) {
if (strncmp(dyxlat->xlat[i].str, str, len) == 0
&& dyxlat->xlat[i].str[len] == '\0')
for (i = 0; i < dyxlat->xlat.size; ++i) {
if (dyxlat->data[i].val == val) {
if (strncmp(dyxlat->data[i].str, str, len) == 0
&& dyxlat->data[i].str[len] == '\0')
return;
free((void *) dyxlat->xlat[i].str);
dyxlat->xlat[i].str = xstrndup(str, len);
free((void *) dyxlat->data[i].str);
dyxlat->data[i].str = xstrndup(str, len);
return;
}
}
if (dyxlat->used >= dyxlat->allocated)
dyxlat->xlat = xgrowarray(dyxlat->xlat, &dyxlat->allocated,
sizeof(struct xlat));
if (dyxlat->xlat.size >= dyxlat->allocated)
dyxlat->xlat.data = dyxlat->data =
xgrowarray(dyxlat->data, &dyxlat->allocated,
sizeof(struct xlat_data));
dyxlat->xlat[dyxlat->used - 1].val = val;
dyxlat->xlat[dyxlat->used - 1].str = xstrndup(str, len);
MARK_END(dyxlat->xlat[dyxlat->used]);
dyxlat->used++;
dyxlat->data[dyxlat->xlat.size].val = val;
dyxlat->data[dyxlat->xlat.size].str = xstrndup(str, len);
dyxlat->xlat.size++;
}

22
epoll.c
View File

@ -5,7 +5,27 @@
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -2,10 +2,32 @@
* Copyright (c) 1999-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if defined(HAVE_DEFS_H)
# include "defs.h"
#elif defined(HAVE_CONFIG_H)
# include "config.h"
#endif
@ -26,6 +48,7 @@ verror_msg(int err_no, const char *fmt, va_list p)
{
char *msg;
finish_line();
fflush(NULL);
/* We want to print entire message with single fprintf to ensure

View File

@ -4,22 +4,47 @@
* package. Variable 'program_invocation_name' and function 'die()'
* have to be defined globally.
*
* Copyright (c) 2001-2018 The strace developers.
* Copyright (c) 2001-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_ERROR_PRINTS_H
# define STRACE_ERROR_PRINTS_H
#define STRACE_ERROR_PRINTS_H
# include <stdbool.h>
#include <stdbool.h>
# include "gcc_compat.h"
#include "gcc_compat.h"
extern bool debug_flag;
void die(void) ATTRIBUTE_NORETURN;
#ifdef HAVE_FINISH_LINE
extern void finish_line(void);
#else
static inline void finish_line(void) {}
#endif
void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
@ -31,29 +56,29 @@ void error_msg_and_die(const char *fmt, ...)
ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
/* Wrappers for if (debug_flag) error_msg(...) */
# define debug_msg(...) \
#define debug_msg(...) \
do { \
if (debug_flag) \
error_msg(__VA_ARGS__); \
} while (0)
# define debug_perror_msg(...) \
#define debug_perror_msg(...) \
do { \
if (debug_flag) \
perror_msg(__VA_ARGS__); \
} while (0)
/* Simple wrappers for providing function name in error messages */
# define error_func_msg(fmt_, ...) \
#define error_func_msg(fmt_, ...) \
error_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
# define perror_func_msg(fmt_, ...) \
#define perror_func_msg(fmt_, ...) \
perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
# define debug_func_msg(fmt_, ...) \
#define debug_func_msg(fmt_, ...) \
debug_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
# define debug_func_perror_msg(fmt_, ...) \
#define debug_func_perror_msg(fmt_, ...) \
debug_perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__)
# define error_func_msg_and_die(fmt_, ...) \
#define error_func_msg_and_die(fmt_, ...) \
error_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
# define perror_func_msg_and_die(fmt_, ...) \
#define perror_func_msg_and_die(fmt_, ...) \
perror_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__)
#endif /* !STRACE_ERROR_PRINTS_H */

77
evdev.c
View File

@ -4,7 +4,27 @@
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -33,8 +53,6 @@
# define SYN_MAX 0xf
# endif
const size_t evdev_abs_size = ARRAY_SIZE(evdev_abs) - 1;
static int
abs_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
{
@ -78,7 +96,7 @@ keycode_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
if (!umove_or_printaddr(tcp, arg, &keycode)) {
tprintf("[%u, ", keycode[0]);
printxval_index(evdev_keycode, keycode[1], "KEY_???");
printxval(evdev_keycode, keycode[1], "KEY_???");
tprints("]");
}
@ -105,7 +123,7 @@ keycode_V2_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
unsigned int i;
tprintf("index=%" PRIu16 ", keycode=", ike.index);
printxval_index(evdev_keycode, ike.keycode, "KEY_???");
printxval(evdev_keycode, ike.keycode, "KEY_???");
tprints(", scancode=[");
for (i = 0; i < ARRAY_SIZE(ike.scancode); i++) {
if (i > 0)
@ -144,9 +162,9 @@ getid_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
}
static int
decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
const struct xlat decode_nr[], const unsigned int max_nr,
const char *const dflt, size_t decode_nr_size, enum xlat_type xt)
decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg,
const struct xlat *decode_nr, const unsigned int max_nr,
const char *const dflt)
{
tprints(", ");
@ -167,7 +185,7 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
if (i < 0) {
tprints(" 0 ");
} else {
printxval_dispatch(decode_nr, decode_nr_size, i, dflt, xt);
printxval(decode_nr, i, dflt);
while ((i = next_set_bit(decoded_arg, i + 1, size)) > 0) {
if (abbrev(tcp) && bit_displayed >= 3) {
@ -175,8 +193,7 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
break;
}
tprints(", ");
printxval_dispatch(decode_nr, decode_nr_size, i, dflt,
xt);
printxval(decode_nr, i, dflt);
bit_displayed++;
}
}
@ -186,10 +203,6 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
return RVAL_IOCTL_DECODED;
}
# define decode_bitset(tcp_, arg_, decode_nr_, max_nr_, dflt_, xt_) \
decode_bitset_((tcp_), (arg_), (decode_nr_), (max_nr_), \
(dflt_), ARRAY_SIZE(decode_nr_) - 1, (xt_))
# ifdef EVIOCGMTSLOTS
static int
mtslots_ioctl(struct tcb *const tcp, const unsigned int code,
@ -240,42 +253,41 @@ bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr,
switch (ev_nr) {
case 0:
return decode_bitset(tcp, arg, evdev_ev,
EV_MAX, "EV_???", XT_SORTED);
EV_MAX, "EV_???");
case EV_KEY:
return decode_bitset(tcp, arg, evdev_keycode,
KEY_MAX, "KEY_???", XT_INDEXED);
KEY_MAX, "KEY_???");
case EV_REL:
return decode_bitset(tcp, arg, evdev_relative_axes,
REL_MAX, "REL_???", XT_INDEXED);
REL_MAX, "REL_???");
case EV_ABS:
return decode_bitset(tcp, arg, evdev_abs,
ABS_MAX, "ABS_???", XT_INDEXED);
ABS_MAX, "ABS_???");
case EV_MSC:
return decode_bitset(tcp, arg, evdev_misc,
MSC_MAX, "MSC_???", XT_INDEXED);
MSC_MAX, "MSC_???");
case EV_SW:
return decode_bitset(tcp, arg, evdev_switch,
SW_MAX, "SW_???", XT_INDEXED);
SW_MAX, "SW_???");
case EV_LED:
return decode_bitset(tcp, arg, evdev_leds,
LED_MAX, "LED_???", XT_INDEXED);
LED_MAX, "LED_???");
case EV_SND:
return decode_bitset(tcp, arg, evdev_snd,
SND_MAX, "SND_???", XT_INDEXED);
SND_MAX, "SND_???");
case EV_REP:
return decode_bitset(tcp, arg, evdev_autorepeat,
REP_MAX, "REP_???", XT_INDEXED);
REP_MAX, "REP_???");
case EV_FF:
return decode_bitset(tcp, arg, evdev_ff_types,
FF_MAX, "FF_???", XT_SORTED);
FF_MAX, "FF_???");
case EV_PWR:
tprints(", ");
printnum_int(tcp, arg, "%d");
return RVAL_IOCTL_DECODED;
case EV_FF_STATUS:
return decode_bitset(tcp, arg, evdev_ff_status,
FF_STATUS_MAX, "FF_STATUS_???",
XT_INDEXED);
FF_STATUS_MAX, "FF_STATUS_???");
default:
tprints(", ");
printaddr(arg);
@ -329,23 +341,22 @@ evdev_read_ioctl(struct tcb *const tcp, const unsigned int code,
# ifdef EVIOCGPROP
case _IOC_NR(EVIOCGPROP(0)):
return decode_bitset(tcp, arg, evdev_prop,
INPUT_PROP_MAX, "PROP_???",
XT_INDEXED);
INPUT_PROP_MAX, "PROP_???");
# endif
case _IOC_NR(EVIOCGSND(0)):
return decode_bitset(tcp, arg, evdev_snd,
SND_MAX, "SND_???", XT_INDEXED);
SND_MAX, "SND_???");
# ifdef EVIOCGSW
case _IOC_NR(EVIOCGSW(0)):
return decode_bitset(tcp, arg, evdev_switch,
SW_MAX, "SW_???", XT_INDEXED);
SW_MAX, "SW_???");
# endif
case _IOC_NR(EVIOCGKEY(0)):
return decode_bitset(tcp, arg, evdev_keycode,
KEY_MAX, "KEY_???", XT_INDEXED);
KEY_MAX, "KEY_???");
case _IOC_NR(EVIOCGLED(0)):
return decode_bitset(tcp, arg, evdev_leds,
LED_MAX, "LED_???", XT_INDEXED);
LED_MAX, "LED_???");
}
/* multi-number fixed-length commands */

View File

@ -4,14 +4,34 @@
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#ifdef HAVE_LINUX_INPUT_H
# include DEF_MPERS_TYPE(struct_ff_effect)
#include DEF_MPERS_TYPE(struct_ff_effect)
# include <linux/ioctl.h>
# include <linux/input.h>

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2007 Ulrich Drepper <drepper@redhat.com>
* Copyright (c) 2008-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2008-2015 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -9,7 +9,27 @@
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -2,20 +2,40 @@
* Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_F_OWNER_EX_H
# define STRACE_F_OWNER_EX_H
#define STRACE_F_OWNER_EX_H
# include <linux/fcntl.h>
#include <linux/fcntl.h>
# if defined HAVE_STRUCT_F_OWNER_EX
#if defined HAVE_STRUCT_F_OWNER_EX
typedef struct f_owner_ex struct_kernel_f_owner_ex;
# elif defined HAVE_STRUCT___KERNEL_F_OWNER_EX
#elif defined HAVE_STRUCT___KERNEL_F_OWNER_EX
typedef struct __kernel_f_owner_ex struct_kernel_f_owner_ex;
# else
# error struct f_owner_ex definition not found in <linux/fcntl.h>
# endif
#else
# error struct f_owner_ex definition not found in <linux/fcntl.h>
#endif
#endif /* !STRACE_F_OWNER_EX_H */

View File

@ -5,10 +5,30 @@
* Copyright (c) 2009 Andreas Schwab <schwab@redhat.com>
* Copyright (c) 2009 Kirill A. Shutemov <kirill@shutemov.name>
* Copyright (c) 2011-2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2014-2018 The strace developers.
* Copyright (c) 2014-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#ifdef HAVE_LINUX_FALLOC_H

View File

@ -3,10 +3,31 @@
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include "print_fields.h"
#include "xlat/fan_classes.h"
#include "xlat/fan_init_flags.h"
@ -17,6 +38,236 @@
#ifndef FAN_NOFD
# define FAN_NOFD -1
#endif
#ifndef FAN_AUDIT
# define FAN_AUDIT 0x10
#endif
#include "xlat/fan_mark_flags.h"
#include "xlat/fan_event_flags.h"
#include "xlat/fan_responses.h"
static void
print_fanfd(struct tcb *tcp, int fd)
{
if (fd == FAN_NOFD)
print_xlat_d(FAN_NOFD);
else
printfd(tcp, fd);
}
#define PRINT_FIELD_FANFD(prefix_, where_, field_, tcp_) \
do { \
STRACE_PRINTF("%s%s=", (prefix_), #field_); \
print_fanfd((tcp_), (where_).field_); \
} while (0)
bool
decode_fanotify_read(struct tcb *tcp, int fd, const char *fdpath,
enum fileops op, kernel_ulong_t addr,
kernel_ulong_t addrlen)
{
struct fev_hdr {
uint32_t event_len;
union {
struct {
uint8_t vers;
uint8_t reserved;
uint16_t metadata_len;
};
uint32_t vers_v2;
};
} fev_hdr;
uint32_t fev_ver = 0;
union fev_md {
struct fev_md_v2 {
uint64_t ATTRIBUTE_ALIGNED(8) mask;
int32_t fd;
int32_t pid;
} v2;
struct fev_md_v1 {
int32_t fd;
uint64_t ATTRIBUTE_ALIGNED(8) mask;
int64_t pid;
} ATTRIBUTE_PACKED v1;
} fev_md;
enum {
FEV_V1_SIZE = sizeof(struct fev_hdr) + sizeof(struct fev_md_v1),
FEV_V2_SIZE = sizeof(struct fev_hdr) + sizeof(struct fev_md_v2),
FEV_MIN_SIZE = MIN(FEV_V1_SIZE, FEV_V2_SIZE),
};
kernel_ulong_t pos = 0;
if (addrlen < sizeof(fev_hdr))
return false;
tprints("[");
do {
if (pos)
tprints(", ");
if (umove(tcp, addr + pos, &fev_hdr)) {
printaddr_comment(addr + pos);
break;
}
PRINT_FIELD_U("{", fev_hdr, event_len);
if (fev_hdr.event_len < FEV_MIN_SIZE) {
tprints(", ... /* invalid event_len */}");
if (!fev_hdr.event_len)
goto end_decoded;
goto end_fev_decoded;
}
switch (fev_hdr.vers) {
case 0: case 1: case 2:
switch (fev_hdr.vers_v2) {
case 1: case 2:
PRINT_FIELD_U(", ", fev_hdr, vers_v2);
fev_ver = fev_hdr.vers;
break;
default:
tprints("}");
pos += offsetof(struct fev_hdr, vers_v2);
goto end_decoded;
}
break;
case 3: default:
PRINT_FIELD_U(", ", fev_hdr, vers);
fev_ver = fev_hdr.vers;
if (fev_hdr.reserved)
PRINT_FIELD_U(", ", fev_hdr, reserved);
PRINT_FIELD_U(", ", fev_hdr, metadata_len);
if (fev_hdr.metadata_len < FEV_V2_SIZE) {
tprints(", ... /* invalid metadata_len */}");
goto end_fev_decoded;
}
}
if (fev_ver < 1 || fev_ver > 3) {
tprints(", ... /* invalid vers */}");
goto end_fev_decoded;
}
switch (fev_ver) {
case 1:
if (umove(tcp, addr + pos + sizeof(fev_hdr),
&fev_md.v1)) {
printf(", ...}");
pos += sizeof(fev_hdr);
goto end_decoded;
}
PRINT_FIELD_FANFD(", ", fev_md.v1, fd, tcp);
PRINT_FIELD_FLAGS(", ", fev_md.v1, mask,
fan_event_flags, "FAN_???");
PRINT_FIELD_D(", ", fev_md.v1, pid);
if (FEV_V1_SIZE < fev_hdr.event_len) {
tprints(", ");
printstrn(tcp, addr + pos,
fev_hdr.event_len - FEV_V1_SIZE);
}
break;
case 2: case 3:
if (umove(tcp, addr + pos + sizeof(fev_hdr),
&fev_md.v2)) {
printf(", ...}");
pos += sizeof(fev_hdr);
goto end_decoded;
}
PRINT_FIELD_FLAGS(", ", fev_md.v2, mask,
fan_event_flags, "FAN_???");
PRINT_FIELD_FANFD(", ", fev_md.v2, fd, tcp);
PRINT_FIELD_D(", ", fev_md.v2, pid);
if (FEV_V2_SIZE < fev_hdr.event_len) {
tprints(", ");
printstrn(tcp, addr + pos,
fev_hdr.event_len - FEV_V2_SIZE);
}
}
tprints("}");
end_fev_decoded:
pos += fev_hdr.event_len;
} while (pos <= addrlen - sizeof(fev_hdr));
end_decoded:
if (pos < addrlen) {
if (pos)
tprints(", ");
printstrn(tcp, addr + pos, addrlen - pos);
}
tprints("]");
return true;
}
bool
decode_fanotify_write(struct tcb *tcp, int fd, const char *fdpath,
enum fileops op, kernel_ulong_t addr,
kernel_ulong_t addrlen)
{
struct fresp {
int32_t fd;
uint32_t response;
} fresp;
kernel_ulong_t pos = 0;
if (addrlen < sizeof(fresp))
return false;
tprints("[");
do {
if (pos)
tprints(", ");
if (umove(tcp, addr + pos, &fresp)) {
printaddr_comment(addr + pos);
break;
}
PRINT_FIELD_FD("{", fresp, fd, tcp);
tprints(", response=");
if (fresp.response | FAN_AUDIT) {
print_xlat(FAN_AUDIT);
tprints("|");
}
printxval(fan_responses, fresp.response, "FAN_???");
tprints("}");
pos += sizeof(fresp);
} while (pos <= addrlen - sizeof(fresp));
if (pos < addrlen) {
if (pos)
tprints(", ");
printstrn(tcp, addr + pos, addrlen - pos);
}
tprints("]");
return true;
}
SYS_FUNC(fanotify_init)
{
@ -34,9 +285,6 @@ SYS_FUNC(fanotify_init)
return RVAL_DECODED | RVAL_FD;
}
#include "xlat/fan_mark_flags.h"
#include "xlat/fan_event_flags.h"
SYS_FUNC(fanotify_mark)
{
printfd(tcp, tcp->u_arg[0]);

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(fchownat)

69
fcntl.c
View File

@ -6,7 +6,27 @@
* Copyright (c) 1999-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -14,6 +34,7 @@
#include "xlat/f_owner_types.h"
#include "xlat/f_seals.h"
#include "xlat/fcntl_rw_hints.h"
#include "xlat/fcntlcmds.h"
#include "xlat/fdflags.h"
#include "xlat/lockfcmds.h"
@ -64,6 +85,32 @@ print_f_owner_ex(struct tcb *const tcp, const kernel_ulong_t addr)
tprintf(", pid=%d}", owner.pid);
}
static void
print_rwhint(struct tcb *const tcp, const kernel_ulong_t addr)
{
uint64_t hint;
if (umove_or_printaddr(tcp, addr, &hint))
return;
tprints("[");
printxval(fcntl_rw_hints, hint, "RWH_WRITE_LIFE_???");
tprints("]");
}
static void
print_owner_uids(struct tcb *const tcp, const kernel_ulong_t addr)
{
uint32_t uids[2];
if (umove_or_printaddr(tcp, addr, uids))
return;
printuid("[", uids[0]); /* Real */
printuid(", ", uids[1]); /* Effective */
tprints("]");
}
static int
print_fcntl(struct tcb *tcp)
{
@ -116,6 +163,11 @@ print_fcntl(struct tcb *tcp)
tprints(", ");
printsignal(tcp->u_arg[2]);
break;
case F_SET_RW_HINT:
case F_SET_FILE_RW_HINT:
tprints(", ");
print_rwhint(tcp, tcp->u_arg[2]);
break;
case F_GETOWN:
case F_GETPIPE_SZ:
break;
@ -159,11 +211,26 @@ print_fcntl(struct tcb *tcp)
tcp->auxstr = sprintflags("seals ", f_seals,
(kernel_ulong_t) tcp->u_rval);
return RVAL_HEX | RVAL_STR;
case F_GET_RW_HINT:
case F_GET_FILE_RW_HINT:
if (entering(tcp)) {
tprints(", ");
return 0;
}
print_rwhint(tcp, tcp->u_arg[2]);
break;
case F_GETSIG:
if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
return 0;
tcp->auxstr = signame(tcp->u_rval);
return RVAL_STR;
case F_GETOWNER_UIDS:
if (entering(tcp)) {
tprints(", ");
return 0;
}
print_owner_uids(tcp, tcp->u_arg[2]);
break;
default:
tprintf(", %#" PRI_klx, tcp->u_arg[2]);
break;

View File

@ -1,8 +1,28 @@
/*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -2,7 +2,27 @@
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2018 The strace developers.
* Copyright (c) 2015-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2016-2018 Eugene Syromyatnikov <evgsyr@gmail.com>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#include DEF_MPERS_TYPE(struct_keyctl_kdf_params)

View File

@ -1,8 +1,28 @@
/*
* Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,8 +1,28 @@
/*
* Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016-2018 The strace developers.
* Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016-2018 The strace developers.
* Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016-2018 The strace developers.
* Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#include DEF_MPERS_TYPE(struct_xfs_dqstats)

View File

@ -1,9 +1,4 @@
#!/bin/sh
#
# Copyright (c) 2017-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
#! /bin/sh
if [ "$1" = "-f" ]; then
shift
@ -27,7 +22,7 @@ date=
[ -f "${DATE_FILE}" ] && date="$(cat "${DATE_FILE}")"
[ -n "${date}" ] ||
date="$(git log -s -n 1 --format=format:%cD "${FILE}")"
date="$(git log -n 1 --format=format:%cD --no-patch "${FILE}")"
[ -n "${date}" ] ||
date="${DEFAULT_DATE}"

View File

@ -1,9 +1,29 @@
/*
* Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2018 The strace developers.
* Copyright (c) 2015-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -3,7 +3,27 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -3,11 +3,31 @@
* Copyright (c) 2017-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_FILTER_H
# define STRACE_FILTER_H
#define STRACE_FILTER_H
struct number_set;
typedef int (*string_to_uint_func)(const char *);

View File

@ -3,7 +3,27 @@
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -28,30 +48,55 @@ struct inject_personality_data {
uint16_t scno;
};
struct alt_name {
const char *syn;
const char *orig;
};
#define _(a_, b_) { (a_), (b_) }
static const struct alt_name alt_signames[] = {
#include "linux/alt_signalent.h"
};
static const struct alt_name alt_errnames[] = {
#include "linux/alt_signalent.h"
};
#undef _
static bool
signame_eq(const char *needle, const char *straw)
{
if (strncasecmp(straw, "SIG", 3) != 0)
return false;
straw += 3;
if (strncasecmp(needle, "SIG", 3) == 0)
needle += 3;
return (strcasecmp(needle, straw) == 0);
}
static int
sigstr_to_uint(const char *s)
{
for (size_t i = 0; i < ARRAY_SIZE(alt_signames); i++) {
if (!signame_eq(s, alt_signames[i].syn)) {
error_msg("Signal name \"%s\" is selected instead of "
"synonymous \"%s\"",
alt_signames[i].orig, s);
s = alt_signames[i].orig;
break;
}
}
if (*s >= '0' && *s <= '9')
return string_to_uint_upto(s, 255);
return string_to_uint_upto(s, nsig);
if (strncasecmp(s, "SIG", 3) == 0)
s += 3;
for (int i = 1; i <= 255; ++i) {
const char *name = signame(i);
if (!name)
continue;
if (strncasecmp(name, "SIG", 3) != 0)
continue;
name += 3;
if (strcasecmp(name, s) != 0)
continue;
return i;
for (size_t i = 1; i <= nsig; i++) {
if (signame_eq(s, signame(i)))
return i;
}
return -1;
@ -60,6 +105,16 @@ sigstr_to_uint(const char *s)
static int
find_errno_by_name(const char *name)
{
for (unsigned int i = 0; i < ARRAY_SIZE(alt_errnames); ++i) {
if (!strcasecmp(name, alt_errnames[i].syn)) {
error_msg("Error name \"%s\" is selected instead of "
"synonymous \"%s\"",
alt_errnames[i].orig, name);
name = alt_errnames[i].orig;
break;
}
}
for (unsigned int i = 1; i < nerrnos; ++i) {
if (errnoent[i] && (strcasecmp(name, errnoent[i]) == 0))
return i;
@ -75,14 +130,15 @@ parse_delay_token(const char *input, struct inject_opts *fopts, bool isenter)
if (fopts->data.flags & flag) /* duplicate */
return false;
long long intval = string_to_ulonglong(input);
if (intval < 0) /* couldn't parse */
struct timespec tsval;
if (parse_ts(input, &tsval) < 0) /* couldn't parse */
return false;
if (fopts->data.delay_idx == (uint16_t) -1)
fopts->data.delay_idx = alloc_delay_data();
/* populate .ts_enter or .ts_exit */
fill_delay_data(fopts->data.delay_idx, intval, isenter);
fill_delay_data(fopts->data.delay_idx, &tsval, isenter);
fopts->data.flags |= flag;
return true;

24
flock.c
View File

@ -3,10 +3,30 @@
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 1999-2018 The strace developers.
* Copyright (c) 1999-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

48
flock.h
View File

@ -1,30 +1,50 @@
/*
* Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2015-2018 The strace developers.
* Copyright (c) 2015-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_FLOCK_H
# define STRACE_FLOCK_H
#define STRACE_FLOCK_H
# include <linux/fcntl.h>
#include <linux/fcntl.h>
# if defined HAVE_STRUCT_FLOCK
#if defined HAVE_STRUCT_FLOCK
typedef struct flock struct_kernel_flock;
# elif defined HAVE_STRUCT___KERNEL_FLOCK
#elif defined HAVE_STRUCT___KERNEL_FLOCK
typedef struct __kernel_flock struct_kernel_flock;
# else
# error struct flock definition not found in <linux/fcntl.h>
# endif
#else
# error struct flock definition not found in <linux/fcntl.h>
#endif
# if defined HAVE_STRUCT_FLOCK64
#if defined HAVE_STRUCT_FLOCK64
typedef struct flock64 struct_kernel_flock64;
# elif defined HAVE_STRUCT___KERNEL_FLOCK64
#elif defined HAVE_STRUCT___KERNEL_FLOCK64
typedef struct __kernel_flock64 struct_kernel_flock64;
# else
# error struct flock64 definition not found in <linux/fcntl.h>
# endif
#else
# error struct flock64 definition not found in <linux/fcntl.h>
#endif
#endif /* !STRACE_FLOCK_H */

View File

@ -1,10 +1,30 @@
/*
* Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
* Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016-2018 The strace developers.
* Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(fstatfs)

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(fstatfs64)

81
futex.c
View File

@ -6,7 +6,27 @@
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
@ -20,17 +40,45 @@
#ifndef FUTEX_OP_OPARG_SHIFT
# define FUTEX_OP_OPARG_SHIFT 8
#endif
#ifndef FUTEX_TID_MASK
# define FUTEX_TID_MASK 0x3fffffffU
#endif
#include "xlat/futexbitset.h"
#include "xlat/futexops.h"
#include "xlat/futexpiflags.h"
#include "xlat/futexwakeops.h"
#include "xlat/futexwakecmps.h"
static void
printaddrnum(struct tcb *tcp, kernel_ulong_t addr)
{
printnum_int_ex(tcp, addr, true, "%#x");
}
static void
printaddrpival(struct tcb *tcp, kernel_ulong_t addr)
{
uint32_t tid;
if (umove_or_printaddr(tcp, addr, &tid))
return;
tprints("[");
if (tid & ~FUTEX_TID_MASK) {
printflags(futexpiflags, tid & ~FUTEX_TID_MASK, NULL);
tprints("|");
}
tprintf("%u]", tid & FUTEX_TID_MASK);
printaddr_comment(addr);
}
SYS_FUNC(futex)
{
const kernel_ulong_t uaddr = tcp->u_arg[0];
const int op = tcp->u_arg[1];
const int cmd = op & 127;
const bool is_rt = op & FUTEX_CLOCK_REALTIME;
const kernel_ulong_t timeout = tcp->u_arg[3];
const kernel_ulong_t uaddr2 = tcp->u_arg[4];
const unsigned int val = tcp->u_arg[2];
@ -38,23 +86,33 @@ SYS_FUNC(futex)
const unsigned int val3 = tcp->u_arg[5];
const char *comment;
printaddr(uaddr);
switch (cmd) {
case FUTEX_LOCK_PI:
case FUTEX_UNLOCK_PI:
case FUTEX_TRYLOCK_PI:
printaddrpival(tcp, uaddr);
break;
default:
printaddrnum(tcp, uaddr);
}
tprints(", ");
printxval(futexops, op, "FUTEX_???");
switch (cmd) {
case FUTEX_WAIT:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
/* timeout in FUTEX_WAIT is relative, contrary to other ops */
print_timespec(tcp, timeout, false);
break;
case FUTEX_LOCK_PI:
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, true);
break;
case FUTEX_WAIT_BITSET:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, is_rt);
tprints(", ");
printxval(futexbitset, val3, NULL);
break;
@ -66,19 +124,20 @@ SYS_FUNC(futex)
case FUTEX_REQUEUE:
tprintf(", %u", val);
tprintf(", %u, ", val2);
printaddr(uaddr2);
printaddrnum(tcp, uaddr2);
break;
case FUTEX_CMP_REQUEUE:
case FUTEX_CMP_REQUEUE_PI:
tprintf(", %u", val);
tprintf(", %u, ", val2);
printaddr(uaddr2);
(cmd == FUTEX_CMP_REQUEUE ? printaddrnum
: printaddrpival)(tcp, uaddr2);
tprintf(", %u", val3);
break;
case FUTEX_WAKE_OP:
tprintf(", %u", val);
tprintf(", %u, ", val2);
printaddr(uaddr2);
printaddrnum(tcp, uaddr2);
tprints(", ");
if ((val3 >> 28) & FUTEX_OP_OPARG_SHIFT) {
print_xlat(FUTEX_OP_OPARG_SHIFT);
@ -98,11 +157,13 @@ SYS_FUNC(futex)
case FUTEX_WAIT_REQUEUE_PI:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, is_rt);
tprints(", ");
printaddr(uaddr2);
printaddrpival(tcp, uaddr2);
break;
case FUTEX_FD:
tprintf(", %u", val);
return RVAL_DECODED | RVAL_FD;
case FUTEX_WAKE:
tprintf(", %u", val);
break;

View File

@ -3,118 +3,119 @@
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRACE_GCC_COMPAT_H
# define STRACE_GCC_COMPAT_H
#define STRACE_GCC_COMPAT_H
# if defined __GNUC__ && defined __GNUC_MINOR__
# define GNUC_PREREQ(maj, min) \
#if defined __GNUC__ && defined __GNUC_MINOR__
# define GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define GNUC_PREREQ(maj, min) 0
# endif
#else
# define __attribute__(x) /* empty */
# define GNUC_PREREQ(maj, min) 0
#endif
# if defined __clang__ && defined __clang_major__ && defined __clang_minor__
# define CLANG_PREREQ(maj, min) \
((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
# else
# define CLANG_PREREQ(maj, min) 0
# endif
#if GNUC_PREREQ(2, 5)
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
#else
# define ATTRIBUTE_NORETURN /* empty */
#endif
# if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
# define __attribute__(x) /* empty */
# endif
#if GNUC_PREREQ(2, 7)
# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
# define ATTRIBUTE_PACKED __attribute__((__packed__))
#else
# define ATTRIBUTE_FORMAT(args) /* empty */
# define ATTRIBUTE_ALIGNED(arg) /* empty */
# define ATTRIBUTE_PACKED /* empty */
#endif
# if GNUC_PREREQ(2, 5)
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
# else
# define ATTRIBUTE_NORETURN /* empty */
# endif
# if GNUC_PREREQ(2, 7)
# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
# define ATTRIBUTE_PACKED __attribute__((__packed__))
# else
# define ATTRIBUTE_FORMAT(args) /* empty */
# define ATTRIBUTE_ALIGNED(arg) /* empty */
# define ATTRIBUTE_PACKED /* empty */
# endif
# if GNUC_PREREQ(3, 0)
# define SAME_TYPE(x, y) __builtin_types_compatible_p(typeof(x), typeof(y))
# define FAIL_BUILD_ON_ZERO(expr) (sizeof(int[-1 + 2 * !!(expr)]) * 0)
#if GNUC_PREREQ(3, 0)
# define SAME_TYPE(x, y) __builtin_types_compatible_p(typeof(x), typeof(y))
# define FAIL_BUILD_ON_ZERO(expr) (sizeof(int[-1 + 2 * !!(expr)]) * 0)
/* &(a)[0] is a pointer and not an array, shouldn't be treated as the same */
# define MUST_BE_ARRAY(a) FAIL_BUILD_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
# else
# define SAME_TYPE(x, y) 0
# define MUST_BE_ARRAY(a) 0
# endif
# define MUST_BE_ARRAY(a) FAIL_BUILD_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
#else
# define SAME_TYPE(x, y) 0
# define MUST_BE_ARRAY(a) 0
#endif
# if GNUC_PREREQ(3, 0)
# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
# else
# define ATTRIBUTE_MALLOC /* empty */
# endif
#if GNUC_PREREQ(3, 0)
# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
#else
# define ATTRIBUTE_MALLOC /* empty */
#endif
# if GNUC_PREREQ(3, 1)
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
# else
# define ATTRIBUTE_NOINLINE /* empty */
# endif
#if GNUC_PREREQ(3, 1)
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
#else
# define ATTRIBUTE_NOINLINE /* empty */
#endif
# if GNUC_PREREQ(4, 0)
# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
# else
# define ATTRIBUTE_SENTINEL /* empty */
# endif
#if GNUC_PREREQ(4, 0)
# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
#else
# define ATTRIBUTE_SENTINEL /* empty */
#endif
# if GNUC_PREREQ(4, 1)
# define ALIGNOF(t_) __alignof__(t_)
# else
# define ALIGNOF(t_) (sizeof(struct { char x_; t_ y_; }) - sizeof(t_))
# endif
#if GNUC_PREREQ(4, 1)
# define ALIGNOF(t_) __alignof__(t_)
#else
# define ALIGNOF(t_) (sizeof(struct { char x_; t_ y_; }) - sizeof(t_))
#endif
# if GNUC_PREREQ(4, 3)
# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
# else
# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
# endif
#if GNUC_PREREQ(4, 1)
# define CMPXCHG(val_, old_, new_) \
__sync_bool_compare_and_swap((val_), (old_), (new_))
#else
# define CMPXCHG(val_, old_, new_) \
((val_) == (old_) ? (val_) = (new_), true : false)
#endif
# if GNUC_PREREQ(7, 0)
# define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__))
# else
# define ATTRIBUTE_FALLTHROUGH ((void) 0)
# endif
#if GNUC_PREREQ(4, 3)
# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
#else
# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
#endif
# if CLANG_PREREQ(2, 8)
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT \
_Pragma("clang diagnostic push"); \
_Pragma("clang diagnostic ignored \"-Winitializer-overrides\"");
# define DIAG_POP_IGNORE_OVERRIDE_INIT \
_Pragma("clang diagnostic pop");
# elif GNUC_PREREQ(4, 2)
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Woverride-init\"");
# define DIAG_POP_IGNORE_OVERRIDE_INIT \
_Pragma("GCC diagnostic pop");
# else
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT /* empty */
# define DIAG_POP_IGNORE_OVERRIDE_INIT /* empty */
# endif
#if GNUC_PREREQ(7, 0)
# define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__))
#else
# define ATTRIBUTE_FALLTHROUGH ((void) 0)
#endif
# if GNUC_PREREQ(6, 0)
# define DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE \
#if GNUC_PREREQ(6, 0)
# define DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wtautological-compare\"");
# define DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE \
# define DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE \
_Pragma("GCC diagnostic pop");
# else
# define DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE /* empty */
# define DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE /* empty */
# endif
#else
# define DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE /* empty */
# define DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE /* empty */
#endif
#endif /* !STRACE_GCC_COMPAT_H */

View File

@ -2,7 +2,27 @@
# Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
input="$1"
shift

82
gen_ptp_clock_check.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/sh -efu
# Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
input="$1"
shift
cat <<EOF
/* Generated by $0 from $input; do not edit. */
#include "defs.h"
#ifdef HAVE_LINUX_PTP_CLOCK_H
# include <linux/ptp_clock.h>
# include "ptp_clock.h"
# include "static_assert.h"
# define SoM(type_, member_) (sizeof(((type_ *)0)->member_))
EOF
for struct in $(sed -n 's/^struct \(strace_ptp_[^[:space:]]\+\) .*/\1/p' < "$input"); do
type_name="struct ${struct#strace_}"
TYPE_NAME="$(printf %s "$type_name" |tr '[:lower:] ' '[:upper:]_')"
sed -n '/^'"struct $struct"' [^{]*{$/,/^};$/p' < "$input" |
sed -n 's/^[[:space:]]\+[^][;]*[[:space:]]\([^][[:space:];]\+\)\(\[[^;]*\]\)\?;$/\1/p' |
while read field; do
FIELD="$(printf %s "$field" |tr '[:lower:]' '[:upper:]')"
if [ "rsv" = "$field" ]; then
cat <<EOF
# ifdef HAVE_${TYPE_NAME}_$FIELD
static_assert(SoM(struct $struct, $field) <= SoM($type_name, $field),
"$struct.$field is bigger than in system headers");
# endif /* HAVE_${TYPE_NAME}_$FIELD */
EOF
continue;
fi
cat <<EOF
# ifdef HAVE_${TYPE_NAME}_$FIELD
static_assert(SoM(struct $struct, $field) == SoM($type_name, $field),
"$struct.$field size mismatch");
static_assert(offsetof(struct $struct, $field) == offsetof($type_name, $field),
"$struct.$field offset mismatch");
# endif /* HAVE_${TYPE_NAME}_$FIELD */
EOF
done
cat <<EOF
static_assert(${struct}_size == expected_${struct}_size,
"${struct}_size mismatch");
EOF
done
cat <<'EOF'
#endif /* HAVE_LINUX_BPF_H */
EOF

View File

@ -1,9 +1,4 @@
#!/bin/sh -e
#
# Copyright (c) 2015-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
list="$(sed -r -n '/^strace_SOURCES[[:space:]]*=/,/^[[:space:]]*# end of strace_SOURCES/ s/^[[:space:]]*([[:alnum:]][^.]*\.c)[[:space:]]*\\$/\1/p' Makefile.am |
xargs -r grep -Elx '#[[:space:]]*include[[:space:]]+MPERS_DEFS' |

View File

@ -1,9 +1,4 @@
#!/bin/sh -e
#
# Copyright (c) 2015-2018 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later
echo 'enum {'
echo 'SEN_printargs = 0,'

View File

@ -1,14 +0,0 @@
/*
* Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#if SUPPORTED_PERSONALITIES > 1
# include "get_personality.h"
# include <linux/audit.h>
# include "arch_get_personality.c"
#endif

View File

@ -1,16 +0,0 @@
/*
* Copyright (c) 2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef STRACE_GET_PERSONALITY_H
# define STRACE_GET_PERSONALITY_H
# include "ptrace.h"
extern int
get_personality_from_syscall_info(const struct ptrace_syscall_info *);
#endif /* !STRACE_GET_PERSONALITY_H */

View File

@ -1,18 +1,89 @@
/*
* Copyright (c) 2012-2018 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2012-2015 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include DEF_MPERS_TYPE(struct_robust_list_head)
#include <linux/futex.h>
typedef struct robust_list_head struct_robust_list_head;
#include MPERS_DEFS
#include "print_fields.h"
static void
decode_robust_list(struct tcb *tcp, kernel_ulong_t addr, kernel_ulong_t len)
{
struct_robust_list_head rl;
if (len < sizeof(rl)) {
printaddr(addr);
return;
}
if (umove_or_printaddr(tcp, addr, &rl))
return;
PRINT_FIELD_PTR("{list={", rl.list, next);
PRINT_FIELD_D("}, ", rl, futex_offset);
PRINT_FIELD_PTR(", ", rl, list_op_pending);
if (len > sizeof(rl))
tprints(", /* ??? */");
tprints("}");
printaddr_comment(addr);
}
SYS_FUNC(set_robust_list)
{
decode_robust_list(tcp, tcp->u_arg[0], tcp->u_arg[1]);
tprintf(", %lu", (unsigned long) tcp->u_arg[1]);
return RVAL_DECODED;
}
SYS_FUNC(get_robust_list)
{
if (entering(tcp)) {
tprintf("%d, ", (int) tcp->u_arg[0]);
} else {
printnum_ptr(tcp, tcp->u_arg[1]);
mpers_ptr_t rl_ptr;
mpers_ptr_t len = 0;
if (!umove_or_printaddr(tcp, tcp->u_arg[1], &rl_ptr)) {
tprints("[");
if (!umove(tcp, tcp->u_arg[2], &len))
decode_robust_list(tcp, rl_ptr, len);
else
printaddr(tcp->u_arg[1]);
tprints("]");
}
tprints(", ");
printnum_ulong(tcp, tcp->u_arg[2]);
}

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(getcpu)

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2014-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(getcwd)

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
SYS_FUNC(getpagesize)

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#include "xlat/getrandom_flags.h"

23
glibc_compat.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef STRACE_GLIBC_COMPAT_H
#define STRACE_GLIBC_COMPAT_H
#if defined __GLIBC__
# ifndef __GLIBC_MINOR__
# warning "__GLIBC__ is defined, but __GLIBC_MINOR__ isn't"
# define __GLIBC_MINOR__ 0
# endif /* __GLIBC_MINOR__ */
# ifdef __GLIBC_PREREQ
# define GLIBC_PREREQ __GLIBC_PREREQ
# else
# define GLIBC_PREREQ(maj, min) \
((((__GLIBC__) << 16) + (__GLIBC_MINOR__)) >= (((maj) << 16) + (min)))
# endif /* __GLIBC_PREREQ */
# define GLIBC_OLDER(maj, min) (!GLIBC_PREREQ((maj), (min)))
#else /* !__GLIBC__ */
# define GLIBC_PREREQ(maj, min) 0
# define GLIBC_OLDER(maj, min) 0
#endif
#endif /* STRACE_GLIBC_COMPAT_H */

Some files were not shown because too many files have changed in this diff Show More