Honor xlat styles when decoding wait4

Dmitry V. Levin ldv at altlinux.org
Fri Apr 5 00:03:54 UTC 2019


Hi,

On Mon, Mar 25, 2019 at 07:23:30PM -0700, shankarapailoor wrote:
> Hi Dmitry,
> 
> It seems that strace doesn't honor xlat styles when decoding the wait4
> system call. Attached is a patch that fixes this issue.
[...]
> diff --git a/wait.c b/wait.c
> index dbc917b1..92031082 100644
> --- a/wait.c
> +++ b/wait.c
> @@ -24,29 +24,39 @@
>  static int
>  printstatus(int status)
>  {
> -	int exited = 0;
> -
> +	bool stopped = WIFSTOPPED(status);
> +	bool signaled = WIFSIGNALED(status);
> +	bool exited = WIFEXITED(status);
> +	bool print_raw = !stopped && !signaled && !exited;
> +#ifdef WIFCONTINUED
> +	print_raw = print_raw && !WIFCONTINUED(status);
> +#endif
>  	/*
>  	 * Here is a tricky presentation problem.  This solution
>  	 * is still not entirely satisfactory but since there
>  	 * are no wait status constructors it will have to do.
>  	 */
> -	if (WIFSTOPPED(status)) {
> +
> +	if (print_raw || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
> +		tprintf("[%#x]", status);

The status is printed in square brackets because of indirection:
it was fetched earlier from memory right before printstatus invocation.

That's why the suggested style [%#x] /* [comment] */ is not applicable,
it should rather be [%#x /* comment */] instead.

I think you could simplify the code by moving the printing of these square
brackets out of printstatus().


-- 
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/20190405/9412c84d/attachment.bin>


More information about the Strace-devel mailing list