Compare commits

..

35 Commits

Author SHA1 Message Date
cff0b9e5ca tests: add kill_child test
This tests repeatedly creates and kills children, so some corner
cases in handling of not-quite-existing processes can be observed.

Previously, strace was crashing in the following situation:

    13994 ????( <unfinished ...>
    ...
    13994 <... ???? resumed>) = ?

as tcp->s_ent wasn't initialised on syscall entering and
strace.c:print_event_exit segfaulted when tried to access
tcp->s_ent->sys_name.

* tests/kill_child.c: New file.
* tests/kill_child.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add kill_child.
(MISC_TESTS): Add kill_child.test.
2019-02-01 12:40:58 +01:00
5cf7f16bad syscall.c: set MEMORY_MAPPING_CHANGE in stub sysent
As unknown syscalls may incur unknown side effects.

* syscall.c (stub_sysent): Set sys_flags to MEMORY_MAPPING_CHANGE.
2019-02-01 12:40:58 +01:00
762abe0ce3 Use accessors for tcp->s_ent, return a stub struct if it is NULL
Since code paths are non-trivial, it's an attempt to future-proof and
prevent improper access of tcp->s_ent fields.

* defs.h (struct tcb): Update the description of s_ent field.
(stub_sysent): New declaration.
(tcp_sysent, n_args): New macro functions.
* ipc.c (SYS_FUNC(ipc)): Use n_args() instead of tcp->s_ent->nargs.
* linux/alpha/get_syscall_args.c (get_syscall_args): Likewise.
* linux/bfin/get_syscall_args.c (get_syscall_args): Likewise.
* linux/hppa/get_syscall_args.c (get_syscall_args): Likewise.
* linux/ia64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/microblaze/get_syscall_args.c (get_syscall_args): Likewise.
* linux/mips/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh/get_syscall_args.c (get_syscall_args): Likewise.
* linux/sh64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/xtensa/get_syscall_args.c (get_syscall_args): Likewise.
* prctl.c (print_prctl_args): Likewise.
* signal.c (SYS_FUNC(sgetmask)): Likewise.
* util.c (printargs, printargs_u, printargs_d): Likewise.
* syscall.c (decode_ipc_subcall, decode_syscall_subcall: Likewise.
(dumpio, tamper_with_syscall_exiting, syscall_entering_decode,
syscall_entering_decode, syscall_entering_trace, syscall_entering_trace,
syscall_exiting_decode, print_syscall_resume, syscall_exiting_trace,
get_syscall_result): Use tcp_sysent instead of tcp->s_ent().
(stub_sysent): New stub sysent.
(get_scno): Reset scno, s_ent, qual_flg; initialise s->ent from
stub_sysent.
* pathtrace.c (pathtrace_match_set): Use tcp_sysent instead of
tcp->s_ent().
2019-02-01 12:40:58 +01:00
8c015ef905 syscall.c: remove arch check for SEN_execv usage
SEN_* decalrations are always present and can be used regardless
of architecture.

* syscall.c (syscall_entering_trace): Remove "#if defined SPARC ||
defined SPARC64" guard.
2019-02-01 12:40:58 +01:00
fc6c6578dc Merge "<... resumed>" printing
Apparently, it was slightly different with no apparent reason. Use
a single routine to print this message now.

* defs.h (print_syscall_resume): New function declaration.
* strace.c (print_event_exit): Replace open-coding of "<... resumed>"
message printing with a print_syscall_resume() call.
* syscall.c (syscall_exiting_trace): Likewise.
(print_syscall_resume): New function.
* tests/threads-execve.c: Update expected output.
2019-02-01 12:40:57 +01:00
756ccfa00b Implement queueing of threads before dispatching them
It is possible that some tracees call a lot of cheap syscalls too fast,
and that can lead to starvation to the point some tracees are not served
for indefinite amount of time.  In order to solve that unfairness, try
to collect all the pending tracees first along with the relevant
information and only then dispatch the events.

* defs.h: Include "list.h".
(struct tcb): Add wait_data_idx and wait_list fields.
* strace.c (struct tcb_wait_data): Add "msg" field.
(tcb_wait_tab): New static variable.
(expand_tcbtab): Resize tcb_wait_tab along with tcbtab, provide
an additional slot for extra event.
(droptcb): Remove tcp from wait_list.
(maybe_switch_tcbs): Get old pid from
tcb_wait_tab[tcp->wait_data_idx].msg.
(next_event): Add pending_tcps, extra_tcp, wait_nohang, elem, and
wait_tab_pos variables; check for elements in pending_tcps and skip
waiting if the list is not empty; check for extra_tcp and skip waiting
along with swapping wait_data_idx with wait_extra_data_idx;
after the initial wait, call wait4() in loop with WNOHANG flag set;
fetch siginfo on signal and eventmsg on PTRACE_EVENT_EXEC;
return the first tcp in pending_tcps list.
* tests/Makefile.am (XFAIL_TEST): Remove looping_threads.test.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=478419
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=526740
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=851457
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1609318
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1610774
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Co-Authored-by: Denys Vlasenko <dvlasenk@redhat.com>
Co-Authored-by: Andreas Schwab <aschwab@redhat.com>
Co-Authored-by: Jeff Law <law@redhat.com>
Co-Authored-by: DJ Delorie <dj@redhat.com>
2019-02-01 12:40:57 +01:00
1bff0fadad Add a generic list implementation
Similar to the one used in the Linux kernel.

* macros.h (cast_ptr, containerof): New macros.
* list.h: New file.
* Makefile.am (strace_SOURCES): Add it.
2019-02-01 12:40:29 +01:00
c1838de552 tests: check tracing of looping threads
* test/many_looping_threads.c: Remove.
* test/.gitignore: Remove many_looping_threads.
* test/Makefile (PROGS): Likewise.
(many_looping_threads): Remove.
* tests/looping_threads.c: New file.
* tests/looping_threads.test: New test.
* tests/.gitignore: Add looping_threads.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(looping_threads_LDADD): New variable.
(MISC_TESTS, XFAIL_TESTS): Add looping_threads.test.
2019-01-29 15:39:18 +01:00
2c8b6de913 mips o32: fix build
Commit 917c2ccf3a "Refactor stack pointers" moved mips_REG_* macros
from linux/mips/arch_regs.h to linux/mips/arch_regs.c because these
macros are no longer used outside syscall.c or files included by
syscall.c, but this caused a build regression on mips o32 because
decode_syscall_subcall() uses mips_REG_SP prior to its definition.

* syscall.c (decode_syscall_subcall): Move ...
* linux/mips/get_syscall_args.c: ... here.
* NEWS: Mention this fix.

Reported-by: Baruch Siach <baruch@tkos.co.il>
Fixes: v4.26~61 "Refactor stack pointers"
2019-01-08 02:27:18 +00:00
f414d9e3ba Fix build for no-MMU targets
Commit 7488ce9e23 "Check whether PTRACE_GET_SYSCALL_INFO is supported
by the kernel" added a fork() call in test_ptrace_get_syscall_info()
which is included in the main strace executable code.  Although the
test_ptrace_get_syscall_info() routine is not called on no-MMU targets,
the compiler can't optimize it out because it is a global symbol.
So build for no-MMU targets currently fails:

strace-ptrace_syscall_info.o: In function `test_ptrace_get_syscall_info':
ptrace_syscall_info.c:(.text+0x1c): undefined reference to `fork'

* ptrace_syscall_info.c (test_ptrace_get_syscall_info): Make
the definition depend on HAVE_FORK.
* strace.c (init): Call test_ptrace_get_syscall_info unconditionally.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.26~50 "Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel"
2019-01-08 02:27:18 +00:00
04512207ac linux/mips/.gitignore: drop copyright header
The '/*' in the first line of the copyright header matches all files in
that directory.  No other .gitignore file has this header.  Drop it.

* linux/mips/.gitignore: Remove copyright header.

Fixes: v4.26~23 "Add copyright headers to some files that lack them"
2019-01-08 02:27:18 +00:00
3798b04eab Honor xlat styles when decoding sockaddr_in, sockaddr_in6, and sockaddr_ll
* print_fields.h (PRINT_FIELD_NET_PORT): Handle xlat styles.
* sockaddr.c (print_sll_protocol): New function.
(print_sockaddr_data_ll, print_inet_addr, print_sockaddr_data_in6):
Handle xlat styles.
* NEWS: Mention this.
* tests/sockaddr_xlat.c: New file.
* tests/sockaddr_xlat-Xabbrev.c: Likewise.
* tests/sockaddr_xlat-Xraw.c: Likewise.
* tests/sockaddr_xlat-Xverbose.c: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add sockaddr_xlat.c.
* tests/gen_tests.in (sockaddr_xlat-Xabbrev, sockaddr_xlat-Xraw,
sockaddr_xlat-Xverbose): New tests.
* tests/pure_executables.list: Add sockaddr_xlat-Xabbrev,
sockaddr_xlat-Xraw, and sockaddr_xlat-Xverbose.
* tests/.gitignore: Likewise.
2019-01-08 02:27:18 +00:00
b9a262af78 Remove PRINT_FIELD_INET4_ADDR
Reduce code duplication by removing PRINT_FIELD_INET4_ADDR
and using PRINT_FIELD_INET_ADDR instead.

* print_fields.h (PRINT_FIELD_INET4_ADDR): Remove.
* msghdr.c (print_cmsg_ip_pktinfo): Use PRINT_FIELD_INET_ADDR
instead of PRINT_FIELD_INET4_ADDR.
* net.c (print_mreq): Likewise.
* sockaddr.c (print_sockaddr_data_in): Likewise.
2019-01-07 23:30:52 +00:00
bc87159e49 xlat: update REL_* constants
* xlat/evdev_relative_axes.in (REL_HWHEEL_HI_RES): New constant
introduced by Linux kernel commit v5.0-rc1~18^2^7~7.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
77265f5d49 xlat: update UDP_* constants
* xlat/sock_udp_options.in (UDP_GRO): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~379^2~8.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
88d842435e xlat: update FAN_* constants
* xlat/fan_event_flags.in (FAN_OPEN_EXEC, FAN_OPEN_EXEC_PERM): New
constants introduced by Linux kernel commits v5.0-rc1~124^2~5
and v5.0-rc1~124^2~3, respectively.
* NEWS: Mention this.
* tests/fanotify_mark.c (main): Update expected output.
2019-01-05 21:14:42 +00:00
9c529cda68 xlat: update SCTP_* constants
* xlat/sock_sctp_options.in (SCTP_EVENT): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~255^2.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
3ef1efa2d1 xlat: update IFLA_* constants
* xlat/rtnl_ifla_info_data_bridge_attrs.in (IFLA_BR_MULTI_BOOLOPT): New
constant introduced by Linux kernel commit v5.0-rc1~129^2~207^2~2.
* NEWS: Mention this.
* tests/nlattr_ifla_linkinfo.c (main): Update.
2019-01-05 21:14:42 +00:00
17a1b88f8e xlat: update NETNSA_* constants
* xlat/rtnl_nsid_attrs.in (NETNSA_TARGET_NSID, NETNSA_CURRENT_NSID): New
constants introduced by Linux kernel commits v5.0-rc1~129^2~201^2~2
and v5.0-rc1~129^2~201^2, respectively.
* rtnl_nsid.c (rtgenmsg_nla_decoders): Add NETNSA_TARGET_NSID
and NETNSA_CURRENT_NSID.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
be27e07c97 xlat: update SECCOMP_* constants
* xlat/seccomp_ops.in (SECCOMP_GET_NOTIF_SIZES): New constant introduced
by Linux kernel commit v5.0-rc1~66^2~1^2~1.
* xlat/seccomp_ret_action.in (SECCOMP_RET_USER_NOTIF): Likewise.
* xlat/seccomp_filter_flags.in (SECCOMP_FILTER_FLAG_NEW_LISTENER):
Likewise.
* NEWS: Mention this.
* tests/seccomp-filter.c (main): Update expected output.
* tests/seccomp-filter-v.c (main): Likewise.
* tests/seccomp_get_action_avail.c (main): Check SECCOMP_RET_USER_NOTIF.
2019-01-05 21:14:42 +00:00
48f74df7d3 xlat: update NT_* constants
* xlat/nt_descriptor_types.in (NT_ARM_PAC_MASK, NT_MIPS_MSA): New
constants introduced by Linux kernel commits v5.0-rc1~35^2~21
and v5.0-rc1~30^2~58, respectively.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
63de2e2055 xlat: update PR_* constants
* xlat/prctl_options.in (PR_PAC_RESET_KEYS): New constant introduced
by Linux kernel commit v5.0-rc1~35^2~19.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
2b31eeb6c1 xlat: update V4L2_* constants
* xlat/v4l2_buf_types.in (V4L2_BUF_TYPE_META_OUTPUT): New constant
introduced by Linux kernel commit v5.0-rc1~181^2~21.
* xlat/v4l2_device_capabilities_flags.in (V4L2_CAP_META_OUTPUT):
Likewise.
* xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_CNF4): New constant introduced
by Linux kernel commit v5.0-rc1~182^2~120.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
4ba813df47 xlat: update KVM_CAP_* constants
* xlat/kvm_cap.in (KVM_CAP_MANUAL_DIRTY_LOG_PROTECT,
KVM_CAP_HYPERV_CPUID): New constants introduced by Linux kernel commits
v5.0-rc1~156^2~115 and v5.0-rc1~156^2~74, respectively.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
d0d79b4b7e xlat: update NDA_* constants
* xlat/rtnl_neigh_attrs.in (NDA_PROTOCOL): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~79.
* rtnl_neigh.c (ndmsg_nla_decoders): Add NDA_PROTOCOL.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
536d2af968 xlat: update BTRFS_FEATURE_INCOMPAT_* constants
* xlat/btrfs_features_incompat.in
(BTRFS_FEATURE_INCOMPAT_METADATA_UUID): New constant introduced by Linux
kernel commit v5.0-rc1~126^2~64.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
bfff2ebaa6 xlat: update *_MAGIC constants
* xlat/fsmagic.in (BINDERFS_SUPER_MAGIC): New constant introduced
by Linux kernel commit v5.0-rc1~95^2~15.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
25a73fb12f xlat: update KERN_* constants
* xlat/sysctl_kern.in (KERN_PANIC_ON_WARN, KERN_PANIC_PRINT): New
constants introduced by Linux kernel commits v3.19-rc1~135^2~91
and v5.0-rc1~38^2~16, respectively.
* configure.ac (AC_CHECK_DECLS): Add them.
* NEWS: Mention this.
2019-01-05 21:14:42 +00:00
cf36cc7c78 xlat: update BPF_F_* constants
* xlat/bpf_map_flags.in (BPF_F_ZERO_SEED): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~114^2~18^2~3.
* xlat/bpf_prog_flags.in (BPF_F_ANY_ALIGNMENT): New constant introduced
by Linux kernel commit v5.0-rc1~129^2~209^2~17^2~3.
* NEWS: Mention this.
* tests/bpf.c (BPF_MAP_CREATE_checks, BPF_PROG_LOAD_checks,
print_BPF_PROG_LOAD_attr3, print_BPF_PROG_LOAD_attr4): Update.
2019-01-05 21:14:42 +00:00
91cdd32f65 tests: fix prog_info initialization in bpf-obj_get_info_by_fd-prog*
The sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &bpf_prog_get_info_attr, ...) is
called in a loop.  The bpf_prog_get_info_attr.info object is in size 104
but bpf_prog_get_info_attr.info_len is in size 168.  Hence, if the prog
is jited, the second iteration onwards will have nr_jited_ksyms == 1
which is asking the kernel to fill the
bpf_prog_get_info_attr.info.jited_ksyms and it is NULL.

