From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D199C433DF for ; Mon, 15 Jun 2020 11:45:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 328E42065F for ; Mon, 15 Jun 2020 11:45:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 328E42065F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jknYS-0002dk-EM for qemu-devel@archiver.kernel.org; Mon, 15 Jun 2020 07:45:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jknXi-0001mr-En for qemu-devel@nongnu.org; Mon, 15 Jun 2020 07:44:46 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:47267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jknXg-0002ND-I3 for qemu-devel@nongnu.org; Mon, 15 Jun 2020 07:44:46 -0400 Received: from [192.168.100.1] ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.119]) with ESMTPSA (Nemesis) id 1MiJhQ-1jESru43F8-00fW6Q; Mon, 15 Jun 2020 13:44:41 +0200 Subject: Re: [PATCH v3 1/6] linux-user: Extend strace support to enable argument printing after syscall execution To: Filip Bozuta , qemu-devel@nongnu.org References: <20200611155109.3648-1-filip.bozuta@syrmia.com> <20200611155109.3648-2-filip.bozuta@syrmia.com> From: Laurent Vivier Autocrypt: addr=laurent@vivier.eu; prefer-encrypt=mutual; keydata= mQINBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1zN4NKubApQOlNKZZC4hu6/ 8pv2t4HRi7s0K88jQYBRPObjrN5+owtI51xMaYzvPitHQ2053LmgsOdN9EKOqZeHAYG2SmRW LOxYWKX14YkZI5j/TXfKlTpwSMvXho+efN4kgFvFmP6WT+tPnwARAQABtCJMYXVyZW50IFZp dmllciA8bGF1cmVudEB2a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wGS ZiJK0xFusPQehjWTHn9WjMG1zvQ5TQQHxau/2FkP45+nRPco6vVFQe8JmgtRF8WFJA== Message-ID: <214b3da5-db76-a1ca-8ea2-5d10cc3370d8@vivier.eu> Date: Mon, 15 Jun 2020 13:44:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200611155109.3648-2-filip.bozuta@syrmia.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:bxNv7d7oNZotFQZ/NSA+iioHM/TmGgxhiLK+gkGV+HS2G+0Apc1 8n3+OLvStfm4j59VnMdqWCVMheZ2Md8yHv+hmAtPtdeY1Wga7YqNnt7bAetWYlrNeDxcrGa 0kUDYrIa4g6bLP70pYIB/9lA6s6bdrmX4QanLTFV8JmKLb9c6xTQMUvtT/RAG6hjZSUGKlV VTgahjR48e2dz4BtZr5og== X-UI-Out-Filterresults: notjunk:1;V03:K0:B/nRJb/Fgpg=:Kz7+zTeShvfGTndkswoHUF xUqX+Ts4eTGl4+0o0Lm0gWj5AvZEWuoVScwrGm4zhcsATsNUHPBHUJuAphWDa+twXmdFr5uD8 TC9QwGsrQHGWAf2e0OPbyiNLkAYJ4sbkOjGUO9HYRTisyhbXL0EJcdWIlQY7M9NrBSFUjD+G6 JLkMQw3cHNmz1sz6iKxXuWvVCGJMCK6OxpHL47Bo3i4DCRMiY1x6weSF8L/VcxrMkzrIfip+n xcxvlDfY5RCxDlg+yqyiOS8+MDtZ0fhS2Ero7j6LqhTMiQW5lWXTonJlYOoqQMWXo4nCr5Dvc I/2HtUinGYXPYJveuzyP3zBYxjj5pNrFK5q5otjCv0nrY3o3DSv4E3gFaMot+sqTohk1Wl8nf eM52amVFKtWSQKHPe9BNcPR74VzSxw0TJOEPE6sV7lK8IfuGDw8Y0FsW8DD7pvXQ630ZNmtQP GawXFOWodp/j+DVBq0YNhW8e/EH+byosi0ZFATUHi9LLY+xb2CT/wrNfUuw+SuTCbFr96ZCSD GzhA0lAHkXw83pfvUPjvoXvxdjWwf5MTP64qxGcu5WWtOVQhQuvFo+Rf+o3UHWMHkqgFWnMTY qHUsLhqWGbtuZ64+3hOSzGfpl+Nl7Hgg/WyU9hIN8+8EOO8mUCSDNu8J8gMqvfGm2r1zgpcKm hEXgrB3waG2BlnNMA3Z45QfmZOk6uMc++OzZOUrIJpssRp4VUFz+iIIJiThWdmGauPqxVsiXJ fhXek5tRRUgRiwR+Eb+lOqPetpEhSTRXP/7htKSThZNhDCMewtYk1MRtNRmtyQjhydT82ducs YXNa0YWSAf2Icv6GNFf3bSToN8rWdOISPQMsQUzmgr6g1WvaTcwjwBzj/GU0vrk/aynjr9h Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/15 07:44:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Le 11/06/2020 à 17:51, Filip Bozuta a écrit : > From: Filip Bozuta > > Structure "struct syscallname" in file "strace.c" is used for "-strace" > to print arguments and return values of syscalls. The last field of > this structure "result" represents the calling function that prints the > return values. This field was extended in this patch so that this functions > takes all syscalls arguments beside the return value. In this way, it enables > "-strace" to print arguments of syscalls that have changed after the syscall > execution. This extension will be useful as there are many syscalls that > return values inside their arguments (i.e. listxattr() that returns the list > of extended attributes inside the "list" argument). > > Implementation notes: > > Since there are already three existing "print_syscall_ret*" functions inside > "strace.c" ("print_syscall_ret_addr()", "print_syscall_ret_adjtimex()", > "print_syscall_ret_newselect()"), they were changed to have all syscall arguments > beside the return value. This was done so that these functions don't cause build > errors (even though syscall arguments are not used in these functions). > There is code repetition in these functions for checking the return value > and printing the approppriate error message (this code is also located in > print_syscall_ret() at the end of "strace.c"). That is the reason why a generic > function SYSCALL_RET_ERR() was added for this code and put inside these > functions. > > Signed-off-by: Filip Bozuta > --- > linux-user/qemu.h | 4 ++- > linux-user/strace.c | 71 ++++++++++++++++++++++++++------------------ > linux-user/syscall.c | 2 +- > 3 files changed, 46 insertions(+), 31 deletions(-) > > diff --git a/linux-user/qemu.h b/linux-user/qemu.h > index ce902f5132..8f938b8105 100644 > --- a/linux-user/qemu.h > +++ b/linux-user/qemu.h > @@ -383,7 +383,9 @@ int host_to_target_waitstatus(int status); > void print_syscall(int num, > abi_long arg1, abi_long arg2, abi_long arg3, > abi_long arg4, abi_long arg5, abi_long arg6); > -void print_syscall_ret(int num, abi_long arg1); > +void print_syscall_ret(int num, abi_long ret, > + abi_long arg1, abi_long arg2, abi_long arg3, > + abi_long arg4, abi_long arg5, abi_long arg6); > /** > * print_taken_signal: > * @target_signum: target signal being taken > diff --git a/linux-user/strace.c b/linux-user/strace.c > index 0d9095c674..8678a2aeac 100644 > --- a/linux-user/strace.c > +++ b/linux-user/strace.c > @@ -19,7 +19,9 @@ struct syscallname { > void (*call)(const struct syscallname *, > abi_long, abi_long, abi_long, > abi_long, abi_long, abi_long); > - void (*result)(const struct syscallname *, abi_long); > + void (*result)(const struct syscallname *, abi_long, > + abi_long, abi_long, abi_long, > + abi_long, abi_long, abi_long); > }; > > #ifdef __GNUC__ > @@ -735,18 +737,29 @@ print_ipc(const struct syscallname *name, > * Variants for the return value output function > */ > > +#define SYSCALL_RET_ERR(ret, errstr) \ > +{ \ > + qemu_log(" = "); \ > + if (ret < 0) { \ > + qemu_log("-1 errno=%d", errno); \ > + errstr = target_strerror(-ret); \ > + if (errstr) { \ > + qemu_log(" (%s)", errstr); \ > + } \ > + } \ > +} You should move the declaration of errstr into this block, and then I think it would be better to have function rather than a macro. Thanks, Laurent