From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 0543F3854153 for ; Wed, 29 Jun 2022 13:35:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0543F3854153 X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="262437113" X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="262437113" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 06:35:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="658555045" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga004.fm.intel.com with ESMTP; 29 Jun 2022 06:35:54 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 29 Jun 2022 06:35:54 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 29 Jun 2022 06:35:53 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 29 Jun 2022 06:35:53 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 29 Jun 2022 06:35:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IqCGia4pI4LsEZya3YmpcqwxWJo4mwt2HkNFn2FhBon3ucZrw+syFqJ1GzVJnmG1uQ/2+9mj5pBaV5y08UYstB3GLOWfiHHXZcRFL4OxTgJarYBYfrw6OGURdoxZF6GPNKAwvLAnL1llxKaRwHHtbGjMVw9oAschzIyE7Zpyfw9iVYR7fEq9dA7KqnFZ7e5FFkWq1+yChY0wUX3JIy4qzsDxZXrg+pG1kXuQ3Zw92lTguT+OydpokhBH+cmtKO13LxyymVvDStE8U7mWot06yVxsY9todpeedOt1V7TIf3cLr3zO6B2twPkkYCaFtbkHczBN4Oso6dSen4M/z3GcPg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JrmV76lxRwvAO7orDLeRah/BqLIx1TMiesRlUcrjeM8=; b=SPpg8da+S415sXHYijMJe9d5ujzIMAjNwixD+eKXHUgG/ONEkN3ZDZla8Uej/j4dXKeGvgYrOayU0qYgmwhAZikuIm5jIA2TpbzQcT3N+mLpEin0R4K/79PA3MLq2pjbNbGMLf5M+eFB96qa/f6YHnLggw97Qd1q0TfJpcngllX6VAJVVnFxvgCUuaCesXPm9HLHObaZNnXQdyTUga/GHaa1MJY1Wu419+OVHI42xw0bP4mV94RMG7VSsX0zdrM5KUk5bSJlxXpOwhPC4vKWbPZp8wolKqsUyQVUrRtNBHK/3uEjelVF8hwKp5RnGK1P38U4M0q8osGhaMR8+NPX7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM8PR11MB5749.namprd11.prod.outlook.com (2603:10b6:8:10::15) by BYAPR11MB2936.namprd11.prod.outlook.com (2603:10b6:a03:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Wed, 29 Jun 2022 13:35:50 +0000 Received: from DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::f9d8:e8a8:94ec:58db]) by DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::f9d8:e8a8:94ec:58db%8]) with mapi id 15.20.5395.014; Wed, 29 Jun 2022 13:35:50 +0000 From: "Metzger, Markus T" To: "Willgerodt, Felix" CC: "gdb-patches@sourceware.org" Subject: RE: [PATCH v5 10/10] btrace: Extend ptwrite event decoding. Thread-Topic: [PATCH v5 10/10] btrace: Extend ptwrite event decoding. Thread-Index: AQHYhi3HN5lduBcQyEqw3/fidomR3K1mW8rg Date: Wed, 29 Jun 2022 13:35:50 +0000 Message-ID: References: <20220622114340.55830-1-felix.willgerodt@intel.com> <20220622114340.55830-11-felix.willgerodt@intel.com> In-Reply-To: <20220622114340.55830-11-felix.willgerodt@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.500.17 dlp-product: dlpe-windows x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 47da064b-07d4-49f4-4a5c-08da59d447f9 x-ms-traffictypediagnostic: BYAPR11MB2936:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1XXIfYWU3X7REyBVKD8ZhQwnl4UCW5sH5v/XbTCNtRdAiR4DQEJFKODl3ICVRNyOrmL+f1ZrXdz+5ZOUv8FS0hGhgJnhk/uRCF7HZ0nKWOGJczVOk35WEHP7YKcngwJFruUC6VnrBYoL79Af4yUx1UX50HshD30cKwqzKpX7nEOJ+67FZ28vvFVAklMSxD5ZCjJFFqKY5s44C1Khhw9mkeRLDPBvbLpzU1LaN9sm2VpUaF/5p22KTDWRc6xaIjukdZ3ioJDsZu3DjEkC2sO7n2es8pVUIXNS2EyqCz4kAUxFLtS7TS/qtDhkoIjID4NewPi2zreTrhwF2ZNUdX+/dwRTzNFE0NAnNoLAH5U6++EMZSj7iwXtwnPwmF3CdyD6ADbaEEwpgppqg9rtiEBMDD0c0ptoMr9rLY8M0WGBTJdl9q/YdoPGFeEXO2FLOxENnfYsvdHyqWjXp7NWMv8LlM6FeNAMY39fWDXncemFfKmBrb3vvV+uhcTgd/1V5SwVWaEDYQvjVPLsgEIuVWuS7zT6Ntj6TmaTUcDEugVL8/m7iqsfBFxQQjcOBaGwlBwmyWpB4gEfMkXSugyQdVzrb6vht/U1homfLVzf2fEQ/l1qoMOQF7dlvxGPwa4OnbFXq4CLSqB3TgHS9Dgya5UwMaF6AQhS+usCRYQIKh0NHDfuWFC/s1CQeCtiCBsg2+lueOKKuQFnWewE7stjfFZFRyKKhd3Y4OhjJ7E/MU1yrl6BXXAySAvjiCWRMYOvZs3K/Q3+WMDJb5Z2U/5B2IZMZXARxOWBmPaJM9CBVPf2zeU= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR11MB5749.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(346002)(396003)(366004)(39860400002)(6636002)(86362001)(66556008)(2906002)(122000001)(66946007)(66446008)(76116006)(26005)(6506007)(7696005)(64756008)(82960400001)(66476007)(316002)(9686003)(186003)(6862004)(5660300002)(8936002)(52536014)(55016003)(38100700002)(38070700005)(41300700001)(33656002)(71200400001)(8676002)(4326008)(83380400001)(478600001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eZwvZUAWXEARACW3i6VIUh5HCfnZiU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ttcwdk0YhDViGmNl9pfWFsk+zPEsFp9Gksy3Z/3e0+GHH/v3?= =?us-ascii?Q?9AXbqbyKmwBeLu+hh8TJjci8TMxqKDCjlmjl+d+r5rhQwv58Uw4/qz2lcVSi?= =?us-ascii?Q?Nfz0haECWdRGaTOm9MnFa2vedOAiOWVfVkfgTxBXgv5UifxxNfdf18HumuMD?= =?us-ascii?Q?/ujLSt8od9DgluVnDwKml5E8k0s321/SwaraqfpVhEwtPzVOL3X3f01LkPQV?= =?us-ascii?Q?1i4K/9866xRrOvajQTE0RZAhU0y3/ZjguEy9v/Z3uQBt9z8U/nZPP8hl/KGs?= =?us-ascii?Q?I5Dnv3jxTmLCLEya2ATjn9NKjM3uiq6VYHAcuK4Hz7wp44awmBPMfwTVw4Ob?= =?us-ascii?Q?bCMK5+ShdPzv+4B1aiupT/43WCg8oQ+gYaiTnft6mfYeCK2ffDSWrQ1JPU89?= =?us-ascii?Q?A53DwWpSpYtiDescktQqI/c0QmTQ7UfsZxoGKP+kWkpUrpTsY/6cEJKxqNzb?= =?us-ascii?Q?jvruO8u25A8wGhedQrXe5SGQNxos8nP4GTYUNUaKVaJmZPcHdwDWvPvlvahs?= =?us-ascii?Q?WlYGzMj9qXefzg/3ayZ34D94njQAY3Ka0p3gqPTfKydl0IaHXPh4PlbWC1Y8?= =?us-ascii?Q?6eQj0OMbtwzV5cRKr5nVZiXaZJGDvBwwcelDXn8FTXncwS2dY2140L8wLLY0?= =?us-ascii?Q?C8bKGl24uUu3ToFOdWHwzexXjap5xKnzVyV9DInH?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5749.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47da064b-07d4-49f4-4a5c-08da59d447f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2022 13:35:50.1180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GdZCjYTlKpBBEH9GWNMnDp6qQELdy6AJGcahjWugw3St4wGaNGZJB+ioxqNHhkaB4XhjMXaZU99yqSdAkfnK4NGzLapTCT0GoLn7wkTgvbo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2936 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 13:35:58 -0000 Hello Felix, >Call the ptwrite filter function whenever a ptwrite event is decoded. >The returned string is written to the aux_data string table and a >corresponding auxiliary instruction is appended to the function segment. >--- > gdb/NEWS | 6 + > gdb/btrace.c | 53 +++ > gdb/config.in | 3 + > gdb/configure | 11 + > gdb/doc/python.texi | 150 +++++++++ > gdb/testsuite/gdb.btrace/i386-ptwrite.S | 379 ++++++++++++++++++++++ > gdb/testsuite/gdb.btrace/ptwrite.c | 37 +++ > gdb/testsuite/gdb.btrace/ptwrite.exp | 219 +++++++++++++ > gdb/testsuite/gdb.btrace/x86_64-ptwrite.S | 374 +++++++++++++++++++++ > gdb/testsuite/lib/gdb.exp | 74 +++++ > gdbsupport/common.m4 | 2 + > gdbsupport/config.in | 3 + > gdbsupport/configure | 11 + > 13 files changed, 1322 insertions(+) > create mode 100644 gdb/testsuite/gdb.btrace/i386-ptwrite.S > create mode 100644 gdb/testsuite/gdb.btrace/ptwrite.c > create mode 100644 gdb/testsuite/gdb.btrace/ptwrite.exp > create mode 100644 gdb/testsuite/gdb.btrace/x86_64-ptwrite.S This looks good to me with a few nits and one test bug. >+ if (!btinfo->functions.empty () >+ && !btinfo->functions.back ().insn.empty ()) >+ flags =3D btinfo->functions.back ().insn.back ().flags; >+ >+ /* Update insn list with ptw payload insn. */ >+ struct btrace_insn ptw_insn =3D { 0 }; >+ ptw_insn.aux_data_index =3D btinfo->aux_data.size () - 1; >+ ptw_insn.flags =3D flags; >+ ptw_insn.iclass =3D BTRACE_INSN_AUX; Why use 0 as IP and not IP? Let's assign the members in the order in which they are declared. >+void >+ptwrite64 (int value) >+{ >+ asm volatile ("PTWRITE %0;" : : "b" (value)); >+} >+ >+void >+ptwrite32 (int value) >+{ >+ asm volatile ("PTWRITE %0;" : : "b" (value)); >+} What's the difference between the two functions? Could we use the intrinsic functions we call out in the documentation or would different compilers spell them differently? >+### 1. Default testrun >+ >+# Setup recording >+gdb_test_no_output "set record instruction-history-size unlimited" >+gdb_test_no_output "record btrace pt" >+gdb_test "next" ".*" "first next" >+gdb_test "next" ".*" "second next" How about "next 2"? >+# Test auxiliary type in python >+gdb_test_multiline "auxiliary type in python" \ >+ "python" "" \ >+ "h =3D gdb.current_recording().instruction_history" "" \ >+ "for insn in h:" "" \ >+ " if hasattr(insn, 'decoded'):" "" \ >+ " print(insn.decoded.decode())" "" \ >+ " elif hasattr(insn, 'data'):" "" \ >+ " print(insn.data)" "" \ >+ "end" \ >+ [multi_line \ >+ ".*mov %eax,%ebx" \ >+ "ptwrite %ebx" \ We'd want %rbx here, I assume. >+# Run a test on the target to see if it supports ptwrite instructions and >+# if GDB can decode ptwrite events. Return 0 if so, 1 if it does not. >+ >+gdb_caching_proc skip_btrace_ptw_tests { >+ global srcdir subdir gdb_prompt inferior_exited_re decimal >+ >+ set me "skip_ptw_tests" >+ if { [skip_btrace_pt_tests] } { >+ verbose "$me: target does not support btrace, returning 1" 2 Should this say 'target does not support btrace pt'? regards, markus. Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928