From patchwork Tue Jun 16 10:39:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C457B1392 for ; Tue, 16 Jun 2020 10:42:07 +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 894A220767 for ; Tue, 16 Jun 2020 10:42:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="HgCYIjIk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 894A220767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl92c-0002PB-Ed for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:42:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90O-0006r0-7E for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:48 -0400 Received: from mail-db8eur05on2113.outbound.protection.outlook.com ([40.107.20.113]:30304 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90M-0002xB-4G for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ih/DowvKsOf8HtNr4FnhC32IBHQemI0vMPq1yMDujpRJEgfGHdkzWAIPh8e697zUGJThvJb7xJ3EnK70+5xZWRMnaYUkxL6GlL58mxI57fGI4HbR79l/uGA6PtCGhzQoFgMNvZzrmW0xKVWb6ycFKd8hJz5axuxDKtIZ51+bTYEudn25BTdjB8rH+zJlUoF3L1vNyrD/cCgKwYZu9W1z2xeu3oZu9HmNNfvYO+LousitEh9D/m+tPfIDRVmEzk5RVM4BQkc48Hh3EMwTaX1wB7eqG5MrXb7sy1/DAT0fKZBevRL8wl4a61+d30wz2JuebuwAe5xaC64Z1XKQaGRj1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVn1tLFduN7ywzh6RphziuXVIFJ38+1zV94eGPNP+2c=; b=Yu3d2h3dMaatUTA05CJ5RH8pXkLy4NCb3ifsgYvrLmdPUCe71RYx0I1KDVjysc9LQN1rVxGcTRVoPxrplFESUBUfmzsjKatnKIBaZA7RWUFGZJybFNkv/hkZInFo84CATfSfkd6YzaLprSxe2bcxVgzL3cC5ZqWk9otppK5XQ2BRhghzTBIXofsW5srpQPz/W0hVoN4StyDUqyI0pgNlihC++0DmwgEUmHod6UjHo0B+tF+sYTbX6Rx306MllnUXo7SXj0SbX27SI+/n+TnzDIqx41DD/dhNY4v9d6CEBJml4I/V9IwZMuH8IGuzd+p9g4sYCr08ms5cK0bhWtmaIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVn1tLFduN7ywzh6RphziuXVIFJ38+1zV94eGPNP+2c=; b=HgCYIjIk/uKKtE9lBk0Z/4zlas6+QKUZPoqESkG89PMnP4jdqdYBfaWDWYp+dFwwUTqR4CTiQIi21sPJGVyB7hUh+hEaZxww3I1WwD+pkfetMHBr8H10yyZ9QUhB7Y93qIM+FYskOv17H+QboTOpoMjtqCDRJa3WeDj1+jYYhRE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:41 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:41 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 1/6] linux-user: Extend strace support to enable argument printing after syscall execution Date: Tue, 16 Jun 2020 12:39:22 +0200 Message-Id: <20200616103927.20222-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:41 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1138bbe3-6cfe-4aea-69e6-08d811e19392 X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R00PCe2q3Q6lUfWYTc/nQ9GGkD/AKi0v8wA+ahs9KqEtwazwvmv17UKf07/dSY/veuxYrn/VDqPxrFdxKGq40v30m4P8Zp4LL8sRQkzPL4JjXjYcNysLYFGKEJSqX0s6ZRni/0hJ7mdjruDz8gvOGBI5Uu8ZjBQBzpEi2u1l9saZNhPIGY+FRz511p+uspotSruXPeePJnBeqRC2ihxli807g9f6fRxn804AnyiGHI0LspkRKH8NYSnB8A0k1u/yrzTom9R931KjeQpCkE0EDUHBhQHNM+/iAqRPob8vMX8QSDBfHSgN/UsVbaG9d5ID6y6dCEfc7bC+uzz7TccTIA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(376002)(39830400003)(136003)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: T3hIl54rE506oOOHHKTR72StDPtc8G1F8eg/0EozcZfAMSq+kfSOHGZCrS+ug5SF0h75Rkzqpq+w7ZBdDj93ANrY4HbIpCnzlcy/CmebkhGL/LdubcT5ZvA0SUUg0hgCR41fX7lgtrbF9DYzwktkN97St0owpGEWaH6HjrcW6OjVAtXK/+p3Au5ARzEubaI96OmO218WmanEEiMyp8gyGBblpaG7xwLr+NLRoFdwM9w8dp/3+nyxYBpT3Dm/7PKPnYv77J4ujc0qUDvyvk7XrFd3Ir/xKTMOQF4cXFG95ASGCXghOy/YvzZwzRPfMH1XygtS0Royhv15IzRvp2df10igj+pPGe8qTdXm5L5Pttp7181HRqaE6DbDCAQUpnV4ZNqmXX4igLH/9Vp1+FKgb4A97Un2PhNr9b5L/63bwCB89zUN7HYIGlNAZNt0/1yXLU/RHy6T/7iYsZ1hL8CUnOiUmx+i0rSqEK+ONMJPVdU= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1138bbe3-6cfe-4aea-69e6-08d811e19392 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:41.5454 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 85uyXzE1pkN0LrkfI9HfqIKCVWfi0t9A3xf3oadunvwrOJk2xSE8rtFGsI0r9e1so+wP4LdPShjL4rLu2hUfVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.113; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:41 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 function 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 function "syscall_print_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 | 67 ++++++++++++++++++++++++++------------------ linux-user/syscall.c | 2 +- 3 files changed, 43 insertions(+), 30 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..805fcb9fd1 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__ @@ -736,17 +738,29 @@ print_ipc(const struct syscallname *name, */ static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) +print_syscall_err(abi_long ret) { const char *errstr = NULL; + qemu_log(" = "); if (ret < 0) { + qemu_log("-1 errno=%d", errno); errstr = target_strerror(-ret); + if (errstr) { + qemu_log(" (%s)", errstr); + } } - if (errstr) { - qemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); - } else { - qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); +} + +static void +print_syscall_ret_addr(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); } } @@ -760,7 +774,9 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret) #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) +print_syscall_ret_newselect(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); print_fdset(newselect_arg1,newselect_arg2); @@ -783,18 +799,13 @@ print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) #define TARGET_TIME_ERROR 5 /* clock not synchronized */ #ifdef TARGET_NR_adjtimex static void -print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) +print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { - const char *errstr = NULL; + print_syscall_err(ret); - qemu_log(" = "); - if (ret < 0) { - qemu_log("-1 errno=%d", errno); - errstr = target_strerror(-ret); - if (errstr) { - qemu_log(" (%s)", errstr); - } - } else { + if (ret >= 0) { qemu_log(TARGET_ABI_FMT_ld, ret); switch (ret) { case TARGET_TIME_OK: @@ -2847,25 +2858,25 @@ print_syscall(int num, void -print_syscall_ret(int num, abi_long ret) +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) { int i; - const char *errstr = NULL; for(i=0;i= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); } + qemu_log("\n"); } break; } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..009bb67422 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12441,7 +12441,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg5, arg6, arg7, arg8); if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_syscall_ret(num, ret); + print_syscall_ret(num, ret, arg1, arg2, arg3, arg4, arg5, arg6); } record_syscall_return(cpu, num, ret); From patchwork Tue Jun 16 10:39:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0694B14DD for ; Tue, 16 Jun 2020 10:40:37 +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 D17E620767 for ; Tue, 16 Jun 2020 10:40:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="gE6D95oR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D17E620767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl919-0008S0-Pa for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90R-0006tm-73 for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:51 -0400 Received: from mail-db8eur05on2134.outbound.protection.outlook.com ([40.107.20.134]:62689 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90P-0002xj-Dg for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZBAd0VQMzaFWrRYxrExPyA9dFX56XlgT/OE9NvZbCNQ0VxIA5yK6rZy7PnDmHgPcp0Ngh7T+u0T0MqkY3irg18STH0qhT4SbfY+SdSmmv0PdbgLoIXe37nuh8YBzNGrSXwEig3wrgdhvSBkbh+x9+42e5aZidzcMAEUyJkGgxM9VoIWhorbwB4Tc31/4DQXdaKuWKOUN308OlZq9HuPRFFXThrQzxDO3PCdLJQGMwNDKXHWOr+iuWvgZPrz5Tmce4E0qS53g2xSi+qC95eHnJG/RY6adn5q/UT0jlywBqArpFBSlMFftG1G4EFSutHjrexR34vC0ir1Ss8EaLAY35Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T2T/my9LqTMcwLuou1CYoXMRuC+N9Y0bcI0lG9ts/Dk=; b=df8fpIAENF+ypjDShkcYHxeMc5uR/XjivA+5Bymk3bdgUuo6YF6MF91N9h3Ecoi3v9Dvwh3D7Bha3//XIsYnQ6D382Yf28L5/L/odNuqZh0mL3gmELrAa6kpndHr9qJMmwmOWoFtWIvqL0soNCDrdWwhvmOcL7fZXsdzYQ83xwVsqR7inF7xlzKKSo8Tx3ay1lLrrsksY/UqVuxcNuvlp1F7EGBH+0hWZOAaI60tKCOcCkhFHQ1taLagJDX0xcX++EnqgA7zHASnxECvJocZ9Nbx4E6wDLD+WRCCQHVLSu5jWdkXU6+6hnY0GiB6AyIXq+fav5Cmhn7Ms+x6lFscRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T2T/my9LqTMcwLuou1CYoXMRuC+N9Y0bcI0lG9ts/Dk=; b=gE6D95oRfRGg8QAa1uAG3yHWQ/bg85T0wetHo238abpsmoh5jgDQoJ8cDMuRv3rHTzc0pDfyL3/cxZx0PoDzOrQqXxZDgFghFfImQg8ArdHnOOHctgPKcn4WB+NErrkv8xInHVkqT9I6+TUCLr1+URixUGpQegyU+UZA3ML+QRQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:42 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:42 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 2/6] linux-user: Add strace support for a group of syscalls Date: Tue, 16 Jun 2020 12:39:23 +0200 Message-Id: <20200616103927.20222-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:41 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21373464-7de3-4525-7b0a-08d811e193d9 X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ERPSFsmufYes9DElCSsV1aaX574ueJo+i6S+uwNlsRjxWSZUH2wws4pg0VsqRN07qecjzH3VHlmR9UYO0LujFtoMi5Uz3PMJR3z9h9EDyKJrQwLT5EQC/Oa+UWrtPsnAn1pWvKZ8HQxQ4WaYYBZv7OPrN4PY6XdisbiN0TeaMfJpuyuXQSZoh5CVyZL38jZKuoDItlQzGFO3czy7UtRqEet4ixzCJZOVPaRuQnmYsyQqH7QukmkV0tVif0NynyGDq2Z5wmLxZbt1hU8IE9frIr+9yEvupJLWE12/nJG8nbFNbQv//TcZEeGNUVQ8tnhX4txN/NRlSJdbqnOIMORTQRXrYyhS9jGmYEIwX5t4teAJ55Y9JsfqpyraGUwnBkGfPnF0Ii0Onh9BMH+pxFynUQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(376002)(39830400003)(136003)(966005)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 11tO2hUmbc2routHygtyySwhGUooFg4yVnb2NbryVYEiN0YLi/Y/kDOfmvmzgBlwDXjV67iDxA7m1M8L1mXSjoikXnC6idzn2E143+tTpZx/ytJeisVP8h1Wb5DFIAUIi2Qcs4z25IqgToiRSnqjFX5Vvmob3La8nxhJvt9lH8fekbWmJFdVEE4wZY4Wr76K6ZNbEsVC3ZmKtQMDigpwhqMWP4kcmb+D5NFOc98GFuI2k/qnvjZ3DDH/i+6jOvBUK2dW+yat2ClM45M9ST4Hs79c+Ga9FKVkCmvcZ8kKs9eQlLQ3UOfoOolr1oSBBuNbUNwvKsxkiiPvZRciuTSJb3k8zgdSmnRpwTWly5fnJDjxI4xdY3Y3zKWIeqFNuGpeN2ZYevVf8O0tS6p+BlpZv7z4pBo/Bvp+PLBCIEfb+PMgbh0li6QZVJAe4Je6hawD3qhZh4Zsvjt0TT8Nr51KV/61BJgRlyANcnA+Y+9KPZY= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21373464-7de3-4525-7b0a-08d811e193d9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:41.9841 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HBNwOk2xIO1CtbA2C4yoQVWWrkoZXup/HieWV11Yigi7SoqDGs3MYK0sOpp0poF9vDdxG+5s7B/DtIruy0HeOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.134; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:47 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.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 --- 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 805fcb9fd1..6d7accaa4c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1364,6 +1364,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, @@ -1628,7 +1640,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 d49a1e92a8..fb9799e7e6 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 }, From patchwork Tue Jun 16 10:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607121 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2908A1392 for ; Tue, 16 Jun 2020 10:40:36 +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 E3E8720767 for ; Tue, 16 Jun 2020 10:40:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="uTWFtr7Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3E8720767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl919-0008T1-5Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90Q-0006sv-Gu for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:50 -0400 Received: from mail-db8eur05on2113.outbound.protection.outlook.com ([40.107.20.113]:30304 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90O-0002xB-FT for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WevISPDYCYYgtnVMGGyskzSo4ZA71RK9+BD7MtrUNiXbUPyl0bN6tVanSadPKN+pdoiWwrE8i/dm/sfdrw/l0Lcc7AuYPSD3Lm5ONxTWdDY3jcVRqPYx+IhXRnpLWEOO1SjBEO8Rn6H7Q5bJz3nmbq7eK1LRglcg1GAu8Dc9BjI3kM1GkB8uNnlZ3wGwqiGOb1XsHp4oJ2kMyXRvwKr/SYl+6z085pRd1+9ePF76mv1Z3f/MOU/WfnqpAR5/UZcdH+UwoGG6lNmxuUo7iKXRnRd0uhbS37e9ntPGJ6jNc3NRu3DfF2TUXGoay6fdxsrIzTTVZl8Tt/9/RGAUm7nm5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vPSdFXYJawze262J22eUdv5iOsyYwSDNBoSHgHQQfY4=; b=X0gpAsGPZFP2HHO0kFawH+NG3wgmG6x73TTXjgHv6GM22lSOyv7fRvFAahhc2L4LdvwuJsw6iARXhdNCd7nwUrJyiPcb8TrYC3dBaVsbE9z8EPjjt+cnwoRLnvik5cLi3ZzCBD2VIFedqfUGZM/KADDXJBTce0X2r0sRRJxO94OeVQcVMoXpJrfK79Ai5OkiXz9tX7NJUYLSiu94/Tt6fHk6dh0ZuNm1G2K5ZO+gPgp4vR3h6jP65jUIR0SMXbh93Z4ROSnStZLZnJQ2dnciq/pX4fEHokRiUbbXEuhEk2c2dLsFdtG/SSAkWwP+h2rSqWfQzANs4KiTxxMWTmtxag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vPSdFXYJawze262J22eUdv5iOsyYwSDNBoSHgHQQfY4=; b=uTWFtr7QL/+oLmMqAJscGo2YIB6Gw8oGtcBZ6Q4rXN/J1EVpQZT8w98cWKTUEpm+T1zSDJY4g+Zt76Rkymf7t52UBPs6Gwt4LKPQ1ooiQLQ/zdgSnBFIohJgt/bCaVVvAu84eVFoaaoeAYjCqeZ1LM6hWp36fsWTUmor8BlqjQQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:42 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:42 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Tue, 16 Jun 2020 12:39:24 +0200 Message-Id: <20200616103927.20222-4-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:42 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54c2633a-8de9-42bf-247b-08d811e1941a X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HVsXblJbPtm/KDr5N552Q/u82Qt+J5AEDItQsdLhWss55GIgiuwMFJQWvte0ko9qaf9CzCm61Kh20itLobHP2l3O2ZyS9yiXuzEySYTmDtiASEvxP1WKVBvgxhBYhd+fjFdkcS6jz3vMNUSnDZp4PKSkEf3jRTkCVURreekQrHiwZMzhMOaygYHpJcrvwIHwBRiU0V6YbT1Twg3OL7l8KqRYowDLxoxpIjOwW6jSFegpyCCeT/0FN/sPVsNEMi6Y/RibB7DX1aNdFNkbvF8XZiDS7a5SAlXDSrkj3F3ltgRKkHrtbd8Wpnz2yb9hTsuUamQDCLZ6N/qLpE8EHhcaOGO2EdrJ3han3HLQgPuSgnP7R3XKAyp7z43pBd+B2G0+X51bvUz6/nAc/E/NzU2EbHzA3/DIrbX3eNelS3UIrJ16Ux0TXzigmMf1OqYBI32xMPwBuJKUOawqK+AQW8WeuA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(376002)(39830400003)(136003)(966005)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: syla03kK0gcyMMy2k4m04HNPJ5yVV4r6BrZt7jL6UjJxXuLz3Mv8kyAoTuUyQIC0RjOKK9IM4y+xapi+TT+x3cVtsVyfn/EGL4Mw6Ox+dTUamAGj+glbH/xwKy3I6cNAazk/yNvQD2tbtjOBTUe+hsoRVsyMs3PxYpIPtfBqtJ37qm4JKhcxbO+jwiKmUU9YJHXDDT1IM1NsfGmG33/mFaThrL5CtatYq3vxMylNUUJy35ySi/J1T+z9g0dccHRmrUHNkrX0Zggsr3W/EafaglVQ/OPk6oUJulFcKxFy+OauHWW1Kgbl3tE+xQqAH64skj1c+G7NMAMJ7vxzq6w8ketNb8ZDFu2FqnffMjzyQJcC/zEZQ9z82I8QYjjUDonx3F+meBO2fP+17BdwGPFUNuy+uUnFuDCCHn3nWD1oS+DgyCgKHnwhX4IIL2HK1LMK5FPVCKDpAjyhPNZ8KbKG5n5zpTW1Osb+JdpktuLzvj4= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54c2633a-8de9-42bf-247b-08d811e1941a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:42.4419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2YmKb1KdEL+mBkQFePh+RUNfyZRgIjqgcRW37c2r0G3hPLfheBwipyL+ef7O4WHvWycxfa3u5Q+ch23pJ9sYJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.113; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:41 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value ssize_t getxattr(const char *path, const char *name, void *value, size_t size) ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html *listxattr, llistxattr, flistxattr - list extended attribute names ssize_t listxattr(const char *path, char *list, size_t size) ssize_t llistxattr(const char *path, char *list, size_t size) ssize_t flistxattr(int fd, char *list, size_t size) man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html *removexattr, lremovexattr, fremovexattr - remove an extended attribute int removexattr(const char *path, const char *name) int lremovexattr(const char *path, const char *name) int fremovexattr(int fd, const char *name) man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html Implementation notes: All of the syscalls have strings as argument types and thus a separate printing function was stated in file "strace.list" for every one of them. All of these printing functions were defined in "strace.c" using existing printing functions for appropriate argument types: "print_string()" - for (const char*) type "print_pointer()" - for (char*) and (void *) type "print_raw_param()" for (int) and (size_t) type Syscalls "getxattr()" and "lgetxattr()" have the same number and type of arguments and thus their print functions ("print_getxattr", "print_lgetxattr") share a same definition. The same statement applies to syscalls "listxattr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returned list of extended attributes for syscalls "print_listxattr(), print_llistxattr() and print_flistxattr()". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 122 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 21 ++++--- 2 files changed, 134 insertions(+), 9 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 6d7accaa4c..f76bbbc1ff 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -833,6 +833,41 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, } #endif +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ + || defined(TARGGET_NR_flistxattr) +static void +print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list = "); + if (arg1 != 0) { + abi_long bts_printed = 0; + abi_long attr = arg1; + while (bts_printed < ret) { + if (attr != arg1) { + qemu_log(","); + } + print_string(attr, 1); + bts_printed += target_strlen(attr) + 1; + attr += target_strlen(attr) + 1; + } + } else { + qemu_log("NULL"); + } + qemu_log(")"); + } + + qemu_log("\n"); +} +#define print_syscall_ret_llistxattr print_syscall_ret_listxattr +#define print_syscall_ret_flistxattr print_syscall_ret_listxattr +#endif + UNUSED static struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1640,6 +1675,93 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif +#ifdef TARGET_NR_fgetxattr +static void +print_fgetxattr(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_raw_param("%d", arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_flistxattr +static void +print_flistxattr(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_raw_param("%d", arg0, 0); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) +static void +print_getxattr(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, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#define print_lgetxattr print_getxattr +#endif + +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) +static void +print_listxattr(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, 0); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#define print_llistxattr print_listxattr +#endif + +#if defined(TARGET_NR_fremovexattr) +static void +print_fremovexattr(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_raw_param("%d", arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) +static void +print_removexattr(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, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#define print_lremovexattr print_removexattr +#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 fb9799e7e6..af12b23276 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -218,13 +218,14 @@ { TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr -{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, print_fgetxattr, NULL }, #endif #ifdef TARGET_NR_finit_module { TARGET_NR_finit_module, "finit_module" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_flistxattr -{ TARGET_NR_flistxattr, "flistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_flistxattr, "flistxattr" , NULL, print_flistxattr, + print_syscall_ret_flistxattr}, #endif #ifdef TARGET_NR_flock { TARGET_NR_flock, "flock" , NULL, NULL, NULL }, @@ -233,7 +234,7 @@ { TARGET_NR_fork, "fork" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_fremovexattr -{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, print_fremovexattr, NULL }, #endif #ifdef TARGET_NR_fsetxattr { TARGET_NR_fsetxattr, "fsetxattr" , NULL, NULL, NULL }, @@ -396,7 +397,7 @@ { TARGET_NR_getuid32, "getuid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getxattr -{ TARGET_NR_getxattr, "getxattr" , NULL, NULL, NULL }, +{ TARGET_NR_getxattr, "getxattr" , NULL, print_getxattr, NULL }, #endif #ifdef TARGET_NR_getxgid { TARGET_NR_getxgid, "getxgid" , NULL, NULL, NULL }, @@ -480,7 +481,7 @@ { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lgetxattr -{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, print_lgetxattr, NULL }, #endif #ifdef TARGET_NR_link { TARGET_NR_link, "link" , NULL, print_link, NULL }, @@ -495,10 +496,12 @@ { TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr -{ TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, +{ TARGET_NR_listxattr, "listxattr" , NULL, print_listxattr, + print_syscall_ret_listxattr}, #endif #ifdef TARGET_NR_llistxattr -{ TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_llistxattr, "llistxattr" , NULL, print_llistxattr, + print_syscall_ret_llistxattr}, #endif #ifdef TARGET_NR__llseek { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, @@ -510,7 +513,7 @@ { TARGET_NR_lookup_dcookie, "lookup_dcookie" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lremovexattr -{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL }, #endif #ifdef TARGET_NR_lseek { TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, @@ -1116,7 +1119,7 @@ { TARGET_NR_remap_file_pages, "remap_file_pages" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_removexattr -{ TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL }, +{ TARGET_NR_removexattr, "removexattr" , NULL, print_removexattr, NULL }, #endif #ifdef TARGET_NR_rename { TARGET_NR_rename, "rename" , NULL, print_rename, NULL }, From patchwork Tue Jun 16 10:39:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AF2114DD for ; Tue, 16 Jun 2020 10:42:17 +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 11EFF20767 for ; Tue, 16 Jun 2020 10:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="Yz6XLp+8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11EFF20767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl92m-0002bF-B8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:42:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90T-0006wM-5G for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:53 -0400 Received: from mail-db8eur05on2134.outbound.protection.outlook.com ([40.107.20.134]:62689 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90R-0002xj-EQ for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gwTasGX//spULDwOFfCOJWyI1iWBoobQAnqLtRWMGoBly/g4ru0IyMT94+xHPtHFpQVwwVqRguIrzh2IaZ21irIi7kWpvFZAx0UOApzNnp5ERS9W9TUZcsU/yvgYa5yS3/00Pg7IDrRP23MSeTjZTcgVdU/xVlx9i/IunI076Kx3sXsVz0xy/0yD6qweA3wQm5TT6U+jOP/2UFaN3Y+Aa4iDpmDjVJVXPs2YjJc4FGq82l0UNOAIqTOaAO7r+0DpSYpQsIBbEq4J7JCNqq/ughx5Nh+h6gDjX2Xf/h3EiBADPnwU2gxupcQ/WOSmDf6rz8JUYbVAdO0o8y8OxnRYjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wAkJOpp4vVJfx2IroOpDJITNyxXboEoL4zNW1eRyqo=; b=Ve9iY54t3G4YajDCN/eTpULwtnGBgXst9d/LPrTi9wclquKShKHu0b+QYcqEJ4l20hyWsGM9hYa79tuhG9vdIjM5s7fJ3oym3pGOZpWWVmudp+WhWn3MvWllkhrwl/BjrH6U6YnBdrScaap9kSwTlYTSYxeaa7VEOhgv/nReYYKlMix2E8ZeSHwQnjhKjzYHYl/UMkPfhB9p4/7CIM31zeLxi4MTI/4UEMFukTGWA2x/ogbJPTuhWNNh6g6hRsjMjUaaL8qW9kTcvMnCdHgfnZJJ9CVh3ubTvUhTtHlc9JmKoi4rdV2P2KM9i8K6iiF2OxFA8qoZmY1kOfEsLc0ruQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wAkJOpp4vVJfx2IroOpDJITNyxXboEoL4zNW1eRyqo=; b=Yz6XLp+8X0Bi3Y0qmdvfN397giN+waxpit0q85/jwArzd2Yj0xkpsIlOyrTR5U8SctY3DwRB7h62h7rqdojts9D2eUOoHYIjtlRYE9dS+olQb4+/tlhC+vbOJzy6rhcwL8EQRAEz9b3MTWTtr9z6xiMoXZxn34igqbpyejk/sEI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:42 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:43 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 4/6] linux-user: Add strace support for printing arguments of lseek() Date: Tue, 16 Jun 2020 12:39:25 +0200 Message-Id: <20200616103927.20222-5-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:42 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 029fc219-4f4c-4324-bc0f-08d811e19462 X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QL/OCHYyJokb+4EdOCxS/hy6qHgCBnVgWuGzEq71C/Tw+GvPh4n6UuSI/YBGSf5Vkz7w6+Yad82Tg1nsbU3W8yxZ7zGxtBsYyjaxtqLyKMgKrASYyh5Z9j7ns7nN+BgEqLh8sskPQvCYDd4jI5TJWCn7LUcWXfWsk0ylQZzIgo4ppuhyvE3Lk0d9JryxVEQMmp/AZLyGLdqqEE1USwyKXa98T6JMAs1k3yyfnVbS/q+78LZltcmDLazyShwkgnef5ENVxEW1K27mM9kJNvn19S9nbyJ2WcagcEXf3JWiXIjhmMVP4XaJmlVfQ26KYoSzxoCUJmgyelIZQ7+NDuT8ZWUkHUTyHZDbxSWNimiFaJyDyT0QHYTGzYyfYCyI7fkbb0xxtSGgbqHg0i8aQFtJ3g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(39840400004)(376002)(136003)(966005)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UpRdYPBq62NhlC5rZrX+km5WixIq84APBt+w8mkZ5nKD9ybp6IKjUhdqjAC9fHjjXdCokEbSl6UqJI6KKjaOMrhFKsCuKSFAyDg5izL9oenokx75pcxvGJ51Ue5j2J9zHoY8UgIXzeZ2ZvgoF5soI35cWGmG7gpNiA6aHhr9blmDrhZ4EQz1Xf8ztQRBjX8go66A6Irtpm4n57lG+vseIox8X2phb8KbnMwq+tONHu11KI1ma8ALcSHhOZD0Wraf3P/dyx3J5uaNr6MnGd2pc6vg5rUCpVd0raZBETA3pW1I5juKxriCpoPZvwOY7LgyolYHZ/kray1RRVinf0RhZu1eVT/tcJ3wWPrqoPJjcOd4zpAf8ASBuieUd4os6ByrO9vosgevqj8Wi/+dNszHmW9n6rgmGggGCvCNx0PploTc6sBooJJssjKvLCZ7E/u52CEqt5QXx4oIQDrQpQnVQXSSnJgXk5msvqVpZaOeB88= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 029fc219-4f4c-4324-bc0f-08d811e19462 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:42.8876 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: byQe/7mgCKY6ta6OwwrxD6uqc6zwnSYVkx56RscCU+jMAvUKy5Lst71WkL5zuuRcLI3n7k/u0/TIC5fdt165ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.134; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:47 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for syscall: *lseek - reposition read/write file offset off_t lseek(int fd, off_t offset, int whence) man page: https://www.man7.org/linux/man-pages/man2/lseek.2.html Implementation notes: The syscall's third argument "whence" has predefined values: "SEEK_SET","SEEK_CUR","SEEK_END","SEEK_DATA","SEEK_HOLE" and thus a separate printing function "print_lseek" was stated in file "strace.list". This function is defined in "strace.c" by using an existing function "print_raw_param()" to print the first and second argument and a switch(case) statement for the predefined values of the third argument. Values "SEEK_DATA" and "SEEK_HOLE" are defined in kernel version 3.1. That is the reason why case statements for these values are enwrapped in #ifdef directive. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 31 +++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index f76bbbc1ff..db561dc4c9 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1841,6 +1841,37 @@ print__llseek(const struct syscallname *name, } #endif +#ifdef TARGET_NR_lseek +static void +print_lseek(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_raw_param("%d", arg0, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); + switch (arg2) { + case SEEK_SET: + qemu_log("SEEK_SET"); break; + case SEEK_CUR: + qemu_log("SEEK_CUR"); break; + case SEEK_END: + qemu_log("SEEK_END"); break; +#ifdef SEEK_DATA + case SEEK_DATA: + qemu_log("SEEK_DATA"); break; +#endif +#ifdef SEEK_HOLE + case SEEK_HOLE: + qemu_log("SEEK_HOLE"); break; +#endif + default: + print_raw_param("%#x", arg2, 1); + } + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index af12b23276..905a9c395c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -516,7 +516,7 @@ { TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL }, #endif #ifdef TARGET_NR_lseek -{ TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, +{ TARGET_NR_lseek, "lseek" , NULL, print_lseek, NULL }, #endif #ifdef TARGET_NR_lsetxattr { TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL }, From patchwork Tue Jun 16 10:39:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3C9F1392 for ; Tue, 16 Jun 2020 10:42:47 +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 7A7A420767 for ; Tue, 16 Jun 2020 10:42:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="sr61xicK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A7A420767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:60952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl93G-0003TH-MJ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:42:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90V-000716-5v for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:55 -0400 Received: from mail-db8eur05on2134.outbound.protection.outlook.com ([40.107.20.134]:62689 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90T-0002xj-Ba for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acBqf6qHFzFjVCvaY1//V+YqbHRTrey3vrlbMm963f5MOT22dfgPaS2lLmF6sC1GAavihPgLn1QJSfsGV9FiNMxfaILuhAGQW2d0zM32b7M6eWoymKpHRyfnhUrAbqhFnGzOSplnaYSSERKhOJnxuuZZE+8OiZAxBMamWHY2UZIwiAGyEbQSUASkM5cCalezJuBijDf8tcwUM34AgIDTIe+07yL6sb0PB+I/zEoAHThllZLGPaRY5DD/jAnYDWtrC9vTo+7osYKC49DXxFqXD2PiS0rxu6X4LwT4Eo248VjUZr85p2g1NW8FBZOCkEo9RUHSaryYy/D+kQHfsfBFEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=67LdaiN587Renf4rYoPnW0TLdnPQtv9yDNhnssDtlHY=; b=HL/mh+TwOers8Q+2rTWG8OLe1ziLpWGs73i8jN8qfnOA5OMF8Wsccd4T+1F+gqsxt2nr7ux3sPL7otk0vLdJySGN04WtbXs9nd6wV+yqCuVAmugojB19JX12xqFVm2Bysboorcokwp62s0G5KDG9CkEwctjnWSTneuNL1YAttKK3Q5WzYbr1RMSGdfo9XigGnyGAOHoiwA12b6ek5J0DH7ZmeyVQ0yIXgTB/ZqbADPePl/WjDJ2YM+LbnUQTuQhLt+Eyd5RdRbEytIQbxcDbnq2c3PZaGVNWZUbcfLQXBsgB2ZgW5tiLu0NmkjoHySASRsPSCtkp5QEy6N75GXd6HA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=67LdaiN587Renf4rYoPnW0TLdnPQtv9yDNhnssDtlHY=; b=sr61xicKa0cxITZZBLVA9sZm2y4kz0NLB+qOqtE7c/uYFvoB8d/0WTsbv6nYs5YY6W21JLx/3plcWMfJBRi/o6sUTAAWjZTMl1X7DcZnW4lBcbYuNVhPA/6xvH2BY7B9gMyqVoqeOZFIM05l252wGo+E4sya61DTrvScfThme5E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:43 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:43 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 5/6] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Tue, 16 Jun 2020 12:39:26 +0200 Message-Id: <20200616103927.20222-6-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1435393-1655-440f-46d5-08d811e194a8 X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u+cgeP+aa26Mlwe6ays7rx4TDbFlYcXLzZ5mW+TA0fd/9CmjEPebDLc5ZG2Oqg120bEb1E8e26Rzdp5jGGJu341sl8BLbobJJOPGZjWD80PVIUW9khhPPMsff1L8PiZF06FdS+2+qL7L+hhnWXW6dbb9wKiHrtXkfIvHEJidJ9AN39jrFfk0G9zmgsLW8G64k/kHtf2hBv0o88wI2ydDxrl/lqYdq49ScerQGQMaTczmyZLEXJ/bWWkxiqhZPS+p5WhEhdFNT6aHF7O7zEvSbeyKOIk9UZ+7G9o8yr7qk79WUTxOxWr9vVUY34cRI16SKKLU3ZRxKd4Wx0zMaotNCXBDUIfnCwkctg9TfEvzPsSobbH8wc6LD30C2jTdAgrUg2HsF74flwxQX7VyZ0Mdvg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(39840400004)(376002)(136003)(966005)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ABZoTdsP0Uk9s6rFUZ3gE1kzAzkHQ2l7uZ7v61aCQXNOUgORWN0Y3Yetbii6vzQaynQmkb3TNoowJ0gPwfU6RFO3d+c2aariZEMZzoQ1015QS3qgZ/2+BdXw14IRQpytH72r5pKLmv1bgXNZ135M9jCjZHMNjM/zRkn0xamSDI9T91emz/wCQjotVenMs+OEY2nrwgFhmDo6SwUrATwjX/67OMDrxtVJBEuXjnwTQ6fz2kpD47+BrI+IBJsXHSQFrs3/LQg/ynYBS8G8VuBms09BOt9Uhlsrvt5KlsWTIaJzTOqD4pPzWBYCur5EnLm5z4ngj1gvOYbuLNJ+NHmZid+KP2tdpvdtXZLD4d0vvy8MVnUol/V3LNA9yiTHnQsEWi/tMXbe0FuimYrUWnBZLSYtxVoAWQSG24vexOdq/Xk4TZB9JSgayQNAQGwOuy3IMHlmQVEKjq6oTSGGi4O9kVR0bQYBEgUcqXz4sTTZeUU= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1435393-1655-440f-46d5-08d811e194a8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:43.3534 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6XcRBug7CexFDuU1moBiCqPf1a9Szy13hQEcJAE2pU9RmWUAIOH9qMiB1UzyfNpxXXX+rlhKnKaQdal6ae74Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.134; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:47 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for syscalls: *chown, lchown - change ownership of a file int chown(const char *pathname, uid_t owner, gid_t group) int lchown(const char *pathname, uid_t owner, gid_t group) man page: https://www.man7.org/linux/man-pages/man2/lchown.2.html Implementation notes: Both syscalls use strings as arguments and thus a separate printing function was stated in "strace.list" for them. Both syscalls share the same number and types of arguments and thus share a same definition in file "syscall.c". This defintion uses existing functions "print_string()" to print the string argument and "print_raw_param()" to print other two arguments that are of basic types. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index db561dc4c9..f44ab0ab84 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1460,6 +1460,21 @@ print_chmod(const struct syscallname *name, } #endif +#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) +static void +print_chown(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, 0); + print_raw_param("%d", arg1, 0); + print_raw_param("%d", arg2, 1); + print_syscall_epilogue(name); +} +#define print_lchown print_chown +#endif + #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 905a9c395c..633f43f490 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -71,7 +71,7 @@ { TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, #endif #ifdef TARGET_NR_chown -{ TARGET_NR_chown, "chown" , NULL, NULL, NULL }, +{ TARGET_NR_chown, "chown" , NULL, print_chown, NULL }, #endif #ifdef TARGET_NR_chown32 { TARGET_NR_chown32, "chown32" , NULL, NULL, NULL }, @@ -475,7 +475,7 @@ { TARGET_NR_kill, "kill", NULL, print_kill, NULL }, #endif #ifdef TARGET_NR_lchown -{ TARGET_NR_lchown, "lchown" , NULL, NULL, NULL }, +{ TARGET_NR_lchown, "lchown" , NULL, print_lchown, NULL }, #endif #ifdef TARGET_NR_lchown32 { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, From patchwork Tue Jun 16 10:39:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 11607155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8014714DD for ; Tue, 16 Jun 2020 10:43:43 +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 563A920767 for ; Tue, 16 Jun 2020 10:43:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="zBMXSqpT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 563A920767 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl94A-0004xD-Jk for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jun 2020 06:43:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90X-00076f-Es for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:57 -0400 Received: from mail-db8eur05on2134.outbound.protection.outlook.com ([40.107.20.134]:62689 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl90V-0002xj-F6 for qemu-devel@nongnu.org; Tue, 16 Jun 2020 06:39:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtQc04IA7kEfq41fesGfPl2K2W565T9hMB5eSdK4I0lijmhM12GjgGTGlQhwiqmWQdFH4t3lRObc5CvE3oAkscjC/XuBefWXQJ4omlQs4PHTm4m2oXqlN9VbWOnh7bOwWSLkq6si9rIdP9D1qG057DBLDWaTbnGq3VT+D4P0Yp6Di3qNF9bnLHITvdOMPXVkg0tj28SID+HFKmnx+6Ah0dG6ZbNxQ4Jh8o+1GiDMJjs9rmfk0A/3EqyAOvdTQdQh0q5OfwNQK0rmb/ngHhvDj3BjlfYfagqDmD+9uGb37my5IatLhWMbiHo1HdUXQGa1k83XDETn11qRAmbds86B7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EiQL0LEJsy8L/HVFkhcy2wY3b8AoF1LERO0tqnpf48w=; b=Y25mZO16HvLQDI3k674Up2PEaLzS77/A+YmKvZ8OWuaNOKwdJ/qnMAuWBcvQDh/aGfVe/OHwep0/cMwa5p2HKObEue1/0HUvcg0MlRzHi2dw/0ICGKJ7WOghWPi1c3I5MGfQikGWgvAOFpOOVs7wKJEAblrfgJTY4flIDLVWUXFDwJvMAzRNlhiVt4NzxtcYl6XOMG/DA6TeffiCf5D3uzT9ruD3Zykv2keqzHjeHi+TixbDSjKRbejuFO4EFxPdgGZrKsIJRDuqRVfsBp7Su0UQp/WMNWvxQ1037IsYgvoXPnEfIsDHOj1b1QW/MaoAOd9YZoGC48pW9I82rqTAeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EiQL0LEJsy8L/HVFkhcy2wY3b8AoF1LERO0tqnpf48w=; b=zBMXSqpTqKlACyrX0yZYtbSIJbZ0l84PB9cucCD65n/o/yAsHsDIs894ixqM38h84qiwYesig3rMf0JSxPf+1YK6nkL1vbPtnaNF/a/wBbwLLI7n6JlQ+c6rWey+NTdiy9piUaF9oHKKPYZ3KAFDXKV+j7AYAAWQJnS2U3DH7bY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB3960.eurprd03.prod.outlook.com (2603:10a6:20b:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21; Tue, 16 Jun 2020 10:39:43 +0000 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618]) by AM6PR03MB5233.eurprd03.prod.outlook.com ([fe80::98f0:b948:78a8:f618%7]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 10:39:43 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v4 6/6] linux-user: Add strace support for printing arguments of fallocate() Date: Tue, 16 Jun 2020 12:39:27 +0200 Message-Id: <20200616103927.20222-7-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616103927.20222-1-filip.bozuta@syrmia.com> References: <20200616103927.20222-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0046.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 10:39:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acca9bef-583f-4372-aa82-08d811e194ed X-MS-TrafficTypeDiagnostic: AM6PR03MB3960: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GEV3kX072+wTJ1MeVPoX7ByUfek5L6QTKNiveDME2qRNHtxC2UnNgALEaTEoS4NU1f3aTAe4RBFqxV/NqV+5yJ2+NRIx2WzSJ2m+7FTqp/QY5yifuqvJndGcDRAGA+YQbrLOcsL4UqpHFaUx0dbW/r6LpDka+0a92zJbFcNvVP51Xo+uGbyhf5wX96Bsnwl9EDz12vnZf0BB/oCy+eqIU5Uri7V8AQN+23InFb4qgA2H4R95OBZNgLCL9LkMkdH4zEnhla9BTbsu8CxKox0OblzAfh6hAIzOPrx7qTsfJkCs8r7F00lYWCykQbgU4UdmZyITYUzfrpxKsLm0rvKXKwzl7L5UWbwUK3PJ7nFG6/NMFiOuYJYWlOP6Uxsdk5JGys85DVgX8d3uL+Quy+0lRQyNss3na0qXT1TOJGUJcm5pywsHSkJAUW9S1Ew9TC02LhFPwQSGH2FenmLNcwvwew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(346002)(366004)(39840400004)(376002)(136003)(966005)(5660300002)(83380400001)(86362001)(508600001)(8936002)(316002)(6666004)(66476007)(6916009)(7696005)(36756003)(2616005)(52116002)(66946007)(66556008)(956004)(44832011)(26005)(1076003)(2906002)(4326008)(16526019)(6486002)(186003)(8676002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: i88j/+rrDFLfw4PJRyI/ICYavxnsoaK+SFQtXSLK5e+X6TfSq+3UweDYLUke5RS4Nn6bPXo6eo8mkOuMKmJr0E3TKEjyFuQqpAE3KI/gV0snslheyZlgugBLwyH7HDTo6tMXuTsx2bQadagZQPSgFYNF76U2T4vXgEdEzbDrIqitIOgVOxS21MYN3wYG6btnCi/zfo46MigKvraYSCGdjEoFZK77zT8s6QtGPkmP5fGL6Ii3NnP5Y3TuA5mML/tSPfGVdQG+PFGPLXJOy+pAHQxUO5NoeQpa2ycAMupzI3nK3nX1LcFjQvC9f0+YUVVRYJ1uwvqk+t3G8opfQ71UnZrGrvW6pT9uVOIzSRiViKwKAkmLcMiEkZDuJN5a1Ip4ojqhd+RrvyeZ4uYPJmPX73BQYKxc0bX1qTvhg4czUvxvrOdv8ZaunXzq3N5u/on4gbHYViZIdsQinE08OVVaHnlJM8WxOg7RD8CCyilRavI= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: acca9bef-583f-4372-aa82-08d811e194ed X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 10:39:43.7922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DD7ikh0pypp7LXVLn3op/Q9X3nUYBYP8zadNpsQLSB12y4tCK9D3CFB2CVBfd4DqS246ZZLWf5OVh1s9+eV6GA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3960 Received-SPF: pass client-ip=40.107.20.134; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 06:39:47 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscall: *fallocate - manipulate file space int fallocate(int fd, int mode, off_t offset, off_t len) man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html Implementation notes: This syscall's second argument "mode" is composed of predefined values which represent flags that determine the type of operation that is to be performed on the file space. For that reason, a printing function "print_fallocate" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print flags of the "mode" argument. These flags are stated inside an array "falloc_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_GENERIC()". Most of these flags are defined after kernel version 3.0 which is why they are enwrapped in an #ifdef directive. The syscall's third ant fourth argument are of type "off_t" which can cause variations between 32/64-bit architectures. To handle this variation, function "target_offset64()" was copied from file "strace.c" and used in "print_fallocate" to print "off_t" arguments for 32-bit architectures. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/qemu.h | 16 ++++++++++++++++ linux-user/strace.c | 40 ++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 16 ---------------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8f938b8105..be67391ba4 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -670,6 +670,22 @@ static inline int is_error(abi_long ret) return (abi_ulong)ret >= (abi_ulong)(-4096); } +#if TARGET_ABI_BITS == 32 +static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +{ +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +} +#else /* TARGET_ABI_BITS == 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS != 32 */ + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index f44ab0ab84..4dbed81a55 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1143,6 +1143,26 @@ UNUSED static struct flags statx_mask[] = { FLAG_END, }; +UNUSED static struct flags falloc_flags[] = { + FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), + FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), +#ifdef FALLOC_FL_NO_HIDE_STALE + FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), +#endif +#ifdef FALLOC_FL_COLLAPSE_RANGE + FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), +#endif +#ifdef FALLOC_FL_ZERO_RANGE + FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), +#endif +#ifdef FALLOC_FL_INSERT_RANGE + FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), +#endif +#ifdef FALLOC_FL_UNSHARE_RANGE + FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), +#endif +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1560,6 +1580,26 @@ print_faccessat(const struct syscallname *name, } #endif +#ifdef TARGET_NR_fallocate +static void +print_fallocate(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_raw_param("%d", arg0, 0); + print_flags(falloc_flags, arg1, 0); +#if TARGET_ABI_BITS == 32 + print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); + print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); +#else + print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); +#endif + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_fchmodat static void print_fchmodat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 633f43f490..10e3e4a814 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -182,7 +182,7 @@ { TARGET_NR_fadvise64_64, "fadvise64_64" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_fallocate -{ TARGET_NR_fallocate, "fallocate" , NULL, NULL, NULL }, +{ TARGET_NR_fallocate, "fallocate" , NULL, print_fallocate, NULL }, #endif #ifdef TARGET_NR_fanotify_init { TARGET_NR_fanotify_init, "fanotify_init" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 009bb67422..7cc5a65b4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6608,22 +6608,6 @@ void syscall_init(void) } } -#if TARGET_ABI_BITS == 32 -static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) -{ -#ifdef TARGET_WORDS_BIGENDIAN - return ((uint64_t)word0 << 32) | word1; -#else - return ((uint64_t)word1 << 32) | word0; -#endif -} -#else /* TARGET_ABI_BITS == 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS != 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2,