From nobody Sun May 19 10:14:42 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=1591890773; cv=pass; d=zohomail.com; s=zohoarc; b=LeJ99c8hbAWQIUnvV+hcT+nBVmjxd+eOmHW1VEyTXfp32CWGMn/z8Enn36YdQkpytwe5HZlGr+zPXTqqb9bhW/5UV0Zvs0RJoqHzZ8MHdjfaFpcsrcqRjKwROIHxvoiHyMX0fWjHTDfjhJjaE0rLFAkORyVEZ56dHIFWHm2Dw3M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591890773; 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=1mJJDj45l7kJQ/nSdhCJPa7Sj5e+iEDYbZsLEg0OSKo=; b=LQihgSD92xw70gSExbHkNES63rLBMQhb+PR1ihKWpdupg2YYbrWP9dNyyT31XpHHJR4SQpTYcscnj8KZxUGXwGRmy51kPM5Orx7TdpPq75NL3skOn30ZG9mX1zK0YwmWTG9auNCrMFuapXLSqx5f6MJltPzE51FJ05i6T8YVIsM= 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 15918907731991020.9044857826466; Thu, 11 Jun 2020 08:52:53 -0700 (PDT) Received: from localhost ([::1]:53136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPVa-0005l2-W1 for importer@patchew.org; Thu, 11 Jun 2020 11:52:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPUL-0004Um-L2 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:33 -0400 Received: from mail-eopbgr60103.outbound.protection.outlook.com ([40.107.6.103]:37760 helo=EUR04-DB3-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 1jjPUI-0005xt-O0 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:33 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:23 +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.3066.023; Thu, 11 Jun 2020 15:51:23 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JyEaY+x26qAQYz1R2X5jUsrL9TBHEECsZWFJnPVExwjQ7vFo1OdSzpl3eVZ364608cNb/sDhq6h/gG2Aqoig+1PNzRIzTf3s6/RpTmj13Xhv8wdaULiCDzck6HLu/zXE+N9P6iBMfVVu7UnKErS0hIzUAd72YUCKvVTkY8vWpyS3HJSKqMf0ygepq9NecjtzRqHLYugy9D3bIrtM+m+crbT3MW39r2/UrcKhlEHM0p0HJ/aJvOFgGk4RK7/TcpR58bcco3Tr4izeMyVmvY85iHWt+oTn5kTIpLOYLW5P+NE3KkYZDNgvRTaWFEMtKCQIm77B2So/O7D8C+TGrwiJZw== 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=1mJJDj45l7kJQ/nSdhCJPa7Sj5e+iEDYbZsLEg0OSKo=; b=H0Y8hm2Ni2ZfW9hwSTv1ue8bZe8QcuVejLkgjID5KY5I6eVDRZ6QREBuX9xWJJF88mlLFi1RpY5N3q7+2Z0fyCHs+tabMbLv2yvQPvHAxVi0cIPsdL7XhEUNPoSI9HuO18Y/eSdUpJi8RgTF4HfEPrx5RKPhzzTD402bRGmj05LcCPF+qiXnAdzLG/6ojtbSamMPmj35EHavkcY1wf3ZDr3bQvYi7hXhY4AxKHrF6f1TogryYJElB4kRDLNZFIpR06YhAF9BG18k7cM7trG+aJB2/KUKs1CpD5igYPjr2KR+UrliLwfuo82DoX4g6QWQJhXLLkXKgP1TetRwqMTj6A== 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=1mJJDj45l7kJQ/nSdhCJPa7Sj5e+iEDYbZsLEg0OSKo=; b=E2p3b/fbgpNhu4AD08kPDjqQ7OfWlNfYR44A38Tfsjp8jgmxQngHBBgh9h7qlgV17A2T2s5VHcaT1kiRRl66mPGXz9CSrLpURVPo+GaVSCQFdrncA8lBtK3kRHuM9qPfT20he3k5ZqWMZigHvvXCmXXv79Py0pJNNqwuquU562o= 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 v3 1/6] linux-user: Extend strace support to enable argument printing after syscall execution Date: Thu, 11 Jun 2020 17:51:04 +0200 Message-Id: <20200611155109.3648-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62a33594-1eaf-43c6-538c-08d80e1f4a7e X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 30bKeJhbzKVj6qqSglOwdvPQvuXvvc3ZCxfaW+tkC13x0/EXwZq27uvo2sdM2j4KLz3mK77MpxT/kgwz0vEqS01LcF0Nkvkg3WjDRLbU9XwpJGQUmqXdt14fY1DTo+4aPbPhn1S3+3JtSH+NReUSzO+moiqV1xjS0qPVJKOH2hoH5dHvg+/zwe0D+W/0YKMDgd+cIL+qtpLYXxtoFjd0sW54KtqI/YwKKZBS5ZlpqCQV3OX4dhzug3B3M1HTVvsXRi6YRrKHJdPXPq4R2Nk2lylFKl6S+SvB7F47WxDrJ+JI2bTinN8+weJbnV9rxhn9h1teTA+d9ZtIu0gZZQ/KtA== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: a6b+OSsI7hMlcebcb/ON9SrN+ujLAcpYkO/2S1S0bkcVKU/Ca6Hi3kb3JULjsVSk1Bm557seA4TyU22qYDeVlJhQCXYxOapkQM4ZnwGj3MLixdtQjIu86BpTctSfdkF4QnqVsEsvxKhZe2nz697fBHAP4YST6Z8q3egjzjDRV22hgicbeTtXmA83AtiP1JDn3EiiN1JNeN4cqZmR1Omklu2t5zrQX6T+VI5JYJoQ/R5WTdf6JXdQztYK7KYC0LuaQuuoPhDlVNAB1sIRNWxGHq5YXN5SYkRicBv2i+mCN557kJmmXP5sdpcI/pF7d8ozcieQmUYqLVg+hiDcIopD0+x2wpExbI1W8lXvZq+PgGOtWz2p6+qwnxcDtLeKI5Ii8VQaGlmhOpk1F4LNhV9VKzUfPvfxoQ6Vtj/vvZFYqzyzMp8F/mZatAf2LFc4da7wPDimmQDYsbvyEQMbOPAS03OMts+ShcgHSH2JLPfP4cM= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62a33594-1eaf-43c6-538c-08d80e1f4a7e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:23.0762 (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: YzMVuWvxfyRq54g/MKUOjNqJN72YPh0NXuPLmFEdyqrflnwN2UiAIfCV8c+W0MWBuQPW8/m6Z8FT0zHsBm75yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.6.103; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 11:51:27 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+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" 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 funct= ions takes all syscalls arguments beside the return value. In this way, it e= nables "-strace" to print arguments of syscalls that have changed after the sy= scall 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 i= nside "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 ca= use build errors (even though syscall arguments are not used in these functions). There is code repetition in these functions for checking the return val= ue and printing the approppriate error message (this code is also located = in print_syscall_ret() at the end of "strace.c"). That is the reason why a= generic function SYSCALL_RET_ERR() was added for this code and put inside these functions. Signed-off-by: Filip Bozuta --- linux-user/qemu.h | 4 ++- linux-user/strace.c | 71 ++++++++++++++++++++++++++------------------ linux-user/syscall.c | 2 +- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ce902f5132..8f938b8105 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -383,7 +383,9 @@ int host_to_target_waitstatus(int status); void print_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); -void print_syscall_ret(int num, abi_long arg1); +void print_syscall_ret(int num, abi_long ret, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6); /** * print_taken_signal: * @target_signum: target signal being taken diff --git a/linux-user/strace.c b/linux-user/strace.c index 0d9095c674..8678a2aeac 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -19,7 +19,9 @@ struct syscallname { void (*call)(const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); - void (*result)(const struct syscallname *, abi_long); + void (*result)(const struct syscallname *, abi_long, + abi_long, abi_long, abi_long, + abi_long, abi_long, abi_long); }; =20 #ifdef __GNUC__ @@ -735,18 +737,29 @@ print_ipc(const struct syscallname *name, * Variants for the return value output function */ =20 +#define SYSCALL_RET_ERR(ret, errstr) \ +{ \ + qemu_log(" =3D "); \ + if (ret < 0) { \ + qemu_log("-1 errno=3D%d", errno); \ + errstr =3D target_strerror(-ret); \ + if (errstr) { \ + qemu_log(" (%s)", errstr); \ + } \ + } \ +} + static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) +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) { const char *errstr =3D NULL; =20 - if (ret < 0) { - errstr =3D target_strerror(-ret); - } - if (errstr) { - qemu_log(" =3D -1 errno=3D%d (%s)\n", (int)-ret, errstr); - } else { - qemu_log(" =3D 0x" TARGET_ABI_FMT_lx "\n", ret); + SYSCALL_RET_ERR(ret, errstr); + + if (ret >=3D 0) { + qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); } } =20 @@ -760,7 +773,9 @@ print_syscall_ret_raw(struct syscallname *name, abi_lon= g ret) =20 #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(" =3D 0x" TARGET_ABI_FMT_lx " (", ret); print_fdset(newselect_arg1,newselect_arg2); @@ -783,18 +798,15 @@ 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 =3D NULL; =20 - qemu_log(" =3D "); - if (ret < 0) { - qemu_log("-1 errno=3D%d", errno); - errstr =3D target_strerror(-ret); - if (errstr) { - qemu_log(" (%s)", errstr); - } - } else { + SYSCALL_RET_ERR(ret, errstr); + + if (ret >=3D 0) { qemu_log(TARGET_ABI_FMT_ld, ret); switch (ret) { case TARGET_TIME_OK: @@ -2847,7 +2859,9 @@ print_syscall(int num, =20 =20 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 =3D NULL; @@ -2855,17 +2869,16 @@ print_syscall_ret(int num, abi_long ret) for(i=3D0;i=3D 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_lon= g arg1, arg5, arg6, arg7, arg8); =20 if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_syscall_ret(num, ret); + print_syscall_ret(num, ret, arg1, arg2, arg3, arg4, arg5, arg6); } =20 record_syscall_return(cpu, num, ret); --=20 2.17.1 From nobody Sun May 19 10:14:42 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=1591891942; cv=pass; d=zohomail.com; s=zohoarc; b=RkcPXkHwCltFRaWghz5Mr/xgWGTAED4SUREOeprcMc2MaTaIllJGccJQPU/B0HLnZ56fKiFJ6EV2oEWI/qsyQjvr4TUv94R2I35sNaYExC5m1v5oge5qB6lxa2MmUiPua01nLckjdHJ63bKUzoyFPRIcvYq+ys00dZrfYqgxPAg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591891942; 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=oBl2H6hbVcegyp+EsCQCI1C8r8tpdRRumyzlF36DHc0=; b=kVu+AH6WKzm8UiAES+7v2Bi6zG6OQKiCFcI2Goy/nBsphnd7Ivfp1f/BAxb1NsFQ0vw4h0XPwkBI5v+f7c7WTsUU3WC62d3oteNhKoMVhqkKmVncZQ6SYgqPo4+YYCfVahuz6lUC9e3yxFt4kChU8Kew6+mmrt2I0ZXI6M/sG6Y= 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 1591891942578215.94783961487974; Thu, 11 Jun 2020 09:12:22 -0700 (PDT) Received: from localhost ([::1]:35898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPoT-0001nq-Cq for importer@patchew.org; Thu, 11 Jun 2020 12:12:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPip-0000Zm-6G for qemu-devel@nongnu.org; Thu, 11 Jun 2020 12:06:31 -0400 Received: from mail-eopbgr80117.outbound.protection.outlook.com ([40.107.8.117]:27360 helo=EUR04-VI1-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 1jjPim-0001cI-2x for qemu-devel@nongnu.org; Thu, 11 Jun 2020 12:06:30 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:23 +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.3066.023; Thu, 11 Jun 2020 15:51:23 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iR0K9isxbbAlaJdlNqNfMGkZKzF+NN+FejiE+j4yV2IT3+oqD0B864PjigNfixeR9H/iBFscpzPQaJkAGSIwSPhpb92LpQlihtrZUTSOES9ZFf0NYn3sfUPiQp7Rev/mPgNCj4aboOIxV8pFWl9h6UHXkcP0HqKVCbZ9hVV2VxQw5OXgsbm1liNp4A/zn7QOhRXaO2wKYi8zaicTfQc92nIzcuUZR7KvZdCewZRsBHw6tvaKFfgldU3XPFW+Q0MgmG7cZ0Vrr30TsdM221iye6X+yckI8E/7T2bUSj0/VpRo/L+V5YeFA7s5FdDJrmj5KSz0lZd/ViIXkFOdjM6LUg== 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=oBl2H6hbVcegyp+EsCQCI1C8r8tpdRRumyzlF36DHc0=; b=f/9oYpMOnnJEMKLImmGqgtLZx/zcJmbA+3PhowvlrDWPs19uBmXlEpYXLISGUffWqRrSFjeqMVb1zmwcN/nUGOIejmpdj148rOnOZ95AnhiWsyLSiGlFBnCTqNNy0QNs/cseCP3BXnmR2UX29KQ1R4XHgxcQPWLXSKDc7FWBEfH69hEUtO9BOTmQu0J48IpHFgfM5kEzIRxLWdcGjfHDs1O3qxgPd1NglA6YqiTFWdU4gSaUd+7jsCI4Vpjdw9UuQStdu7hFI/M18P5upQI5160fpKZdV64qN8tqlq+qg3h1AVFRy7JZ0ZQTlg9/pEXFhNDk3DteGRnOKmwWDh1HFA== 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=oBl2H6hbVcegyp+EsCQCI1C8r8tpdRRumyzlF36DHc0=; b=D62MLptYQ1lmHWyeFbZ2+79lxS4npswsrehwDAH2RDtYDPaxfU2PZ/+1yv9RRjwnDVATC8quZ4/8VVbQoxl+Ozd4A4jOlq/EJ1zvICcmUwF3yXS061GrK2HyjZQft8v1akIAQLudqQ3WMkSrUt8sS3BNNbpJht/9yMp/tAxVeLE= 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 v3 2/6] linux-user: Add strace support for a group of syscalls Date: Thu, 11 Jun 2020 17:51:05 +0200 Message-Id: <20200611155109.3648-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8991b82-f2eb-4d4a-aa74-08d80e1f4ac0 X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XTpb2lLRLElr/DA/QBconsQcRn7BAlXRBjtr10G+X9Bwesz02BaEIs3W2hoEFy2bZ33hrCMsD3nuPwNSgL20BzA/sYbKCqUP5r8zw7hxrHRX4zhO53C1NJ+pHRT3eScxqnqBh5Ld5qOJo4EgRbuT+erliXH0kyNYYnwCfJKQ5kPE+00v8wAs3/pmLxzg24KAkGmCZGH2BgLeHO+fahjUE4GZbn5Hy3DZs0qsUt0gfxA9uV7oBZqjEpnH46nLX3IftBXWqdtaC4IZYBw0OGV0Ekrw5dN6R03NaUS9rH41oJBApu/o87TMXS9Z7LHUtWOoIrVcNI24NffRbbRgGOHVhbVRhddeX47AMYhzSpzhi9MPmBy3Eq8Inisch2kwV/ZpkrD4tOtNGTQ6lbmnVsbCPg== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(966005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: DWRHxTodW6JejHPropuIcfSrrGgR1auMOjPJNsrsaL00kYjzanOZcsm3fLWX2GKbYCl4kj9Y68sJpfbRYO2Rw8yUzeIQ+/EmvI1r2ubBC/OVboxyretZQ1ZesJXbAFmCs9fzck67ouDALsoypMJ5HYrQZbSz864lbbl1vXCN1wgPTp8iuibMeHDZ8/5qGBmqESosEUg1YtlrudOjhRL82es0e8smg/a6o2wH1r4YLb2bO13MetV9xS+fwWYO0O7dOuWauh+SwyktH7ocovf3cU+DEzECpNpeL5+du9Isn8h4w/3ZtkMNAzeBQ7c0niN6OqtFkJ1n7THLOKWWlWyV6S0DUa8BBNdKuP1I63s2ezAxlVDYjIJoMAvYhp0fKW4juiQa+fUpddAMT//bTgqezJV/wJP1sFrsab1WMNL4p58MU9Hb+aqMGeiwV0VQErZk6H0+wkY2LlyB+4M8/OYJljjq2I0Lj3T/NHqoXBEwep8= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8991b82-f2eb-4d4a-aa74-08d80e1f4ac0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:23.5249 (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: n5vbAycm1HrEW8B+D2Lao0On4EVcLKmDF9VKxg1w+V3DcH1sAmwjt7e0XahSnv/IDnQaqhc12DsQNKEYUaQPRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.8.117; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 12:06:26 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+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" 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 dev= ice 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 8678a2aeac..4f85606c19 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1365,6 +1365,18 @@ print_access(const struct syscallname *name, } #endif =20 +#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, @@ -1629,7 +1641,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif =20 - #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 }, --=20 2.17.1 From nobody Sun May 19 10:14:42 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=1591890777; cv=pass; d=zohomail.com; s=zohoarc; b=Wa4+LR0XpMgVi/L/VE/omzirghVFqS7sd8U6+VFvGPq6BmKd8IjN44ZLrl9VClNRsR2L5/Mb8DHnmawsPrXL6qgEWGQPLejFNiB+8yf6gKMz/n0dFYxZRi4/igvV5J8K0tpOUj2dIQrxmwb2FirTpKlxETajeHC4Umx2uo3d8qY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591890777; 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=7+un8hhiFpIgar7A2Cao7PdGEtRafIILDYCD1LiPvL0=; b=C42FR4Km8wYiDk0Su7qHQKK+dKPBtfS8xlFlx1IgZU/JKf/WrIyQ/bEFqpryXZLs63306FpsdWh2BClX6sYdrNSYUo1rK2mwAx8KB+/IjE19K24FYRxe7NNtqO+VzgQo2e6z4r9/KEwlwQmMLP5pylqPMr/wTKwCf5+7vT0nHc4= 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 1591890777123784.8597058795228; Thu, 11 Jun 2020 08:52:57 -0700 (PDT) Received: from localhost ([::1]:53440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPVf-0005uh-FD for importer@patchew.org; Thu, 11 Jun 2020 11:52:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPUP-0004WW-3q for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:37 -0400 Received: from mail-eopbgr60103.outbound.protection.outlook.com ([40.107.6.103]:37760 helo=EUR04-DB3-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 1jjPUL-0005xt-Rm for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:36 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:24 +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.3066.023; Thu, 11 Jun 2020 15:51:24 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EOd1z1mxykVk1NmozrTX88B4KrHpAdR0HQ3oRudQkCKqFvXp80BB3mRhSs0nhXXzh2tJBGTwRbEpHRiF6ENllvycv5DAWJXlQde0j+GHSQe9q28SUussGp3qQeeO9kywmi8A7nuWoD4Pa2kEdsghk1YPjYzWTm9Iar0b8RyLFtCVRlMOr+qKPz1TSDTplTSOwjQZKPAZYJWiGBRWZSz62e0dScurWSmEFxsll/tNqUfQ+YQ7X2EfXh73p7jj7g0lOCfINL2ZoYEJDiFmvcscB51Am6UUbfnJusMPmI2+zEeVHhXrtrWlA3FuIPxx9do6mp/gCerddVu64PS8hjAQLQ== 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=7+un8hhiFpIgar7A2Cao7PdGEtRafIILDYCD1LiPvL0=; b=gVLG1ic2wm75fvMN2basRq9GdWthbyMnEhhYSgLn54EK1AJf1hgc4qhd/yGSEKZmvdQdtjiDf/DszZOmWSXJ0/tCIVF89JXtznIFWTRhJ3WJGcS/ttDuUr5oBhXL4dd/28/lHzqoBaa/62McCZBotTsY3IvhlSwakDQ7DBLC46y/3AHFjRJno9+nOhca8oFaWSWDNhY0rPcKnpyfSgbofYziCXI+zthXhKpEpBFZa0FdvGfBkjQoOGnuwtGH0eHUGrNokAtjnlIsJPnHNPlWZD7L/UZ9Z7jZ/vCJrVfVX5QUcZq3J2y3cqNYoguDidYQb1opEDHUHoJVTLYSlgV0kw== 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=7+un8hhiFpIgar7A2Cao7PdGEtRafIILDYCD1LiPvL0=; b=w4PXkvJwp50N7d0Ai+z4fciSrotq+9p+HGpPiuHZIw4qwmgzUuQqsqx3hc1VSKDVDRgOWCH4vXUmdn7/twTOyxgbdyd51Gzv1tWsrWgkuaSrYzkfxN0fYyHtycZX04OKEhGF/avQxKow9DH/hcQoORXKXdmZXVDCAD5z+wfhW30= 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 v3 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Thu, 11 Jun 2020 17:51:06 +0200 Message-Id: <20200611155109.3648-4-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c3a458e-e980-42f8-4681-08d80e1f4b07 X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kwTRdjGuSm4xzO8P35aOIe+jQb4Je8JpWOPXsEEUMpA/PTQ0h7qUuYQhAwRbPp8vjZZ4C0Ew7tmnACt4XE2rrHFTcjw/eOhY2lcoXydCKSeo4uo+30fXaiEY+XmV9RO7me6QuX8xVPhcYw16Khd+HCRcL9sH//J5DCssyYzHkh7ZGDyf8ubbfHVzj+KQtr9Iv2OjOTA2jek57mCKUymXn0Rcge6QqgeDGgZx2nL5gNHjOm17jOSVEjO82upibaXwhRdiMyDXDABoCfH48453INc//gfar/bkXLWmVV3AoMJ+OnIcdlHT7JFTo9Nzg4Hyjzo3XCqgdo/ltghj1faBBM0m0I1i8N4oATQ9Yd50b/E7Ye8casGkZ7+KONFmks+oF3oafPdSpvIfUcNZ2RTvtUehMpP/YSxMzXTqnobD1B7hbgRVShsky9TcLG8FWAUS78deJopo8nJ4ZlgqQPBQJQ== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(966005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: WY+77hDnLNy17psNW4HAX9tJhMPLvERfRkPv5IqStWFIfZU5RCc8J7E8qrwZp7Qd8i1V24z2i0LlHWm1eb/dvQz8yZK4T+sSvAPOuwpy921XXvGOlJQnMUogZF5lzINzX7LDgURimd6eeJMJxVqFqAxXgPdGfpasQVbRLNvP9rkYMbSCFAhZ8ttzrwuVCUFAoz+l1MrPQKdOymyZd8jkj4VUcY1HQBG0oWYm3lruzY1mtviyFSuiVZYErG1OCxrx+aHZXpb/FXANjbGWyC43BpwPU1qNBdT3gfRHSayJJ6Pk335DaF76Xl1HoMnstzQ1WB0rZhAO+Pto1uMuo8/WPCJqfuBVvtPYHghauvFpLEC5wRs6+QeGFikzq05EAzCJz6Efv5f0Qkigkq95MgP37S39QPU8pr6lSydUKOurBsz3HLMl3QFoVPKTLeCOSXjR6guEvjHf4OmOIx6X8Izw73ZB6YRfaUckr9RvNExEMzc= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c3a458e-e980-42f8-4681-08d80e1f4b07 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:24.0197 (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: Oi1Vx880sPRvxluoIF/Us1+U7/RijebFTFXfzMxu0/5RObrRVna8fWoBId2CnMABknBbsayGm2p9y60S/f8TOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.6.103; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 11:51:27 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+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" 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, s= ize_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 siz= e) 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 the= m. All of these printing functions were defined in "strace.c" using existi= ng 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_lget= xattr") share a same definition. The same statement applies to syscalls "listxa= ttr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returne= d list of extended attributes for syscalls "print_listxattr(), print_llistxatt= r() and print_flistxattr()". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 95 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 15 ++++--- 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 4f85606c19..a7c3ea8df3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -834,6 +834,41 @@ print_syscall_ret_adjtimex(const struct syscallname *n= ame, abi_long ret, } #endif =20 +#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) +{ + const char *errstr =3D NULL; + + SYSCALL_RET_ERR(ret, errstr); + + if (ret >=3D 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list =3D "); + if (arg1 !=3D 0) { + abi_long attr =3D arg1; + while (target_strlen(attr) !=3D 0) { + if (attr !=3D arg1) { + qemu_log(","); + } + print_string(attr, 1); + attr +=3D 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[] =3D { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1641,6 +1676,66 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif =20 +#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 + #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..35c66e9fc8 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 }, @@ -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 }, --=20 2.17.1 From nobody Sun May 19 10:14:42 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=1591890879; cv=pass; d=zohomail.com; s=zohoarc; b=Iirwp6sE7WCzNw+Pym0DAK6/FbiF5DDeK3RnPXWgJ68EqM21BH5y6aaHUq4fZM2INDipUVAUO+WjOx65JZOj3bjBd4fpRWIHF1UmWLD5pYKjzyDGJI0rS7rIClvScaIIjS4S1AWEG/OEZmusoZDvubxFqrIJ6knE4gvkz9X/nWg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591890879; 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=iJwOHN338pZzLJ05d1WjB1bWbrlpQSa4ZRzxeDnQWpc=; b=BPaUrEK9Au5tRojNekpzNuj0nDal44PAwSSOCwDsiseByP10mOdJyas6QcqwlsetV2BhXQGPawig+GCWbgRpbA7kiDGqgqIMv5RdyciDnVpWw4dyMnfTg+Z6U44mL/9LyygllYOiw8uICuBGWrLLaI+QY7D+2rkGRRm3kzGXBhc= 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 1591890879699292.5401109911445; Thu, 11 Jun 2020 08:54:39 -0700 (PDT) Received: from localhost ([::1]:59050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPXK-0000Sl-Gs for importer@patchew.org; Thu, 11 Jun 2020 11:54:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPUR-0004Ye-67 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:39 -0400 Received: from mail-eopbgr60103.outbound.protection.outlook.com ([40.107.6.103]:37760 helo=EUR04-DB3-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 1jjPUP-0005xt-D3 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:38 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:24 +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.3066.023; Thu, 11 Jun 2020 15:51:24 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ch1xeJ4vQEZXERWIbKQFOSOqNRjSoRESAeB5gXOBv2dEtnA9chmDXF9YG5YQ3G9gUsrbisQ9oPnXqwwmUk8wwIYYenxPo89wzW5zFAtTS2Y9EJDWKob1TeFedUqJifOSrCqvZqNcRenf7K2nAbfaX0x3ucJm2P3IzAAhmXP9aKrrBGf7qnHwjwr1RLEjU9lYYiCU0Dz/vUkz6YnvOlM7PwnQvOfiLGR1Dg65VpKxR90Geq9N7yUyW1xoCz1t0PaRNXluog7lil4YN9iL5fCZlN2Wc8Diu5zocHgI0AE8UyJMc+8FEJ5EyKSHCQ2DIhLJcqkROrQIwO+LskYSQjB1Bg== 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=iJwOHN338pZzLJ05d1WjB1bWbrlpQSa4ZRzxeDnQWpc=; b=WyXgl/iekV3lO+2a6pYL982W7xV2AmEkAhB/6lSt5DbrCXERf57O+BIH8IxurnKX7O7a3FklMpEuwNR1aPOPEI5bHRWUvhe/nhQPziElzlPCDNNVqxSYkhxxYajSCI7mUSa22i1Fl3w8JuJUEnfX8FD41PGPoAoZuPA57cEIHajrnaf6bS/fGChczw4rUDXeJMS4fmC8kbYPX/KzFRwrWAKXpy5ql2cQm+t6wf5dQDugQCl221uzuMxtEga3AN77Vrbw0xB7Ag7RchwDaByyuRjgCH+Ehojgya6OulcBaMmWqLpxvJp0LIauX4LUJXM3+TEhIYkB4bb1wNXVRJj/YQ== 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=iJwOHN338pZzLJ05d1WjB1bWbrlpQSa4ZRzxeDnQWpc=; b=K3KEcX2fAgCESBdUm4PhYqkhT3vsCEQuTsKgIRgIxEyX/8zRdSga3vzLHlNmRmgKGWu6FU/RkasI4UQ4ghW4qH44JwVt0QCN4JSBZcCCS8GyJ0S+0+vsFRH/uaQIAScbChpi7TIVmtlZJF4MFuOZ18l1UBTThy1yYu8RsqVbr+k= 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 v3 4/6] linux-user: Add strace support for printing arguments of lseek() Date: Thu, 11 Jun 2020 17:51:07 +0200 Message-Id: <20200611155109.3648-5-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e24c7622-61ef-4d8f-ef70-08d80e1f4b50 X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GiKYCegFy91WrSCoKuaurMHVLmCxbvD7105vMq41nZ2btbJo4gWguro56iNlsx3rNHyMPxCX8IudDXUtkVjKwPUm7QQWKyH0NJ6yfspWqcjpqETP9DdpzPZYay6QRmUWJGuvLCj/GG4/2gTq5g+GY4bhNUI+VIU7u7RYoVPTyvTckIA3w8KaNWK1HZExWsqQ3pa5tMIlvn39/WKT5StVvdhBOwleWntjGO5bLLUR5TSkBOT0AjBX+TfrRaMzP0SDXTP3vYJzBcLrFA9JqAEPGNnlzSt0UTnLeHBJyY5/g0AKwj2ByRt1iLFmwkbcv8/aZwN+xvdRZZ6atGWAhHMLjOIB3OyldwUUCObQCwqE/1buuPZTpokl4vUmDGCjtMERs1GDyQiTyALNEbxNiq0nUA== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(966005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: qo+cwvyKl6U5pgW6eB11r2TynlnE8HH0LFQ3CF2n86tfjJrvuhrQjrVwv9iEfYHoC4EqnU7GNIjhBqhzzQvFE4FqrsVIXTSM5yr98hLsHxTeISyjYrxlM7oF2h0z5eONIJS/9sBzapxuheW5tzrxtD7boDhWYSRKjTVODPQW+MPmWOh/D1wyyv7VtIdta2M4GnTVIAJNXBCdtntPSDz/9Sl9Yweaqiz8bAtgDP2jzjSGwz35x04d4njl1zdrCdN9vb0EAneDVexNs5I8Zk2kNdK7vYdsOcsbw0wvHXPjrzVd099SRQzFPCN0S3NWjOyLMiBnaayStrDGfY2qQoeS6DbCIvKeKFLXsn0c53zXm75kdlzI8oJiJanjhMofD8dmq5ZQLe2/C8+CbpHToRG+39cKDp5XtA75V5ajf2yYxnfCkS0gJ4Gk03jk69Y7xlxs4Glb8bbyRDeZIrF0tc1EcX9Pz7RiUU8sVOOZ1hUmiNw= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e24c7622-61ef-4d8f-ef70-08d80e1f4b50 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:24.4744 (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: sDfYVjuncR370puZke7WWL912P056d+fgle0OW7joHr/D9+OGO/4nYs6i39OCB6zuM9Hq+rWYjgV58Hh5c6tpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.6.103; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 11:51:27 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+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" 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 a7c3ea8df3..ee73ff575c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1815,6 +1815,37 @@ print__llseek(const struct syscallname *name, } #endif =20 +#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 35c66e9fc8..63e150736e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -516,7 +516,7 @@ { TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, 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 }, --=20 2.17.1 From nobody Sun May 19 10:14:42 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=1591890781; cv=pass; d=zohomail.com; s=zohoarc; b=IqPGXDulFlHqDVISg0wsv6n32/8495kqrURSi1wcwcqHGS0lt9JzFZnxJU8VGhRganQQFX5+5frnUxf9Yit41WHelzBGk7lc71LitYApQOnx1/xhSoquW0ZEA5PAxN+Wi/wKqjs3XC+LphdtALVe+VCg/clIqzHHXl6YkB/CgV0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591890781; 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=FSalO0zv4ImkEtPpcBO9NclPkkKQj3lzl9Avq4Xmv0I=; b=UOrFukRJ0Zem/wznuHHBJqt7ADPLhbmqr8r6tdyuI/o38Z2aTbqH0kdzlcDfUD+zk4oT3PfyHudR8VRVgeEMOXpG+xLAQwBiqN7h4r7rD1dErPavU/BcAovf/F6JuXBa8jsSVs+vpyPv2D8zjqAsVmgw3d14uOIkesL5DRh5MKI= 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 1591890781434986.5630163547166; Thu, 11 Jun 2020 08:53:01 -0700 (PDT) Received: from localhost ([::1]:53804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPVk-00065O-5E for importer@patchew.org; Thu, 11 Jun 2020 11:53:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPUU-0004bY-9I for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:42 -0400 Received: from mail-eopbgr60103.outbound.protection.outlook.com ([40.107.6.103]:37760 helo=EUR04-DB3-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 1jjPUR-0005xt-E8 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:51:40 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:24 +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.3066.023; Thu, 11 Jun 2020 15:51:24 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VxWGMj5F2vzS2+XWIdw/DsKpOkRfHlpjTLP34vpAJ5eSpyRmG0ExpPrhUBJK05oy1TWmm5pam5bjMMRMv9Ppkbj/RQKBByMleOjBorHtme458DV7MfPgl2yG4YDCLdF98fFAaPPERXhsurF9wy1mZpUwRalNp1taDuXeep2DbxUcZTXaBQtxbtId3foF5lza5YMomB4uFxi0C9bNdtMYjXJjxI1u7bYSOUiOtgsbLs5KT9Eg89Eos+7ZjZANhg7LZvKoGH8w2FEFtanzgGl1U7U96LrnR0DQ7G/P7bYOrDVF37+VkiYL3y3quxZEfO0w6U3IdvvIx9B/trGleLxvbA== 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=FSalO0zv4ImkEtPpcBO9NclPkkKQj3lzl9Avq4Xmv0I=; b=Z22ODg4Fa8gnGLiNQ/PN5ZET/61VQVoppvw80DPtapSXZjd1g8nnkvEmt0McHCjT7wiRrpQbULVQbZkaw6RvhI7VfqvXS8jG4pWd/NcjOiW/QotS37igu8KZ4aVVc3B+5XHA5Vtj8sl2VVYlccsB5lCfWKKI+UIBuwGNkaGMwOvf142Lroo+7NGQpNfamg/R5lU1NgIiRBt5nXykuezC1Ve70oAzctMPmImQtwbfww2CQ8W45rWIQfkFX04VDqUkEsjC++P/AB+RwUHsQZYg75OljG5cRLnMyzcz8RyeWj9HCJqB+B3tgeswgWX88n2HBJiPgloE1CBuSbIlYMCP9w== 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=FSalO0zv4ImkEtPpcBO9NclPkkKQj3lzl9Avq4Xmv0I=; b=jvp6Vn2oZeogAhDzL9YLEo9xQ23nK2MyYZZ1Scy3Os4u0stPGf9yXRG1OkQqEBhJrhCkNAUtNo/QgAxAbghUtbytW5Z7qB4EOgHbvDKbUn7/prhRnLEhvv7HwFq9ZpvcqMavpnyXK1FVPS+mZJOs5axkb+U/T55qkKVzWqxsy9E= 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 v3 5/6] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Thu, 11 Jun 2020 17:51:08 +0200 Message-Id: <20200611155109.3648-6-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba8cc42b-6fdb-420e-a142-08d80e1f4b96 X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xnh++RzaxMlKOBOupd6hrathyKZlrfEHZdsU3k4qiB6ONSqJhM9SA/iz6kbs5Gau6Nyn262wJn9cZo3H4BUFz9GJFv9eBQrsnZyxAAf3brGC581zR107DBJFFHEdsWdugSEe16Aqm/9vi22Ow1DAjW6s69p9IqPc73Er4U8aUCUPepQiTa8cgTPWtV9k56ipRlSq+Yku8Tq7yckLmUGsy2Exua5VE6Pdjs5zLJqXLC+4T4s21rLyISmxTlDrILXo/v4fMK2YbB+tJTu24tZmZ9TNAO4KmJo+veCJfqLrC10eT3Fl56fk5IraFJ3hFBcoAkSWO0iw/Wt/8JBzjuR6n+QwS9qZYKDG+XktlNt8SFupU4jCHpw70NjVb8xDegqBbrZrwmaXTQP5x+4BRKzOmQ== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(966005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: T6TwyUQNceNzklL2dIoahxS8uDUQ5FdV9eaFQBZWsT1NY1YNAqIZq/8ylJDzPQNcJH1JSzTFKfHnY0cCWaymve1WzuCxb+jCHUxLYentT7nPPsoupfXEwWRGWhIxf9QWt/SUj70vnr1shfEEH8sRfHBkYC99f0Ti7bvIG5pu1IfOp3s/qpI8ZYXWPUyYnDGilKG0sAAhNNLE4VLdYfh4AtDrQ7GUKWtgGdVqYFarYlEo0nomfih6DOpzGyH55azTpm7lOnklpGUGalR8+ATWITTMNmq1Ig82BdMCpg4ln0sRfO0dtXpq9dSqd07pIi8rqOYzbX0jUa+RxckIL2QsELWZBswx6LSGNsvFEXjhJ2VcN++CZ4i46CSZmOePcNm0CXtyXWH1Fzn6RY4pJaTMOOVhYUhAlNwf9Y2/0W/zugIlHqd6Kg90o93T43nvK3tdT/5UP5AfVwr7AfcLbiAeDC21KdMAaQtCTkXGtDrqYu4= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba8cc42b-6fdb-420e-a142-08d80e1f4b96 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:24.9232 (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: xymapXb5+rEjMxz19jTDCMqo7s5ViAlcHOzxZ9SVYYsFS5TwjgF9hZd8nPFP3WngYSp3SKB5Vb7qcTof39b5bA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.6.103; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 11:51:27 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+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" 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 ee73ff575c..40c17f7abe 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1461,6 +1461,21 @@ print_chmod(const struct syscallname *name, } #endif =20 +#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 63e150736e..552184098c 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 }, --=20 2.17.1 From nobody Sun May 19 10:14:42 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=1591891012; cv=pass; d=zohomail.com; s=zohoarc; b=VP2msycOc1BdD9+aK1j3DuZtW7q76FdvDwrJjwWvmnZnP6MZhcgy+Ijn7Z6DrS0Ch8rXgNcfGNAc68uyXQXkNm2hxYaoYPyLnR7/8PlI1OAjs+3ekapIEksWAkaFlacN1ct66sCKDCvOinUe/ByLbkhGntlx6O1fgJv3/N8Y+oI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591891012; 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=4OVMzrXMGnIAEA5NqHkQ8tKzo3Ds1FwZ3f+KSepE1dg=; b=P9sC9njnaGm0POxNNdJLZkp1yQT1uFk0nROnYp9UZ6F8QMcOVe+Bs5WKFbntScSMET6I/xghG2ZZje/j+IGmVJMi+H+slmTapQ3U6Y0AkqiTGa9Up4hLR4VrdT3S8VkXY6B+/WdrSCn7ckbve8kNF4qV7zH3mpc5GVx/+qgnmR4= 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 1591891012736491.6653302924923; Thu, 11 Jun 2020 08:56:52 -0700 (PDT) Received: from localhost ([::1]:34140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjPZT-0002Em-FV for importer@patchew.org; Thu, 11 Jun 2020 11:56:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPV1-0005aR-NX for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:52:15 -0400 Received: from mail-eopbgr60094.outbound.protection.outlook.com ([40.107.6.94]:37766 helo=EUR04-DB3-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 1jjPUz-00068R-J3 for qemu-devel@nongnu.org; Thu, 11 Jun 2020 11:52:15 -0400 Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB6008.eurprd03.prod.outlook.com (2603:10a6:20b:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19; Thu, 11 Jun 2020 15:51:25 +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.3066.023; Thu, 11 Jun 2020 15:51:25 +0000 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Thu, 11 Jun 2020 15:51:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awl0Br0IZyqjN9cjjxEGfCaDKSHYHJLlz8hrIg7er90dnao8WFqKKlzpwOILMj0qCm0Uzf+CPy1/LK1AUrPqaYb5sSGKA6sNW/jkkRPyrjGJlLKi6nhrPQEAy833Ht8rJ04yz+T+zgSgJQArRlYh/JIbzNfIBcHTnWXF4czHOa9aAVv7+ckAlqVzN2CAB2cGjAAO3fLdZhAIl0o9L11IypUiNx9HYU/DiL/CRv75n2OtZ2KLRGJ7Rh3bgOeong6epUh9ziM5eeYmssMejfS5i0JFJBF4qyaIRoUMmFMfCBemXCjM9h76BFK9m7wrlQcCZSqN97RpdBG1Q3UxuLVZcw== 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=4OVMzrXMGnIAEA5NqHkQ8tKzo3Ds1FwZ3f+KSepE1dg=; b=dtan0Tz846It9gY6XnkIaTF5cUjZefI24kibRNDw+YJkRknrsy/PqOi5DcFyjRm9DML8gQWWaCEf1HZm64ZjlplSGXSQQqjJu8yvBSgM+W8ZngXiFvgJncOi9+Kyxk71+p5hdAOinmf2ox/YXMr2SHAS7zemzd3yrxW144zNuRYROTI7i9BGI97Usa/wfNMQE+EhVXbjv+Yu3YbQz+SfNJstNTT0R/Pq7DOSp00xaPBbuEDZDmr8vxkPG1IZAFSwDHHMhZUYkJx4N+asSAaqIeDkiHGiis6wJD/ot1dOZ+EcAzWKg3id3eKXd2ifw8DHncEKjqtKSWBDYvR7MAKG9A== 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=4OVMzrXMGnIAEA5NqHkQ8tKzo3Ds1FwZ3f+KSepE1dg=; b=CalH6y+P5+hQfEcTzbyb+WZpJmm5m0n/m+7+Rs+NaIUQbEbi8yk+WDFbqYxF7k9sXlO+RP4GgxLMR3a8ebijp1zQ5ugiDGez7n3IXEuMZzNJyWMqi0L1WC4cgpwOptZAlg+i/JO17FfAMwUqLCMl6Ty6AbAn26WI/B9qzMil870= 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 v3 6/6] linux-user: Add strace support for printing arguments of fallocate() Date: Thu, 11 Jun 2020 17:51:09 +0200 Message-Id: <20200611155109.3648-7-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611155109.3648-1-filip.bozuta@syrmia.com> References: <20200611155109.3648-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0031.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::18) 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: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 155b97cd-7d53-4400-6844-08d80e1f4be4 X-MS-TrafficTypeDiagnostic: AM6PR03MB6008: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: diy4jJk+5U43oobmMbXo1P8LFH+3GTRgnbA8UxOO9oY6hwDV3c8yBGFtndvDbKJE5jfaUvggSSaIYV9YNvppR8ZiRgMcfXBpO5MGpOrxqVTEGaiOZM8QpBy66UDhWXyJ7iXKgGKFIuXmyc4uSBF0o+JEsudmsW0cgqXKN6ZbdwRBDye0Gi/lhwklIAjM3Tu+hTlg2JcaM6xrmHZ+sKdqW5y91NVyja0q4Jvza7PRcmzT7+23A1tlU5fWYdkyhRbJKzNB3dfhCVhgMu7/3xA6n9e7sRH9u8sBw137kHM3nVgaP/k48ooyoFJklkPalB0mUXtac/pcrMD4pfDenqBVvR8vuZaIeNBC6L3U6+/iyQzqu0ifiaVcmld+JD537EW6mH8zYioG/D8oIz0nd90VltOabsjhZPu/ezruQB9f3NPUspfLH2gTkb3ayTDMqVsu53FZIvXshwI1aRhQtzL0Mw== 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:(366004)(376002)(346002)(136003)(39830400003)(396003)(508600001)(7696005)(966005)(52116002)(316002)(83380400001)(8936002)(8676002)(956004)(2906002)(6916009)(6486002)(2616005)(4326008)(36756003)(186003)(44832011)(6666004)(16526019)(5660300002)(1076003)(86362001)(66556008)(66476007)(66946007)(26005)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: t6rUWnRG/Xq855VzFWuAn6EgtUKlBz7E/EbCtu3XVmneVt4i5Y3Yd3Q3VaPod77vu+TwPobv8J8FG21SQEYnWCFqWzu66VoJiadUW/e588WhUoWBLpWb+YfHkr5bHFEzMiRoLw0lBUsOW0R0HbWpz9Q0I8acbkEjvCM1PCJJYL1d/arcjq+4TIlVeURKCdi56OpUs3cEpO7yRvINXV8MuovjHq7siFyD/r5fwj2J8jhsZ7on4pdqLMS7BC4vN7HS4ZgkVpasD2l0Ol2dwdXjoqCZI+jOc8F4eetqgYFvoygbU8nOPlp/Zy1LxVkwz0iYqTo+G+Amek+Bwf0rp5OhmBec9ZrtpnxKK0yXe3UlOSwTnN/Hf8Sd7PkUZHSubtr3NxnW+JHs29A5UH26HPMUrkUX5OpTd/8GJCGzf6Vc8yC8qOzIhv1f5JP4JEgcD4J9tMZyVN5QDu0W2uPVbtVWm3IWUdoXlRNJGAPu3a7biTk= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 155b97cd-7d53-4400-6844-08d80e1f4be4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 15:51:25.4219 (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: 3dhYX+JBJGAwLtG4zblfGoWhjeb6M5wDm8weUSwPCARA6RH4f5vOlm5YUOTKwAVGLoZ3h/uANmCARRkQk4yRkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB6008 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.6.94; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/11 11:52:12 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+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" 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 print= ing function uses an already existing function "print_flags()" to print fla= gs of the "mode" argument. These flags are stated inside an array "falloc_fla= gs" that contains values of type "struct flags". These values are instantia= ted using an existing macro "FLAG_GENERIC()". Most of these flags are defin= ed 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 variat= ion, 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 Reviewed-by is not relevant for the v3. --- 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 >=3D (abi_ulong)(-4096); } =20 +#if TARGET_ABI_BITS =3D=3D 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 =3D=3D 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS !=3D 32 */ + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index 40c17f7abe..5f370256e3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1144,6 +1144,26 @@ UNUSED static struct flags statx_mask[] =3D { FLAG_END, }; =20 +UNUSED static struct flags falloc_flags[] =3D { + 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 @@ -1561,6 +1581,26 @@ print_faccessat(const struct syscallname *name, } #endif =20 +#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 =3D=3D 32 + print_raw_param("%ld", target_offset64(arg2, arg3), 0); + print_raw_param("%ld", target_offset64(arg4, arg5), 1); +#else + print_raw_param("%ld", arg2, 0); + print_raw_param("%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 552184098c..05bb91acc6 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) } } =20 -#if TARGET_ABI_BITS =3D=3D 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 =3D=3D 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS !=3D 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2, --=20 2.17.1