* tests/bpf-obj_get_info_by_fd.c (main): Clear memory beyond prog_info
at the start of every iteration.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2019-01-05 21:14:42 +00:00
3e93457d5f tests: use tail_alloc instead of calloc in bpf-obj_get_info_by_fd-prog*
This guarantees that map_info and prog_info objects are not accessed
out of bounds.

* tests/bpf-obj_get_info_by_fd.c: Include <string.h>.
(main): Use tail_alloc instead of calloc for map_info and prog_info.
2019-01-05 21:14:42 +00:00
cd5b418320 Bring lists back to the sorted order
* .gitignore: Make the list sorted again.
* Makefile.am (strace_SOURCES): Likewise.
* tests/.gitignore: Likewise.
* tests/gen_tests.in: Likewise.
* tests/Makefile.am (check_PROGRAMS, DECODER_TESTS, EXTRA_DIST):
Likewise.
2019-01-02 00:29:09 +00:00
cab745b842 tests: fix strace-k.test on alpha
Change strace-k.test to use chdir syscall instead of getpid syscall
because the latter is not universally available, e.g. there is no getpid
syscall on alpha.

* tests/stack-fcall-3.c (f3) <default>: Replace getpid with chdir.
* tests/strace-k.test: Likewise.
* tests/strace-k.expected: Likewise.
* tests/strace-k-demangle.expected: Likewise.
* NEWS: Mention this.
2019-01-01 21:36:08 +00:00
d6c71dd061 Fix preprocessor indentation
Indent the C preprocessor directives to reflect their nesting
using the following script:

$ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' |grep -v '\.sh$') |while read f; do
	cppi < "$f" > "$f".cppi; mv "$f".cppi "$f"
done
2018-12-30 15:35:21 +00:00
51bd6db1ef Post-release administrivia
* NEWS: Add a header line for the next release.
* debian/changelog.in: Add a changelog entry for 4.26-1.
* strace.spec.in: Likewise.
2018-12-30 15:35:21 +00:00
274 changed files with 3217 additions and 2304 deletions

6
.gitignore vendored
View File

@ -12,6 +12,8 @@
/.version
/CREDITS
/ChangeLog
/INSTALL
/README
/aclocal.m4
/autom4te.cache
/bpf_attr_check.c
@ -25,7 +27,6 @@
/configure
/depcomp
/gnu
/INSTALL
/install-sh
/ioctl_iocdef.[ih]
/ioctl_redefs[12].h
@ -54,15 +55,14 @@
/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.1
/strace-log-merge.1
/strace.1
/strace.dsc
/strace.spec
/sys_func.h

View File

@ -127,8 +127,8 @@ strace_SOURCES = \
fetch_struct_xfs_quotastat.c \
file_handle.c \
file_ioctl.c \
filter_qualify.c \
filter.h \
filter_qualify.c \
flock.c \
flock.h \
fs_x_ioctl.c \
@ -168,6 +168,7 @@ 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 \
@ -193,10 +194,9 @@ strace_SOURCES = \
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,6 +205,7 @@ 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 \
@ -227,8 +228,8 @@ strace_SOURCES = \
prctl.c \
print_aio_sigset.c \
print_dev_t.c \
print_group_req.c \
print_fields.h \
print_group_req.c \
print_ifindex.c \
print_instruction_pointer.c \
print_kernel_version.c \
@ -307,8 +308,8 @@ strace_SOURCES = \
statx.c \
statx.h \
strace.c \
string_to_uint.h \
string_to_uint.c \
string_to_uint.h \
swapon.c \
syscall.c \
sysctl.c \

14
NEWS
View File

@ -1,3 +1,17 @@
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)
===============================================

View File

