From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 9F08E385EC59 for ; Thu, 17 Mar 2022 17:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F08E385EC59 X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="255765833" X-IronPort-AV: E=Sophos;i="5.90,188,1643702400"; d="scan'208";a="255765833" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 10:59:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,188,1643702400"; d="scan'208";a="541471704" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 17 Mar 2022 10:59:16 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Mar 2022 10:59:16 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Thu, 17 Mar 2022 10:59:16 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.21; Thu, 17 Mar 2022 10:59:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnozjt67L1R5jx3Ii40D5vQVwh9nnqNfJloHr+wLVOklrpk3RGfxXGjKaYYuc8mCSM6mj1mIxdqtU7WOkn/Bnp1BAOF0k1kZobASaq5+Dmmw6z5BWJ4FeJKV4E1vliAIiIZcJ/rM0P8VyBnAxRsjL+U3qCT42VVB75l1ab4X7qXOjPUlx7wY9iL7gfQXyVI5TEBKAYJbPaaNLhhRboW9Z8NFTagBRQieB93HsxdkAqmRV67qEb5CO3sLJU9GEORKHz37GA3hBaFY0JbbFS3fDCv49U1ZPTrNxMevfqlVNV/H78k//LwNwlExFdDuEcQG0yMGn8H2XeEqPC1Mns7e/A== 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=7mLhc0cMn5upYQfFMzgJkt0JUpGw5Hp/9DrQq/mtmDc=; b=aI1VB6qAHp3E1CknCaaFmpyKufYq+ws8g4GRx53VgHkqQWgO3n7DSHahHTMphVceLVBEqbpFBPsOiDaFzDrqcr6v6DeZaFdDCV2JR5yoMYm+Byn/bSbKXw5uIEcp5B8wIT5G/zCbA4oV5bJ1WJOnQoEWdMZXVduA0L0VBbHNrpFJX+mKVGG0uJgGWh4JA5LmKHtZFVj6JQO25u6LckgXkk7icpnuDDnK/ABE/7YwNfNCCxPAk/1uZFH9WVJ4/PC3s+DylTaeFZjDP53Eog3eqtc0kb4SfkJqpBVXW/+f8Dv6lopVo7qnJWtCnA4DGxdtEgfabn5+9blHbOV/fR08JQ== 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 DM4PR11MB5995.namprd11.prod.outlook.com (2603:10b6:8:5e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Thu, 17 Mar 2022 17:59:14 +0000 Received: from DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::8072:5ca1:297a:f7f9]) by DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::8072:5ca1:297a:f7f9%5]) with mapi id 15.20.5081.017; Thu, 17 Mar 2022 17:59:14 +0000 From: "Metzger, Markus T" To: "Hannula, Ari" CC: Tim Wiederhake , "gdb-patches@sourceware.org" Subject: RE: [PATCH 4/5] [func_call] Add function-call-history-length command to MI. Thread-Topic: [PATCH 4/5] [func_call] Add function-call-history-length command to MI. Thread-Index: AQHYHoXW+86+68JzCEOMkbbglJNJMqzECBpA Date: Thu, 17 Mar 2022 17:59:13 +0000 Message-ID: References: <20220210135243.3127629-1-ari.hannula@intel.com> <20220210135243.3127629-5-ari.hannula@intel.com> In-Reply-To: <20220210135243.3127629-5-ari.hannula@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.401.20 dlp-product: dlpe-windows x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f3e16a1d-33a2-424b-2ac4-08da083fd8e1 x-ms-traffictypediagnostic: DM4PR11MB5995:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IuETGXat3d3wDafzyj0RSbMRyviWNRvBJTODuK2I3e136PsZB09HxJPzz4/zwDQUp3aQXD0MNlP4FTqZ2WvAx8Yu8D7xopdrZMg/oE5pGf9ug1QnNyvBW03WIBuTV3gJSIy0U3G+0/80v7J3nXNb3wvnraHlEjzrFsSzCVFk0TjwSxiWcgdZFafQaVxUQFjFgPyLNSeHmGn1zVduss32pvonrQjpOcIuqVW8YrwOlNcxolQREF1alomhXErQwo65P8RDF7XZ7SA8wOHsduWnWhURqRJqDWqBn70Fmmo5ZJfWAYmobl/oko51Kum8O9xmeyFYcERXRgMV+hbKph899EdVmiKH7L5kEkBbX1DK0FMELrHiFpu2Fcgbwgm8QVJu29vdXXjqFiX+8+9XC79nqWLPTzBntHXyc2qnOEAdicGcqqDJXzSoE4ogMsRqLNnIHU4GfF/hiYAilTLB63NYGY7Bq3W7LVQ5JylscI87i86se1vpXOLE/e2hhRq5T4afzuopqUEE438wIZ+cIkYwsrtWbQhco2byMoowm0gNE9HxlXOE8H8G0N8lFwT8zLFo1YIoG/IgRoVBrDPVPkgKrVgTITpMG5IG5ozdHka85dp/pb80VjCQnxrfbm1JOLblPBzPoHFPezP/pymUUKPt3li+2rO1SHZE58RNjuvO9kDV1VQY8irqY1S1RckloSOaPTL2s548asYgtHs58eNtoYEcJ7/JOk5q7wtwRJY9kXv/TWPsoV0WJG4uLImHft8z7Yu2dPEoG/1anOwlHv9ROBUY7iVhSEUYdizGmHtkHIF8484L70+3vRIoyt+ln8zF 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:(13230001)(366004)(82960400001)(316002)(54906003)(38100700002)(55016003)(122000001)(8676002)(6636002)(66946007)(66556008)(71200400001)(508600001)(76116006)(64756008)(9686003)(6862004)(4326008)(38070700005)(66476007)(2906002)(33656002)(52536014)(83380400001)(26005)(186003)(6506007)(8936002)(86362001)(5660300002)(7696005)(66446008)(2004002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CjjI/2TL7XqBywio5U7JQKWXL7Ie7AXKQ5BOkjf16zVomT2vbzOngUv91bcK?= =?us-ascii?Q?rvU1byIYqCbiEpTamoDeYNeM+wQYgVGu6CghgozAVeKS6nHecF394ywQL4iY?= =?us-ascii?Q?sl62+/MCSHZ9WHcuUaeyM4Ypd/fkxRbS4CllknpGH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hTxfITBB9hmezdNIzSibcvCn34Inh8bm7GDmMNSw0tz1Q5tHqkcsUSr8udZ?= =?us-ascii?Q?LSNh1ZKQWFnafAZTOM28fBbt+Sjw+K6NLEreHxEjXoIaQhVWyPH6fqwRdOFN?= =?us-ascii?Q?WtUnsPyQbSNDwUn8xCwA6JnxGQTen4MDGE4VKjWdLn6blZBSHGD4XWWQZgWK?= =?us-ascii?Q?MZAdfLaWoOQQ+BSkTMMVW2WVHqJFyatku0Qt4jSrt5udmga26E5rMlUsSWSC?= =?us-ascii?Q?L83u4LA9qIK44Dbz6KpA8MZQjxeLFJx2NXsnuVQUvpFq/VmvMoe+bwWrWQWf?= =?us-ascii?Q?MFLQXtwvCDNQxKGBNPIx1GYXxzFJ8T810+MfNAacBPNQEvX9s2zIGNhb0MZ7?= =?us-ascii?Q?vKoQ+vx857VvXaCGT+aLKXMXJe1xlROB9xbTvR8m6hPN8kdZJXpHTqYOzcoQ?= =?us-ascii?Q?+3h+JPXXC/gbV0U4N1AF0AVGKMRYJNQUzm0rLvTlhFrCWv74Ub7xcg=3D=3D?= 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: f3e16a1d-33a2-424b-2ac4-08da083fd8e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Mar 2022 17:59:13.9850 (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: e2OukKM0rdjRM+b0/stuR+tPDxKQ0kXjQhshPAtvOGprIHDZVvPrWVCK3K9OovZksN3sTNfkhKYRblCJNNdXwJ71PuwA6+x1LzZrqSwMKsU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5995 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 17 Mar 2022 17:59:20 -0000 Hello Ari, >diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c >index cd7cabdda9..945a439d3a 100644 >--- a/gdb/mi/mi-cmds.c >+++ b/gdb/mi/mi-cmds.c >@@ -227,11 +227,11 @@ add_builtin_mi_commands () > add_mi_cmd_mi ("catch-unload", mi_cmd_catch_unload, > &mi_suppress_notification.breakpoint); > add_mi_cmd_mi ("catch-throw", mi_cmd_catch_throw, >- &mi_suppress_notification.breakpoint), >+ &mi_suppress_notification.breakpoint); > add_mi_cmd_mi ("catch-rethrow", mi_cmd_catch_rethrow, >- &mi_suppress_notification.breakpoint), >+ &mi_suppress_notification.breakpoint); > add_mi_cmd_mi ("catch-catch", mi_cmd_catch_catch, >- &mi_suppress_notification.breakpoint), >+ &mi_suppress_notification.breakpoint); Those changes appear to be unrelated. You may want to send them in a separate patch. > add_mi_cmd_mi ("complete", mi_cmd_complete); > add_mi_cmd_mi ("data-disassemble", mi_cmd_disassemble); > add_mi_cmd_mi ("data-evaluate-expression", >mi_cmd_data_evaluate_expression); >@@ -275,10 +275,12 @@ add_builtin_mi_commands () > add_mi_cmd_mi ("file-list-exec-source-files", > mi_cmd_file_list_exec_source_files); > add_mi_cmd_mi ("file-list-shared-libraries", >- mi_cmd_file_list_shared_libraries), >+ mi_cmd_file_list_shared_libraries); Those, as well. >@@ -1221,6 +1222,29 @@ btrace_call_history (struct ui_out *uiout, > } > } > >+/* The call_history_length method of target record-btrace. */ >+ >+void >+record_btrace_target::call_history_length () >+{ >+ struct btrace_call_iterator end; >+ btrace_call_end (&end, require_btrace ()); >+ >+ const int length =3D btrace_call_number (&end) - 1; You'd want to check that the trace is not empty. Also, the end iterator points one beyond the last function. There is similar code in record_btrace_target::info_record(). Let's extract that into a separate function so we're sure we report the same numbers in 'info record' and here. >+ >+ if (current_uiout->is_mi_like_p ()) >+ { >+ ui_out_emit_list list_emitter (current_uiout, "func history length"= ); >+ ui_out_emit_tuple tuple_emitter (current_uiout, nullptr); >+ current_uiout->field_unsigned ("end", length); >+ } >+ else >+ { >+ ui_out_emit_tuple tuple_emitter (current_uiout, "func history lengt= h"); >+ current_uiout->field_unsigned ("end", length); >+ } Could we use the same code for both MI and CLI? Should the field be called 'length' instead of 'end'? >diff --git a/gdb/record.h b/gdb/record.h >index 0fbca9d44c..174b71c67c 100644 >--- a/gdb/record.h >+++ b/gdb/record.h >@@ -114,4 +114,10 @@ extern void record_start (const char *method, const >char *format, > /* Stop recording. Throw on failure. */ > extern void record_stop (int from_tty); > >+/* The MI version of the command to get the length of the function call h= istory >+ for record targets. */ >+extern void mi_cmd_record_function_call_history_length (char *command, >+ char **argv, >+ int argc); >+ > #endif /* RECORD_H */ Why would this go into record.[hc] and not, say, some gdb/mi/mi-cmd-*.[hc]? >diff --git a/gdb/testsuite/gdb.mi/mi-function_call_history.exp >b/gdb/testsuite/gdb.mi/mi-function_call_history.exp >new file mode 100644 >index 0000000000..948a04a5ed >--- /dev/null >+++ b/gdb/testsuite/gdb.mi/mi-function_call_history.exp >@@ -0,0 +1,88 @@ >+# This testcase is part of GDB, the GNU debugger. >+# >+# Copyright 2013-2022 Free Software Foundation, Inc. >+# >+# This program is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program. If not, see . Would you please briefly comment what this test does? >+set errorInfo >+ >+if [skip_btrace_tests] { There should be an untested message. >+ return 0 >+} >+ >+load_lib mi-support.exp >+set MIFLAGS "-i=3Dmi" >+ >+gdb_exit >+if [mi_gdb_start] { >+ continue >+} >+ >+# start inferior >+standard_testfile mi-function_call_history.c >+ >+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab= le {debug}] >!=3D "" } { I think the default should be to use prepare_for_testing. >+ untested mi-function_call_history.exp >+ return -1 >+} >+ >+mi_delete_breakpoints >+mi_gdb_reinitialize_dir $srcdir/$subdir >+mi_gdb_load ${binfile} >+ >+if {[mi_runto_main] < 0} { >+ return -1 >+} >+ >+# start btrace >+send_gdb "record btrace\n" >+ >+gdb_expect { >+ -re "=3Drecord-started,thread-group=3D\".*\"\r\n\\^done\r\n$mi_gdb_pr= ompt$" { >+ # Done >+ } >+ -re "\\^error,msg=3D\"Target does not support branch tracing.\"" { >+ perror "Branch tracing not supported" >+ return -1 >+ } >+ timeout { >+ perror "Unable to start branch tracing" >+ return -1 >+ } >+} Would this work with gdb_test_multiple instead of separate send and expect? Looks like this might be used more often if we want to test btrace over MI. Would it make sense to put this into some mi_gdb_record function? >+ >+mi_create_breakpoint "-t $testfile.c:41" "insert temp breakpoint at >$testfile.c:41" \ >+ -number 2 -disp del -func main -file "$srcdir/$subdir/$testfile.c" -l= ine 41 >+ >+mi_send_resuming_command "exec-continue" "continue to bp.1" >+ >+mi_expect_stop "breakpoint-hit" "main" ".*" "$testfile.c" 41 \ >+ {"" "disp=3D\".*\"" } "run to breakpoint bp.1" >+ >+mi_gdb_test "125-function-call-history-length" \ >+ "125\\^done,func history length=3D\\\[\{end=3D\"21\"\}\\\]" \ >+ "125 function call history length" >+ >+mi_create_breakpoint "-t $testfile.c:42" "insert temp breakpoint at >$testfile.c:42" \ >+ -number 3 -disp del -func main -file "$srcdir/$subdir/$testfile.c" -l= ine 42 >+ >+mi_send_resuming_command "exec-continue" "continue to bp.2" >+ >+mi_expect_stop "breakpoint-hit" "main" ".*" "$testfile.c" 42 \ >+ {"" "disp=3D\".*\"" } "run to breakpoint bp.2" >+ >+mi_gdb_test "225-function-call-history-length" \ >+ "225\\^done,func history length=3D\\\[\{end=3D\"375\"\}\\\]" \ >+ "225 function call history length" >+ >+mi_gdb_exit >-- >2.25.1 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