[PATCH v7 2/4] Stage output for -z and -Z options
Dmitry V. Levin
ldv at altlinux.org
Thu Jul 11 12:30:46 UTC 2019
On Sat, Jul 06, 2019 at 09:19:41AM +0200, Paul Chaignon wrote:
> -z and -Z options print only successful and failing syscalls respectively.
> However, failure of syscall is only known after syscall return. Thus, we
> end up with something like this on, e.g., ENOENT:
>
> open("does_not_exist", O_RDONLY <unfinished ...>
>
> whereas the intended result is that the open(...) line is not shown at all.
>
> This patch fixes this issue using open_memstream. When either the -z or
> the -Z option is used, the output is staged in memory (using
> open_memstream) until we know the syscall return status. If the
> open_memstream function is not available, these new options error out.
>
> * stage_output.c: New file.
> * defs.h (struct tcb): Add real_outf, memfptr, memfloc fields for
> memstream.
> (strace_open_memstream, strace_close_memstream): New prototypes.
> * Makefile.am (strace_SOURCES): Add stage_output.c.
> * configure.ac (AC_CHECK_FUNCS): Add open_memstream.
> * strace.1.in: Document -z and -Z options.
> * strace.c (init): Error on -z and -Z options if open_memstream if
> unavailable.
> (maybe_switch_tcbs): Handle switch of memstream between tcbs.
> * syscall.c (syscall_entering_trace): Open memstream.
> (syscall_exiting_trace): Filter failed syscalls if failing_only is set,
> handle raw(tcp) case.
> * NEWS: Mention this change.
>
> Resolves https://github.com/strace/strace/issues/49.
This should be
Resolves: https://github.com/strace/strace/issues/49
> diff --git a/NEWS b/NEWS
> index ddca2b2b..7bd17e00 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -4,6 +4,7 @@ Noteworthy changes in release ?.? (????-??-??)
> * Bug fixes
> * Fixed syscall tampering on powerpc, powerpc64, sparc, and sparc64 when
> PTRACE_GET_SYSCALL_INFO is in use.
> + * Fixed -z option to print only successful syscalls.
>
> * Improvements
> * Implemented decoding of open_tree, move_mount, fsopen, fsconfig, fsmount,
I suggest documenting -z option as a new feature instead of a bug fix
since -z has never worked properly before and was explicitly undocumented
since commit v4.4.95~21:
2003-01-21 Roland McGrath <roland at redhat.com>
* strace.c (usage): Omit -z, since it has never worked properly.
* NEWS: Likewise.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20190711/85ba1fba/attachment.bin>
More information about the Strace-devel
mailing list