@ -7,9 +7,9 @@
/* 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

@ -47,7 +47,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

View File

@ -6,7 +6,7 @@
*/
#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 +19,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"
# 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
#endif
#ifndef BPF_TAG_SIZE
# define BPF_TAG_SIZE 8
#else
# if BPF_TAG_SIZE != 8
# error "Unexpected value of BPF_TAG_SIZE"
# ifndef BPF_TAG_SIZE
# define BPF_TAG_SIZE 8
# else
# if BPF_TAG_SIZE != 8
# error "Unexpected value of BPF_TAG_SIZE"
# endif
# endif
#endif
struct BPF_MAP_CREATE_struct {
uint32_t map_type;
@ -47,9 +47,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 +57,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 +68,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 +87,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 +106,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 +116,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 +130,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 +140,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 +155,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 +165,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 +178,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 +188,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 +198,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 +211,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 +241,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 +267,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

@ -8,7 +8,7 @@
*/
#ifndef STRACE_BPF_FILTER_H
#define STRACE_BPF_FILTER_H
# define STRACE_BPF_FILTER_H
struct bpf_filter_block {
uint16_t code;

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_BPF_FPROG_H
#define STRACE_BPF_FPROG_H
# define STRACE_BPF_FPROG_H
struct bpf_fprog {
unsigned short len;

134
btrfs.c
View File

@ -10,10 +10,10 @@
#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 +32,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 +41,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 +58,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 +97,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 +135,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 +222,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 +718,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 +729,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 +892,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 +1262,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

@ -20,15 +20,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 +72,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

@ -645,6 +645,8 @@ 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,

6
debian/changelog.in vendored
View File

@ -4,6 +4,12 @@ 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.

594
defs.h

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
*/
#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);

2
dm.c
View File

@ -98,7 +98,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

@ -11,11 +11,11 @@
*/
#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;
@ -31,29 +31,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 */

View File

@ -186,7 +186,7 @@ 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_) \
# 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_))

View File

@ -11,7 +11,7 @@
#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

@ -6,16 +6,16 @@
*/
#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

@ -7,7 +7,7 @@
*/
#ifndef STRACE_FILTER_H
#define STRACE_FILTER_H
# define STRACE_FILTER_H
struct number_set;
typedef int (*string_to_uint_func)(const char *);

24
flock.h
View File

@ -7,24 +7,24 @@
*/
#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

@ -7,114 +7,114 @@
*/
#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 GNUC_PREREQ(maj, min) 0
# endif
#if defined __clang__ && defined __clang_major__ && defined __clang_minor__
# define CLANG_PREREQ(maj, min) \
# 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
# else
# define CLANG_PREREQ(maj, min) 0
# endif
#if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
# define __attribute__(x) /* empty */
#endif
# if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
# define __attribute__(x) /* empty */
# endif
#if GNUC_PREREQ(2, 5)
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
#else
# define ATTRIBUTE_NORETURN /* 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(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, 3)
# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
# else
# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
# endif
#if GNUC_PREREQ(7, 0)
# define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__))
#else
# define ATTRIBUTE_FALLTHROUGH ((void) 0)
#endif
# if GNUC_PREREQ(7, 0)
# define ATTRIBUTE_FALLTHROUGH __attribute__((__fallthrough__))
# else
# define ATTRIBUTE_FALLTHROUGH ((void) 0)
# endif
#if CLANG_PREREQ(2, 8)
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT \
# 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 \
# define DIAG_POP_IGNORE_OVERRIDE_INIT \
_Pragma("clang diagnostic pop");
#elif GNUC_PREREQ(4, 2)
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT \
# 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 \
# 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
# else
# define DIAG_PUSH_IGNORE_OVERRIDE_INIT /* empty */
# define DIAG_POP_IGNORE_OVERRIDE_INIT /* empty */
# 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

@ -6,9 +6,9 @@
*/
#ifndef STRACE_GET_PERSONALITY_H
#define STRACE_GET_PERSONALITY_H
# define STRACE_GET_PERSONALITY_H
#include "ptrace.h"
# include "ptrace.h"
extern int
get_personality_from_syscall_info(const struct ptrace_syscall_info *);

2
ipc.c
View File

@ -21,7 +21,7 @@ SYS_FUNC(ipc)
printxval_u(ipccalls, call, NULL);
unsigned int i;
for (i = 1; i < tcp->s_ent->nargs; ++i)
for (i = 1; i < n_args(tcp); ++i)
tprintf(", %#" PRI_klx, tcp->u_arg[i]);
return RVAL_DECODED;

View File

@ -7,21 +7,21 @@
*/
#ifndef STRACE_IPC_DEFS_H
#define STRACE_IPC_DEFS_H
# define STRACE_IPC_DEFS_H
#ifdef HAVE_SYS_IPC_H
# include <sys/ipc.h>
#elif defined HAVE_LINUX_IPC_H
# include <linux/ipc.h>
# ifdef HAVE_SYS_IPC_H
# include <sys/ipc.h>
# elif defined HAVE_LINUX_IPC_H
# include <linux/ipc.h>
/* While glibc uses __key, the kernel uses key. */
# define __key key
#endif
# define __key key
# endif
#if !defined IPC_64
# define IPC_64 0x100
#endif
# if !defined IPC_64
# define IPC_64 0x100
# endif
#define PRINTCTL(flagset, arg, dflt) \
# define PRINTCTL(flagset, arg, dflt) \
do { \
if ((arg) & IPC_64) { \
print_xlat(IPC_64); \

View File

@ -7,11 +7,11 @@
*/
#ifndef STRACE_KERNEL_TYPES_H
#define STRACE_KERNEL_TYPES_H
# define STRACE_KERNEL_TYPES_H
# if defined HAVE___KERNEL_LONG_T && defined HAVE___KERNEL_ULONG_T
# include <asm/posix_types.h>
# include <asm/posix_types.h>
typedef __kernel_long_t kernel_long_t;
typedef __kernel_ulong_t kernel_ulong_t;
@ -35,15 +35,15 @@ typedef struct {
char d_name[1];
} kernel_dirent;
#if SIZEOF_KERNEL_LONG_T > SIZEOF_LONG
# define PRI_kl "ll"
#else
# define PRI_kl "l"
#endif
# if SIZEOF_KERNEL_LONG_T > SIZEOF_LONG
# define PRI_kl "ll"
# else
# define PRI_kl "l"
# endif
#define PRI_kld PRI_kl"d"
#define PRI_klu PRI_kl"u"
#define PRI_klx PRI_kl"x"
# define PRI_kld PRI_kl"d"
# define PRI_klu PRI_kl"u"
# define PRI_klx PRI_kl"x"
/*
* The kernel used to define 64-bit types on 64-bit systems on a per-arch
@ -54,17 +54,17 @@ typedef struct {
* every printing of __u64 or __s64 to stdint types.
* The exception is Android, where for MIPS64 unsigned long long is used.
*/
#if SIZEOF_LONG == 4
# define PRI__64 "ll"
#elif defined ALPHA || defined IA64 || defined __powerpc64__ \
# if SIZEOF_LONG == 4
# define PRI__64 "ll"
# elif defined ALPHA || defined IA64 || defined __powerpc64__ \
|| (defined MIPS && !defined __ANDROID__)
# define PRI__64 "l"
#else
# define PRI__64 "ll"
#endif
# define PRI__64 "l"
# else
# define PRI__64 "ll"
# endif
#define PRI__d64 PRI__64"d"
#define PRI__u64 PRI__64"u"
#define PRI__x64 PRI__64"x"
# define PRI__d64 PRI__64"d"
# define PRI__u64 PRI__64"u"
# define PRI__x64 PRI__64"x"
#endif /* !STRACE_KERNEL_TYPES_H */

View File

@ -6,16 +6,16 @@
*/
#ifndef STRACE_KEYCTL_KDF_PARAMS_H
#define STRACE_KEYCTL_KDF_PARAMS_H
# define STRACE_KEYCTL_KDF_PARAMS_H
#include <stdint.h>
#include "kernel_types.h"
# include <stdint.h>
# include "kernel_types.h"
/* from include/linux/crypto.h */
#define CRYPTO_MAX_ALG_NAME 128
# define CRYPTO_MAX_ALG_NAME 128
/* from security/keys/internal.h */
#define KEYCTL_KDF_MAX_OI_LEN 64 /* max length of otherinfo */
# define KEYCTL_KDF_MAX_OI_LEN 64 /* max length of otherinfo */
struct keyctl_kdf_params {
char *hashname;

View File

@ -6,11 +6,11 @@
*/
#ifndef STRACE_KILL_SAVE_ERRNO_H
#define STRACE_KILL_SAVE_ERRNO_H
# define STRACE_KILL_SAVE_ERRNO_H
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
# include <sys/types.h>
# include <signal.h>
# include <errno.h>
static inline int
kill_save_errno(pid_t pid, int sig)

2
kvm.c
View File

@ -107,7 +107,7 @@ map_len(struct mmap_cache_entry_t *map_info)
: 0;
}
#define VCPU_DENTRY_PREFIX "anon_inode:kvm-vcpu:"
# define VCPU_DENTRY_PREFIX "anon_inode:kvm-vcpu:"
static struct vcpu_info*
vcpu_get_info(struct tcb *const tcp, int fd)

View File

@ -9,30 +9,30 @@
*/
#ifndef STRACE_LARGEFILE_WRAPPERS_H
#define STRACE_LARGEFILE_WRAPPERS_H
# define STRACE_LARGEFILE_WRAPPERS_H
#include "defs.h"
# include "defs.h"
#ifdef _LARGEFILE64_SOURCE
# ifdef HAVE_FOPEN64
# define fopen_stream fopen64
# ifdef _LARGEFILE64_SOURCE
# ifdef HAVE_FOPEN64
# define fopen_stream fopen64
# else
# define fopen_stream fopen
# endif
# define struct_stat struct stat64
# define stat_file stat64
# define struct_dirent struct dirent64
# define read_dir readdir64
# define struct_rlimit struct rlimit64
# define set_rlimit setrlimit64
# else
# define fopen_stream fopen
# define struct_stat struct stat
# define stat_file stat
# define struct_dirent struct dirent
# define read_dir readdir
# define struct_rlimit struct rlimit
# define set_rlimit setrlimit
# endif
# define struct_stat struct stat64
# define stat_file stat64
# define struct_dirent struct dirent64
# define read_dir readdir64
# define struct_rlimit struct rlimit64
# define set_rlimit setrlimit64
#else
# define fopen_stream fopen
# define struct_stat struct stat
# define stat_file stat
# define struct_dirent struct dirent
# define read_dir readdir
# define struct_rlimit struct rlimit
# define set_rlimit setrlimit
#endif
#endif /* STRACE_LARGEFILE_WRAPPERS_H */

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -11,7 +11,7 @@ arch_get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, REG_A0+i, &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"
@ -17,7 +17,7 @@ raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
{
*err = 0;
#ifdef __thumb__ /* && FRAME_POINTERS_ENABLED */
# ifdef __thumb__ /* && FRAME_POINTERS_ENABLED */
register kernel_ulong_t rt;
register kernel_ulong_t r0 __asm__("r0");
@ -26,7 +26,7 @@ raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
: "r"(nr)
: "memory");
#else
# else
register kernel_ulong_t r7 __asm__("r7") = nr;
register kernel_ulong_t r0 __asm__("r0");
@ -35,7 +35,7 @@ raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
: "r"(r7)
: "memory");
#endif
# endif
return r0;
}

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_ASM_STAT_H
#define STRACE_ASM_STAT_H
# define STRACE_ASM_STAT_H
# undef dev_t
# undef gid_t

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -14,7 +14,7 @@ arch_get_syscall_args(struct tcb *tcp)
};
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
int sig;

View File

@ -8,140 +8,140 @@
*/
#ifndef STRACE_LINUX_DUMMY_H
#define STRACE_LINUX_DUMMY_H
# define STRACE_LINUX_DUMMY_H
#ifndef HAVE_STRUCT___OLD_KERNEL_STAT
#define sys_oldfstat printargs
#define sys_oldstat printargs
#endif
# ifndef HAVE_STRUCT___OLD_KERNEL_STAT
# define sys_oldfstat printargs
# define sys_oldstat printargs
# endif
/* still unfinished */
#define sys_rseq printargs
#define sys_vm86 printargs
#define sys_vm86old printargs
# define sys_rseq printargs
# define sys_vm86 printargs
# define sys_vm86old printargs
/* machine-specific */
#ifndef HAVE_STRUCT_USER_DESC
# define sys_modify_ldt printargs
#endif
# ifndef HAVE_STRUCT_USER_DESC
# define sys_modify_ldt printargs
# endif
#if !(defined HAVE_STRUCT_USER_DESC || defined M68K || defined MIPS)
# define sys_set_thread_area printargs
#endif
# if !(defined HAVE_STRUCT_USER_DESC || defined M68K || defined MIPS)
# define sys_set_thread_area printargs
# endif
#if !(defined HAVE_STRUCT_USER_DESC || defined M68K)
# define sys_get_thread_area printargs
#endif
# if !(defined HAVE_STRUCT_USER_DESC || defined M68K)
# define sys_get_thread_area printargs
# endif
#ifdef ALPHA
# define sys_getdtablesize printargs
#endif
# ifdef ALPHA
# define sys_getdtablesize printargs
# endif
/* like another call */
#define sys_acct sys_chdir
#define sys_chroot sys_chdir
#define sys_clock_getres sys_clock_gettime
#define sys_connect sys_bind
#define sys_fchdir sys_close
#define sys_fdatasync sys_close
#define sys_fsync sys_close
#define sys_getegid sys_getuid
#define sys_getegid16 sys_geteuid16
#define sys_geteuid sys_getuid
#define sys_geteuid16 sys_getuid16
#define sys_getgid sys_getuid
#define sys_getgid16 sys_getuid16
#define sys_getpeername sys_getsockname
#define sys_getresgid sys_getresuid
#define sys_getresgid16 sys_getresuid16
#define sys_lstat sys_stat
#define sys_lstat64 sys_stat64
#define sys_mkdir sys_chmod
#define sys_mkdirat sys_fchmodat
#define sys_mlock sys_munmap
#define sys_mq_unlink sys_chdir
#define sys_munlock sys_munmap
#define sys_oldlstat sys_oldstat
#define sys_pivotroot sys_link
#define sys_rename sys_link
#define sys_rmdir sys_chdir
#define sys_sched_get_priority_max sys_sched_get_priority_min
#define sys_set_robust_list sys_munmap
#define sys_setdomainname sys_sethostname
#define sys_setfsgid sys_setfsuid
#define sys_setfsgid16 sys_setfsuid16
#define sys_setgid sys_setuid
#define sys_setgid16 sys_setuid16
#define sys_setregid sys_setreuid
#define sys_setregid16 sys_setreuid16
#define sys_setresgid sys_setresuid
#define sys_setresgid16 sys_setresuid16
#define sys_stime sys_time
#define sys_swapoff sys_chdir
#define sys_symlink sys_link
#define sys_syncfs sys_close
#define sys_umount sys_chdir
#define sys_unlink sys_chdir
#define sys_uselib sys_chdir
#define sys_vfork sys_fork
# define sys_acct sys_chdir
# define sys_chroot sys_chdir
# define sys_clock_getres sys_clock_gettime
# define sys_connect sys_bind
# define sys_fchdir sys_close
# define sys_fdatasync sys_close
# define sys_fsync sys_close
# define sys_getegid sys_getuid
# define sys_getegid16 sys_geteuid16
# define sys_geteuid sys_getuid
# define sys_geteuid16 sys_getuid16
# define sys_getgid sys_getuid
# define sys_getgid16 sys_getuid16
# define sys_getpeername sys_getsockname
# define sys_getresgid sys_getresuid
# define sys_getresgid16 sys_getresuid16
# define sys_lstat sys_stat
# define sys_lstat64 sys_stat64
# define sys_mkdir sys_chmod
# define sys_mkdirat sys_fchmodat
# define sys_mlock sys_munmap
# define sys_mq_unlink sys_chdir
# define sys_munlock sys_munmap
# define sys_oldlstat sys_oldstat
# define sys_pivotroot sys_link
# define sys_rename sys_link
# define sys_rmdir sys_chdir
# define sys_sched_get_priority_max sys_sched_get_priority_min
# define sys_set_robust_list sys_munmap
# define sys_setdomainname sys_sethostname
# define sys_setfsgid sys_setfsuid
# define sys_setfsgid16 sys_setfsuid16
# define sys_setgid sys_setuid
# define sys_setgid16 sys_setuid16
# define sys_setregid sys_setreuid
# define sys_setregid16 sys_setreuid16
# define sys_setresgid sys_setresuid
# define sys_setresgid16 sys_setresuid16
# define sys_stime sys_time
# define sys_swapoff sys_chdir
# define sys_symlink sys_link
# define sys_syncfs sys_close
# define sys_umount sys_chdir
# define sys_unlink sys_chdir
# define sys_uselib sys_chdir
# define sys_vfork sys_fork
/* printargs does the right thing */
#define sys_getpgrp printargs
#define sys_getpid printargs
#define sys_getppid printargs
#define sys_gettid printargs
#define sys_idle printargs
#define sys_inotify_init printargs
#define sys_munlockall printargs
#define sys_pause printargs
#define sys_printargs printargs
#define sys_sched_yield printargs
#define sys_setsid printargs
#define sys_set_tid_address printargs
#define sys_setup printargs
#define sys_sync printargs
#define sys_syscall printargs
#define sys_vhangup printargs
# define sys_getpgrp printargs
# define sys_getpid printargs
# define sys_getppid printargs
# define sys_gettid printargs
# define sys_idle printargs
# define sys_inotify_init printargs
# define sys_munlockall printargs
# define sys_pause printargs
# define sys_printargs printargs
# define sys_sched_yield printargs
# define sys_setsid printargs
# define sys_set_tid_address printargs
# define sys_setup printargs
# define sys_sync printargs
# define sys_syscall printargs
# define sys_vhangup printargs
/* printargs_u does the right thing */
#define sys_alarm printargs_u
# define sys_alarm printargs_u
/* printargs_d does the right thing */
#define sys_exit printargs_d
#define sys_getpgid printargs_d
#define sys_getsid printargs_d
#define sys_nice printargs_d
#define sys_setpgid printargs_d
#define sys_setpgrp printargs_d
#define sys_timer_delete printargs_d
#define sys_timer_getoverrun printargs_d
# define sys_exit printargs_d
# define sys_getpgid printargs_d
# define sys_getsid printargs_d
# define sys_nice printargs_d
# define sys_setpgid printargs_d
# define sys_setpgrp printargs_d
# define sys_timer_delete printargs_d
# define sys_timer_getoverrun printargs_d
/* unimplemented */
#define sys_afs_syscall printargs
#define sys_break printargs
#define sys_create_module printargs
#define sys_ftime printargs
#define sys_get_kernel_syms printargs
#define sys_getpmsg printargs
#define sys_gtty printargs
#define sys_lock printargs
#define sys_mpx printargs
#define sys_nfsservctl printargs
#define sys_prof printargs
#define sys_profil printargs
#define sys_putpmsg printargs
#define sys_query_module printargs
#define sys_security printargs
#define sys_stty printargs
#define sys_timerfd printargs
#define sys_tuxcall printargs
#define sys_ulimit printargs
#define sys_vserver printargs
# define sys_afs_syscall printargs
# define sys_break printargs
# define sys_create_module printargs
# define sys_ftime printargs
# define sys_get_kernel_syms printargs
# define sys_getpmsg printargs
# define sys_gtty printargs
# define sys_lock printargs
# define sys_mpx printargs
# define sys_nfsservctl printargs
# define sys_prof printargs
# define sys_profil printargs
# define sys_putpmsg printargs
# define sys_query_module printargs
# define sys_security printargs
# define sys_stty printargs
# define sys_timerfd printargs
# define sys_tuxcall printargs
# define sys_ulimit printargs
# define sys_vserver printargs
/* deprecated */
#define sys_bdflush printargs
#define sys_oldolduname printargs
#define sys_olduname printargs
#define sys_sysfs printargs
# define sys_bdflush printargs
# define sys_oldolduname printargs
# define sys_olduname printargs
# define sys_sysfs printargs
#endif /* !STRACE_LINUX_DUMMY_H */

View File

@ -11,7 +11,7 @@ arch_get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
unsigned int tramp[9];

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
uint32_t pretcode;

View File

@ -18,7 +18,7 @@ arch_get_syscall_args(struct tcb *tcp)
unsigned long *out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i) {
for (i = 0; i < n_args(tcp); ++i) {
if (umove(tcp,
(unsigned long) ia64_rse_skip_regs(out0, i),
&tcp->u_arg[i]) < 0) {

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
unsigned long arg0;
@ -19,7 +19,7 @@ typedef struct {
struct sigcontext sc;
} struct_rt_sigframe;
#define OFFSETOF_SIGMASK_IN_RT_SIGFRAME \
# define OFFSETOF_SIGMASK_IN_RT_SIGFRAME \
offsetof(struct_rt_sigframe, sc.sc_mask)
#endif /* !STRACE_RT_SIGFRAME_H */

View File

@ -6,10 +6,10 @@
*/
#ifndef STRACE_LINUX_INET_DIAG_H
#define STRACE_LINUX_INET_DIAG_H
# define STRACE_LINUX_INET_DIAG_H
#define TCPDIAG_GETSOCK 18
#define DCCPDIAG_GETSOCK 19
# define TCPDIAG_GETSOCK 18
# define DCCPDIAG_GETSOCK 19
/* Socket identity */
struct inet_diag_sockid {

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
char *pretcode;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -11,7 +11,7 @@ arch_get_syscall_args(struct tcb *tcp)
{
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, (5 + i) * 4, &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -1,10 +1,3 @@
/*
* Copyright (c) 2015-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
syscallent-n32-stub.h
syscallent-n64-stub.h
syscallent-o32-stub.h

View File

@ -21,19 +21,45 @@ arch_get_syscall_args(struct tcb *tcp)
tcp->u_arg[1] = mips_REG_A1;
tcp->u_arg[2] = mips_REG_A2;
tcp->u_arg[3] = mips_REG_A3;
if (tcp->s_ent->nargs > 4
if (n_args(tcp) > 4
&& umoven(tcp, mips_REG_SP + 4 * sizeof(tcp->u_arg[0]),
(tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]),
(n_args(tcp) - 4) * sizeof(tcp->u_arg[0]),
&tcp->u_arg[4]) < 0) {
/*
* Let's proceed with the first 4 arguments
* instead of reporting the failure.
*/
memset(&tcp->u_arg[4], 0,
(tcp->s_ent->nargs - 4) * sizeof(tcp->u_arg[0]));
(n_args(tcp) - 4) * sizeof(tcp->u_arg[0]));
}
#else
# error unsupported mips abi
#endif
return 1;
}
#ifdef SYS_syscall_subcall
static void
decode_syscall_subcall(struct tcb *tcp)
{
if (!scno_is_valid(tcp->u_arg[0]))
return;
tcp->scno = tcp->u_arg[0];
tcp->qual_flg = qual_flags(tcp->scno);
tcp->s_ent = &sysent[tcp->scno];
memmove(&tcp->u_arg[0], &tcp->u_arg[1],
sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
/*
* Fetching the last arg of 7-arg syscalls (fadvise64_64
* and sync_file_range) requires additional code,
* see linux/mips/get_syscall_args.c
*/
if (n_args(tcp) == MAX_ARGS) {
if (umoven(tcp,
mips_REG_SP + MAX_ARGS * sizeof(tcp->u_arg[0]),
sizeof(tcp->u_arg[0]),
&tcp->u_arg[MAX_ARGS - 1]) < 0)
tcp->u_arg[MAX_ARGS - 1] = 0;
}
}
#endif /* SYS_syscall_subcall */

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
uint32_t pad[6];

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_LINUX_NETLINK_DIAG_H
#define STRACE_LINUX_NETLINK_DIAG_H
# define STRACE_LINUX_NETLINK_DIAG_H
struct netlink_diag_req {
uint8_t sdiag_family;
@ -45,18 +45,18 @@ enum {
NETLINK_DIAG_FLAGS,
};
#define NDIAG_SHOW_MEMINFO 0x00000001
#define NDIAG_SHOW_GROUPS 0x00000002
#define NDIAG_SHOW_RING_CFG 0x00000004 /* deprecated since 4.6 */
#define NDIAG_SHOW_FLAGS 0x00000008
#define NDIAG_PROTO_ALL ((uint8_t) ~0)
# define NDIAG_SHOW_MEMINFO 0x00000001
# define NDIAG_SHOW_GROUPS 0x00000002
# define NDIAG_SHOW_RING_CFG 0x00000004 /* deprecated since 4.6 */
# define NDIAG_SHOW_FLAGS 0x00000008
# define NDIAG_PROTO_ALL ((uint8_t) ~0)
/* flags */
#define NDIAG_FLAG_CB_RUNNING 0x00000001
#define NDIAG_FLAG_PKTINFO 0x00000002
#define NDIAG_FLAG_BROADCAST_ERROR 0x00000004
#define NDIAG_FLAG_NO_ENOBUFS 0x00000008
#define NDIAG_FLAG_LISTEN_ALL_NSID 0x00000010
#define NDIAG_FLAG_CAP_ACK 0x00000020
# define NDIAG_FLAG_CB_RUNNING 0x00000001
# define NDIAG_FLAG_PKTINFO 0x00000002
# define NDIAG_FLAG_BROADCAST_ERROR 0x00000004
# define NDIAG_FLAG_NO_ENOBUFS 0x00000008
# define NDIAG_FLAG_LISTEN_ALL_NSID 0x00000010
# define NDIAG_FLAG_CAP_ACK 0x00000020
#endif /* !STRACE_LINUX_NETLINK_DIAG_H */

View File

@ -6,6 +6,6 @@
*/
static struct user_pt_regs nios2_regs;
# define ARCH_REGS_FOR_GETREGSET nios2_regs
#define ARCH_REGS_FOR_GETREGSET nios2_regs
#define ARCH_PC_REG nios2_regs.regs[PTR_EA]
#define ARCH_SP_REG nios2_regs.regs[PTR_SP]

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_LINUX_PACKET_DIAG_H
#define STRACE_LINUX_PACKET_DIAG_H
# define STRACE_LINUX_PACKET_DIAG_H
struct packet_diag_req {
uint8_t sdiag_family;
@ -17,12 +17,12 @@ struct packet_diag_req {
uint32_t pdiag_cookie[2];
};
#define PACKET_SHOW_INFO 0x00000001
#define PACKET_SHOW_MCLIST 0x00000002
#define PACKET_SHOW_RING_CFG 0x00000004
#define PACKET_SHOW_FANOUT 0x00000008
#define PACKET_SHOW_MEMINFO 0x00000010
#define PACKET_SHOW_FILTER 0x00000020
# define PACKET_SHOW_INFO 0x00000001
# define PACKET_SHOW_MCLIST 0x00000002
# define PACKET_SHOW_RING_CFG 0x00000004
# define PACKET_SHOW_FANOUT 0x00000008
# define PACKET_SHOW_MEMINFO 0x00000010
# define PACKET_SHOW_FILTER 0x00000020
struct packet_diag_msg {
uint8_t pdiag_family;
@ -52,11 +52,11 @@ struct packet_diag_info {
uint32_t pdi_tstamp;
uint32_t pdi_flags;
#define PDI_RUNNING 0x1
#define PDI_AUXDATA 0x2
#define PDI_ORIGDEV 0x4
#define PDI_VNETHDR 0x8
#define PDI_LOSS 0x10
# define PDI_RUNNING 0x1
# define PDI_AUXDATA 0x2
# define PDI_ORIGDEV 0x4
# define PDI_VNETHDR 0x8
# define PDI_LOSS 0x10
};
struct packet_diag_mclist {

View File

@ -5,7 +5,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#define SIGNAL_FRAMESIZE32 64
#define SIGNAL_FRAMESIZE32 64
FUNC_GET_RT_SIGFRAME_ADDR
{

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,13 +6,13 @@
*/
#undef FUNC_GET_RT_SIGFRAME_ADDR
#define FUNC_GET_RT_SIGFRAME_ADDR \
#define FUNC_GET_RT_SIGFRAME_ADDR \
static kernel_ulong_t ppc_get_rt_sigframe_addr(struct tcb *tcp)
#include "powerpc/arch_rt_sigframe.c"
#undef FUNC_GET_RT_SIGFRAME_ADDR
#define FUNC_GET_RT_SIGFRAME_ADDR DEF_FUNC_GET_RT_SIGFRAME_ADDR
#define FUNC_GET_RT_SIGFRAME_ADDR DEF_FUNC_GET_RT_SIGFRAME_ADDR
FUNC_GET_RT_SIGFRAME_ADDR
{

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
/* This is a generic definition for compatible architectures. */

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
uint8_t callee_used_stack[__SIGNAL_FRAMESIZE];

View File

@ -19,7 +19,7 @@ arch_get_syscall_args(struct tcb *tcp)
};
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, syscall_regs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -13,7 +13,7 @@ arch_get_syscall_args(struct tcb *tcp)
static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 };
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, REG_GENERAL(syscall_regs[i]),
&tcp->u_arg[i]) < 0)
return -1;

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
siginfo_t *pinfo;

View File

@ -6,11 +6,11 @@
*/
#ifndef STRACE_LINUX_SMC_DIAG_H
#define STRACE_LINUX_SMC_DIAG_H
# define STRACE_LINUX_SMC_DIAG_H
#include <linux/inet_diag.h>
# include <linux/inet_diag.h>
#include "gcc_compat.h"
# include "gcc_compat.h"
/* Request structure */
struct smc_diag_req {

View File

@ -6,12 +6,12 @@
*/
#ifndef STRACE_LINUX_SOCK_DIAG_H
#define STRACE_LINUX_SOCK_DIAG_H
# define STRACE_LINUX_SOCK_DIAG_H
#define SOCK_DIAG_BY_FAMILY 20
#define SOCK_DESTROY 21
# define SOCK_DIAG_BY_FAMILY 20
# define SOCK_DESTROY 21
#define SK_MEMINFO_VARS 9
# define SK_MEMINFO_VARS 9
struct sock_diag_req {
uint8_t sdiag_family;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,10 +6,10 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include "ptrace.h"
#include <signal.h>
# include "ptrace.h"
# include <signal.h>
typedef struct {
struct sparc_stackf ss;
@ -19,7 +19,7 @@ typedef struct {
/* more data follows */
} struct_rt_sigframe;
#define OFFSETOF_SIGMASK_IN_RT_SIGFRAME \
# define OFFSETOF_SIGMASK_IN_RT_SIGFRAME \
offsetof(struct_rt_sigframe, mask)
#endif /* !STRACE_RT_SIGFRAME_H */

View File

@ -5,7 +5,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#define STACK_BIAS 2047
#define STACK_BIAS 2047
FUNC_GET_RT_SIGFRAME_ADDR
{

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -8,13 +8,13 @@
*/
#ifndef STRACE_LINUX_SYSCALL_H
#define STRACE_LINUX_SYSCALL_H
# define STRACE_LINUX_SYSCALL_H
#include "dummy.h"
#include "sys_func.h"
#include "sen.h"
# include "dummy.h"
# include "sys_func.h"
# include "sen.h"
#if HAVE_ARCH_UID16_SYSCALLS
# if HAVE_ARCH_UID16_SYSCALLS
extern SYS_FUNC(chown16);
extern SYS_FUNC(fchown16);
extern SYS_FUNC(getgroups16);
@ -25,6 +25,6 @@ extern SYS_FUNC(setgroups16);
extern SYS_FUNC(setresuid16);
extern SYS_FUNC(setreuid16);
extern SYS_FUNC(setuid16);
#endif /* HAVE_ARCH_UID16_SYSCALLS */
# endif /* HAVE_ARCH_UID16_SYSCALLS */
#endif /* !STRACE_LINUX_SYSCALL_H */

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -6,9 +6,9 @@
*/
#ifndef STRACE_RT_SIGFRAME_H
#define STRACE_RT_SIGFRAME_H
# define STRACE_RT_SIGFRAME_H
#include <signal.h>
# include <signal.h>
typedef struct {
unsigned char save_area[C_ABI_SAVE_AREA_SIZE];

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_LINUX_UNIX_DIAG_H
#define STRACE_LINUX_UNIX_DIAG_H
# define STRACE_LINUX_UNIX_DIAG_H
struct unix_diag_req {
uint8_t sdiag_family;
@ -18,12 +18,12 @@ struct unix_diag_req {
uint32_t udiag_cookie[2];
};
#define UDIAG_SHOW_NAME 0x01
#define UDIAG_SHOW_VFS 0x02
#define UDIAG_SHOW_PEER 0x04
#define UDIAG_SHOW_ICONS 0x08
#define UDIAG_SHOW_RQLEN 0x10
#define UDIAG_SHOW_MEMINFO 0x20
# define UDIAG_SHOW_NAME 0x01
# define UDIAG_SHOW_VFS 0x02
# define UDIAG_SHOW_PEER 0x04
# define UDIAG_SHOW_ICONS 0x08
# define UDIAG_SHOW_RQLEN 0x10
# define UDIAG_SHOW_MEMINFO 0x20
struct unix_diag_msg {
uint8_t udiag_family;

View File

@ -25,9 +25,9 @@ get_personality_from_syscall_info(const struct ptrace_syscall_info *sci)
kernel_ulong_t scno = sci->entry.nr;
#ifndef __X32_SYSCALL_BIT
# define __X32_SYSCALL_BIT 0x40000000
#endif
# ifndef __X32_SYSCALL_BIT
# define __X32_SYSCALL_BIT 0x40000000
# endif
if (pers == 0 && (scno & __X32_SYSCALL_BIT)) {
/*

View File

@ -6,7 +6,7 @@
*/
#ifndef STRACE_X86_64_ASM_STAT_H
#define STRACE_X86_64_ASM_STAT_H
# define STRACE_X86_64_ASM_STAT_H
# if defined __x86_64__ && defined __ILP32__
# define stat redirect_kernel_stat

View File

@ -50,9 +50,9 @@ arch_get_scno(struct tcb *tcp)
if ((long long) x86_64_regs.orig_rax != -1) {
currpers = 2;
} else {
# ifdef X32
#ifdef X32
currpers = 2;
# endif
#endif
}
}
}

View File

@ -11,7 +11,7 @@ arch_get_syscall_args(struct tcb *tcp)
{
if (x86_io.iov_len != sizeof(i386_regs)) {
/* x86-64 or x32 ABI */
if (tcp->s_ent->sys_flags & COMPAT_SYSCALL_TYPES) {
if (tcp_sysent(tcp)->sys_flags & COMPAT_SYSCALL_TYPES) {
/*
* X32 compat syscall: zero-extend from 32 bits.
* Use truncate_klong_to_current_wordsize(tcp->u_arg[N])

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

View File

@ -20,7 +20,7 @@ arch_get_syscall_args(struct tcb *tcp)
};
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
for (i = 0; i < n_args(tcp); ++i)
if (upeek(tcp, xtensaregs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -8,7 +8,7 @@
*/
#ifndef STRACE_RAW_SYSCALL_H
#define STRACE_RAW_SYSCALL_H
# define STRACE_RAW_SYSCALL_H
# include "kernel_types.h"

295
list.h Normal file
View File

@ -0,0 +1,295 @@
/*
* Some simple implementation of lists similar to the one used in the kernel.
*
* Copyright (c) 2016-2018 The strace developers.
* 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.
*/
#ifndef STRACE_LIST_H
#define STRACE_LIST_H
/*
* struct list_item and related macros and functions provide an interface
* for manipulating and iterating linked lists. In order to have list
* associated with its payload, struct list_item has to be embedded into
* a structure type representing payload, and (optionally) an additional
* struct list_item should be added somewhere as a starting point for list
* iteration (creating a list with a designated head). A situation where
* no designated head exists, and each embedded struct list_head is considered
* a head (i.e. starting point for list iteration), is also possible.
*
* List head has to be initialised with list_init() call. Statically allocated
* list heads can also be defined with an EMPTY_LIST() macro.
*
* In order to get a pointer to list item from a struct list_item, list_elem
* macro is used.
*
* When a designated head is used, list_head() and list_tail() can be used
* for getting pointer to the first and the last list item, respectively.
*
* list_next() and list_prev() macros can be used for obtaining pointers
* to the next and the previous items in the list, respectively. Note that
* they do not perform additional checks for the validity of these pointers,
* so they have to be guarded with respective list_head/list_tail checks in case
* of lists with designated heads (where the list's head is not embedded withing
* a list item.
*
* list_{insert,append,remove,remove_tail,remove_head,replace} provide some
* basic means of list manipulation.
*
* list_foreach() and list_foreach_safe() are wrapper macros for simplifying
* iteration over a list, with the latter having an additional argument
* for storing temporary pointer, thus allowing list manipulations during
* its iteration.
*
* A simple example:
*
* struct my_struct {
* int a;
* struct list_item l1;
* struct list_item l2;
* };
*
* EMPTY_LIST(list_1); <--- Defining a designated head for list
*
* struct my_struct *item =
* calloc(1, sizeof(*item));
* list_init(&item->l2); <--- Initialising structure field that
* is used for lists without designated
* head.
* list_insert(&list_1, &item->l1); <--- Inserting an item into the list
*
* item = calloc(1, sizeof(*item));
* list_init(&item->l2);
*
* list_append(&(list_head(list_1, struct my_struct, l1)->l2), &item->l2);
*
* struct my_struct *cur = item; <--- Iteration over a headless list
* do {
* printf("%d\n", cur->a);
* } while ((cur = list_next(&cur, l2)) != item);
*
* struct my_struct *i;
* list_foreach(i, list_1, l1) { <--- Iteration over list_1 without list
* printf("%d\n", i->a); modification
* }
*
* struct my_struct *tmp; <--- Iteration with modification
* list_foreach_safe(i, list_1, l1, tmp) {
* list_remove(&i->l1);
* free(i);
* }
*
* See also:
* "Linux kernel design patterns - part 2", section "Linked Lists"
* https://lwn.net/Articles/336255/
*/
#include "macros.h"
struct list_item {
struct list_item *prev;
struct list_item *next;
};
/**
* Define an empty list head.
*
* @param l_ List head variable name.
*/
#define EMPTY_LIST(l_) struct list_item l_ = { &l_, &l_ }
/** Initialise an empty list. */
static inline void
list_init(struct list_item *l)
{
l->prev = l;
l->next = l;
}
/** Check whether list is empty. */
static inline bool
list_is_empty(struct list_item *l)
{
return (l->next == l) && (l->prev == l);
}
/**
* Convert a pointer to a struct list_item to a pointer to a list item.
*
* @param var Pointer to struct list_item.
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
#define list_elem(var, type, field) containerof((var), type, field)
/**
* Get the first element in a list.
*
* @param head Pointer to the list's head.
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
#define list_head(head, type, field) \
(list_is_empty(head) ? NULL : list_elem((head)->next, type, field))
/**
* Get the last element in a list.
*
* @param head Pointer to the list's head.
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
#define list_tail(head, type, field) \
(list_is_empty(head) ? NULL : list_elem((head)->prev, type, field))
/**
* Get the next element in a list.
*
* @param var Pointer to a list item.
* @param field Name of the field that holds the respective struct list_item.
*/
#define list_next(var, field) \
list_elem((var)->field.next, typeof(*(var)), field)
/**
* Get the previous element in a list.
*
* @param var Pointer to a list item.
* @param field Name of the field that holds the respective struct list_item.
*/
#define list_prev(var, field) \
list_elem((var)->field.prev, typeof(*(var)), field)
/**
* Insert an item into a list. The item is placed as a next list item
* to the head.
*/
static inline void
list_insert(struct list_item *head, struct list_item *item)
{
item->next = head->next;
item->prev = head;
head->next->prev = item;
head->next = item;
}
/**
* Insert an item into a list. The item is placed as a previous list item
* to the head.
*/
static inline void
list_append(struct list_item *head, struct list_item *item)
{
item->next = head;
item->prev = head->prev;
head->prev->next = item;
head->prev = item;
}
/** Remove an item from a list. */
static inline void
list_remove(struct list_item *item)
{
if (!item->next || !item->prev)
return;
item->prev->next = item->next;
item->next->prev = item->prev;
item->next = item->prev = item;
}
/**
* Remove the last element of a list.
*
* @param head Pointer to the list's head.
* @return Pointer to struct list_item removed from the list;
* or NULL, if the list is empty.
*/
static inline struct list_item *
list_remove_tail(struct list_item *head)
{
struct list_item *t = list_is_empty(head) ? NULL : head->prev;
if (t)
list_remove(t);
return t;
}
/**
* Remove the first element of a list.
*
* @param head Pointer to the list's head.
* @return Pointer to struct list_item removed from the list;
* or NULL, if the list is empty.
*/
static inline struct list_item *
list_remove_head(struct list_item *head)
{
struct list_item *h = list_is_empty(head) ? NULL : head->next;
if (h)
list_remove(h);
return h;
}
/** Replace an old struct list_item in a list with the new one. */
static inline void
list_replace(struct list_item *old, struct list_item *new)
{
new->next = old->next;
new->prev = old->prev;
old->prev->next = new;
old->next->prev = new;
old->next = old->prev = old;
}
/**
* List iteration wrapper for non-destructive operations.
*
* @param var_ Variable holding pointer to a current list item.
* @param head_ Pointer to the list's head.
* @param field_ Name of the field containing the respective struct list_item
* inside list items.
*/
#define list_foreach(var_, head_, field_) \
for (var_ = list_elem((head_)->next, typeof(*var_), field_); \
&(var_->field_) != (head_); var_ = list_next(var_, field_))
/**
* List iteration wrapper for destructive operations.
*
* @param var_ Variable holding pointer to a current list item.
* @param head_ Pointer to the list's head.
* @param field_ Name of the field containing the respective struct list_item
* inside list items.
* @param _tmp Temporary variable for storing pointer to the next item.
*/
#define list_foreach_safe(var_, head_, field_, _tmp) \
for (var_ = list_elem((head_)->next, typeof(*var_), field_), \
_tmp = list_elem((var_)->field_.next, typeof(*var_), field_); \
&var_->field_ != head_; var_ = _tmp, _tmp = list_next(_tmp, field_))
#endif /* !STRACE_LIST_H */

2
loop.c
View File

@ -19,7 +19,7 @@ typedef struct loop_info struct_loop_info;
#include "print_fields.h"
#define XLAT_MACROS_ONLY
# include "xlat/loop_cmds.h"
#include "xlat/loop_cmds.h"
#undef XLAT_MACROS_ONLY
#include "xlat/loop_flags_options.h"

View File

@ -30,11 +30,11 @@ SYS_FUNC(lseek)
kernel_long_t offset;
# ifndef current_klongsize
#ifndef current_klongsize
if (current_klongsize < sizeof(kernel_long_t)) {
offset = (int) tcp->u_arg[1];
} else
# endif /* !current_klongsize */
#endif /* !current_klongsize */
{
offset = tcp->u_arg[1];
}

View File

@ -6,35 +6,44 @@
*/
#ifndef STRACE_MACROS_H
#define STRACE_MACROS_H
# define STRACE_MACROS_H
#include <stdbool.h>
#include <sys/types.h>
# include <stdbool.h>
# include <sys/types.h>
#include "gcc_compat.h"
# include "gcc_compat.h"
#define ARRAY_SIZE(a_) (sizeof(a_) / sizeof((a_)[0]) + MUST_BE_ARRAY(a_))
# define ARRAY_SIZE(a_) (sizeof(a_) / sizeof((a_)[0]) + MUST_BE_ARRAY(a_))
#define ARRSZ_PAIR(a_) a_, ARRAY_SIZE(a_)
# define ARRSZ_PAIR(a_) a_, ARRAY_SIZE(a_)
#define STRINGIFY(...) #__VA_ARGS__
#define STRINGIFY_VAL(...) STRINGIFY(__VA_ARGS__)
# define STRINGIFY(...) #__VA_ARGS__
# define STRINGIFY_VAL(...) STRINGIFY(__VA_ARGS__)
#ifndef MAX
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define CLAMP(val, min, max) MIN(MAX(min, val), max)
# ifndef MAX
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
# endif
# ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
# endif
# define CLAMP(val, min, max) MIN(MAX(min, val), max)
#ifndef ROUNDUP
# define ROUNDUP(val_, div_) ((((val_) + (div_) - 1) / (div_)) * (div_))
#endif
# ifndef ROUNDUP
# define ROUNDUP(val_, div_) ((((val_) + (div_) - 1) / (div_)) * (div_))
# endif
#ifndef offsetofend
# define offsetofend(type_, member_) \
# ifndef offsetofend
# define offsetofend(type_, member_) \
(offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
# endif
#ifndef cast_ptr
# define cast_ptr(type, var) ((type) (uintptr_t) (const volatile void *) (var))
#endif
#ifndef containerof
# define containerof(x, s, m) \
cast_ptr(s *, (const volatile char *) (x) - offsetof(s, m))
#endif
static inline bool
@ -47,7 +56,7 @@ is_filled(const char *ptr, char fill, size_t size)
return true;
}
#define IS_ARRAY_ZERO(arr_) \
# define IS_ARRAY_ZERO(arr_) \
is_filled((const char *) (arr_), 0, sizeof(arr_) + MUST_BE_ARRAY(arr_))
#endif /* !STRACE_MACROS_H */

View File

@ -5,7 +5,7 @@
*/
#ifndef STRACE_MMAP_CACHE_H
#define STRACE_MMAP_CACHE_H
# define STRACE_MMAP_CACHE_H
/*
* Keep a sorted array of cache entries,

View File

@ -5,9 +5,9 @@
*/
#ifndef STRACE_MMAP_NOTIFY_H
#define STRACE_MMAP_NOTIFY_H
# define STRACE_MMAP_NOTIFY_H
#include "defs.h"
# include "defs.h"
typedef void (*mmap_notify_fn)(struct tcb *, void *);

View File

@ -8,28 +8,28 @@
*/
#ifndef STRACE_MPERS_TYPE_H
#define STRACE_MPERS_TYPE_H
# define STRACE_MPERS_TYPE_H
#include "macros.h"
# include "macros.h"
#ifdef IN_MPERS
# define DEF_MPERS_TYPE(args) STRINGIFY(args.h)
# ifdef MPERS_IS_m32
# define MPERS_PREFIX m32_
# define MPERS_DEFS "m32_type_defs.h"
# elif defined MPERS_IS_mx32
# define MPERS_PREFIX mx32_
# define MPERS_DEFS "mx32_type_defs.h"
# endif
#else
# define MPERS_PREFIX
# define DEF_MPERS_TYPE(args) "empty.h"
# if IN_MPERS_BOOTSTRAP
# define MPERS_DEFS "empty.h"
# ifdef IN_MPERS
# define DEF_MPERS_TYPE(args) STRINGIFY(args.h)
# ifdef MPERS_IS_m32
# define MPERS_PREFIX m32_
# define MPERS_DEFS "m32_type_defs.h"
# elif defined MPERS_IS_mx32
# define MPERS_PREFIX mx32_
# define MPERS_DEFS "mx32_type_defs.h"
# endif
# else
# define MPERS_DEFS "native_defs.h"
# endif
# define MPERS_PREFIX
# define DEF_MPERS_TYPE(args) "empty.h"
# if IN_MPERS_BOOTSTRAP
# define MPERS_DEFS "empty.h"
# else
# define MPERS_DEFS "native_defs.h"
# endif
typedef unsigned long mpers_ptr_t;
#endif
# endif
#endif /* !STRACE_MPERS_TYPE_H */

View File

@ -107,8 +107,8 @@ print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
const struct in_pktinfo *info = cmsg_data;
PRINT_FIELD_IFINDEX("{", *info, ipi_ifindex);
PRINT_FIELD_INET4_ADDR(", ", *info, ipi_spec_dst);
PRINT_FIELD_INET4_ADDR(", ", *info, ipi_addr);
PRINT_FIELD_INET_ADDR(", ", *info, ipi_spec_dst, AF_INET);
PRINT_FIELD_INET_ADDR(", ", *info, ipi_addr, AF_INET);
tprints("}");
}

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