From patchwork Fri Jun 19 12:33:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=Oix284gR; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJCY2Dvgz9sNR for ; Fri, 19 Jun 2020 22:34:31 +1000 (AEST) Received: from localhost ([::1]:44728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGE0-0006wq-4p for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:34:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDY-0006wg-C0 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:00 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDS-0003z4-9z for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gTMJZkcNSV6urbsfkDU2slb5dNAxOvswF/kIHVKCcCt6rbgTNZ62pI1G68H7/Vq+vEnkjyOUsrl+2p4ZSzzxUMsXT8RqfCz3aaZvk7jaGHmy01aOcUxlBh5ZsAGPhXXXZy8HoR627pXEGaqZj00OVeNdvnmk3Y1kXak7z5p53naJJvp9PWx7kdEqYFsKEwatJmKnkq5htl1CIh/udhYj7VSYlfkG4b1t2ifah53KUYrkrqO7hDrhVb2wwGm32j32AAUhN1bODSiN+DrdtKkgZUU1Jahvyig44s7W3XFLdCDIFPKAZTALS/xEVlVemL4RV+sCOetUMcJMRDGKBGuNRw== 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=YmnpLgk7qnIxuFu5ckEsL5ZBIzJNQyL0wv7TpK+aRbw=; b=SpUYv7kpQtmP7bmmo48cKCmyk0OF/oh8ykg80ZsKgUBFt0VTPkA/rsm+jOIwSXL82d9QrxgU6oLT253rveH4jiStVEqWI0qJQa8zoBfZtOOrssioyJusaXY1d2Dz7OtgmUFrnT9B1jw46IDY17MIkMy9xFF/qeObOv0Cluqwxh2isknFrU0GBcUk3oSxK9bw4mLELdc7HuRF+s6XgiUYjf+9ILQtJoU111R2HOWxshVD1m0yxyL+ytqspKP5h8FYaC8XVj7mRQFl0yQliL3q4lkb+FjFsiasi6ujuzEfgEC1gUwSKTYGjsQoMHwuhxLY3wxETi/BxkSQn6BuZNAirQ== 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=YmnpLgk7qnIxuFu5ckEsL5ZBIzJNQyL0wv7TpK+aRbw=; b=Oix284gR1EmmLT2bSRuA81srRVKjo1sXdE0TMwHU+Iyu2KD8IGdh6zED09QEecjaW+GbiSnkHh7yNdryzZfqc7xwIh3Psr4kAH773qyHF1i1fQv/GIMb5SpF7gOu6hH2rPQkiUB5512Sd7vpv5eMLQRjJ0/+fdP0NOO4C+hXPp0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:45 +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.3109.023; Fri, 19 Jun 2020 12:33:45 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 1/6] linux-user: Extend strace support to enable argument printing after syscall execution Date: Fri, 19 Jun 2020 14:33:26 +0200 Message-Id: <20200619123331.17387-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:44 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6129f82a-76e4-48bc-fe6f-08d8144d01c6 X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q3p/MjGYBcmAHcPqBbr+uIrYKa2nUl+kJLygqLT1NxGKj/1Umf7zvk9cXHzgHdVkAyrbsvV1x3NpEbb494iAJE0i+zJxiTu4kLUbGvCnBBFDbCsXcNIuC8Cif3NXavtUWoV0e0xgYEod+5Ya0zUXcL8uDVZhPwRoN7/dhhvsGU2A7ZiV/sTNpW5kfP28p91eXDfMItNdMps2nnN1DdIVI4SPqFEVEi6h2T8N/Vti9BuvjIk0J3az3KORo6fw24SPq6wrdo/MritWXf90BbShgzdmKZKEJDEPQNEJbH6JRQnTMyBbn4ihpc6j+pjI2XFdrAngU0/sNZSvf6JYw7dQsw== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mxfibeStqlkugSOQJGy1xOapmsVN8D4/2RBYeuAS3JiWhcCi6RuHeOv30QR741v0Z5E8KOSAfhY7U8T4lRsEZ3XRzBEU8FrBoKG+SprlbgQcT0mUAxVP5lmDI7QG1kejLBG9BYD4zdiu6dtmxo0DjsC2K4YsCcOgpz8Q1kLv0hDiTTH2/3G8TgXhPA+AnHS/dqtQNjZ1LXAH+UNM6C/buWL6ix3UTdJgkrC5Zu4x8uO+OYHdluXoABAJZvQLf5Yz/t8PmdmKcsQZckue3F4pbRIWLZ11+oCa8WeyVhUCLVGax0BZUwEAnRAicN1peE8/PFYAM0Owo2U8jdrpgHFgm0U8ie1n/+Hz39A/F058wIVZ1fyAR0LI3uJSTrDo4THouy0E58m98qS3nwYQPNxflfMerTgPlVClUQex/hf2smiCwWSlLlGo/oiWzqYrCSsl24EIu2CKrMaiUdZK3kPkZuATOkvGbYd2nEdGg+SRRA0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6129f82a-76e4-48bc-fe6f-08d8144d01c6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:45.0069 (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: XN53AK2k66TenqO8xgGIF87CXhxnaknmill0KPH5b5bbh6Ko5DNudTOd4Sz22E0r/cxrcyj0eOaTJu6JhyJcbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Structure "struct syscallname" in file "strace.c" is used for "-strace" to print arguments and return values of syscalls. The last field of this structure "result" represents the calling function that prints the return values. This field was extended in this patch so that this function takes all syscalls arguments beside the return value. In this way, it enables "-strace" to print arguments of syscalls that have changed after the syscall execution. This extension will be useful as there are many syscalls that return values inside their arguments (i.e. listxattr() that returns the list of extended attributes inside the "list" argument). Implementation notes: Since there are already three existing "print_syscall_ret*" functions inside "strace.c" ("print_syscall_ret_addr()", "print_syscall_ret_adjtimex()", "print_syscall_ret_newselect()"), they were changed to have all syscall arguments beside the return value. This was done so that these functions don't cause build errors (even though syscall arguments are not used in these functions). There is code repetition in these functions for checking the return value and printing the approppriate error message (this code is also located in print_syscall_ret() at the end of "strace.c"). That is the reason why a function "syscall_print_err()" was added for this code and put inside these functions. Functions "print_newselect()" and "print_syscall_ret_newselect()" were changed to use this new implemented functionality and not store the syscall argument values in separate static variables. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/qemu.h | 4 +- linux-user/strace.c | 110 ++++++++++++++++++++++--------------------- linux-user/syscall.c | 2 +- 3 files changed, 61 insertions(+), 55 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..62117e8555 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -19,7 +19,9 @@ struct syscallname { void (*call)(const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); - void (*result)(const struct syscallname *, abi_long); + void (*result)(const struct syscallname *, abi_long, + abi_long, abi_long, abi_long, + abi_long, abi_long, abi_long); }; #ifdef __GNUC__ @@ -631,18 +633,12 @@ print_clockid(int clockid, int last) /* select */ #ifdef TARGET_NR__newselect -static long newselect_arg1 = 0; -static long newselect_arg2 = 0; -static long newselect_arg3 = 0; -static long newselect_arg4 = 0; -static long newselect_arg5 = 0; - static void print_newselect(const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { - qemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); + print_syscall_prologue(name); print_fdset(arg1, arg2); qemu_log(","); print_fdset(arg1, arg3); @@ -650,14 +646,7 @@ print_newselect(const struct syscallname *name, print_fdset(arg1, arg4); qemu_log(","); print_timeval(arg5, 1); - qemu_log(")"); - - /* save for use in the return output function below */ - newselect_arg1=arg1; - newselect_arg2=arg2; - newselect_arg3=arg3; - newselect_arg4=arg4; - newselect_arg5=arg5; + print_syscall_epilogue(name); } #endif @@ -736,17 +725,29 @@ print_ipc(const struct syscallname *name, */ static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) +print_syscall_err(abi_long ret) { const char *errstr = NULL; + qemu_log(" = "); if (ret < 0) { + qemu_log("-1 errno=%d", errno); errstr = target_strerror(-ret); + if (errstr) { + qemu_log(" (%s)", errstr); + } } - if (errstr) { - qemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); - } else { - qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); +} + +static void +print_syscall_ret_addr(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); } } @@ -760,17 +761,25 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret) #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) -{ - qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); - print_fdset(newselect_arg1,newselect_arg2); - qemu_log(","); - print_fdset(newselect_arg1,newselect_arg3); - qemu_log(","); - print_fdset(newselect_arg1,newselect_arg4); - qemu_log(","); - print_timeval(newselect_arg5, 1); - qemu_log(")\n"); +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) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); + print_fdset(arg0, arg1); + qemu_log(","); + print_fdset(arg0, arg2); + qemu_log(","); + print_fdset(arg0, arg3); + qemu_log(","); + print_timeval(arg4, 1); + qemu_log(")"); + } + + qemu_log("\n"); } #endif @@ -783,18 +792,13 @@ print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) #define TARGET_TIME_ERROR 5 /* clock not synchronized */ #ifdef TARGET_NR_adjtimex static void -print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) +print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { - const char *errstr = NULL; + print_syscall_err(ret); - qemu_log(" = "); - if (ret < 0) { - qemu_log("-1 errno=%d", errno); - errstr = target_strerror(-ret); - if (errstr) { - qemu_log(" (%s)", errstr); - } - } else { + if (ret >= 0) { qemu_log(TARGET_ABI_FMT_ld, ret); switch (ret) { case TARGET_TIME_OK: @@ -2847,25 +2851,25 @@ print_syscall(int num, void -print_syscall_ret(int num, abi_long ret) +print_syscall_ret(int num, abi_long ret, + abi_long arg1, abi_long arg2, abi_long arg3, + abi_long arg4, abi_long arg5, abi_long arg6) { int i; - const char *errstr = NULL; for(i=0;i= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); } + qemu_log("\n"); } break; } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..009bb67422 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12441,7 +12441,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg5, arg6, arg7, arg8); if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_syscall_ret(num, ret); + print_syscall_ret(num, ret, arg1, arg2, arg3, arg4, arg5, arg6); } record_syscall_return(cpu, num, ret); From patchwork Fri Jun 19 12:33:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=uouBsvdO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJCZ1L5rz9sSg for ; Fri, 19 Jun 2020 22:34:34 +1000 (AEST) Received: from localhost ([::1]:44810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGE3-0006zq-UA for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:34:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDa-0006xY-Il for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:02 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDY-0003z4-Jw for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBiH/fvHYuTFRO9ZZf5qd5oKXYPWicd1DS3CnYgeeuo/yccBArk/dpYIsYTrThQ+c4jtAJwPHkDxWgIyOqW+gpFzFnuPWJBz4ArgTgPvARBVzS08tsUheedWPgrJT7+ngO8oGCuo2/BGZmS7Sz9SxVU5mO2uQ+ZfeTiNi0MbvXB/FszzViYaqZ0mPbLSEl0sKunCif9A59VgLIAvco6kY8F4SlWusWYh3+ZepcvbaU/NqAisD2dagdEe06aTafoKBji8kHYGSOh3ZKZfQqq7CohvcwJ+8lukdT2liFIVzRELZBX9Z+SbRCfRSdxlgwOeADwDT2++3UQkRuEIUDjquw== 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=RAdoEJJjbXGc2+2K7DrF2I6dK/xOpEkM6Nkt8Ib0nzQ=; b=Z7Glj+oxeIkgzimVqq5UWwbTrCbc0c/yQkMsqM+4HRBppuQgWNEaAZCW2Fu9W/o6QMbtgFI281fbYV2t25SxEUExazGlznYf5g2jc7TfaNiZ8XSVY3zmJyPlEdB2lIVNOaNjxqi0g6ekUZWjQ401/nf8MTE90wbVqlOB+Vk8BdhR400yWPvLzJujJy+Fq8rQZACMKIYk6WjXj+NlSXf7XPwr/1pzrwG4Uh9AuDIwFcm7Xqgu8r8sBb+ZVmcgvY5PeHxzF7122UFf0SjCqWdOCWqP5kSHaFXOlTOXT6i15OPeWUb/avp4xqkS1NNCD963MxYOVGA4zSRjtcyZdT/Uwg== 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=RAdoEJJjbXGc2+2K7DrF2I6dK/xOpEkM6Nkt8Ib0nzQ=; b=uouBsvdOub7dC7Vweo4ntFS40Tnkiwe1pGlwW0iyXcgb2R+/ZGD91dsicefSOj5gMiNuJ447CcuUzmm4kAmcQQF41NSvS6sRLQ0pdnpnELLcIqLDoMT/i6uiRzXBlOpzz4BHuc0rC9fIjcAAW8crpZOnH1UcL99qIRa5JOjQO9s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:45 +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.3109.023; Fri, 19 Jun 2020 12:33:45 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 2/6] linux-user: Add strace support for a group of syscalls Date: Fri, 19 Jun 2020 14:33:27 +0200 Message-Id: <20200619123331.17387-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc036064-5dcd-4810-8f8e-08d8144d022c X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h6B8wfTogrBgYn2sbCvnTokQQpmJQSEvCrshRBq7iVs7mtKGQFJudMC0LYQrr38+rH81Wt5VPpjzSHZaeQibXmgV8y5kjtZYM2nxZwmoStbtSDlDr3T2aikLE1HQOxsnKgiOQTkg/l4I5zO4BQd1t+/psaV/onElnpsPX91QqH99pgwfLFpWv6jkAgyAYRzKwjn7wvkged3rSiTqDfnnroEYZ4wX36BYHcx1JZRBOHXFDVmSvNWRA5G1JVQS4qkqbh7s6bCyKRzbe9X5BS/b/R2IdwKV7eO6IwXv805Vmfw9BkeYWs8wqAeGQ45NXiqwOuPyWrpyEDdNlLNdF+bIfE+RBDRP3QOCIm5+6BZG3d1S8L4e7sZjDeL/3027CL9b4cP4CS5L7Xg+RQ41dOYBZA== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(966005)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: D79+kDJqBbYU4VHT79qW+v3PjXxlv9JyBFW/qLLZ40QOX2hcemQm6NDwqj6f2FYS1zezYCStt9gz3PaFeWD9yibBefDybhLU28pB8Ji2THKMIMxig1Q9N659dghOEQIMwoIPh0+JbaBmriI27EZlPSRa7uCzPDdmi1NppjDqCgSmKP//kIu/L67shAzXADpJMGOn4Mk3Xx2UC2A5YozdJNnepJgZEU2ci+pu72RUXiKzfZqpNsAhuu6m5dkwywUQxSG7KLiACPmfkLu9lu9/oRPjcSrXFpEiQf822Jfsr9iZJGG/9gT8/SBYouX/q9QGxd1d/ki+RPbW+y4Zxtl6jyk9ERu13XaBdvcX/r/i4uHHbZFwCMENOIg2/VWZkjpJRZlBoLhcED9lr3vmSR0TVUTJcISf65riONQ0UykGvbsKi6mqlR/w7tlylOlpgrr4aRcpw7qi/rOBRW6lfSxZnuOPoOYJIJSWj2MtGEj1K9E= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc036064-5dcd-4810-8f8e-08d8144d022c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:45.6086 (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: cLwEjB+QiYI/ODFU+DfxEdalvFAg7APpUfM8qsyYB/tleWldWPz9/AEPshNuSLOBaP5P94Oyy43jCQx3Aw28eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- 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 62117e8555..123e022c35 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1357,6 +1357,18 @@ print_access(const struct syscallname *name, } #endif +#ifdef TARGET_NR_acct +static void +print_acct(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name, @@ -1621,7 +1633,6 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif - #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index d49a1e92a8..fb9799e7e6 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -13,7 +13,7 @@ { TARGET_NR_access, "access" , NULL, print_access, NULL }, #endif #ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, +{ TARGET_NR_acct, "acct" , NULL, print_acct, NULL }, #endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, @@ -215,7 +215,7 @@ { TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, #endif #ifdef TARGET_NR_fdatasync -{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, +{ TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr { TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, @@ -251,7 +251,7 @@ { TARGET_NR_fstatfs64, "fstatfs64" , "%s(%d,%p)", NULL, NULL }, #endif #ifdef TARGET_NR_fsync -{ TARGET_NR_fsync, "fsync" , NULL, NULL, NULL }, +{ TARGET_NR_fsync, "fsync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, @@ -492,7 +492,7 @@ { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_listen -{ TARGET_NR_listen, "listen" , NULL, NULL, NULL }, +{ TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr { TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, From patchwork Fri Jun 19 12:33:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=qhCfNX35; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJCh3flyz9sNR for ; Fri, 19 Jun 2020 22:34:40 +1000 (AEST) Received: from localhost ([::1]:45072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGEA-00079h-56 for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:34:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDh-00077a-3G for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:09 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDa-0003z4-Tc for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lbz768SqelfO0L8iKF1oi+rAF3PypcoolNPtPtd1tnfQyrAEZG4zNtVIEE7u45w+peFUlMDd9ly6xO7Tid1uh4V5/tsIjZDRR1iOhR5K0N3AQ9HzI+md67q6niKOMTGcv6dJX7Zuyor/W55mtoz9JhJ4KID8dOFytXBtQq1kBX98GDbK/OfZX44bSS03IqKmozd0q3pyKHf9XM5JeixOb3zjkafPcF2UQ3QEks2xYReE+R/sJW15m/gPLgOAbfHzT9kP5h8CF4v7rDyXi+tAcNa9fUls/0Mr0HOnDeO8y7eq2E3KRSp3nOcnkP15xEOkiecGK/qB8VWVQTqrCSiBqA== 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=JgnL2oQB81o4/gj0ijnO5s82h39gdQ2kcQNlxdyzD60=; b=E2qpcR5gsE1VxhzsJg3F2zfOY2a5IAmfE4/Y9n3v0j2jTkYPfWwoAOK/Pxcpr6cqjGZj3J6rOIU62xnZE6oxVka/mQojh56JuZnAqunrhgGRo8IVppilbEWopLUWZjAGGtVVBAsCAXerJRi474Q+TiURqXNT9/4Hv/1MY6jLtvvRjinTdYwqtFnm5cpTGyFOi3B7POPUp1ZWlQiKulbaLu7OyNMoY3Aq+0S0eoCubxxISkkxXacYQGk7VXx/MKis5XNhZOBTdBM1oCKBQnoCzuwk37YDBUzYKzJjB+E7P6s1jgZLrUYAI31z0r+2sbp+V58s5jVbMUbItQcXmUxcIQ== 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=JgnL2oQB81o4/gj0ijnO5s82h39gdQ2kcQNlxdyzD60=; b=qhCfNX35+sYsKG84X5XUEij/POuvSrVR0BDgqzy7Q/P/F4b0e7fofqmkipmaoiPrZbG7PXjbph0SXsKnfA/3gQ7YWU1REF+H7WTBTBEw65yevlpEYga0lHO7JPLgpAkriVnc5n2hNPypLOA9ibFFODpnInN103HLP3LFQpNNgIM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:46 +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.3109.023; Fri, 19 Jun 2020 12:33:46 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Fri, 19 Jun 2020 14:33:28 +0200 Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3a8ce14-7317-4495-e093-08d8144d0282 X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qgAXPIg68TKSny9HMj2KaTQNKBKqIzyOpFNWY7147m8+nnPo3v4bqdvxBF9wDV6N5xr12QeZNjtyFYRLrA3uvdwn+djMc0sZOmRDeBpS6GBG1rKGHf8b3yGSDPX9ECpQ3iZ/fswZE2lVHAhHv/m/GO3dM0BQiIQpwCb6iFJwwgDNMzrJk94iNkng4Nz4oaaMLp40pNMw2agJQ9rb06KQFXZ0AcBOqgTCpq1wNnfn44TqhYcglpyiYUCI7yjOnBj8uoaOdKLngvvkrPrvQJ8wzv7sHpC0vMrcejAu0gaS57eHLw2Fs6w/MemNf/LnT5b2Z7eRaWNhDtqqb2bmJOuJ6VJGGF9h3srKL2xfMHH6KAlS2kIjNPqvGurXVo6kOiAoslvUTjje+munLJs3WRI42vFe7vIBOGVP/OydwDn6NsQqhnyNw/O++XBbC0ZsFiEWTC4IkVeJwGU37iPV6zK9gA== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(966005)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Fy2GuUUarXFTNrslOd8mVPkcTyx0AiAfNTJX8p5MtGW3NzEoYYTUQSdGZf8hwBwCalXhA3rA5+X/SO4xQhYMYiSqCxLabllI83o078J4HHgPRhPkRXDpgtdLemoZaSdPj+uUzZfC95mvyHEJnoonG4cxBVXGuICkXvnuuVeI6MUxdKtT6ZPxCvRjORtxDLw6CBP50iiagt4MlzLQ6cIMW0aIYy20CaJ3q9bbt6Qz+mBcxA9tZRvUIQm49ncHv6seLmrJpeFTEnZuTkM6XXy6CRLCLWEFHzYWoCrCtkULwRri4CsZzsanVYPLqLKx/jy7V5rtnTpvsDSpNIPLnKRjYpPo5nduESCv+T4apuOEmwoggYxWe41wdUSDVmMnOb3oYLxHJ9kq6eFx8KoVaNJnOJiSHTnWpQKqRW1spyFf3DuZNn3wzsaK14mmGqPJ1seRKxljsOv/LGI1jLdfqPydcLjwY/PUZCq8ovAKVVha3ec= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3a8ce14-7317-4495-e093-08d8144d0282 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:46.1733 (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: pRhS9xBxJ++P/i+N+XdkMSF1IAqdZwGzeWmXyJIHtUlcE+G5NEAucqT/VNQmXMUHSR7GSVPbadKiFa6ezgYmcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value ssize_t getxattr(const char *path, const char *name, void *value, size_t size) ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html *listxattr, llistxattr, flistxattr - list extended attribute names ssize_t listxattr(const char *path, char *list, size_t size) ssize_t llistxattr(const char *path, char *list, size_t size) ssize_t flistxattr(int fd, char *list, size_t size) man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html *removexattr, lremovexattr, fremovexattr - remove an extended attribute int removexattr(const char *path, const char *name) int lremovexattr(const char *path, const char *name) int fremovexattr(int fd, const char *name) man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html Implementation notes: All of the syscalls have strings as argument types and thus a separate printing function was stated in file "strace.list" for every one of them. All of these printing functions were defined in "strace.c" using existing printing functions for appropriate argument types: "print_string()" - for (const char*) type "print_pointer()" - for (char*) and (void *) type "print_raw_param()" for (int) and (size_t) type Syscalls "getxattr()" and "lgetxattr()" have the same number and type of arguments and thus their print functions ("print_getxattr", "print_lgetxattr") share a same definition. The same statement applies to syscalls "listxattr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returned list of extended attributes for syscalls "print_listxattr(), print_llistxattr() and print_flistxattr()". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 121 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 21 ++++--- 2 files changed, 133 insertions(+), 9 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 123e022c35..760020132b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -826,6 +826,40 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, } #endif +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ + || defined(TARGGET_NR_flistxattr) +static void +print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_err(ret); + + if (ret >= 0) { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list = "); + if (arg1 != 0) { + abi_long attr = arg1; + while (ret) { + if (attr != arg1) { + qemu_log(","); + } + print_string(attr, 1); + ret -= target_strlen(attr) + 1; + attr += target_strlen(attr) + 1; + } + } else { + qemu_log("NULL"); + } + qemu_log(")"); + } + + qemu_log("\n"); +} +#define print_syscall_ret_llistxattr print_syscall_ret_listxattr +#define print_syscall_ret_flistxattr print_syscall_ret_listxattr +#endif + UNUSED static struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1633,6 +1667,93 @@ print_fcntl(const struct syscallname *name, #define print_fcntl64 print_fcntl #endif +#ifdef TARGET_NR_fgetxattr +static void +print_fgetxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_flistxattr +static void +print_flistxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) +static void +print_getxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param(TARGET_FMT_lu, arg3, 1); + print_syscall_epilogue(name); +} +#define print_lgetxattr print_getxattr +#endif + +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) +static void +print_listxattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_pointer(arg1, 0); + print_raw_param(TARGET_FMT_lu, arg2, 1); + print_syscall_epilogue(name); +} +#define print_llistxattr print_listxattr +#endif + +#if defined(TARGET_NR_fremovexattr) +static void +print_fremovexattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) +static void +print_removexattr(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#define print_lremovexattr print_removexattr +#endif + #ifdef TARGET_NR_futimesat static void print_futimesat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index fb9799e7e6..af12b23276 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -218,13 +218,14 @@ { TARGET_NR_fdatasync, "fdatasync" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_fgetxattr -{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_fgetxattr, "fgetxattr" , NULL, print_fgetxattr, NULL }, #endif #ifdef TARGET_NR_finit_module { TARGET_NR_finit_module, "finit_module" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_flistxattr -{ TARGET_NR_flistxattr, "flistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_flistxattr, "flistxattr" , NULL, print_flistxattr, + print_syscall_ret_flistxattr}, #endif #ifdef TARGET_NR_flock { TARGET_NR_flock, "flock" , NULL, NULL, NULL }, @@ -233,7 +234,7 @@ { TARGET_NR_fork, "fork" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_fremovexattr -{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_fremovexattr, "fremovexattr" , NULL, print_fremovexattr, NULL }, #endif #ifdef TARGET_NR_fsetxattr { TARGET_NR_fsetxattr, "fsetxattr" , NULL, NULL, NULL }, @@ -396,7 +397,7 @@ { TARGET_NR_getuid32, "getuid32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getxattr -{ TARGET_NR_getxattr, "getxattr" , NULL, NULL, NULL }, +{ TARGET_NR_getxattr, "getxattr" , NULL, print_getxattr, NULL }, #endif #ifdef TARGET_NR_getxgid { TARGET_NR_getxgid, "getxgid" , NULL, NULL, NULL }, @@ -480,7 +481,7 @@ { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lgetxattr -{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, +{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, print_lgetxattr, NULL }, #endif #ifdef TARGET_NR_link { TARGET_NR_link, "link" , NULL, print_link, NULL }, @@ -495,10 +496,12 @@ { TARGET_NR_listen, "listen" , "%s(%d,%d)", NULL, NULL }, #endif #ifdef TARGET_NR_listxattr -{ TARGET_NR_listxattr, "listxattr" , NULL, NULL, NULL }, +{ TARGET_NR_listxattr, "listxattr" , NULL, print_listxattr, + print_syscall_ret_listxattr}, #endif #ifdef TARGET_NR_llistxattr -{ TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, +{ TARGET_NR_llistxattr, "llistxattr" , NULL, print_llistxattr, + print_syscall_ret_llistxattr}, #endif #ifdef TARGET_NR__llseek { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, @@ -510,7 +513,7 @@ { TARGET_NR_lookup_dcookie, "lookup_dcookie" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_lremovexattr -{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, NULL }, +{ TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL }, #endif #ifdef TARGET_NR_lseek { TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, @@ -1116,7 +1119,7 @@ { TARGET_NR_remap_file_pages, "remap_file_pages" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_removexattr -{ TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL }, +{ TARGET_NR_removexattr, "removexattr" , NULL, print_removexattr, NULL }, #endif #ifdef TARGET_NR_rename { TARGET_NR_rename, "rename" , NULL, print_rename, NULL }, From patchwork Fri Jun 19 12:33:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=npP4cM5P; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJFT4XqJz9sT2 for ; Fri, 19 Jun 2020 22:36:13 +1000 (AEST) Received: from localhost ([::1]:51924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGFf-0002n1-5x for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:36:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDj-0007BH-2s for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:11 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDh-0003z4-8N for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lgtZSHMb6yNWqAETI7xmXtLSwqa5TEc5DKpI8jl/uL5FBRChntd15TDwPtUVusjGyUjZZVk9pr6yc1Ku8qOCBOMsh8uCvuM4BA8zhDPbA2vlIK0dqlwed6rUGrvUOoqOZitJjzVTEzspuwSmZdaEocAHSCNK35DjY87zqfvSqXg7/RmoYmkv3ee8wi1MPRNLgLVGACsXucJQvY08zY2uMvKQ3a4bFN0pE6DmjpNBc2cqQUYoMEAFX75H+tXlKamUurY0eq1Ejlbe95MbYXnCwKX/Rii1NpdNCV62Svm3Y1BhSj5ALZg9qd6mgud9ht1L6vCB4CTrZ7hfoamiqUdMEg== 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=yoBKQCFk0HsH39fgbPv9dwoCdbsHxrdk6cY3L0Rk7TA=; b=DNLnuJHJE6qpZBpLeZaLGp9iJa4/57zyxzeX+sgLIkYejsdm002qyOy/NqcvNm7T7eRH4lfZsgMpU4vbW0ESjrO8hNyZcUG6ccFtwT6J39iJhp4DJQ94toWwbBcg3SlBqyOYcD6jKaX1SwxSJfqbIOLzshgKEMu/sDllKQqR2hl6f+t1b/Fp2O7BIXbD6lqHkMjmigAxbWP+9cNBVVu66LOcxgDLwnSy4dMk3SG3f5AZMmeU+RUj3KUHboH5qTiCp02rjt8vzeBpHQM3wLsFTqZi+TdbKgTpr5nh7kGV4KxBCMHCiSynqGBYvSCKTLwG4BkUCLm6HyUjZvCaFjfUGA== 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=yoBKQCFk0HsH39fgbPv9dwoCdbsHxrdk6cY3L0Rk7TA=; b=npP4cM5PdyOOK1KF0MEJ5OffQ+VS833N8DmSyFSnrAjCgizacpBTGeIgB5yljHqmcAyAvzAOnK/ZxfEhQU8B7MBrbYVfKeK7S8LQk/1DrA6xDCGyyEQY9zouC3hg9flW/P9pH2y985H86912+2qZSHQioKu0C+JyNJjFCx1Qzm4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:46 +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.3109.023; Fri, 19 Jun 2020 12:33:46 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 4/6] linux-user: Add strace support for printing arguments of lseek() Date: Fri, 19 Jun 2020 14:33:29 +0200 Message-Id: <20200619123331.17387-5-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c43bea46-f80f-45ed-b810-08d8144d02da X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iLUt3wGPCi11MOnt3meEvLYA0BFyyELUoPz7F3NezCuyFG8aePWmF2L1362WSNVk8UdOiuB1BZzknEIWf3BpM7niAUB+FgmLZPZ/8kQlGTIXLZ9bnK9r53piAkaBJ8UokuMB6grcZQUwIjtyKR3mvw5tKAtmicIisVKYn1MxGiaS1oWuUBjEMpEvU4Ke2LRagzZzxMnvvUOz0yGyiceDjsx5sqNt5AY6BoGGcnLs2eV05cdPCcYD+7213SBCQgH/5IZLsDPaxBMhQpW4fD9tVOkr6rqYux+wkoBBpNjwInlXo12WMYmGrFIOLLaOZjQN0YweDnVjxtfm4X3TE3zem7QckKFi7pq3TRBTzlAJHRw8u9NLMVsfWl/FJpzBqUeVX2+upOFzK1aM7IvPMG4B3Q== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(966005)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fl3F9kDcMv3SlE9FVGRShA+sf/DdaqaigenMbgWq7ZarIYRgYwzyt/q12ysHYiHArnRZTYfrDGM3uUy3ujwIbk2dRCy8GgOQ/pnDeNXLXLS6wIzePdxgw6N3Wp6qSMR90XFd1/KIrA1puHLdWp77fXARK3arYkWRSt4HTjs5rfuN02k0PKXH8Ou3z4QtrRRWB4fl1L87m55Knk8dqhhYd3CEbarnV42O1UYATvGdeHOlREtk3odAONj798xx5OyC/oKaQrfr6p/eGypJCK1NW8+D7WJP9ShmT882NFnyZyX9bcaMMbqfT+WKFGVwpZi5ZwlbBE0sSYriQ9VnhzIZJ4WMiaJKcQMnjtoj8K9SF7kB6Wj7LlsA7bFtjxwy8HPKyVDGPSLoAAUvb8sL8qNflGF3xd+hJWOMfLupVDYxH1xTQzGoePvQfN1mYhfmXpaBcw8ZmnuUpRg0Dw0QpmvhRzx9emmjLAS9ZS4Xp5IQhN8= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c43bea46-f80f-45ed-b810-08d8144d02da X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:46.7509 (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: oh3Oisow5U+3YIWmHd9nVelLR0ukYOtB6rRtF+GkGtmkuRcY8siSEKnmhL7FtS+1pBOc2H9OZ929o7FL2kg3qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for 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 760020132b..a26736516b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1833,6 +1833,37 @@ print__llseek(const struct syscallname *name, } #endif +#ifdef TARGET_NR_lseek +static void +print_lseek(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); + switch (arg2) { + case SEEK_SET: + qemu_log("SEEK_SET"); break; + case SEEK_CUR: + qemu_log("SEEK_CUR"); break; + case SEEK_END: + qemu_log("SEEK_END"); break; +#ifdef SEEK_DATA + case SEEK_DATA: + qemu_log("SEEK_DATA"); break; +#endif +#ifdef SEEK_HOLE + case SEEK_HOLE: + qemu_log("SEEK_HOLE"); break; +#endif + default: + print_raw_param("%#x", arg2, 1); + } + print_syscall_epilogue(name); +} +#endif + #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index af12b23276..905a9c395c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -516,7 +516,7 @@ { TARGET_NR_lremovexattr, "lremovexattr" , NULL, print_lremovexattr, NULL }, #endif #ifdef TARGET_NR_lseek -{ TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, +{ TARGET_NR_lseek, "lseek" , NULL, print_lseek, NULL }, #endif #ifdef TARGET_NR_lsetxattr { TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL }, From patchwork Fri Jun 19 12:33:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=H2f2GK9i; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJH30hkBz9sDX for ; Fri, 19 Jun 2020 22:37:35 +1000 (AEST) Received: from localhost ([::1]:55942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGGy-0004TA-Rv for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:37:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDl-0007Ho-VR for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:13 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDj-0003z4-8t for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OupyIOaYyS5fpdWQKrZ2gzkISNPJND/YKUZgBTTsabzJyKCHOBf0yVvuk1ebT1oRpXqI0/wgJcFAWcnv2sowgBuz94iQ9kyeqW60N1w8JOgrOX7xrVa8vJaeMA9SDAEJom6jY67ejyLN2ifje5GeV6Upq6IVtEf3ER8iwHdDS6ChDHABlTy1hACHYUeo87BI8IWDPFXsDkWPunsi9DiIpEPJZv4wHess8/DiJmoj/4AOKwj/hg9+cwU7KsCqlzuuzRSo/FH+/B4Ll6+T4hYpM68qEmfwRttQOeCrHbpujHOAoT83DyZUHLdO43eULYyne6w/BxyNOCp/aORKk70Gkg== 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=EgzN8txt3mzdm1ocEJXUVSaKAKJ8PghbeluPcypdvps=; b=jAQYTGAJglOOLxHV8aK+4zMkyjwIuo/DF6DP7RRvoAzuACm4+VwKFx/wYvfag5RA4KORI6yUv4TyRwFL6QL3kUkAbm1vS1AKbhKkj1PG1XaegbCMqEoD1yb+BFHrYkCeCj0ReJZSVci4Q/4aGIUeURxb4YC2kwDhlnFNUpGNKhXKO6sa7U5FWaamgtk5k4LFUJscSQ0Kf06fQXycsOLgLgxeldxGpxUGiZVOLeOTJ2u5+gdeJW5ZuI99W1zp7j9HmWZchA0OdaQqom380nywuv1VAF8Cn05SrVZtO5/ukB1HGXnSSAVBuXynIU6SXTPulgNg8+3Zl68LiKp/8JG7Gw== 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=EgzN8txt3mzdm1ocEJXUVSaKAKJ8PghbeluPcypdvps=; b=H2f2GK9iKd4JkqTnnbMyqWch/pVH9D8rdB/9cKA+T7jvEKKU6/deJbhtkFiYrhzHZkD6SQ39MBiAEw1F687gPPLiOkr68JHsAOETFLPZrSU1zdx6AUuiOnsstHyA5BYHsArTMSSJZV8yYC8FwEsDASo2fUtHYjUxR3GRnEy9Xkg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:47 +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.3109.023; Fri, 19 Jun 2020 12:33:47 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 5/6] linux-user: Add strace support for printing arguments of chown()/lchown() Date: Fri, 19 Jun 2020 14:33:30 +0200 Message-Id: <20200619123331.17387-6-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f58ac836-bbc1-45f4-1a5e-08d8144d0332 X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EwaeNRBK5aCek2hmZyuhm4e1GRWGZAI7jf54aVSorjKdmi9O5lA2ltcxcmBqe/QOhJss9bKqcIKDMPJth3mAtPbCOcLMeM24niiE5M3be9fzDp/Mi2llFV8xz6zzzzZyg+QCEeuoDYbTZjuPc9aPN29jZy4P+TdphxWxfF4NOa+a+B6Zrq0lJE3bdjw8zLLVpjjKcxPZfeKi187MH+wCgSfmCpyXJYGKnlJTclbopvYKskDsW2CTadxs/8NXT/YL9MDjzInnSh46A89Ov+VD0iyvM967hYjj9VaXY30Gpy5BpJOyl2eTOp5X63KATrr5Hp98kDm/47R3b1cmdW7UE8qtwguopkgGO6jxeAMliTZkFuW15tRA4qNjLuUSTtpndcV54qC7SpQyRlK8b+IBYg== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(966005)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: s1hdfIOx+4A5L3hv+MjJhjzfcYiluX+Xy9PksAXfkfTeDi1GEiqQwmw7tNCFsusspMnxqIyuT+eFqspEKyzRlIqlUcQUNQw69BSGJwZP2nQJpZh/JQFA5XTfvY7pQNc2IPNm/f6tp548ACoz/DODNELvYcIf47ZZNN5YQs/cBj8KqWvm+QW+XIO67b/jNktTIil0suMhRz0kXZYaLIwJAJOrluOi2uSSvCSw5OuYr5k1sHrrqAJr2TJaQ6VYiDL7Ua0RtIW5y7MR5wGqNj4wwx4W+KrRox6MKCEDTznEUdwdfVXvA/9wfBbvUitTYg87tnCFvCNMurXrK7lB6Ue8QHi9vsYGraO5M5FzavProCadv3J1RM8ZrVvgS46myFzvhWfFVC12C61/vqFdjiuRlH9NclZL6CipdlDLVWqwtnMBMpDk63tpvd7oCL15K328XoWtCwd/X6dm19yQCd0jL3Sq07HxbYSyU6N/Ft5ryJk= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f58ac836-bbc1-45f4-1a5e-08d8144d0332 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:47.3226 (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: CWrzP7eKQL0F2Dk0e585VuM4f+n6WDiaEMahBkDqtJ6/HTWSi7TDCaJ2PPInWGA8L8ghcxDpmZ8JqJSJ3ysKVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for 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 a26736516b..957f08f1ad 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1452,6 +1452,21 @@ print_chmod(const struct syscallname *name, } #endif +#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) +static void +print_chown(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_string(arg0, 0); + print_raw_param("%d", arg1, 0); + print_raw_param("%d", arg2, 1); + print_syscall_epilogue(name); +} +#define print_lchown print_chown +#endif + #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 905a9c395c..633f43f490 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -71,7 +71,7 @@ { TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, #endif #ifdef TARGET_NR_chown -{ TARGET_NR_chown, "chown" , NULL, NULL, NULL }, +{ TARGET_NR_chown, "chown" , NULL, print_chown, NULL }, #endif #ifdef TARGET_NR_chown32 { TARGET_NR_chown32, "chown32" , NULL, NULL, NULL }, @@ -475,7 +475,7 @@ { TARGET_NR_kill, "kill", NULL, print_kill, NULL }, #endif #ifdef TARGET_NR_lchown -{ TARGET_NR_lchown, "lchown" , NULL, NULL, NULL }, +{ TARGET_NR_lchown, "lchown" , NULL, print_lchown, NULL }, #endif #ifdef TARGET_NR_lchown32 { TARGET_NR_lchown32, "lchown32" , NULL, NULL, NULL }, From patchwork Fri Jun 19 12:33:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1312876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=syrmia.com header.i=@syrmia.com header.a=rsa-sha256 header.s=selector1 header.b=J/dTAibv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pJFL2SxDz9sNR for ; Fri, 19 Jun 2020 22:36:06 +1000 (AEST) Received: from localhost ([::1]:51356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmGFY-0002Yz-0d for incoming@patchwork.ozlabs.org; Fri, 19 Jun 2020 08:36:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmGDo-0007N9-Bx for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:16 -0400 Received: from mail-eopbgr00110.outbound.protection.outlook.com ([40.107.0.110]:51142 helo=EUR02-AM5-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 1jmGDm-0003z4-7e for qemu-devel@nongnu.org; Fri, 19 Jun 2020 08:34:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JxLSCedC/lUkkOJs0W9I4HI3MVcp+uc7iUaIWhMqM7GhwX9zZFLxo41zg1DD493m1di3uYrfCwShW6eaXLMsC6J3Xpg1XFL7c/cchd8qdBHB958jTRmMUFFZxhwOqo5+GqzWelAa+nI4hkQoM8o2Y2bB7cLGEmoUdbBYOD4UoVR0L9Zm5aaX4UgZolTq2jGoeuNj4rnPxWGtLXvWvB39o8dWPdXf8mylHmIDV6V8xRff9BnFDRspIfnDnzCqWMRq0tXmm4I4R5Q6J12OztaNeLDvzwUZSAe3UEQe61KrERAB3g/lPTOHs6CKTxX1qFxZKHxae4bqVAwxWfHY29Db0Q== 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=QuvlNwSiYxlMrbmmSksbl94NPcf+Xi96bVZzevzSh80=; b=CSq63wOrrDVmkaFWV+uHws1Qn18sAJiraCbWXVQBaqd2sjNmEb+D0tK81CEqimNjysmKbKwdlMonEX33VQjLLC0JGan5c0XjxvBzjXR2W49ZwcKDRZ7T0cvV6pcPa+qFGFvoAGODoETqbBlCdJu1wIRlinnb5ax/TqU12XTnROo/mVrp97O/BfMGZBKr923fX7B2lCp5ZXjYxY5T2ipCV88/04XxPbQVy0r2YmyYOS5is2vgKvlmd/wkyZEGct1JhK0bbkPcm58HLEKD/w5qfcs1rD5OK9eZa7DNlWty1zSkawdD0I5dS56YnzpK9cX5Yk8ydmL0U4anlFo6Veo5Lw== 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=QuvlNwSiYxlMrbmmSksbl94NPcf+Xi96bVZzevzSh80=; b=J/dTAibv1VC+SkeIIYgvb0KQF0HM4Et3UhPZ9zXnvTGbjHwax+MwoXbaoWIhBapChhvr3xSm1f/MYHmPYqjr/IFAT3NJccoGNPTQw0KAbcClQBCn/WkjbH8qkWu6h6tdjhlF83OmCA6pOY+v1XHyBdwbeWdymEP98WsD9+H6ChM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; Received: from AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) by AM6PR03MB5315.eurprd03.prod.outlook.com (2603:10a6:20b:d1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Fri, 19 Jun 2020 12:33:48 +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.3109.023; Fri, 19 Jun 2020 12:33:48 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v5 6/6] linux-user: Add strace support for printing arguments of fallocate() Date: Fri, 19 Jun 2020 14:33:31 +0200 Message-Id: <20200619123331.17387-7-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619123331.17387-1-filip.bozuta@syrmia.com> References: <20200619123331.17387-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) To AM6PR03MB5233.eurprd03.prod.outlook.com (2603:10a6:20b:d1::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bozuta-ubuntu-18.syrmia.com (46.240.135.226) by ZR0P278CA0023.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21 via Frontend Transport; Fri, 19 Jun 2020 12:33:47 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [46.240.135.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0b4789b-4084-4961-f1d2-08d8144d0389 X-MS-TrafficTypeDiagnostic: AM6PR03MB5315: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VrfRFMnE33q2JNbU0n1mHCo2FmilPCWkeAUBELaGkMMLIgO1FGvSSAc4oJ9UJxJneU3G/+ljCwvdNDN2INw0NB1Onu4JdI09l8VN4vqSUgimTHHWWT5U+SOtKSEWiXZ7CAnndoGNy6uid0QRX4uwKF+9yYSt/crrIVn7J/MpvjtoxZhOXQOuQJjj67eLcHSoCzKg6BuFUVu1yPRhaM7ccVT+PZvXFlqJ9Vkn2js2jCv1FsGPHIphn7vxGtR0Km82h9YuB2ojiC+Q7Ccm/lsSIK7hJG5mrq2J6WHNelrK7+3X6eEhf9sPOZFc5hjqawMPCvAhhIOFV7HmQ0rwBYNjx/5+O+T2xFB4gSG192kzFUXz6N47g+xUjV6VODlG7mZ2/XnNMPVjUDja+gBFrKg1vuu02CxTZzzJyeelqd5U8+SQ6wYPMWsRi+gMvogQrWxQacike2oAiemDN4WFzNDBbA== 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:(346002)(366004)(376002)(136003)(39830400003)(396003)(7696005)(52116002)(4326008)(186003)(36756003)(6916009)(2616005)(26005)(16526019)(66946007)(66476007)(316002)(956004)(66556008)(1076003)(83380400001)(2906002)(508600001)(6486002)(966005)(5660300002)(6666004)(8936002)(86362001)(44832011)(8676002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Lior+6ex/kUkUSHsoSOg++aey22eDeIu8JnWAAwGgjNNUGSjKGvWEpsr75p7aA92io9d0k+WPrtwWK6wOIBbUH/ZFwFOxb3dbGSpGSwV2G6k7hi86Ue5pN196glkg5DAdG0zLl/JlFvKdP+1JJ+qamVP9byjHsZ9M4DCz43ffnJouHCRlOsIdIN184vf+ies7EgETgF1Kee3VWb/lfpDtN/qm9/UVCPshyLpUrimSenSKn//rpFFQUfZINTZtOVAugbv3kpV3HyLQZNmBghyDivC3gtuReuyobehszjYGmL1bsGWTMfNwxtm0vnpeILdifaM/CgOdED8T30mApg1s7tz6efK/WUT1x4Jqpm61nnrYP9PiO2SPbZ3kpbaUe/MHBLR6vCKT5172XIy6GVT84YQ+NAEc9y+CAE6ZkcMIJAPFQmdULJ9gt6102P/Koy1Fqv6W/TSK+l/GJtBwphkVF4licxJeAPqLj/Vi+Fr9Z0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0b4789b-4084-4961-f1d2-08d8144d0389 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 12:33:47.8863 (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: Qy9NcMF3lPyktI49UGFxJ2f8xgV1KQ9ofrJ8E4M9/Uz5b1eMOL5by2Ro9vaeE8X8yf6prppb/7Uskhzit9lTHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5315 Received-SPF: pass client-ip=40.107.0.110; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 08:33:52 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscall: *fallocate - manipulate file space int fallocate(int fd, int mode, off_t offset, off_t len) man page: https://www.man7.org/linux/man-pages/man2/fallocate.2.html Implementation notes: This syscall's second argument "mode" is composed of predefined values which represent flags that determine the type of operation that is to be performed on the file space. For that reason, a printing function "print_fallocate" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print flags of the "mode" argument. These flags are stated inside an array "falloc_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_GENERIC()". Most of these flags are defined after kernel version 3.0 which is why they are enwrapped in an #ifdef directive. The syscall's third ant fourth argument are of type "off_t" which can cause variations between 32/64-bit architectures. To handle this variation, function "target_offset64()" was copied from file "strace.c" and used in "print_fallocate" to print "off_t" arguments for 32-bit architectures. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/qemu.h | 16 ++++++++++++++++ linux-user/strace.c | 40 ++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 16 ---------------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8f938b8105..be67391ba4 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -670,6 +670,22 @@ static inline int is_error(abi_long ret) return (abi_ulong)ret >= (abi_ulong)(-4096); } +#if TARGET_ABI_BITS == 32 +static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +{ +#ifdef TARGET_WORDS_BIGENDIAN + return ((uint64_t)word0 << 32) | word1; +#else + return ((uint64_t)word1 << 32) | word0; +#endif +} +#else /* TARGET_ABI_BITS == 32 */ +static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) +{ + return word0; +} +#endif /* TARGET_ABI_BITS != 32 */ + /** * preexit_cleanup: housekeeping before the guest exits * diff --git a/linux-user/strace.c b/linux-user/strace.c index 957f08f1ad..32e5e987ac 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1135,6 +1135,26 @@ UNUSED static struct flags statx_mask[] = { FLAG_END, }; +UNUSED static struct flags falloc_flags[] = { + FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), + FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), +#ifdef FALLOC_FL_NO_HIDE_STALE + FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), +#endif +#ifdef FALLOC_FL_COLLAPSE_RANGE + FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), +#endif +#ifdef FALLOC_FL_ZERO_RANGE + FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), +#endif +#ifdef FALLOC_FL_INSERT_RANGE + FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), +#endif +#ifdef FALLOC_FL_UNSHARE_RANGE + FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), +#endif +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter @@ -1552,6 +1572,26 @@ print_faccessat(const struct syscallname *name, } #endif +#ifdef TARGET_NR_fallocate +static void +print_fallocate(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_flags(falloc_flags, arg1, 0); +#if TARGET_ABI_BITS == 32 + print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); + print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); +#else + print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); + print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); +#endif + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_fchmodat static void print_fchmodat(const struct syscallname *name, diff --git a/linux-user/strace.list b/linux-user/strace.list index 633f43f490..10e3e4a814 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -182,7 +182,7 @@ { TARGET_NR_fadvise64_64, "fadvise64_64" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_fallocate -{ TARGET_NR_fallocate, "fallocate" , NULL, NULL, NULL }, +{ TARGET_NR_fallocate, "fallocate" , NULL, print_fallocate, NULL }, #endif #ifdef TARGET_NR_fanotify_init { TARGET_NR_fanotify_init, "fanotify_init" , NULL, NULL, NULL }, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 009bb67422..7cc5a65b4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6608,22 +6608,6 @@ void syscall_init(void) } } -#if TARGET_ABI_BITS == 32 -static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) -{ -#ifdef TARGET_WORDS_BIGENDIAN - return ((uint64_t)word0 << 32) | word1; -#else - return ((uint64_t)word1 << 32) | word0; -#endif -} -#else /* TARGET_ABI_BITS == 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS != 32 */ - #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2,