From patchwork Thu Jul 2 15:27:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1321564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 ozlabs.org (Postfix) with ESMTPS id 49yMRY70lkz9sR4 for ; Fri, 3 Jul 2020 01:27:52 +1000 (AEST) Received: from localhost ([::1]:42464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jr17s-0000RB-E1 for incoming@patchwork.ozlabs.org; Thu, 02 Jul 2020 11:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17T-0000R3-Ck for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:23 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:37651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jr17Q-0006I9-Le for qemu-devel@nongnu.org; Thu, 02 Jul 2020 11:27:23 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MryCb-1j33JZ1es9-00nuRY; Thu, 02 Jul 2020 17:27:16 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 05/12] linux-user: Add strace support for a group of syscalls Date: Thu, 2 Jul 2020 17:27:03 +0200 Message-Id: <20200702152710.84602-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702152710.84602-1-laurent@vivier.eu> References: <20200702152710.84602-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:1XMrjVSxvk9CB2IN39hZNQi6GlCjnaSIRXqvfwsk7CQsQVOLZLU cIMoafn1ymfoWo9hXCPjqzR4Bxvkl1aw3AM3JcqpZEuY0VWQOdDZfsnINJdLO9jGQtVp8sO ztP5dqIXmjhb2SligHAHN4GATatU1XgFdkvEu0x/4ucpBZAJdxjAQrozggQEVT9dI0MHAKA Ce34rpQM+oQan46ET3P5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:2vMUf9oL1k8=:mzPIIG0JgQsmI9yJ4CiCIO iiO6iRyB/zKu2nZ3TRgshIlz799xhtqW1UFFlzeTwF3Osbi+GoautBmEOrNLf4nmkvXIoAVjv fjunVLcKtO/YXy4umSdOd3OxwZ1wXdVJTWU9IZtkTS08xm+2BPpicWSXuCTJVpvmd/BiVnHcV YMTNgpWk8EGtHgOiulwMjsZet0oanhGBqHsqp92jW499/BgOCzKR7zO4nzfbnJtuOZVX+MY9N DKXIsGLnHn7e2J55ScDfbnUjeVaszTPYXBSjQmc1DYR8JUOgP78N2ZWMWfken8jdpdK05sbhn rXjXL+7z+RR4qBFPoaRcHFmm3HN2IkZOAkhfDyVKS9kzuNuUv0NvxXW7uY+4vGpOcwN03DO8P LLpjNR0Iw8EfRv1ddtOZcdgic9w8Wz3XvCYgkvLC8gTiIBRmroqqLjhJjNkX+nvEIy+Ji/MNB fdbsFR6eiGh8e1UOQ1Hq9gTvloZ1CiVB0MisYZ3YCmNjaBYxFR3zNbkm5PB9PbZw0wcdwOf3S vhaS5VvXZoiifK+hvEr4NJ3wpeIIS179jsWeX4F0uUcbq4w4vGVvVOMdA/R5rYwQ6dGOy8rY6 qk4l2yaQEW4yxgeP1QbMgi6AfeZ1rLxCEiSGj2x3ssCdo3+vayPjECUo0WbLgSmxAOWAVcUs0 ZL2qoHLLwQN0riy/CrNNK2FmYkBsN/gHTzKYBGaF2twZqsLrqbGQxaGorU3u6A8EFtVWvo/1R 7Pti8uehj9NccUTrlfl3zGOgzaGhqAJdz98vNcs2bvcWhOyZhR3ePN6dZTr5yDVfEh4oFquGV eiA4UpKX9PX/qZaq8rxEiYW0wF0/YOkjVZGk8+uedMhU1TZb3A= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/02 11:27:18 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, URIBL_BLOCKED=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: , Cc: Filip Bozuta , Riku Voipio , Mark Cave-Ayland , Laurent Vivier , Artyom Tarasenko Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200619123331.17387-3-filip.bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 13 ++++++++++++- linux-user/strace.list | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 62117e8555f6..123e022c35bf 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1357,6 +1357,18 @@ print_access(const struct syscallname *name, } #endif +#ifdef TARGET_NR_acct +static void +print_acct(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name, @@ -1621,7 +1633,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif - #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 9281c0a75828..8a887fc16dcc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -13,7 +13,7 @@ { TARGET_NR_access, "access" , NULL, print_access, NULL }, #endif #ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, +{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL }, #endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, @@ -215,7 +215,7 @@ { TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, #endif #ifdef TARGET_NR_fdatasync -{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, +{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr { TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, @@ -251,7 +251,7 @@ { TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_fsync -{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL }, +{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, @@ -492,7 +492,7 @@ { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_listen -{ TARGET_NR_listen, "listen" , NULL, NULL, NULL }, +{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr { TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL },