summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Introduce asinfo toolEdgarKaziakhmedov/asinfoEdgar Kaziakhmedov2020-04-0351-2/+3709
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this query tool is to present all information concluded at sysent.h files in a convenient way. The asinfo tool has the following staged architecture: (command dispatcher)->(architecture dispatcher)-> (abi dispatcher)->(system call dispatcher). Each dispatcher accepts proccesed data from previous one. This point can be illustrated by the following example: $ asinfo --get-arch --get-sname write Firstly, arch_dispatcher will return the current architecture, based on uname return value, after that in case of no options for abi_dispatcher, it perceives empty parameter as get-abi parameter and returns ABI mode set at compile time of strace package. Therefore, syscall_dispatcher accepts this architecture/ABI and works with specific set of system calls. It is worth mentioning that it supports all architectures/ABIs supported by strace. Also, tool can work in multi-arch mode. for instance: $ ./tools/asinfo/asinfo --set-arch mips64,mips --set-abi n64,all --get-snum 100,8,%ipc For more info, use asinfo -h. * Makefile.am (SUBDIRS): Add tools directory. * configure.ac (AC_CONFIG_FILES): Add Makefiles. * tools/Makefile.am: New file. * tools/asinfo/Makefile.am: New file. * tools/asinfo/dispatchers.h: New file. Prototype abi_dispatcher, arch_dispatcher, and syscall_dispatcher. * tools/asinfo/dispatchers.c: New file. Implement them. * tools/asinfo/error_interface.h: New file. Introduce error_service to improve informativeness of output errors. Prototype methods to work with error_service. * tools/asinfo/error_interface.c: New file. Implement it. * tools/asinfo/arch_interface.h: New file. Introduce struct arch_descriptor. Introduce arch_service. Prototype methods to simplify work with the arch_service. * tools/asinfo/arch_interface.c: New file. Implement it. * tools/asinfo/syscall_interface.h: New file. Introduce syscall_service. Prototype methods to simplify work with syscall_service. * tools/asinfo/syscall_interface.c: New file. Implement it. * tools/asinfo/request_msgs.h: New file. Introduce main requests. * tools/asinfo/asinfo.c: New file. Implement support of all options. Implement usage. Implement version. * tools/asinfo/arch_definitions.h: New file. Introduce useful storage for architectures. * tools/asinfo/gen_asinfo_files.sh: New file. * bootstrap: Add it. * tools/asinfo/Makefile.am: Include Makemodule.am. (asinfo_SOURCES): Add $(ARCH_AUX_FILES). * tools/asinfo/README-arch: New README explaining how to add new architecture/ABI to asinfo tool. * configure.ac (AC_CONFIG_FILES): Add asinfo.1. (asinfo_manpage_date): New m4 define. (ASINFO_MANPAGE_DATE): New define/subst. * tools/asinfo/asinfo.1.in: New file. * tools/asinfo/gen_asinfo_files.sh: Add asinfo.1 to .gitignore generation. * debian/control (strace): Add asinfo description. * debian/strace.install: Add path to asinfo binary. * debian/strace.manpages: Add path to asinfo manual page. * strace.spec.in (%files): Add asinfo binary. Update NEWS This set of tests cover all possible cases in asinfo tool. However, as asinfo uses some libraries provided by strace (such as basic_filters) there is no need to test them again in asinfo context. Also, the set of syscalls for specific architecture (hence, its number) might be expanded in the future, so to overcome this obstacle and avoid duplication of the same strings reference output ptintings are stored in ref_asinfo_output.h file. As for syscall-related checks, tests use old syscalls as samples, so their numbers and names can't be changed. * configure.ac (AC_CONFIG_FILES): Add tests Makefile to be generated. * tools/asinfo/Makefile.am (SUBDIRS): Add tests dir. * tools/asinfo/tests/Makefile.m: New file. * tools/asinfo/tests/init.sh: New file. Main subroutines for tests. * tools/asinfo/tests/ref_asinfo_output.h: New file. * tools/asinfo/tests/com_disp_wrong_keys.c: Likewise. * tools/asinfo/tests/com_disp_wrong_keys.test: Likewise. * tools/asinfo/tests/format_output.c: Likewise. * tools/asinfo/tests/format_output.test: Likewise. * tools/asinfo/tests/get_arch_abi.c: Likewise. * tools/asinfo/tests/get_arch_abi.test: Likewise. * tools/asinfo/tests/get_sname.c: Likewise. * tools/asinfo/tests/get_sname.test: Likewise. * tools/asinfo/tests/get_snum.c: Likewise. * tools/asinfo/tests/get_snum.test: Likewise. * tools/asinfo/tests/list_arch.c: Likewise. * tools/asinfo/tests/list_arch.test: Likewise. * tools/asinfo/tests/multiarch_get_sname.c: Likewise. * tools/asinfo/tests/multiarch_get_sname.test: Likewise. * tools/asinfo/tests/multiarch_get_snum.c: Likewise. * tools/asinfo/tests/multiarch_get_snum.test: Likewise. * tools/asinfo/tests/set_abi.c: Likewise. * tools/asinfo/tests/set_abi.test: Likewise. * tools/asinfo/tests/set_arch.c: Likewise. * tools/asinfo/tests/set_arch.test: Likewise. * tools/asinfo/tests/set_mult_abi.c: Likewise. * tools/asinfo/tests/set_mult_abi.test: Likewise. * tools/asinfo/tests/set_mult_arch.c: Likewise. * tools/asinfo/tests/set_mult_arch.test: Likewise. Signed-off-by: Edgar Kaziakhmedov <edos.edgar@gmail.com> Adjusted-and-rebased-by: Dmitry V. Levin <ldv@altlinux.org>
* Update copyright headersDmitry V. Levin2020-04-03132-127/+132
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* Fix preprocessor indentationDmitry V. Levin2020-04-0314-89/+89
| | | | | | | | | 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
* unwind-libdw: add cachingJann Horn2020-04-031-19/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libdw's address-to-symbol logic is quite slow. Since when stracing a process, it is normal to see the same call sites over and over again, let's address that by adding a straightforward N-way associative cache in front of libdw. The cache parameters could probably use some fine-tuning, but ought to be good enough for now. The resulting performance improvement: $ time ./strace-orig -o /dev/null -k bash -c 'for i in {0..10000}; do echo; done' >/dev/null real 0m12,014s user 0m11,512s sys 0m0,575s $ time ./strace-cache -o /dev/null -k bash -c 'for i in {0..10000}; do echo; done' >/dev/null real 0m0,765s user 0m0,451s sys 0m0,371s Reviewed-By: Masatake YAMATO <yamato@redhat.com> * unwind-libdw.c: Include "static_assert.h". (STRACE_UW_CACHE_SIZE, STRACE_UW_CACHE_ASSOC): New macros. (struct cache_entry): New type. (struct ctx): Add "cache" field, extend the type of "last_proc_updating" field. (mapping_generation): Extend the type, initialize to 1. (uwcache_clock): New variable. (tcb_init): Initialize struct ctx.cache. (truct frame_user_data): Add "ctx" field. (find_bucket): New function. (frame_callback): Use it. (tcb_walk): Initialize user_data.ctx.
* sparc, sparc64: wire up former vserver syscallDmitry V. Levin2020-04-022-2/+2
| | | | | | | | ... because Linux kernel arch/sparc/kernel/syscalls/syscall.tbl still lists it. * linux/sparc/syscallent.h [267]: Add vserver entry. * linux/sparc64/syscallent.h [267]: Add vserver entry.
* hppa: wire up kexec_file_load syscallDmitry V. Levin2020-04-022-2/+4
| | | | | | | ... introduced on hppa by Linux kernel commit v5.4-rc1~188^2~3. * linux/hppa/syscallent.h [355]: Add kexec_file_load entry. * NEWS: Mention this.
* hdio: implement HDIO_DRIVE_CMD ioctl command decodingEugene Syromyatnikov2020-04-023-1/+202
| | | | | | | | | | | * xlat/hdio_drive_cmds.in: New file. * hdio.c: Include "xlat/hdio_drive_cmds.h". (print_hdio_drive_cmd): New function. (hdio_ioctl): Call print_hdio_drive_cmd if code is HDIO_DRIVE_CMD. * tests/ioctl_hdio.c (main) <unsupp_cmds>: Remove HDIO_DRIVE_CMD. (main): Add HDIO_DRIVE_CMD checks. Closes: https://github.com/strace/strace/issues/83
* hdio: factor out the HDIO_GETGEO handler into a separate functionEugene Syromyatnikov2020-04-021-15/+27
| | | | | | | | | And update it up to the current coding style. * hdio.c: Include "print_fields.h". (print_hdio_getgeo): New function. (hdio_ioctl) <case HDIO_GETGEO>: Call print_hdio_getgeo instead of decoding in place.
* tests: check decoding of HDIO_* ioctlsEugene Syromyatnikov2020-04-0220-0/+243
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests/.gitignore: Add ioctl_hdio, ioctl_hdio-success, ioctl_hdio-success-Xabbrev, ioctl_hdio-success-Xraw, ioctl_hdio-success-Xverbose, ioctl_hdio-success-v, ioctl_hdio-success-v-Xabbrev, ioctl_hdio-success-v-Xraw, ioctl_hdio-success-v-Xverbose, ioctl_hdio-Xabbrev, ioctl_hdio-Xraw, ioctl_hdio-Xverbose, ioctl_hdio-v, ioctl_hdio-v-Xabbrev, ioctl_hdio-v-Xraw, and ioctl_hdio-v-Xverbose. * tests/Makefile.am (check_PROGRAMS): Add ioctl_hdio-success, ioctl_hdio-success-Xabbrev, ioctl_hdio-success-Xraw, ioctl_hdio-success-Xverbose, ioctl_hdio-success-v, ioctl_hdio-success-v-Xabbrev, ioctl_hdio-success-v-Xraw, and ioctl_hdio-success-v-Xverbose. * tests/gen_tests.in (ioctl_hdio, ioctl_hdio-Xabbrev, ioctl_hdio-Xraw, ioctl_hdio-Xverbose, ioctl_hdio-v, ioctl_hdio-v-Xabbrev, ioctl_hdio-v-Xraw, ioctl_hdio-v-Xverbose, ioctl_hdio-success, ioctl_hdio-success-Xabbrev, ioctl_hdio-success-Xraw, ioctl_hdio-success-Xverbose, ioctl_hdio-success-v, ioctl_hdio-success-v-Xabbrev, ioctl_hdio-success-v-Xraw, ioctl_hdio-success-v-Xverbose): New tests. * tests/ioctl_hdio.c: New file. * tests/ioctl_hdio-Xabbrev.c: Likewise. * tests/ioctl_hdio-Xraw.c: Likewise. * tests/ioctl_hdio-Xverbose.c: Likewise. * tests/ioctl_hdio-success.c: Likewise. * tests/ioctl_hdio-success-Xabbrev.c: Likewise. * tests/ioctl_hdio-success-Xraw.c: Likewise. * tests/ioctl_hdio-success-Xverbose.c: Likewise. * tests/ioctl_hdio-success-v.c: Likewise. * tests/ioctl_hdio-success-v-Xabbrev.c: Likewise. * tests/ioctl_hdio-success-v-Xraw.c: Likewise. * tests/ioctl_hdio-success-v-Xverbose.c: Likewise. * tests/ioctl_hdio-v.c: Likewise. * tests/ioctl_hdio-v-Xabbrev.c: Likewise. * tests/ioctl_hdio-v-Xraw.c: Likewise. * tests/ioctl_hdio-v-Xverbose.c: Likewise. * tests/pure_executables.list: Add ioctl_hdio, ioctl_hdio-Xabbrev, ioctl_hdio-Xraw, ioctl_hdio-Xverbose, ioctl_hdio-v, ioctl_hdio-v-Xabbrev, ioctl_hdio-v-Xraw, and ioctl_hdio-v-Xverbose.
* linux/32: move wait4 and [gs]ettimeofday from syscallent.h to ↵Dmitry V. Levin2020-04-024-12/+19
| | | | | | | | | | | | | | | | | | syscallent-time32.h According to Linux kernel include/uapi/asm-generic/unistd.h, starting with commit v5.1-rc1~160^2~1^2~3 __NR_wait4, __NR_gettimeofday, and __NR_settimeofday are placed under __ARCH_WANT_TIME32_SYSCALLS and therefore should belong to syscallent-time32.h along with other 32-bit time_t based syscalls. * linux/32/syscallent.h [169, 170, 260]: Move entries ... * linux/32/syscallent-time32.h: ... here. * time.c (SYS_FUNC(gettimeofday), SYS_FUNC(settimeofday)): Place under [HAVE_ARCH_TIME32_SYSCALLS || HAVE_ARCH_OLD_TIME64_SYSCALLS] guard. * wait.c (SYS_FUNC(wait4)): Likewise. Complements: v5.5-39-gcc7e89011 "linux/32: Split 32-bit time_t based syscalls into a separate header"
* tests: fix another race condition in strace-DD.testDmitry V. Levin2020-04-024-25/+51
| | | | | | | | | | | | | | | | Apparently, timeout(1) utility first sends its signal to the child process, then installs a signal handler, and finally sends its signal to the process group. This creates a race between timeout(1) and strace, the latter can manage to handle tracee syscall exit trap before a signal to the process group is delivered. * tests/setpgrp-exec.c: New file. * tests/strace-DD.test: Rewrite without use of timeout(1). * tests/strace-DD.expected: Remove. * tests/Makefile.am (check_PROGRAMS): Add setpgrp-exec. (EXTRA_DIST): Remove strace-DD.expected. Fixes: v5.4~106 "tests: check -DD and -DDD options"
* tests: add a workaround for trace_creds test on mips o32Dmitry V. Levin2020-04-011-0/+7
| | | | | | | | | | Since every mips o32 executable used by trace_creds test invokes prctl(PR_GET_FP_MODE) on their own and these calls are not filtered out by %creds, they have to be filtered out manually before comparison. * tests/init.sh (test_pure_prog_set) [$STRACE_ARCH == mips && $MIPS_ABI == o32 && $NAME == *creds]: Filter out prctl(PR_GET_FP_MODE) from the strace log before comparison.
* Lift experimental status from --seccomp-bpf featureDmitry V. Levin2020-04-011-1/+1
| | | | * strace.1.in (.SH OPTIONS) <--seccomp-bpf>: Remove " (experimental)".
* strace.1: enhance --seccomp-bpf descriptionDmitry V. Levin2020-04-011-6/+6
| | | | * strace.1.in (.SH OPTIONS) <--seccomp-bpf>: Reword for clarity.
* strace.1: fix --seccomp-bpf descriptionDmitry V. Levin2020-04-011-3/+3
| | | | | | | | * strace.1.in (.SH OPTIONS) <--seccomp-bpf>: Remove the claim that this option implies -f, document that --seccomp-bpf has no effect unless -f/--follow-forks is also specified. Complements: v5.5-38-g2a7ba2a97 "strace: disable seccomp-bpf instead of enabling following forks"
* ci: use kernel headers from Linux kernel v5.6Dmitry V. Levin2020-04-012-0/+2
| | | | | | | | | When Linux kernel merge window opens, changes of all sorts start to pour down, breaking UAPI in various ways. This does not work for strace, we need a stable UAPI. * .gitlab-ci.yml (variables): Add KBRANCH. * .travis.yml (env:global): Likewise.
* tests: fix get*id-creds tests on mipsDmitry V. Levin2020-03-311-1/+12
| | | | | | | | | Apparently, mips executables may invoke prctl(PR_GET_FP_MODE) on their own. Since these calls are not filtered out by %creds, they have to be dealt with before comparison. * tests/getuid.test [$STRACE_ARCH == mips]: Filter out prctl(PR_GET_FP_MODE) from the log of %creds tests.
* Update ioctl entries from linux v5.6Gleb Fotengauer-Malinovskiy2020-03-318-70/+70
| | | | | | | | | | | | * linux/32/ioctls_inc_align16.h: Update from linux v5.6 using ioctls_gen.sh. * linux/32/ioctls_inc_align32.h: Likewise. * linux/32/ioctls_inc_align64.h: Likewise. * linux/64/ioctls_inc.h: Likewise. * linux/x32/ioctls_inc0.h: Likewise. * linux/s390/ioctls_arch0.h: Likewise. * linux/s390x/ioctls_arch0.h: Likewise. * NEWS: Mention this.
* maint: update for linux v5.6Gleb Fotengauer-Malinovskiy2020-03-311-0/+11
| | | | | * maint/ioctls_sym.sh: Add workarounds for media/v4l2-ioctl.h and sound/pcm.h headers.
* Update NEWSEugene Syromyatnikov2020-03-311-12/+34
|
* tests: fix race condition in strace-D.testDmitry V. Levin2020-03-311-4/+14
| | | | | | | * tests/strace-D.test (test_parent_tracer_pid): Wait for the tracer completion before checking its log. Fixes: v5.4~110 "tests: check -D option"
* tests: fix race condition in strace-DDD.testDmitry V. Levin2020-03-312-5/+24
| | | | | | | | | * tests/tracer_ppid_pgid_sid.c (main): Print tracer pid. * tests/strace-DDD.test: Check tracer pid, wait for the tracer completion before checking its log. Reported-by: Eugene Syromyatnikov <evgsyr@gmail.com> Fixes: v5.4~106 "tests: check -DD and -DDD options"
* tests: fix race condition in strace-DD.testDmitry V. Levin2020-03-311-4/+34
| | | | | | | | | | | Apparently, $SLEEP_A_BIT might be insufficient for the tracer to complete. * tests/strace-DD.test: Find out the tracer pid and wait for the tracer completion before checking its log. Suggested-by: Eugene Syromyatnikov <evgsyr@gmail.com> Fixes: v5.4~106 "tests: check -DD and -DDD options"
* tests: split getxxid testDmitry V. Levin2020-03-316-15/+75
| | | | | | | | | | | | | getxxid used to test alpha-specific getxgid, getxuid, and getxgid syscalls. Now each of these syscalls has its own test. This hopefully fixes trace_creds test on alpha. * tests/getxxid.c: Split into getxpid.c, getxuid.c, and getxgid.c. * tests/gen_tests.in (getxxid): Remove. (getxgid, getxpid, getxuid): New tests. * tests/pure_executables.list: Replace getxxid with getxgid, getxpid, and getxuid. * tests/.gitignore: Likewise.
* ia64: rename getpagesize syscall entry to old_getpagesizeDmitry V. Levin2020-03-301-1/+1
| | | | | | | | ... to match the Linux kernel that introduced __NR_old_getpagesize by commit v5.0-rc1~164^2~4. * linux/ia64/syscallent.h [BASE_NR + 147]: Rename "getpagesize" to "old_getpagesize".
* tests: disable umovestr_cached.test on mips o32 unless ↵Dmitry V. Levin2020-03-301-2/+5
| | | | | | | | | | | | PTRACE_GET_SYSCALL_INFO works If PTRACE_GET_SYSCALL_INFO does not work, then the test has to be skipped on mips o32 because only the first four syscall arguments are obtained from registers on that architecture, remaining syscall arguments have to be fetched from the tracee memory. * tests/umovestr_cached.test [$STRACE_ARCH == mips && $MIPS_ABI == o32]: Skip the test if PTRACE_GET_SYSCALL_INFO does not work.
* tests: re-enable umovestr_cached.test on ia64 if PTRACE_GET_SYSCALL_INFO worksDmitry V. Levin2020-03-301-8/+13
| | | | | | | | | | If PTRACE_GET_SYSCALL_INFO works, then the exception made for ia64 earlier is not relevant. * tests/umovestr_cached.test [$STRACE_ARCH == ia64]: Do not skip the test if PTRACE_GET_SYSCALL_INFO works. Complements: v5.3~23 "tests: disable umovestr_cached.test on ia64"
* Implement pidfd_getfd syscall decodingEugene Syromyatnikov2020-03-308-0/+103
| | | | | | | | | | | | | | Introduced by Linux commit v5.6-rc1~122^2~4 and wired up in Linux commit v5.6-rc1~122^2~3. * pidfd_getfd.c: New file. * Makefile.am (strace_SOURCES): Add it. * linux/syscallent-common.h ([BASE_NR + 438]): Wire up pidfd_getfd. * tests/pidfd_getfd.c: New file. * tests/pidfd_getfd-y.c: Likewise. * tests/.gitignore: Add pidfd_getfd and pidfd_getfd-y. * tests/pure_executables.list: Likewise. * tests/gen_tests.in: Add pidfd_getfd and pidfd_getfd-y tests.
* Move printpidfd from kcmp.c to util.cEugene Syromyatnikov2020-03-303-14/+20
| | | | | | | | | | | | And rename it to print_pid_fd in an attempt to minimise confusion with the kernel's pidfd concept. * kcmp (PRINT_FIELD_PIDFD, SYS_FUNC(kcmp)): Change printpidfd calls to print_pid_fd. (printpidfd): Move it... * util.c (print_pid_fd): ...here. Drop the static qualifier, update the comment describing why this is a stub. * defs.h (print_pid_fd): New declaration.
* open: implement openat2 syscall decodingEugene Syromyatnikov2020-03-3020-4/+319
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced by Linux commit v5.6-rc1~133^2~2. * configure.ac (AC_CHECK_HEADERS): Check for linux/openat2.h. * defs.h (print_numeric_umode_t_64): New declaration. * linux/syscallent-common.h ([BASE_NR + 437]): Wire up openat2. * types/openat2.h: New file. * open.c: Include "print_fields.h", "types/openat2.h", and "xlat/open_resolve_flags.h". (sprint_open_modes64): Rename from sprint_open_modes, change argument type to uint64_t. (sprint_open_modes): New function, a wrapper for sprint_open_modes64 with argument type of unsigned int. (tprint_open_modes64): Rename from tprint_open_modes, change argument type to uint64_t, call sprint_open_modes64 instead of sprint_open_modes. (tprint_open_modes): New function, a wrapper for tprint_open_modes64 with an argument of type unsigned int. (print_open_how): New function. (SYS_FUNC(openat2)): New decoder. * printmode.c (print_numeric_umode_t_64): New function. * tests/openat2.c: New file. * tests/openat2-Xabbrev.c: Likewise. * tests/openat2-Xraw.c: Likewise. * tests/openat2-Xverbose.c: Likewise. * tests/openat2-v.c: Likewise. * tests/openat2-v-y.c: Likewise. * tests/openat2-v-y-Xabbrev.c: Likewise. * tests/openat2-v-y-Xraw.c: Likewise. * tests/openat2-v-y-Xverbose.c: Likewise. * tests/openat2-y.c: Likewise. * tests/.gitignore: Add openat2, openat2-Xabbrev, openat2-Xraw, openat2-Xverbose, openat2-v, openat2-v-y, openat2-v-y-Xabbrev, openat2-v-y-Xraw, openat2-v-y-Xverbose, openat2-y. * tests/pure_executables.list: Likewise. * tests/gen_tests.in: Add openat2, openat2-Xabbrev, openat2-Xraw, openat2-Xverbose, openat2-v, openat2-v-y, openat2-v-y-Xabbrev, openat2-v-y-Xraw, openat2-v-y-Xverbose, openat2-y tests. * xlat/open_resolve_flags.in: New file.
* Move print_nonzero_bytes from clone.c to util.cEugene Syromyatnikov2020-03-303-66/+72
| | | | | | | | As it is to be used elsewhere. * clone.c (print_nonzero_bytes): Move it... * util.c (print_nonzero_bytes): ...here. Remove static qualifier. * defs.h (print_nonzero_bytes): New declaration.
* travis: remove ppc64le buildsEugene Syromyatnikov2020-03-301-11/+0
| | | | | | | They are currently unusable, permanently failing with "Disk quota exceeded" error diagnostics. * .travis.yml (arch: ppc64le): Remove.
* xtensa: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-308-38/+15
| | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on xtensa by Linux kernel commit v2.6.13-rc1~68^2~366. * configure.ac [xtensa]: Remove arch_enable_Werror=no. * linux/xtensa/get_syscall_result.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. * linux/xtensa/arch_regs.c (xtensa_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (xtensa_a2, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/xtensa/get_error.c (arch_get_error): Use xtensa_regs.a[2]. * linux/xtensa/get_syscall_args.c (arch_get_syscall_args): Use xtensa_regs.a. * linux/xtensa/set_error.c (arch_set_error, arch_set_success): Use xtensa_regs.a[2]. * NEWS: Mention this change.
* sh64: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-3011-62/+20
| | | | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on sh64 by Linux kernel commit v2.6.28-rc1~99^2~56. * configure.ac [sh64]: Remove arch_enable_Werror=no. * linux/sh64/arch_regs.h: Remove. * linux/sh64/get_syscall_result.c: Likewise. * Makefile.am (EXTRA_DIST): Remove them. * linux/sh64/arch_regs.c (sh64_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (sh64_r9, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/sh64/get_error.c (arch_get_error): Use sh64_regs.regs[9]. * linux/sh64/get_scno.c (arch_get_scno): Use sh64_regs.regs[9]. * linux/sh64/get_syscall_args.c (arch_get_syscall_args): Use sh64_regs.regs. * linux/sh64/set_error.c (arch_set_error, arch_set_success): Use sh64_regs.gr[9]. * linux/sh64/set_scno.c (arch_set_scno): Use sh64_regs.regs[9]. * NEWS: Mention this change.
* sh: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-3011-64/+23
| | | | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on sh by Linux kernel commit v2.6.28-rc1~99^2~56. * configure.ac [sh]: Remove arch_enable_Werror=no. * linux/sh/get_syscall_result.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. * linux/sh/arch_regs.c (sh_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (sh_r0, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/sh/arch_getrval2.c (getrval2): Use sh_regs.regs[1]. * linux/sh/get_error.c (arch_get_error): Use sh_regs.regs[0]. * linux/sh/get_scno.c (arch_get_scno): Use sh_regs.regs[3]. * linux/sh/get_syscall_args.c (arch_get_syscall_args): Use sh_regs.regs. * linux/sh/set_error.c (arch_set_error, arch_set_success): Use sh_regs.gr[0]. * linux/sh/set_scno.c (arch_set_scno): Use sh_regs.regs[3]. * NEWS: Mention this change.
* v4l2: use PRINT_FIELD_* macros, add abbreviating in print_v4l2_queryctrlEugene Syromyatnikov2020-03-302-9/+26
| | | | | | | | | | | | * v4l2.c (print_v4l2_queryctrl): Use PRINT_FIELD_XVAL for the type field printing; use PRINT_FIELD_D for minimum, maximum, step, and default_value fields printing; use PRINT_FIELD_FLAGS for the flags field printing; print minimum, maximum, step, default_value, and flags fields only if abbrev(tcp) is not set. * tests/ioctl_v4l2-success.c: Update expected output. Suggested-by: Philippe De Muyter <phdm@macqel.be> References: https://github.com/strace/strace/issues/63
* v4l2: simplify print_v4l2_queryctrl and use print_v4l2_cidEugene Syromyatnikov2020-03-303-38/+50
| | | | | | | | | | | | | | | | | | | | Instead of fragile hacks aroung V4L2_CTRL_FLAG_NEXT_CTRL flag, (always) save the id field on entering, restore it later on exiting, and print it second time only if it has changed. That also simplifies the flow with clear entering/exiting code parts separation. The usage of print_v4l2_cid for id field printing has introduced several (anticipated) output formatting changes, hence the changes in expected output. * v4l2.c (print_v4l2_queryctrl): Save c.id on entering, print it using print_v4l2_cid with next_flags set to true, and return 0; remove "entering(tcp) || get_tcb_priv_ulong(tcp)" logic; restore the entering id value into entry_id variable on exiting, compare it to the exiting c.id value and print c.id again if it is different; do not check if tcp is exiting; always return RVAL_IOCTL_DECODED at the end of the function. * tests/ioctl_v4l2.c: Update expected output. * tests/ioctl_v4l2-success.c: Likewise.
* v4l2: add support for V4L2_CTRL_FLAG_NEXT_* flags printing to print_v4l2_cidEugene Syromyatnikov2020-03-301-3/+15
| | | | | | | | | | | | * v4l2.c: Move "xlat/v4l2_control_query_flags.h" inclusion before print_v4l2_cid. (print_v4l2_cid): Remove const qualifier from cid, add bool next_flags argument; print v4l2_control_query_flags and NAND them from cid if they are present. (print_v4l2_control): Pass false as next_flags to the print_v4l2_cid call. References: https://github.com/strace/strace/issues/63
* xlat: add generation of flags-related fieldsEugene Syromyatnikov2020-03-302-0/+47
| | | | | | | | | | | 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.
* v4l2: handle -Xraw in print_v4l2_cidEugene Syromyatnikov2020-03-301-0/+5
| | | | | | | Print class ID as simple hex value in that case. * v4l2.c (print_v4l2_cid): Print cid as hex and return if xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW.
* v4l2: use xsprintf instead of asprintf in print_v4l2_cidEugene Syromyatnikov2020-03-301-6/+6
| | | | | | | Avoid an allocation and steamline code a bit. * v4l2.c (print_v4l2_cid): Change tmp_str to a stack-allocated char array, print to it with xsprintf, eliminate no longer needed free() call.
* v4l2: provide V4L2_CTRL_FLAG_NEXT_CTRL in an xlatEugene Syromyatnikov2020-03-303-8/+7
| | | | | | | | | | | * xlat/v4l2_control_query_flags.in: New file. * v4l2.c: Include "xlat/v4l2_control_query_flags.h". (print_v4l2_queryctrl): Remove "ifdef V4L2_CTRL_FLAG_NEXT_CTRL" guard. * tests/ioctl_v4l2.c [!V4L2_CTRL_FLAG_NEXT_CTRL] (V4L2_CTRL_FLAG_NEXT_CTRL): New macro. (main) [!V4L2_CTRL_FLAG_NEXT_CTRL]: Remove. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: decode frame intervals/sizes unconditionallyEugene Syromyatnikov2020-03-304-14/+60
| | | | | | | | | | | | | * configure.ac (AC_CHECK_TYPES): Check for struct v4l2_frmsizeenum and struct v4l2_frmivalenum. * types/v4l2.h (struct_v4l2_frmsize_discrete, struct_v4l2_frmsize_stepwise, struct_v4l2_frmsizeenum, struct_v4l2_frmival_stepwise, struct_v4l2_frmivalenum): New type definitions. v4l2.c: Remove "ifdef VIDIOC_ENUM_FRAMESIZES" guards. * xlat/v4l2_ioctl_cmds.in (VIDIOC_ENUM_FRAMESIZES, VIDIOC_ENUM_FRAMEINTERVALS): Uncomment. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: always decode VIDIOC_*_EXT_CTRLS ioctl commandsEugene Syromyatnikov2020-03-303-13/+43
| | | | | | | | | | | | | | | * types/v4l2.h (struct_v4l2_area, struct_v4l2_ext_control, struct_v4l2_ext_controls): New type definitions. * v4l2.c (print_v4l2_ext_control, print_v4l2_ext_controls): Do not guard with VIDIOC_S_EXT_CTRLS anymore. (v4l2_ioctl) <case VIDIOC_S_EXT_CTRLS, case VIDIOC_TRY_EXT_CTRLS, case VIDIOC_G_EXT_CTRLS>: Likewise. (print_v4l2_ext_control): Do not guard size and string field printing with HAVE_STRUCT_V4L2_EXT_CONTROL_STRING. * xlat/v4l2_ioctl_cmds.in (VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS): Uncomment. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: bundle struct v4l2_format and related typesEugene Syromyatnikov2020-03-305-33/+236
| | | | | | | | | | | | | | | | | * configure.ac (AC_CHECK_TYPES): Check for struct v4l2_meta_format, struct v4l2_pix_format_mplane, struct v4l2_plane_pix_format, and struct v4l2_sdr_format. * types/v4l2.h (struct_v4l2_clip, struct_v4l2_format): Typedef to an anonymous type definition. (struct_v4l2_pix_format, struct_v4l2_plane_pix_format, struct_v4l2_pix_format_mplane, struct_v4l2_window, struct_v4l2_vbi_format, struct_v4l2_sliced_vbi_format, struct_v4l2_sliced_vbi_cap, struct_v4l2_sdr_format, struct_v4l2_meta_format): New typedefs. * v4l2.c (print_v4l2_format_fmt): Remove guard macros, decode fmt.win.global_alpha and fmt.sdr.buffersize only when they are non-zero. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: provide struct v4l2_capability definitionEugene Syromyatnikov2020-03-304-9/+22
| | | | | | | | | | | * types/v4l2.h (struct_v4l2_capability): New typedef. * v4l2.c: Check struct v4l2_capability with CHECK_V4L2_STRUCT_RESERVED_SIZE. (print_v4l2_capability): Change type of caps variable to struct_v4l2_capability; drop HAVE_STRUCT_V4L2_CAPABILITY_DEVICE_CAPS guard; print device_caps field only if it's non-zero. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: bundle struct v4l2_create_buffers definitionEugene Syromyatnikov2020-03-304-23/+50
| | | | | | | | | | | | | | | | | * configure.ac (AC_CHECK_TYPES): Add a check for struct v4l2_create_buffers definition. * types/v4l2.h: New file. * v4l2.c (DEF_MPERS_TYPE(struct_v4l2_create_buffers)): Remove VIDIOC_CREATE_BUFS guard. (struct_v4l2_create_buffers): Remove typedef. (struct_v4l2_buffer, struct_v4l2_clip, struct_v4l2_ext_control, struct_v4l2_ext_controls, struct_v4l2_format, struct_v4l2_framebuffer, struct_v4l2_input, struct_v4l2_standard): Move to types/v4l2.h. [HAVE_STRUCT_V4L2_CREATE_BUFFERS]: Check struct v4l2_create_buffers with CHECK_V4L2_STRUCT_RESERVED_SIZE. * xlat/v4l2_ioctl_cmds.in (VIDIOC_CREATE_BUFS): Uncomment. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: add V4L2 ioctl command constant macrosEugene Syromyatnikov2020-03-302-0/+107
| | | | | | | | | | | For now, only those that we support, and only for those we don't conditionalise in code, since the fall-back definitions require the relevant type definitions, and not all of them are always available. * xlat/v4l2_ioctl_cmds.in: New file. * v4l2.c: Include "xlat/v4l2_ioctl_cmds.h" under XLAT_MACRO_ONLY definition.
* v4l2: add shorthand macros for v4l2 type checksEugene Syromyatnikov2020-03-301-0/+18
| | | | | | | | | Some wrappers for common static_assert checks. * v4l2.c (CHECK_V4L2_STRUCT_SIZE, CHECK_V4L2_RESERVED_SIZE. CHECK_V4L2_STRUCT_RESERVED_SIZE): New macros. References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
* v4l2: improve buffer flag decodingEugene Syromyatnikov2020-03-306-30/+77
| | | | | | | | | | | | | | * 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. * tests/ioctl_v4l2-success.c: Update expected output. References: https://github.com/strace/strace/issues/63