From nobody Tue May 7 08:01:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1593207713; cv=pass; d=zohomail.com; s=zohoarc; b=eGqXHsGTTFd73+Bu9hXKHIpzxa0joATEYCOpYhqdIzzsLtTY2v4Ytro/aZuhOERlHrwYCngcCm3/n8TmiA1Rdqw6x6RCPFHywGfIWdW3ZWQvk6rpYOqvoPYPW5AuaYYxkcLInM0kLf3HuO17J83LLVsrgHGNBBp8aUCkCTYAJUU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593207713; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=54SWIRdOkKgujbox1T7bMQ48rABURJts6Zb88YDrn88=; b=loDid9ZWbHdZn892M6S+r5iMj4XasStYtaAQ+QwwhqTFWL6etiT2b6/CVhUOFB2wL0oQeE1KuTDKaCD1+9Qg1/YZq+Vlb39lv0t+h2MY9ucgbM3RNTwTLgwN/PQcCo9l6ee9cq1PlT0RxQnTRkcB3JG5OKKp1nwLfd5E4rNFVHc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593207713743519.0923394138989; Fri, 26 Jun 2020 14:41:53 -0700 (PDT) Received: from localhost ([::1]:48070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jow6a-0007zt-9H for importer@patchew.org; Fri, 26 Jun 2020 17:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jow5N-0006jO-Uy for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:38 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:39136 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 1jow5L-0004FJ-Ta for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:37 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5234.eurprd03.prod.outlook.com (2603:10a6:20b:c3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Fri, 26 Jun 2020 21:39:58 +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.3131.021; Fri, 26 Jun 2020 21:39:58 +0000 Received: from localhost.localdomain (147.91.217.240) by ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Fri, 26 Jun 2020 21:39:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O48QQoM6pBYgCIB/pRKafHJrbMuF73PUbg7CgA8APoDnjkU0I3IUSSG0IXzNremfPZLxafRJet/xc39wnpH1MXtmvVmDRJXLpV0ZTW4PU/jmWqfqp/oTDQ23lAfBIv2s+smwn4Q1n37IOLhriim/ToYCRUXIP1YJCJFmQdi77udTdCfIf8UbMlQAiSNnQPRkcxc80atjYDjjAgOJrQto6h7otDgIufCEoZdz0zpCRolcJm/+kgDyn9kyJuGPgA3N/j+0wr07eEFkuTg17lCmE8ywoT5SULPl6Rfz/s6VYjrD/ZZ5ZVm5YXflpDRDT3qFdi8BSlXIUVQO1PlbSCgasQ== 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=54SWIRdOkKgujbox1T7bMQ48rABURJts6Zb88YDrn88=; b=KO/YwPJJVm4hP7HD/JCj29jElIXU84Wyiy55BwhD0mZmYhyWL7qGzqT38GFN5HD8UZKIhRwbRQK1684SUkU2b2/yjtXW/cM9Hb3KiKd5iYujqA+E13QCF4CVtYFyMtzk7ncHrXl89XfyDt4lSAx3ey0MlQ1BZ8sBGTfWAylg7uB8NAkN9z3mxaiv40GfwwFhojuLa2IhQBJ2BqJFsKnCco396oEr80AfkVkFlPiIQhdtc6FW1d2vWfWu270l9GQjsXV7sd8rbzbZewwKdkD1S1ZQ6RyIQPkcpyTx9pDn9UFLmeiyhMwKr5mbSaX9ybfrbutmjaORaLjhXLMjn1bQdw== 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=54SWIRdOkKgujbox1T7bMQ48rABURJts6Zb88YDrn88=; b=YCfEJs989vvRqYZkrvzhZDsIKRdpgkZ5KwCInj2ZLDPAJIlDevoUuTJN8OQj7dHW1m4sE1u++j6o78RZ9J2rD2dsbgRTui7JDLEZvIxP0IIgf0GlsNtfG91SkRVPmcWUp+dq2oWea6mApiRClaFh7rFchrTBlGqFD0k8WB0uuX4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 1/3] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid() Date: Fri, 26 Jun 2020 23:39:35 +0200 Message-Id: <20200626213937.20333-2-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> References: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [147.91.217.240] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37ab2a49-1e58-474a-374f-08d81a197925 X-MS-TrafficTypeDiagnostic: AM6PR03MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-Forefront-PRVS: 0446F0FCE1 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XZYQNJm4TC/3z8h97nfPNJd+IrDQCXsDe81CnGhioTwjBiQ7dpW7d0LSvcPtqwldLRhi1snh5vVjrNIxbKoFpqHTcXYvxbiUtYqMUwAvw9VhbzgQArTzB7wavvrIgLp75HiNuYIJQgIo+9NDuZpcyGpZD8AbpH7wG5djOvNdI0T5EDn4XYJHYhhbxOWZHKPtJMjkqTYnEF3bCk+KAn1Hbsm9ftCvqBT6FROmTsYa0MGkfQwtYzpKwdKyWgqO7x4GQwdVH4PeZF7aUZKh4Cv+MJ31hPr6f6gR8Ca8DP5pM1tGzGw8uFtWTs4jn3nbv6EHZ+GVwfedHI4J4+E/uXf19AshaE66zO9MYAvJXwjeKa/8FmjXByCsDqXEnRW6KNBt8shj5CHBgrUkanJugeraa0EXuASN6Ef2BYOhiTDqq2e5lTs/UJhK/OM0hAzGQAGQ4nMxwuBtMHlKsX1oSO7BWA== 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:(39830400003)(376002)(346002)(396003)(136003)(366004)(4326008)(6666004)(6506007)(1076003)(508600001)(83380400001)(966005)(86362001)(6512007)(16526019)(186003)(6486002)(52116002)(316002)(6916009)(36756003)(2906002)(66476007)(66946007)(69590400007)(66556008)(8936002)(26005)(5660300002)(8676002)(2616005)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mFK/+SANpV8RVfGeHcuR4Y3gN9F9WGyQ3Lf/xj4kRJGCpkj/8vDnw/BXF0iRX/gs0yNx0jU9yct77d4/YfZi821tMcrOdcqsUkVzdOSPFj85tQHx4q0eab0eMavfW6qkvdXk1Ha2n8lKDvUhEUJ+1XUVzH0uDw7rwJMfj6S2FpJNB2BQ/SxDp2wxOhzOXAzpTdM7FDSVmXXAmVZzMXS4V4SRXfLmpoodtohpTkdPbXC6V55DfomB6LU/bgHfuKavGuX3O20hk1dPT7RmZZWlMlFpvuHrG1h12sxUCoQCMTQh/XZym/WvBW+7hRUkIWcbK7s6Pup30JjbQ7dwaLTSTRLdkODNH66Yy9aGt4LKAnzC/SvPDQcK345yBVMF93HhPXyrAiXJIGqYkiRkgjqg+L06iPRV7a1J6WZ0Xc1mEK4C6gcF8nhE7AkvSlgxyqWXeIw/f06CFKz6HKt4a876LJ0oqRbte1Mr1WPcpYgy3gc= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37ab2a49-1e58-474a-374f-08d81a197925 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2020 21:39:58.3950 (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: ocID57RBOpMXa8ttIWWisb7f74zxeFLpnAkJsBZQR0/r6tmhKkH9rPaPaFTPSd/xUKowqWRi+NNXM4q4Eec+0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5234 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.20.124; 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/26 17:40:33 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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, RCVD_IN_SBL_CSS=3.335, 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch implements strace argument printing functionality for following = syscalls: * truncate, ftruncate - truncate a file to a specified length int truncate(const char *path, off_t length) int ftruncate(int fd, off_t length) man page: https://man7.org/linux/man-pages/man2/truncate.2.html * getsid - get session ID pid_t getsid(pid_t pid) man page: https://man7.org/linux/man-pages/man2/getsid.2.html Implementation notes: Syscalls truncate/truncate64 takes string as argument type and thus a separate print function "print_truncate/print_truncate64" 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_st= ring()". The other syscalls have only primitive argument types, so the rest of t= he implementation was handled by stating an appropriate printing format in= file "strace.list". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 14 ++++++++++++++ linux-user/strace.list | 10 +++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 6044c66954..dccfbc46e9 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1925,6 +1925,20 @@ print_lseek(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_truncate +static void +print_truncate(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(TARGET_ABI_FMT_ld, arg1, 1); + print_syscall_epilogue(name); +} +#define print_truncate64 print_truncate +#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 10e3e4a814..3b77b22daf 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -258,10 +258,10 @@ { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ftruncate -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate, "ftruncate" , "%s(%d," TARGET_ABI_FMT_ld ")", NULL,= NULL }, #endif #ifdef TARGET_NR_ftruncate64 -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate64, "ftruncate64" , "%s(%d," TARGET_ABI_FMT_ld ")", N= ULL, NULL }, #endif #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, @@ -372,7 +372,7 @@ { TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getsid -{ TARGET_NR_getsid, "getsid" , NULL, NULL, NULL }, +{ TARGET_NR_getsid, "getsid" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_getsockname { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL }, @@ -1534,10 +1534,10 @@ { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif #ifdef TARGET_NR_truncate -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL }, +{ TARGET_NR_truncate, "truncate" , NULL, print_truncate, NULL }, #endif #ifdef TARGET_NR_truncate64 -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL }, +{ TARGET_NR_truncate64, "truncate64" , NULL, print_truncate64, NULL }, #endif #ifdef TARGET_NR_tuxcall { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL }, --=20 2.17.1 From nobody Tue May 7 08:01:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1593207713; cv=pass; d=zohomail.com; s=zohoarc; b=J5DzUiWsOV9uPT8nzpHkYOv3tbfDmfC3qNISgb13OzCUMOhYm7FSpFIM7QLa8qU2/cVVopU6K5ti+eZQAG9qBH3Buw3uoYmLbfwFxFdnE/psx9wY9LE1Bdn1kTsJ4xZz5WLGMOC2ZJwsDYpR/R4lJShaT64J2Y+wFwbpf9Z+JGM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593207713; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MsZzd8qdifyi1SBubYzCR5kC4yvuuYIuX7CUtsNn2Tc=; b=jGGRKIFkBYTzoMMWaFKiQ3yQXhu1Bkys3S3FIj5TE0EdF2KexJqRoDumUnQyrZGMTpLDq1I8k+HEsgDHnMpu92wQpwwNHrpE4qS4hAZXQSe8z7cfxoxdQN52XhjbraxLpwzoskl3bvVY1xZI9Yft27qZRNtNKBTQ1pBWZiJ8Y1E= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593207713787815.5743321822717; Fri, 26 Jun 2020 14:41:53 -0700 (PDT) Received: from localhost ([::1]:48112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jow6Z-00080u-W2 for importer@patchew.org; Fri, 26 Jun 2020 17:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jow5P-0006jU-QJ for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:39 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:39136 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 1jow5O-0004FJ-5B for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:39 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5234.eurprd03.prod.outlook.com (2603:10a6:20b:c3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Fri, 26 Jun 2020 21:39:59 +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.3131.021; Fri, 26 Jun 2020 21:39:59 +0000 Received: from localhost.localdomain (147.91.217.240) by ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Fri, 26 Jun 2020 21:39:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvsd//ieVzB69oeAq602H7yxWa2bMqsK6KWAMxho7AnJW0yTlxAuxZ72l+tk1yeV+f4XF7Z+expmr4sVuc/uM6jFDTu0DAif7Mbn1Zwavt7LFvjibXjAJ8s/+nRXurnlEufY21Rf/7ipVYbPkxDu69cow4gpjtqIL5Wr4lX1q6Q1o+uktMyIVPSq3CBXbzbCfXqGVT6S0Vv9dRyysvFv3Y2+ROrXvoo/I90Frs96C+yOAPnJfDaApJ8E36lJ/PTf/YaWwM5LbM2xMmF+Euds/YMEBMbNVQqU8P1eWv28ywXaGQ0prb6Xjp0gOPoY4SlnWSkuDjjkVk7k1bupwhFmbQ== 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=MsZzd8qdifyi1SBubYzCR5kC4yvuuYIuX7CUtsNn2Tc=; b=AQYGAg66srFlBuXngd1I6su/EyEkNEvMALIAWZyzG37r0mm1MPLOnblVeK1LueWtkeTx9CPrBFPH41r8uC8bRlbvLIunz3YxuJSZbYECi2EBzl+SGVc5+Dj6Uv+KpRMJ2mE00PR0lpQm5VIvPBNm1Lg8WJ2V8+QuRbOMiWrcTOOtfT7dZGftq5KbxxzfXfOiW+HCIzskEOu6oDYh/6/JrsDaLpYEN5sOzZs6UqClDRLDd8CYfOf3X6UQ93GvjYdU60rF3LiiEoFVf4oqmc3tmvPq8dCLIDUnZmHbA6C8jgBX86gDR+sRk01VLYSAE8Y6fH6FPjCxZEjQkI3sxRwnFQ== 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=MsZzd8qdifyi1SBubYzCR5kC4yvuuYIuX7CUtsNn2Tc=; b=s12u75hyhUjhPJtz4GKc2ACIcn0aNA0PCSsrIfFBXUqAM4DnxD2cKl4U2vnNOGCtTEMyH5O0a+OqB73W12IYu0qAg8s1QCd+95GW4IEtAvDQFDylb5oB+kEjVULFc8kHHiROEoCWR3WmipyDpwAtWvoe+Vsl5/oRW0XR5vAiv7U= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 2/3] linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory Date: Fri, 26 Jun 2020 23:39:36 +0200 Message-Id: <20200626213937.20333-3-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> References: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [147.91.217.240] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf9dca0d-cd9c-4320-de28-08d81a197992 X-MS-TrafficTypeDiagnostic: AM6PR03MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-Forefront-PRVS: 0446F0FCE1 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ppT8pMXd/U6iCnAD0OG/zr3LD8+Vkk9a8SX8V32KEVWXxQd9iaB0m0ph10H7rHtMnI11h/FNcSdwrk/atpkAoqMF3OQutUgBJG5u6VLuYASCzKc4C5RVecxNokuLfDvnKJ0zvl94LS1mRdfd2VYL5J+sB1Xcr3gGcREeIlbJb/PAXssVa225p8qLA+HWABxDTENZJ3unDzz5IP8UDc43DB3YMFxNYlRcpV6lD63wqVXWxu/Is4z1RKt1SgJquPnaXjrECzh0IbJnPyAVwq7fo4nMpN1abHvW2ZzU+wQKTQCmptjudS1dmE2Zv4t0AcfKi3Bz7fDzKbLCyULJhzT6LpsPtExgxJlDdDy84Vbtj4qs55GXu07VB/OGhwvWoEBPc/Ey71TN6dMHLZmMsmafgg14ntq34w/ffzCj8u0NetSa3L7yP8fQR1ZfTtBfW/K0F2FvQzeqlFkjtcupxLXYGKrAzi9D+Q5CEXbuLweNSIM= 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:(39830400003)(376002)(346002)(396003)(136003)(366004)(4326008)(6666004)(6506007)(1076003)(508600001)(83380400001)(966005)(86362001)(6512007)(16526019)(186003)(6486002)(52116002)(316002)(6916009)(36756003)(2906002)(66476007)(66946007)(69590400007)(66556008)(8936002)(26005)(5660300002)(8676002)(2616005)(956004)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: lHtdsj4C4Njl1kYrXFp30yUUkOMLbMXydwLqDpEW2Q9zk8UVAXfW0FRM5pPjGSee+TbcaDABgB8t2MvcyiuenYzKzDHD3kBApjAFFLmGGSNF5PU0Mnn9+nU3M9JdJlwk9M1l/cPpF5mvGc5HhuYDzS1wGNl3knrCJ0LMf8KHP+65g6GDOhOtX1EH+f0JVcakpzoSnTOnWwwdoHIQwiJjORRK8gSbrZh7frL3KwNOmxeN4+V5acWBrn2fHiWkTe2CLJthYjqZIb4OmUVDky/TkZnl9FTaiedPfrzDUWv4uJ5aVhprDREPvj3TiVuKF0cP45Kw/mSC5wrnBXwrPTC9tPF0Tpk9IgBE4R1EcJYI3uyx3vAUiLxGrQmEMUu9FeSqlc9UHrj7laI5jkHVZSeo3aEd6oF3KPHEuMqaFTsb++GzQOJYr9+uCpHnqj1VFGNIkjYUy68Hlc4sam7ZalSSHi78mAUp0t2XwsTCgWun0Ws= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf9dca0d-cd9c-4320-de28-08d81a197992 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2020 21:39:59.1086 (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: sT1sSVMc3fQNmlgEiwdINMpY1krHgTsTpHDmmKU+4iPP3UAFpG6flJ26jfiTTZWSBGVXCq78w4oxGCoDXtEJfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5234 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.20.124; 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/26 17:40:33 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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, RCVD_IN_SBL_CSS=3.335, 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch implements strace argument printing functionality for following = syscalls: * mlock, munlock, mlockall, munlockall - lock and unlock memory int mlock(const void *addr, size_t len) int munlock(const void *addr, size_t len) int mlockall(int flags) int munlockall(void) man page: https://man7.org/linux/man-pages/man2/mlock.2.html Implementation notes: Syscall mlockall() takes an argument that is composed of predefined val= ues which represent flags that determine the type of locking operation that= is to be performed. For that reason, a printing function "print_mlockall" = was stated in file "strace.list". This printing function uses an already ex= isting function "print_flags()" to print the "flags" argument. These flags ar= e stated inside an array "mlockall_flags" that contains values of type "struct f= lags". These values are instantiated using an existing macro "FLAG_GENERIC()". 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". Syscall mlock2() is not implemen= ted in "syscall.c" and thus it's argument printing is not implemented in this = patch. Signed-off-by: Filip Bozuta --- linux-user/strace.c | 21 +++++++++++++++++++++ linux-user/strace.list | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index dccfbc46e9..1fc4404310 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1161,6 +1161,15 @@ UNUSED static struct flags falloc_flags[] =3D { #endif }; =20 +UNUSED static struct flags mlockall_flags[] =3D { + FLAG_GENERIC(MCL_CURRENT), + FLAG_GENERIC(MCL_FUTURE), +#ifdef MCL_ONFAULT + FLAG_GENERIC(MCL_ONFAULT), +#endif + FLAG_END, +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1939,6 +1948,18 @@ print_truncate(const struct syscallname *name, #define print_truncate64 print_truncate #endif =20 +#ifdef TARGET_NR_mlockall +static void +print_mlockall(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_flags(mlockall_flags, arg0, 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 3b77b22daf..822b6be49c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -567,13 +567,13 @@ { TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, #endif #ifdef TARGET_NR_mlock -{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL }, +{ TARGET_NR_mlock, "mlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_mlock2 { TARGET_NR_mlock2, "mlock2" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_mlockall -{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL }, +{ TARGET_NR_mlockall, "mlockall" , NULL, print_mlockall, NULL }, #endif #ifdef TARGET_NR_mmap { TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr }, @@ -636,10 +636,10 @@ { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_munlock -{ TARGET_NR_munlock, "munlock" , NULL, NULL, NULL }, +{ TARGET_NR_munlock, "munlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_munlockall -{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL }, +{ TARGET_NR_munlockall, "munlockall" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, --=20 2.17.1 From nobody Tue May 7 08:01:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1593207718; cv=pass; d=zohomail.com; s=zohoarc; b=LREcxebttcri2WH8MCmvE45/rExMHduem+4DYfEZ5/PZTmo+Rc/yQGDC3LBLJ7rLHiwJJsl/HDKdJJaBI7S7QiIy29ulYR9Nl6moHSaeZOHpyZf798cVN9UKzu7eeB+aZ9Z5T3yvJ/yQRNfqOF3B8DiLO0Y2hSJMU9GF0+LuB64= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593207718; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gS6+bJznuhZnLeLbDo/lo5JjYfjmHeP3FECNDOcTNUA=; b=PvdIZuWXOihN7965UGnWuuB0WN5XKmXZ93Mhhshzpg5j0dfs91fIhLvIyM8vpcSI+bCLUxXLfxyVMentiq/oXv9FtFX4H2j14+q2cUTHwPhoGX7EyklL3byH4TcA60e1IuriPSukN1uFyimxcDKrV7nDGAJxhKNbNg9G0p2RYOs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593207718677445.769758517603; Fri, 26 Jun 2020 14:41:58 -0700 (PDT) Received: from localhost ([::1]:48456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jow6f-00089D-Ar for importer@patchew.org; Fri, 26 Jun 2020 17:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jow5S-0006mG-3K for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:42 -0400 Received: from mail-db8eur05on2124.outbound.protection.outlook.com ([40.107.20.124]:39136 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 1jow5Q-0004FJ-1s for qemu-devel@nongnu.org; Fri, 26 Jun 2020 17:40:41 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5234.eurprd03.prod.outlook.com (2603:10a6:20b:c3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Fri, 26 Jun 2020 21:39:59 +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.3131.021; Fri, 26 Jun 2020 21:39:59 +0000 Received: from localhost.localdomain (147.91.217.240) by ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Fri, 26 Jun 2020 21:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DsvthOMAidyZxPd4G/1xPPET03BbgNsTwSlmKjqQByX9cHvYhuJ4bO19u8K2tAQvipOfTpUNHye6l362N3zNY/d05GAjshPERlPoMOSoraMFM99zvD0MJxLkiyvD/OiuO/yPbbfAo4BEcO4MKSPSCh3C/Ur3uF7nZYRGIpjs0qgs0CCBOvRXGcw/84MDNB2WqdjZRrEgLAsmefDKwhfrLj8rx+W2ic8JGhvcKa4Qno6JbPwrn2+M+pBYAx5QizdAKDChlR22VmmpROlwVsI/MJBwa+vbsZTSZzMoocET3gEldTxg6yoC4OC6ypsv36ZPPSupPDmStJ/7dmFczOZVmA== 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=gS6+bJznuhZnLeLbDo/lo5JjYfjmHeP3FECNDOcTNUA=; b=BHdUVCfDrxaNHaQA5gbKTWMNJa7WW0BdbvBhGfQAkQEKfWKAbYyk8AOe/Jb1U+DCQ5kYt53Rqyh4kvLX4c5v4yGxdsdUJ/LW0BbS6feKUxlVYzTSp1h99/F0fLSEcGfwP6D/I0NbrsSbChoS+ulw99j3raMoKjSKUB/OI4ZLwTbYH6SWzGBoO2sC91JOyAPhDDGbOB5uqeD7OjMMuTzB5YBn1ypEPZAxH/GoXvuEiO7v3hgxsKDNqgUlL5nLBBaeDpe5iauewhZeVq/uq9WooVzicr3SVhzL5jkw3JokIW9gcv9jEroy2Dkwp3Q6KozFWMTr/xBqpW7f5iBkY6dGqg== 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=gS6+bJznuhZnLeLbDo/lo5JjYfjmHeP3FECNDOcTNUA=; b=B15W5z+eaOUrMzWsEe8AvOAcsO8ZVdfTChLIxr7SyCw4w/BJiG6Pg6/2qq2Hi0pVh6Uoax/T2bxzTZD1xlbmTRmJCIwpJQBW/varopjqhv3pu8UKlcS+IJpEHufNWljl7vsLGlxIRS5tYGZlv88jPfqUxcXwbX5CXR9XYLda4h8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 3/3] linux-user: Add strace support for printing arguments of some clock and time functions Date: Fri, 26 Jun 2020 23:39:37 +0200 Message-Id: <20200626213937.20333-4-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> References: <20200626213937.20333-1-Filip.Bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::13) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [147.91.217.240] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bcfa21a9-e82c-49a3-2130-08d81a197a01 X-MS-TrafficTypeDiagnostic: AM6PR03MB5234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-Forefront-PRVS: 0446F0FCE1 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BgAIybkNR9LavtnFMOEuSACavGViY52Mlwqknbset3KzqSOf/ntso+R/qFQe3EK/nuLcqqooFpXKZzI0KyMu4ggNGeHejbzmMUrx4waAT1Kx1Je+u8gaYxM6UOKAmyvnbt4HoDIyc5/FJoTz4f0frw7UWVaZ/ovFJkXKIrwL9g7afsTPtAFGaTw4OsmmLm4UfEIYozP731+ukOwSJ+SL8l+48Vf7TVA2jA4/G3+aJsYbhfx2lhn6VOcN+V0qJymcJgagRmcXXxPLQ0T7W2sZ1dugWRmytVxTOQogWfeNg4b/qtkTykpUGVgNSeCHUJqfP7P6+eLgKyiUkk77i8LKTSQKxKgKpIRrJobpoq4HO6NXfjy5/3TedjNIuIXSW7MtTsIhDypDTpc7u1rBNbj6hklTXlKKg8DiuA2UKxrBhXM95f/BkHUsA3nmRfbthL0p9SPG1tM4x8l4omukEPFhHw== 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:(39830400003)(376002)(346002)(396003)(136003)(366004)(4326008)(6666004)(6506007)(1076003)(508600001)(83380400001)(966005)(86362001)(6512007)(30864003)(16526019)(186003)(6486002)(52116002)(316002)(6916009)(36756003)(2906002)(66476007)(66946007)(69590400007)(66556008)(8936002)(26005)(5660300002)(8676002)(2616005)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pjSQ5w13IKhswtnYp7zmFe+2zTjTQ22cDeExvJR1E2eHOmj9QWkyG4Q1iwiALZJhiAXTrdgp3s62+AUVz4EpccCgRhRfJ4H0CRlyt+dsag3MJdWXVECPeqcmDJR88DtGNNFFd7jWWZrUlilcIuYW4xIvfJevcGYfPba1K0J3mVNeVvDtlomHPe4aDVcgcRzbfp9cwbOsxKxz9wmH2bZzNooAFOzUFr9NQx99wmJxmYahQwEICPRcg9EmwSSYVvzrnztqHk0V2iUpxXW2oaCwfE0ORbVc6hZLJ69Tju2VHcPPpmuC4tRgpsuf/EdAiVF03VShrBd5F9szYmXMQ9Tp+fXRCPSp6/n/00tJ081F64jU4wPAIe26NRfYcKHrfeLowX19LCoFA3J3f09FOBC/dWMd2sKYAWc2t7b1uLNE7TM7AMujo23YUNqHUQzuzw65FNKFrpCIUUTIA+RQPqXmcp7BpwbxsC8INC/imEVffJ8= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcfa21a9-e82c-49a3-2130-08d81a197a01 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2020 21:39:59.8832 (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: aoNZeourPGBC0irvwCPxIhnuvdHEAgdIlTS2Xoj6BKPcfeYQV8fP6AsAlOVPRfWc3LijzlljVS8JH2C4xyH5gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5234 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.20.124; 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/26 17:40:33 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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, RCVD_IN_SBL_CSS=3.335, 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch implements strace argument printing functionality for following = syscalls: * clock_getres, clock_gettime, clock_settime - clock and time functions int clock_getres(clockid_t clockid, struct timespec *res) int clock_gettime(clockid_t clockid, struct timespec *tp) int clock_settime(clockid_t clockid, const struct timespec *tp) man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html * gettimeofday - get time int gettimeofday(struct timeval *tv, struct timezone *tz) man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html * getitimer, setitimer - get or set value of an interval timer int getitimer(int which, struct itimerval *curr_value) int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value) man page: https://man7.org/linux/man-pages/man2/getitimer.2.html Implementation notes: All of the syscalls have some structue types as argument types and thus a separate printing function was stated in file "strace.list" for each of them. All of these functions use existing functions for their appropriate structure types ("print_timeval()" and "print_timezone()"). Functions "print_timespec()" and "print_itimerval()" were added in this patch so that they can be used to print types "struct timespec" and "struct itimerval" used by some of the syscalls. Function "print_itimer= val()" uses the existing function "print_timeval()" to print fields of the structure "struct itimerval" that are of type "struct timeval". Also, the existing function "print_timeval()" was changed a little so that it prints the field names beside the values. Syscalls "clock_getre= s()" and "clocK_gettime()" have the same number and types of arguments and thus their print functions "print_clock_getres" and "print_clock_gettim= e" shate a common definition in file "strace.c". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 186 ++++++++++++++++++++++++++++++++++++++++- linux-user/strace.list | 16 ++-- 2 files changed, 194 insertions(+), 8 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 1fc4404310..414748d0fa 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -64,7 +64,9 @@ UNUSED static void print_string(abi_long, int); UNUSED static void print_buf(abi_long addr, abi_long len, int last); UNUSED static void print_raw_param(const char *, abi_long, int); UNUSED static void print_timeval(abi_ulong, int); +UNUSED static void print_timespec(abi_ulong, int); UNUSED static void print_timezone(abi_ulong, int); +UNUSED static void print_itimerval(abi_ulong, int); UNUSED static void print_number(abi_long, int); UNUSED static void print_signal(abi_ulong, int); UNUSED static void print_sockaddr(abi_ulong, abi_long, int); @@ -833,6 +835,65 @@ print_syscall_ret_adjtimex(const struct syscallname *n= ame, abi_long ret, } #endif =20 +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_syscall_ret_clock_gettime(const struct syscallname *name, abi_long r= et, + abi_long arg0, abi_long arg1, abi_long arg= 2, + abi_long arg3, abi_long arg4, abi_long arg= 5) +{ + print_syscall_err(ret); + + if (ret >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_timespec(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime +#endif + +#ifdef TARGET_NR_gettimeofday +static void +print_syscall_ret_gettimeofday(const struct syscallname *name, abi_long re= t, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_timeval(arg0, 0); + print_timezone(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_syscall_ret_getitimer(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 >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" ("); + print_itimerval(arg1, 1); + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ || defined(TARGGET_NR_flistxattr) static void @@ -1371,13 +1432,34 @@ print_timeval(abi_ulong tv_addr, int last) print_pointer(tv_addr, last); return; } - qemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", - tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); + qemu_log("{tv_sec =3D " TARGET_ABI_FMT_ld + ",tv_usec =3D " TARGET_ABI_FMT_ld "}%s", + tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last= )); unlock_user(tv, tv_addr, 0); } else qemu_log("NULL%s", get_comma(last)); } =20 +static void +print_timespec(abi_ulong ts_addr, int last) +{ + if (ts_addr) { + struct target_timespec *ts; + + ts =3D lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); + if (!ts) { + print_pointer(ts_addr, last); + return; + } + qemu_log("{tv_sec =3D " TARGET_ABI_FMT_ld + ",tv_nsec =3D " TARGET_ABI_FMT_ld "}%s", + tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last= )); + unlock_user(ts, ts_addr, 0); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + static void print_timezone(abi_ulong tz_addr, int last) { @@ -1397,6 +1479,21 @@ print_timezone(abi_ulong tz_addr, int last) } } =20 +static void +print_itimerval(abi_ulong it_addr, int last) +{ + if (it_addr) { + qemu_log("{it_interval=3D"); + print_timeval(it_addr, 0); + qemu_log("it_value=3D"); + print_timeval(it_addr + + offsetof(struct target_itimerval, it_value), 1); + qemu_log("}%s", get_comma(last)); + } else { + qemu_log("NULL%s", get_comma(last)); + } +} + #undef UNUSED =20 #ifdef TARGET_NR_accept @@ -1839,6 +1936,19 @@ print_futimesat(const struct syscallname *name, } #endif =20 +#ifdef TARGET_NR_gettimeofday +static void +print_gettimeofday(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_pointer(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_settimeofday static void print_settimeofday(const struct syscallname *name, @@ -1852,6 +1962,78 @@ print_settimeofday(const struct syscallname *name, } #endif =20 +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_clock_gettime(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_clockid(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#define print_clock_getres print_clock_gettime +#endif + +#ifdef TARGET_NR_clock_settime +static void +print_clock_settime(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_clockid(arg0, 0); + print_timespec(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_getitimer(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); + switch (arg0) { + case ITIMER_REAL: + qemu_log("ITIMER_REAL,"); break; + case ITIMER_VIRTUAL: + qemu_log("ITIMER_VIRTUAL,"); break; + case ITIMER_PROF: + qemu_log("ITIMER_PROF,"); break; + default: + print_raw_param("%#x", arg1, 0); + } + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_setitimer +static void +print_setitimer(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); + switch (arg0) { + case ITIMER_REAL: + qemu_log("ITIMER_REAL,"); break; + case ITIMER_VIRTUAL: + qemu_log("ITIMER_VIRTUAL,"); break; + case ITIMER_PROF: + qemu_log("ITIMER_PROF,"); break; + default: + print_raw_param("%#x", arg1, 0); + } + print_itimerval(arg1, 0); + print_itimerval(arg2, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_link static void print_link(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 822b6be49c..6b5cef149f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -83,16 +83,18 @@ { TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NU= LL }, #endif #ifdef TARGET_NR_clock_getres -{ TARGET_NR_clock_getres, "clock_getres" , NULL, NULL, NULL }, +{ TARGET_NR_clock_getres, "clock_getres" , NULL, print_clock_getres, + print_syscall_ret_clock_getres }, #endif #ifdef TARGET_NR_clock_gettime -{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, print_clock_gettime, + print_syscall_ret_clock_gettime }, #endif #ifdef TARGET_NR_clock_nanosleep { TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_clock_settime -{ TARGET_NR_clock_settime, "clock_settime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_settime, "clock_settime" , NULL, print_clock_settime, NU= LL }, #endif #ifdef TARGET_NR_clone { TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, @@ -315,7 +317,8 @@ { TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getitimer -{ TARGET_NR_getitimer, "getitimer" , NULL, NULL, NULL }, +{ TARGET_NR_getitimer, "getitimer" , NULL, print_getitimer, + print_syscall_ret_getitimer }, #endif #ifdef TARGET_NR_get_kernel_syms { TARGET_NR_get_kernel_syms, "get_kernel_syms" , NULL, NULL, NULL }, @@ -388,7 +391,8 @@ { TARGET_NR_gettid, "gettid" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_gettimeofday -{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, NULL, NULL }, +{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, print_gettimeofday, + print_syscall_ret_gettimeofday }, #endif #ifdef TARGET_NR_getuid { TARGET_NR_getuid, "getuid" , "%s()", NULL, NULL }, @@ -1290,7 +1294,7 @@ { TARGET_NR_sethostname, "sethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_setitimer -{ TARGET_NR_setitimer, "setitimer" , NULL, NULL, NULL }, +{ TARGET_NR_setitimer, "setitimer" , NULL, print_setitimer, NULL }, #endif #ifdef TARGET_NR_set_mempolicy { TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL }, --=20 2.17.1