From patchwork Mon Jun 8 16:43:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 281142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97374C433E0 for ; Mon, 8 Jun 2020 16:48:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FC0A206A4 for ; Mon, 8 Jun 2020 16:48:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="KlZVmVrh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FC0A206A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiKx1-00088f-GD for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 12:48:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKsn-00036z-0d for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:21 -0400 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:62103 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 1jiKsl-0007Fd-9s for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bXM8pHz+0rYtJYDberp6+2wOSFETHsvR0bA+eGeTY4vcZpn6Sqb/4Vp7lZI3g5VeSY4OBfMArMjoRzj5MAOPQZPKS0bumU4KxuJPrp5HJW5TXDEx1WCO/36zCHr4tsYKuQN0po8XJwtVUIyychljDfYrTtNLYSMrTwvI6a3OqcnTzEGLGZBESv0zMLmceaJUTSjP7DyoiL9cm7TMEW0f5JUk07nfGJ307zaIrwyyhZtscBdaPe36Vn0IsQ51yNIj16s8J196DZocbDoJzCYfe7tEe51a6C3ZCnnGXIJtWQ5RAh5kY3Z9rEVGzXcQgKWnYaVNOY2EmC1p0DZt1B0yNA== 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=6bJUNo3V/2/CnSclCnsosB4WCMATua32ydXnuSKw9Es=; b=USJXMAhfRrAMET3VTb4V11qEraV4+e4nCGUbYEmC3o6pxtdaTQhxi1UqsStKZHkvX6EZ7/dDSryEj29r+04GbDgAmiGRlnOxKd4X23zNyuZxe/t1EPIl6HCX1C9yP7BxWs3fup1NDwmTIfM0D1mdMqatF7Lvf9b6rjldYZYeEWCCU0iyb77b1OD/v3qnVO62fMe98SZAv5SCo+z8Co+AwraBOpTRxUUtLbZxAONBXMuALMJ+59/Ko5DW5NjhzTQxhO80mbEOLA1bucDK0sw0b55yCfC0rIbHGUtBV28pR06UF60qCfNYYopZLPoiPIC2SBHdWnCRb+7NpX08GFFAdw== 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=6bJUNo3V/2/CnSclCnsosB4WCMATua32ydXnuSKw9Es=; b=KlZVmVrhnMLoesvM0dAgmoEWioKa+a1G2M2G/NRrvr6fx7m8NdM+QPtAMfJzIhTbii7aQ3YBB4my14tmxkVpCwdEv/F1DvXznmvOJwi7jF8gnVsIxTJLxX9b0dRrSULVr8jgVjQL7pl6+3eCi82d1Rqo17bFfg6AOgU1Jp2I8Tk= 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 AM6PR03MB3798.eurprd03.prod.outlook.com (2603:10a6:20b:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19; Mon, 8 Jun 2020 16:44:11 +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; Mon, 8 Jun 2020 16:44:11 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 1/6] linux-user: Extend strace support to enable argument printing after syscall execution Date: Mon, 8 Jun 2020 18:43:52 +0200 Message-Id: <20200608164357.25065-2-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608164357.25065-1-filip.bozuta@syrmia.com> References: <20200608164357.25065-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) 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 ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 16:44:10 +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: 3ae5f8b6-8195-43f2-0191-08d80bcb2b60 X-MS-TrafficTypeDiagnostic: AM6PR03MB3798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e6E09thjq32e1K8Mf6Kc/A4NYGQdHGWxs8NHqUGnHVVNDiE0be2o5XxHfMStOWHPbrwFUQdnVa65Bu6vFwGTmuKbX15JnV8+NguXfxERHZj7TccI1deYSoJqtcafAz8Es9+b3retO2DNvJG8dBMwz5EMVc0XhXf50yPidCotHBwYBCtV3tCbxN/3hxSYfazio0i+tNhuZyqZyPkpwe7BBhAQEFbdnuxxPTOzLuJ9eUIgl+rQwM5mQTHLd2meuTKoCUzhUm8rxlPmBr7u1aNb+OSbpeXDnrAvmS32/f5JzY0o9Nhg2G3dSscpnFuFrHAN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39830400003)(376002)(396003)(346002)(136003)(366004)(508600001)(4326008)(8676002)(8936002)(1076003)(66556008)(6916009)(66476007)(5660300002)(66946007)(86362001)(316002)(36756003)(16526019)(26005)(2906002)(52116002)(83380400001)(2616005)(956004)(44832011)(6486002)(7696005)(186003)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mLx5vrDPfNCCPh/WAM/Uk7P3E7WDs/hE175jQJYL2EtZ9bd3jY++ivGuqx9F/Kp+7JzMFpNFjPZD64oZcocVwFRpTeohVWF0FMWXtwKoDUsevL7sOMADZVFOyEhrgRSi9g0FaheCzFkKzaJP3Po1f3nNNpg2F8BPxL1jroggjXomz74exTM7JOTnwoWWUozl8EMyTKz2w4fpzpvKyorjMmsNYjh0j8iGAdVHxrAkNWwZQiYYHg39BaeSK+MTue8dfw05jhsz4OdY2tI4DSqp1sq0CpHcYwatMUAdNEkg4uK6jDgH0llPjk6L+Mj4oQTC+jbIeB1CmlzLhbS+0pL52NZdAOZgrIqOU/1LYSyDxjagfloFOO9jxf6cFV9uYyPy/AxlwZX1687BA2sWQ8SmknwQHJJN+zS4/Ty+sDV0zDhH5g3YhJzhALG+JC9acvXecesKpmlEo//F7fUE2YMzWhh6IMByhnoPsshvq/9s0G0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ae5f8b6-8195-43f2-0191-08d80bcb2b60 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 16:44:10.9062 (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: Fni+/SOhP3ec5WOq4yWS3dHSTHQ1xoTyoHZNkn1fqXJLPYtMBlIBz5ZMABKyga2rkS2fAugsK7sPCUd6vghoqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3798 Received-SPF: pass client-ip=40.107.8.91; 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/08 12:44:17 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Structure "struct syscallname" in file "strace.c" is used for "-strace" to print arguments and return values of syscalls. The last field of this structure "result" represents the calling function that prints the return values. This field was extended in this patch so that this functions 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). Signed-off-by: Filip Bozuta --- linux-user/qemu.h | 4 +++- linux-user/strace.c | 24 ++++++++++++++++++------ linux-user/syscall.c | 2 +- 3 files changed, 22 insertions(+), 8 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..23f7c386b5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -19,7 +19,9 @@ struct syscallname { void (*call)(const struct syscallname *, abi_long, abi_long, abi_long, abi_long, abi_long, abi_long); - void (*result)(const struct syscallname *, abi_long); + void (*result)(const struct syscallname *, abi_long, + abi_long, abi_long, abi_long, + abi_long, abi_long, abi_long); }; #ifdef __GNUC__ @@ -736,7 +738,9 @@ print_ipc(const struct syscallname *name, */ 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 = NULL; @@ -760,7 +764,9 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret) #ifdef TARGET_NR__newselect static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) +print_syscall_ret_newselect(const struct syscallname *name, abi_long ret, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) { qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); print_fdset(newselect_arg1,newselect_arg2); @@ -783,7 +789,9 @@ 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; @@ -2847,7 +2855,9 @@ 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; @@ -2855,7 +2865,9 @@ print_syscall_ret(int num, abi_long ret) for(i=0;i X-Patchwork-Id: 281141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C40FC433DF for ; Mon, 8 Jun 2020 16:51:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5438E2053B for ; Mon, 8 Jun 2020 16:51:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="LvVAaFox" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5438E2053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiKzD-0002gP-Bp for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 12:50:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKss-0003JU-F2 for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:26 -0400 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:62103 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 1jiKsn-0007Fd-57 for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/NgMz2nayRRtm3EwdDjtu7TADdIO8rmRaMRp9FIYeQQgsY2hgJkPrlGBw+gLn3Fubcb66Y9xledkMDAUewGRQ16/H9iRh49j8BUMyPcULIB6mUbES5WxrT57A8jwsOrsPkBuE7Vh6WZTycgXrP6r5sM1EPvWRuuhhupkCdnhw0+Bm0dgh4IWqvmnGgIxCBC2MDP6tyHBEZ2U5E/J2LDKP+Obqa9Ff+V3VOHq5EUOf/M/TqhO0S1L3ara/PEMa5Xtu8HccckYRJR/0yAOT8j+LSbhdhTg/K0lkLy0GrbaIh9DTFnnV5E81FxCGpgO6D5je22E4B+vSMrHHhjyD1X+g== 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=ZcVTZUvvqIqsP7TudJ8lNe6q8zY42kdYNe2MTpViLIA=; b=hBtR4qgr/RpL0R43UdUxe3pot9+M1HPhzsVmQ86Y0YY88kUT+wdYpbsFlG40ng+hk3qf6kytNp5Yc1V0qRsgRFHLfZTZ4PVhJsUB6jIPv4yggWWqFU35ID5WeeBz/yTIS6thOKnVDQqJZZlZva5omYDDjYs8bwRhQ0qKAFsv8tsBdoq6XdU4CI5th/LMEgeuC/N+jeiV3bZXZogpIGBQSTQJCHjrh9mlAK2MvBHchPkabGyW4dRJjEKh/+7jVrd4yGoj/5Ih2aQA5mDEElOPTYQ+qOlEvyjG2qR31uXU+IS2sLwU4fz8yzxQ0QIOwfGfuuVRpjRJKGAWU2aSjiSlkQ== 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=ZcVTZUvvqIqsP7TudJ8lNe6q8zY42kdYNe2MTpViLIA=; b=LvVAaFoxZCBDgs0Rt00c0N6nlvKuilnn8eBZkX3rzjDGYF7HeljVqAbvIsgN1Fb6y60eHR7pVupiqhBud76T5Cn+fmLucEwf2FQKcBQz2Q5IVu08XHQEMsBgSpAMDwheyFk/c3uXvW88HKJGILSZOWW+xpjhk5nva/lgPQaoJjA= 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 AM6PR03MB3798.eurprd03.prod.outlook.com (2603:10a6:20b:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19; Mon, 8 Jun 2020 16:44:11 +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; Mon, 8 Jun 2020 16:44:11 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 2/6] linux-user: Add strace support for a group of syscalls Date: Mon, 8 Jun 2020 18:43:53 +0200 Message-Id: <20200608164357.25065-3-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608164357.25065-1-filip.bozuta@syrmia.com> References: <20200608164357.25065-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) 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 ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 16:44:11 +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: 87949a6e-3221-4ea5-baf6-08d80bcb2bb3 X-MS-TrafficTypeDiagnostic: AM6PR03MB3798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JkOcfvzhY1uX8CEvjpx93f13FK7pEv5g1RxeLCwP7XiXK1onlomEXpGvZHz3JU1T8pWQ7fHvIIx7G0AHiTV3F57zwfqD5PZzabV3CrBCS7+VL1t4SVnPRx5cImwxDyt2Q0DkvSbSZFTdHh+fE2PRu0/lRQdY8qXDxgSiq5bR5NSosoD+TftST49hMFDdEEOfWZsMLUXt2C1Sr8K+SehCK8istc43qGVnd2uKJsHUl3mJPnLx+TUDHIgrqnI2mwohIYE6WsVM6hSqfNucXtlFS2fE404NyUEa++bTe2XIiWJAkznNZlbJze2TP0ofP6xIpNfkIafj8DyWfp9sHG/8suKXOZhSOqRB/RV1IydOoDHy7FSdXj3v12aYZJi4RjTWZoaaSv0kU+Ckoow1hajz0Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39830400003)(376002)(396003)(346002)(136003)(366004)(508600001)(4326008)(8676002)(8936002)(966005)(1076003)(66556008)(6916009)(66476007)(5660300002)(66946007)(86362001)(316002)(36756003)(16526019)(26005)(2906002)(52116002)(83380400001)(2616005)(956004)(44832011)(6486002)(7696005)(186003)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +hTi77XScI3vimDB+i/cK4RoUa9W22Cm48kXfWX3ZEQmLb/tZAPDmHf0p7ETVHFVjocthEbEFsCD5r4AOh3OuDLoaBpbaJQxfIN+mSXzjqoG8t75I4SCVWxSNIiPsA6MncuEujzwCCnJZzV7KS3ROLx2KBq9CuWBEuD5YjH9TvtrY4h115teXomxXBYADbnpH4n85RhPVmS9Rl8JomOLnWNdETXGGyVk4H7zeQehZQuex2/CHMo9TUURzdHemE503KSzRQtok3aP2bH41K/0osUXLquV+Nx30eAd83vKSZTY7MJfSkOeFAtWN8FfKgFuQn8MCLxoJ4Vsats6eFO0fH0yaOgwrxabQpTpIPgxkyaqDThKScjgmt5xZWeMGmfxID66i9e9KvLY4aNBZXSflN45/atP+w68mzmTr1pcxftU/F2UQ/zOdAHuq8EtsVEZCDIY/9UJkEvqroVvadyfqR7KDs5Yn1oYPkVlNlFygO0= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87949a6e-3221-4ea5-baf6-08d80bcb2bb3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 16:44:11.4609 (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: TPzcWRp/uX0QObm1QpwFHvthACdm67wzcXLPhGTyup9Tvz6MEMlFlmLqn0WEtsJg99ZNwiSOokexFX4bEiYj2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3798 Received-SPF: pass client-ip=40.107.8.91; 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/08 12:44:17 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *acct - switch process accounting on or off int acct(const char *filename) man page: https://www.man7.org/linux/man-pages/man2/acct.2.html *fsync, fdatasync - synchronize a file's in-core state with storage device int fsync(int fd) int fdatasync(int fd) man page: https://www.man7.org/linux/man-pages/man2/fsync.2.html *listen - listen for connections on a socket int listen(int sockfd, int backlog) man page: https://www.man7.org/linux/man-pages/man2/listen.2.html Implementation notes: Syscall acct() takes string as its only argument and thus a separate print function "print_acct" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". All the other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/strace.c | 13 ++++++++++++- linux-user/strace.list | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 23f7c386b5..f980451e3f 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1361,6 +1361,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, @@ -1625,7 +1637,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 Mon Jun 8 16:43:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 281140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6334AC433E0 for ; Mon, 8 Jun 2020 16:51:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17D3B2053B for ; Mon, 8 Jun 2020 16:51:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="RCcW1M/Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17D3B2053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiKze-0003SS-5u for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 12:51:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKsu-0003NA-1q for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:28 -0400 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:62103 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 1jiKss-0007Fd-RF for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fsdOPjGBCpXwPNdO15j93UfhDyd48uEsam6KKfxTUvPB3ZA/Rmxw6ndGowktTVew6V6/lbOPgbjA+oXWSOq2L/HwJB2KKAtRsP/QNrV5pB0ycndKO8BV4bn8zo2yfFemiY3uPTzvTMwSB0uqJSbeIGxdmsdMsMdviD5vGei0KnaEYpQMGMhuSPGNKThMzpij1rGi7Y1yK6yc1tGhiVpMrRQkq9DLngcAo8ZwetMJ9CB519wfUs+9p8Efu1Uxr0sJqufGC93A8UAIgFMZoaCRBF1VwuJAcO8QkppGb3zdJ1te+ut6lygGE4DFvapqPays536TxSpkO8bqcqHYqcbq4w== 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=DzvfXbuOhXoutjs1cs10nTaCxD/4PwVFgOsgUfQSZK4=; b=VyfSOAdMaRl8/dL2+tvvH/7p8g6dJ0l/gBPYJvPD8AsRKxfhY8+k38Y6qk6AZrkh0kehUo7r4zOcxU1DvMctEToKXlzbKmWLwGS4Rrr/AwY/h1nTrA/nX5BlyvyrRG4cgmGiC2PggX9NOee5LnSodxtuuJlvJm6ZmSuTSiOhTWz0dbiE/u2/rFf2STSu4jm1afm8iEAIMkWQg+qc1GlWfxPM2KplYWSzbLXxesoNP5yyPfSX9ShPwyWYtOCOfThIcNZxt0QjCQ9wySa8XenFGZC2XG4Yngi2ipduV5gDhC4MUi9MMrLQJoFgdFmdkgAUwaxJK1NX0qtZgJ9mKQFKkg== 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=DzvfXbuOhXoutjs1cs10nTaCxD/4PwVFgOsgUfQSZK4=; b=RCcW1M/ZZW+hqQeLHUuvDRQBVgyEdgdo1SC+OYdEc65X6gEd3HmHUJPTrnBP9WjmkRwSgRAF1f7jv1EstKrjUDdImpYxHy+wMLN/9XWylYSDOu0CabJBdkyINBboO1HXQx21Kbhwv4a33zx03NRvk884XSBNOoVxUBMbDEwgp7w= 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 AM6PR03MB3798.eurprd03.prod.outlook.com (2603:10a6:20b:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19; Mon, 8 Jun 2020 16:44:12 +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; Mon, 8 Jun 2020 16:44:12 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes Date: Mon, 8 Jun 2020 18:43:54 +0200 Message-Id: <20200608164357.25065-4-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608164357.25065-1-filip.bozuta@syrmia.com> References: <20200608164357.25065-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) 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 ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 16:44:11 +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: ed87baee-cf27-4fae-85a4-08d80bcb2c08 X-MS-TrafficTypeDiagnostic: AM6PR03MB3798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 59/ApjDJiqOh2ZJ7PMg4Vopuf5J0zhIZ0dV+jaBvbTFDCH9fcewSbjQXCKuSptFTtScM+lwZfCrHOwwjcTKZoB37xnJRSiqZ2wzpnn/hKQ+P5oAuoY6PEcRSWQhljLvoLftow606xevusbCmEV9SRgo6p3sMG2hI5IhwRmj78rs92L+ifE2SiuNcKlOUNMOWwCN232NAjvvfdpbZrpcJs0OxZ9esx0fYzwIwHF+Xp7l8vULYE902ftYeDM7cQ+iWpZEq/8LyEm4Tah23EuqxoD0NWInMk4NTGXnwAi3TIA9iPlUvSJ6VWUu7T0bEOAi4zVkmyvVj5IBCpVHUvTPHVdyl8+2FX3birzaUWj1yKJW4bWnoS7ZkYT3FZWWFOVb/5G36LmrLLVzpMwFZAB/rH+L6EMhdQw4zQV+jGCKQNRKwYHb22odkIWA/0X6N9h78B6BiBn/yEg0VRMUuvA61lQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39830400003)(376002)(396003)(346002)(136003)(366004)(508600001)(4326008)(8676002)(8936002)(966005)(1076003)(66556008)(6916009)(66476007)(5660300002)(66946007)(86362001)(316002)(36756003)(16526019)(26005)(2906002)(52116002)(83380400001)(2616005)(956004)(44832011)(6486002)(7696005)(186003)(6666004)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: VqD6mPWShB25mdBqg++N+FZMeq2AQmzN/soc7e6BuB+8gm6kHy60K2XKvIZJhe3jTQbdQgyo0G7tKCC55kdOSgsIo/FA4hhbtRR/2CYeF3zmdkM5z+ivJyYGo7DepGKnHHUDOV6Xd009cFl2iM2c0BnjP1xUwV3ATCofQLBbDjYqp0BY9ewv2Ay15EW+Dd27PSIYLPCOrVu4wGGybOdvFBEpqbdScZ8rUcIre3uM8NDfNPFnvXs2RYhfsw88kVCk5CdeEiaLa+7pvxACQoct63AZQ+dCe5Jm0DBJ08DN6pGOM4WIF5GtBhlvQmkGBvAeJfdrzpTwBYhUD1y3cBlMvy4etYNCu2z+GtifZRiTgFo4+39wNq2DH21/2s+5fpzmOs0kNyX3gAIkGKhWXOGM8T3aIMFpM8uil4gwixkAhvE7tqUNEydoJbn5f7mqSa2Rt37tmE1H97krKt2sMAiGs2rcM4Vn7fAg24JOPQl7FOA= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed87baee-cf27-4fae-85a4-08d80bcb2c08 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 16:44:11.9986 (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: SgUI69IGsYkTWyteu9K1O1mmKNx3jxBvsNkeAhDFAc1/7CvXaoLVnpWUrku2taJXOQLcqHyQdpzuWXWcSslOMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3798 Received-SPF: pass client-ip=40.107.8.91; 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/08 12:44:17 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for following syscalls: *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value ssize_t getxattr(const char *path, const char *name, void *value, size_t size) ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) ssize_t fgetxattr(int fd, const char *name, void *value, size_t size) man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html *listxattr, llistxattr, flistxattr - list extended attribute names ssize_t listxattr(const char *path, char *list, size_t size) ssize_t llistxattr(const char *path, char *list, size_t size) ssize_t flistxattr(int fd, char *list, size_t size) man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html *removexattr, lremovexattr, fremovexattr - remove an extended attribute int removexattr(const char *path, const char *name) int lremovexattr(const char *path, const char *name) int fremovexattr(int fd, const char *name) man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html Implementation notes: All of the syscalls have strings as argument types and thus a separate printing function was stated in file "strace.list" for every one of them. All of these printing functions were defined in "strace.c" using existing printing functions for appropriate argument types: "print_string()" - for (const char*) type "print_pointer()" - for (char*) and (void *) type "print_raw_param()" for (int) and (size_t) type Syscalls "getxattr()" and "lgetxattr()" have the same number and type of arguments and thus their print functions ("print_getxattr", "print_lgetxattr") share a same definition. The same statement applies to syscalls "listxattr()" and "llistxattr()". Function "print_syscall_ret_listxattr()" was added to print the returned list of extended attributes for syscalls and was listed as a "result" function in file "strace.list" for syscalls: "listxattr(), llistxattr(), flistxattr()". Signed-off-by: Filip Bozuta --- linux-user/strace.c | 126 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 21 ++++--- 2 files changed, 138 insertions(+), 9 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index f980451e3f..59fdb0a05f 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -830,6 +830,45 @@ 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) +{ + 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); + } + } else { + qemu_log(TARGET_ABI_FMT_ld, ret); + qemu_log(" (list = "); + if (arg1 != 0) { + abi_long attr = arg1; + for (;;) { + print_string(attr, 1); + attr += target_strlen(attr) + 1; + if (target_strlen(attr) == 0) { + break; + } + qemu_log(","); + } + } else { + qemu_log("NULL"); + } + qemu_log(")"); + } + + qemu_log("\n"); +} +#endif + UNUSED static struct flags access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), @@ -1637,6 +1676,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..05a72370c1 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_listxattr}, #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_listxattr}, #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 Mon Jun 8 16:43:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 281139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D9AC433E0 for ; Mon, 8 Jun 2020 16:53:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F9472053B for ; Mon, 8 Jun 2020 16:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=syrmia.com header.i=@syrmia.com header.b="GfaPelR8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F9472053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiL1B-0006XJ-Ch for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 12:53:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKsv-0003QW-B6 for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:29 -0400 Received: from mail-eopbgr80091.outbound.protection.outlook.com ([40.107.8.91]:62103 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 1jiKsu-0007Fd-Cz for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:44:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fI3Xh6hyoZ3ISiJvJ9FbMJu+6PdswVzgcGkvodZ7kH6UGYq7utW2E8lk7cVzr4keOr+eZ3he4q7esGY4h5dOaQF5UU75caVzpKxf7ckIdlNQp4O1UIYL9tDG1ksys6xxszLeCvZr/L2O+H4G2nQ5dNw0T64S0Q9qsgaKUvH8ob+VQc0uk2R4GxEu8OYL0EFgEB5jV/yn0jRX6NrMTUOCMc/UKhXddpHeNMan+XMHL9AYt9bpI/bKnna1cXoMcMYTNL1FDOEPLQ6sHjlBjDVuEejADSskovrS2YvQf9IiJYVGUnYC26VIM8j3j+/E3JDJVbdLINdkYecLeaacqL57lA== 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=TLcPByuBr8OPi19Y7QYCB1y3yAJbPcWQt4AU+ZljE2U=; b=F/MUDOpXq5gV8Xfk8vEX0boIYrSbMr5ZT4+fy/Ez7c7zSbS0+d3QpWliq6OSTFxCqdKrTzFxerh6vMMh+8nhNS1EqXxbUYn+GKxutQV9A8vupDgdR5uK662RkUq6/0A4sCFqz36yaCpUyVN+boJHtbo3deJIHgIVLveo2HnJyYkfLzpOnZSbDzKJIPKaRB77BySfTLUMe5SIMWLwUXLg1jGx7oFsgLp/C/hgLcEymeNzz2PDMKTE+vSEySEzWBlnFK8kz8b63MZhGV/g/iA1+oHHM3czELKoqxvnu72zG8qS7iwHKDPkt+mettpoqg8DMlNOHlsNZqdWBvAMcLW3Aw== 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=TLcPByuBr8OPi19Y7QYCB1y3yAJbPcWQt4AU+ZljE2U=; b=GfaPelR8TRMo+B+4lwsAxuSqou40oMBhkfASxbwvPVpWvs4BPERe3ANXxrOBUsTkneVcxs9YLADBxamKaLk9Tm4LNTLK+qeFfHd9JDtmTGtZf+iBAWpW0GgUrUASGKBwCq5/SC3uo2NTXMiUVocqasrgzwtVU0SAric3C9A4ih8= 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 AM6PR03MB3798.eurprd03.prod.outlook.com (2603:10a6:20b:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19; Mon, 8 Jun 2020 16:44:12 +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; Mon, 8 Jun 2020 16:44:12 +0000 From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 4/6] linux-user: Add strace support for printing arguments of lseek() Date: Mon, 8 Jun 2020 18:43:55 +0200 Message-Id: <20200608164357.25065-5-filip.bozuta@syrmia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200608164357.25065-1-filip.bozuta@syrmia.com> References: <20200608164357.25065-1-filip.bozuta@syrmia.com> X-ClientProxiedBy: ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) 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 ZR0P278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 16:44:12 +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: ce3a0c92-2bf1-4769-54cd-08d80bcb2c5b X-MS-TrafficTypeDiagnostic: AM6PR03MB3798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 042857DBB5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p4SZxPf4Gw3Mvax1NbzpIlQGFIdDV8mUPsdD5Xke7WvelpqIKHr1vECdThU9ggJaID2Ol42bf1hjgFOUvXV4lVhXkmvZ64dQY+vrADLu/Atf/xv2kHKAQkUrHyL8QPeeaOTu7lO/QRcrm49uVhAMzZGj2BZbh98f/k/xPkCM+1ceqhvTeZyOUVqYK4nmVt5VGF9731jLKcqKlrBJELkxWBxgVIlHacsRpt9cBy1FUF7hw/hnlszurrzXvuzsVEC38l/WwusL4HZsesDjyDGjMcd1AFeeuFTrogUoNAqFC0Iyb9AVKJXuuZNNY55ViahEvqh3nidrC4iU2bmaZaQ8JZqRgxxQNLVhB6isXKoYh2KKASBGSxByTDy12XuzYcAuaVjGjRmMM8K8wu36xGyvhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5233.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(39830400003)(376002)(396003)(346002)(136003)(366004)(508600001)(4326008)(8676002)(8936002)(966005)(1076003)(66556008)(6916009)(66476007)(5660300002)(66946007)(86362001)(316002)(36756003)(16526019)(26005)(2906002)(52116002)(83380400001)(2616005)(956004)(44832011)(6486002)(7696005)(186003)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: NDHw0P9Df667kd+KZUrwXHQL/e5sF8eVEBXz616Ae8LBJUKUz/jdiWZrTW+bm34LqI+behbFBLs70fPEWhxx0pPIkPXYW1kEmoWDAOlcWbOpDJZ1FKf3iLt0VZ8FuCJ8n7UT2yh5lR6jj48tSFOJJxSPfmpza8hmWTg50aKsWHjAwAf8mpT3LUd9q4fQVT+irxq7q6al4M4b1xCo1JZq91NQCU19xEgsqhbisciF9BN0/sVMaokx6KFOo+keol7cz2Q2OvKSiG91HQFWVLmEVgyN1WMlUBePN4ep+95N4PnvrxsGWe6W34ugGo5iGarQ0O7tHh6wxGjVh3M5NUZY92bkQt+5yYx0K9Jfi9RR+Ry03On9yLaHQu1sKAhIgnCru1Z1YxVX2N/oTBz2pW+OlvsuR7g9dfr2SuLyJ2ow+XdDYMQT+Vv4KkdoAVCSekhsiWsTxJFA+Z8L5n5xK+47IzJDT1cMmjUIn2bL7xlJoOQ= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce3a0c92-2bf1-4769-54cd-08d80bcb2c5b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2020 16:44:12.5103 (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: 7GQmalTyunWEt/vJ/cYs9SkWYKetSINT/9LDTIkbnp0L0wWMBT0/UpcIcJ9/8lIurLJghObYu5q7vwZ0uA5t1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3798 Received-SPF: pass client-ip=40.107.8.91; 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/08 12:44:17 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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=-0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements strace argument printing functionality for syscall: *lseek - reposition read/write file offset off_t lseek(int fd, off_t offset, int whence) man page: https://www.man7.org/linux/man-pages/man2/lseek.2.html Implementation notes: The syscall's third argument "whence" has predefined values: "SEEK_SET","SEEK_CUR","SEEK_END","SEEK_DATA","SEEK_HOLE" and thus a separate printing function "print_lseek" was stated in file "strace.list". This function is defined in "strace.c" by using an existing function "print_raw_param()" to print the first and second argument and a switch(case) statement for the predefined values of the third argument. Values "SEEK_DATA" and "SEEK_HOLE" are defined in kernel version 3.1. That is the reason why case statements for these values are enwrapped in #ifdef directive. Signed-off-by: Filip Bozuta --- 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 59fdb0a05f..adf9a47465 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1842,6 +1842,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 05a72370c1..bd04596c50 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 },