From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IBWUHkX3/GIrjygAWB0awg (envelope-from ) for ; Wed, 17 Aug 2022 10:12:21 -0400 Received: by simark.ca (Postfix, from userid 112) id 70C541E5EA; Wed, 17 Aug 2022 10:12:21 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=D5MqFxDH; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C87DC1E13B for ; Wed, 17 Aug 2022 10:12:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E9AA3858418 for ; Wed, 17 Aug 2022 14:12:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E9AA3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660745540; bh=EibiOlZaWhV4wPbtyM7+81kLDuYFSsD5vyT7Wwju92c=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=D5MqFxDH7KbnP1F9+49HR7KlmRzgV5kYDqk1aFNiyYnezMqKAmwtQL7Iil2ty8L2Y qxwhZ0mPM7PdVZqd+Ga1O1+3j5zBLVMoqoL6P7D4yTkn+PbP78PIDzPYEEC0mW2mbf UnZ+FOGwcYbk9879KnzlLCLfyu4YZtWoc3f0iu8c= Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) by sourceware.org (Postfix) with ESMTPS id BA3953858D1E for ; Wed, 17 Aug 2022 14:11:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA3953858D1E ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=VBz0Tmr50AvGdiKTXe8iQ83vU0OGWjPc8AM762VfnqQF+8i9xmI//bHaWkYQ9tuXJjQIfa2SyWFp4qdahnj9h1VWEFkNWZBDCKFxpd2HeAAge7ynSox2vxAgqcOrpxUO989AV8qVG8jOhl2sPndez8jgztLsDM6E97FBASfj/9albCnZSx2WkLMDNpOi69tJyUsUAiNgw8vQIV0ytwmU3odqatS6M9qayOdTZPXGKGVdQ5uK2DVBAu/uC1t0Ii/U4VlVeTooFtap7CJb59ftK785iV9jSE4ABIXbOcgSc74FjLAESQoKJGDAaBBzTmX5xAm6W++Qjfsy9tWbqeaadQ== ARC-Message-Signature: i=2; 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=EibiOlZaWhV4wPbtyM7+81kLDuYFSsD5vyT7Wwju92c=; b=SckGhvkecNxqvDkPpf6MDYqO+BYpVI/i7+2fD2d28pS+LTdQW8PCKqmlBOogqWLEZA6Df8PdqpqVdnkNJweERTEj9qcewB34ERQvgaP/sJyAc1xvclog5AhP6G92jcZwBXUazIW1ryB5IH1TYg0YKniMOGdcIaGFaS68GAAGb/swnGj+SltbcahBjw42KBwPp1qLgq3CtctU4fchQlpAjolqLJfS+3PbT0nCmTjMS75AEWuUj0N8zjexvN765IXkRelcXUBYC/CMrgHsVpA7Ye400JNQhXXlxjvO7+SpjWwW8e7FCoUNZOU8W2IS7nEEOijhQ9etjPzcL3cMmzXX9w== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8P250CA0030.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::35) by PA4PR08MB6094.eurprd08.prod.outlook.com (2603:10a6:102:f0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 17 Aug 2022 14:11:55 +0000 Received: from VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:330:cafe::ac) by AS8P250CA0030.outlook.office365.com (2603:10a6:20b:330::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.19 via Frontend Transport; Wed, 17 Aug 2022 14:11:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT054.mail.protection.outlook.com (10.152.19.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.15 via Frontend Transport; Wed, 17 Aug 2022 14:11:54 +0000 Received: ("Tessian outbound cc6a8ab50b6b:v123"); Wed, 17 Aug 2022 14:11:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d48cbc7e8404e9a9 X-CR-MTA-TID: 64aa7808 Received: from d79db5771eb1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C9D13A4B-FBB0-4AC4-BEF6-ECA3AB7867AE.1; Wed, 17 Aug 2022 14:11:47 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d79db5771eb1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 17 Aug 2022 14:11:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hmo04RMfT6WfkkQ9RcN6L6Sw466hoEeUPxVyku20VgYlySe4JKwvLbmMSZtNgoPjbUdtHujPs70HI9FipMXmFx8uExewpqRDHuGLIvWp7SmltPZqFaJkNZpgS7bnIdFB0cRnoDZmedPZSbna3iJBUubUeC6lErZ9PmUcXr+g6ncLFfEqBTdPPrRyiMDR6PzByJAUORndqeXXhuFLLoeatbWuXTUaPdl2BwJfMxNUOhDm6N0Ix7U1OG5orzPk/DF3DByXvgsblUy3uXHGtKH2LyWm2Tx7DakMa3XmDxoPmuVJ0P1t3ZFQhTQNQ1oi8sVHUbxd7sIDEoT6VVEyTq8EVg== 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=EibiOlZaWhV4wPbtyM7+81kLDuYFSsD5vyT7Wwju92c=; b=eIzKplc2SZmemZD1ioC+yp7Yu+vW0vgWBH8n75tVnekN5kDCFdWQ7ASA2OobABJ6yJ1MrqwhFCEwxCL3zm86pfrjCruKDXPG9/pKpx9dOPQncC18R35VFOfOSgYMlezQkCjtDxFf/R6BHbSxjqfhf9VpMmAggjd5yP6H9q1U5XwfrlbT9p8b02nIyHiag1yrzizHHNeLSWpiJzJpU7JZIDsH3GJ57+125djil3H+1/lvWonu/i77OI12BtL6RrhRyJ8xNpbDFKdJobyAPHQqoB4PzORxKpdy2yTbuHqjkWniwBqyzZEh+iIvWuW3VWjd4GzMeDOc/X0RHX7NzDOPvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AM6PR08MB3352.eurprd08.prod.outlook.com (2603:10a6:209:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.19; Wed, 17 Aug 2022 14:11:45 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8%4]) with mapi id 15.20.5504.028; Wed, 17 Aug 2022 14:11:45 +0000 Message-ID: <88362c05-8104-b0d2-311e-9f3c5383813e@arm.com> Date: Wed, 17 Aug 2022 15:11:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] gdb: new 'maint print frame-id' command Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <20220816171822.3315660-1-aburgess@redhat.com> In-Reply-To: <20220816171822.3315660-1-aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0081.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:9a::20) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e0912361-8532-448a-ad1d-08da805a7062 X-MS-TrafficTypeDiagnostic: AM6PR08MB3352:EE_|VE1EUR03FT054:EE_|PA4PR08MB6094:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: h6iOtMxCIqDJZHh/U2qwa8E+6lOkO0aU3NY72RrOcv/+HB46mSw287Li0XkSoHzM0KRf2XyiboB5lbNX2SEpmEnrb+LLv+6qIAJVQ/ihiIdKC3xeBpbRH4+tG/KFl3z8Wnd2qHJGl7aIk6AglhAEZ9vRe3VYtZ2zl+UJLS69EfCGXgY0gDNc+JVQ5lSYb7LmLdXQT6nKKCfjym6g1hXxn+ZgeKahLaJVJbqKZi6S5PBLsy+NKnqBTCj5IoUkYtpLgVV5fPe0htcm4rV9EQgpk2cRIjSrGlT/RTpvlg1n5fOLK7Ni0i7ji9FAQVr4lKIlv5ddGs8tqkZfneqe6g63p0tefm7JLB/PMLF1FWLq0PkoM1bv6b3+c4wt4ZVrDHVOr2UHG9g0RXWbnQfTAamr9WZbwWYgU6vAkcajXbfpxj+YhZpm2wM3CheyJqQ4qEsPPDDYkEtbPgc01SPi/opTMDKCa74b3rvGU8/PTy/9BKDR/xvepqYRrYIpDJRDWS6ou5XkbFrYEVfrP1rmlABE2h9nCsI+RsBMS4W2XpHDhqjMiJp0yGNTY+T9X7V/z+mGKVsfW7qJOCsAJXpke8UG9fr2iIQMULRfR5YS5K15BBhe0uPFxSLkei45SRX66lEoqJwz8STGNu2o0K0KKVV3HTnpJfsG1b4LiobdaJ2cX8pXpexMTbnr2UmycK5mzQRhrCLnJ9JQ4/JyIz2vq8+7c4aN70sfEpHzvujuQ0RhDmpikE4WzXjFtylKqhO5IaZyvo2JdFiHumsMD00xCbsU2IcqYBpAd8Noi8qfRl53kqT6XCwbMzp3gxLfvBObU583iBVFOWNFRFzhcHFpcSHZrR5gtMDxeqXxifBq1u0UNA/d0NCHMRmq1YTg+WHln70R X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(376002)(346002)(39860400002)(366004)(136003)(5660300002)(478600001)(44832011)(36756003)(316002)(6666004)(41300700001)(66946007)(6486002)(2906002)(66556008)(31686004)(8936002)(66476007)(8676002)(31696002)(186003)(53546011)(6512007)(2616005)(6506007)(86362001)(26005)(38100700002)(2004002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3352 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b826e771-b651-431f-8858-08da805a6a7a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YZlcK5AlnrmGxOHH9zZb3lYQA9ghsFusXtv4l+DcvQo46p+aJ+mu/rNpBL4GTIwWeQy0yX/ed6iojLM3pbq0wDgwyP75iXb4N7xhrsrigG2Bxn00dx8SViRZ6sjMrWYAd2gJSIT+CjsU0mB+pEt8UTLEOrguVzEhVcNvvJ/mBIrDe41K47agLlYQQKEYYJZ7Jq1GuXHkoIqSqI7LrZLDS39q61Kp5Ipk3DAroOhr6Nsy7ezlLZMPgtxZ7H/wbmt/ut1hSCMf4Gghr3SPEsWzut+NoLjEAJUvA5lG4fHonMzD2AxFGkS6VL2mBLCqj43WITCyW4thqtJ0IIsnfVehI1NB1a7d0yczwa+7vf2MQza2ngo52RaAz+tQ+vv63AInbSRGjhuzeXn6crPYNWs77Z2q1JM5pytQk93nrZVdW0G4/OXaD8mqUicT6ldqH0epAqo9ZMcsotoKGQuOenO4bofMJEgeepXfJ0RFBL+1lWF+XgWxpata14FGgv4Aow/27PgR2cj2qbksX8jUipiqB4HFjGXXTbyYmoRJ8s4cbpfpd2NkGg+F0vElR7r45IIL7KFSqqqaYl8pUiNm3TrX9Kp5KLqECSK7KL6BAmBe94cPMzylMqbaA1K0MP9PovowEmoMyoxSskZ2GxtR0g/1HC25NryF56ujNom0Mtp9Y/cIjWxsFWO47VZ6m8eBOcoNJP/VM/NY4E5w8nJpG9XD1sM3swI3JiWCPuMo7qV1txV+dUjwIKbONpYwxFQ6zUfnYe6aRkuMtq6kYC6f2zFSnX/tW57kfP2sR3aCj6R0zqvLzHhkSBYyzOwb+AVct1ScWggwIGEeQO+Yw9oenM2WNKfe4MDuDlZdpAk4XwGxG2yiM8jeqpgFLoblh6m2pbz6 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(136003)(396003)(346002)(39860400002)(376002)(46966006)(40470700004)(36840700001)(31686004)(6486002)(26005)(316002)(36756003)(8936002)(6666004)(41300700001)(2906002)(44832011)(5660300002)(6506007)(53546011)(6512007)(336012)(47076005)(186003)(2616005)(36860700001)(81166007)(86362001)(31696002)(40460700003)(40480700001)(356005)(70206006)(70586007)(82740400003)(478600001)(8676002)(82310400005)(2004002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 14:11:54.5711 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0912361-8532-448a-ad1d-08da805a7062 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6094 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: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/16/22 18:18, Andrew Burgess via Gdb-patches wrote: > When debugging a certain class of GDB bug, I often end up wanting to > know what GDB thinks the frame-id is in a particular frame. It's > not too hard to pull this from some debug output, but I thought it > might be nice if there was a maintenance command that could tell us. > > This commit adds 'maint print frame-id' which prints the frame-id of > the currently selected frame. You can also pass a frame level number > to find the frame-id for a specific frame. > > There's a new test too. > --- > gdb/NEWS | 4 ++ > gdb/doc/gdb.texinfo | 17 +++++ > gdb/frame.c | 28 ++++++++ > gdb/testsuite/gdb.base/maint-print-frame-id.c | 40 +++++++++++ > .../gdb.base/maint-print-frame-id.exp | 68 +++++++++++++++++++ > 5 files changed, 157 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/maint-print-frame-id.c > create mode 100644 gdb/testsuite/gdb.base/maint-print-frame-id.exp > > diff --git a/gdb/NEWS b/gdb/NEWS > index f2040e26c0c..49ac714efda 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -91,6 +91,10 @@ show style disassembler symbol > The 'disassembler address' and 'disassembler symbol' styles are > aliases for the 'address' and 'function' styles respectively. > > +maintenance print frame-id [ LEVEL ] > + Print GDB's internal frame-id for the frame at LEVEL. If LEVEL is > + not given, then print the frame-id for the currently selected frame. > + > * Changed commands > > maintenance info line-table > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 82cb1c8d668..ca958173b57 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -40142,6 +40142,23 @@ > > Takes an optional file parameter. > > +@kindex maint print frame-id > +@item maint print frame-id > +@itemx maint print frame-id @var{level} > +Print @value{GDBN}'s internal frame-id for the frame at relative > +@var{level}, or for the currently selected frame when @var{level} is > +not given. > + > +If used, @var{level} should be an integer, as displayed in the > +@command{backtrace} output. > + > +@smallexample > +(@value{GDBP}) maint print frame-id > +frame-id for frame #0: {stack=0x7fffffffac70,code=0x0000000000401106,!special} > +(@value{GDBP}) maint print frame-id 2 > +frame-id for frame #2: {stack=0x7fffffffac90,code=0x000000000040111c,!special} > +@end smallexample > + > @kindex maint print registers > @kindex maint print raw-registers > @kindex maint print cooked-registers > diff --git a/gdb/frame.c b/gdb/frame.c > index ae45e22d613..e6bebf575ca 100644 > --- a/gdb/frame.c > +++ b/gdb/frame.c > @@ -3116,6 +3116,30 @@ the rest of the stack trace."), > }, > }; > > +/* Implement the 'maintenance print frame-id' command. */ > + > +static void > +maintenance_print_frame_id (const char *args, int from_tty) > +{ > + struct frame_info *frame; > + > + /* Use the currently selected frame, or select a frame based on the level > + number passed by the user. */ > + if (args == nullptr) > + frame = get_selected_frame ("No frame selected"); > + else > + { > + int level = value_as_long (parse_and_eval (args)); > + frame = find_relative_frame (get_current_frame (), &level); > + } > + > + /* Print the frame-id. */ > + gdb_assert (frame != nullptr); > + gdb_printf ("frame-id for frame #%d: %s\n", > + frame_relative_level (frame), > + get_frame_id (frame).to_string ().c_str ()); > +} > + > void _initialize_frame (); > void > _initialize_frame () > @@ -3160,4 +3184,8 @@ When non-zero, frame specific internal debugging is enabled."), > NULL, > show_frame_debug, > &setdebuglist, &showdebuglist); > + > + add_cmd ("frame-id", class_maintenance, maintenance_print_frame_id, > + _("Print the current frame-id."), > + &maintenanceprintlist); > } > diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.c b/gdb/testsuite/gdb.base/maint-print-frame-id.c > new file mode 100644 > index 00000000000..bc9eb3000e7 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.c > @@ -0,0 +1,40 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 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 . */ > + > +int > +foo (void) > +{ > + return 0; > +} > + > +int > +bar (void) > +{ > + return foo (); > +} > + > +int > +baz (void) > +{ > + return bar (); > +} > + > +int > +main (void) > +{ > + return baz (); > +} > diff --git a/gdb/testsuite/gdb.base/maint-print-frame-id.exp b/gdb/testsuite/gdb.base/maint-print-frame-id.exp > new file mode 100644 > index 00000000000..395927a22c4 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/maint-print-frame-id.exp > @@ -0,0 +1,68 @@ > +# Copyright 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 . > + > +# Test the 'maint print frame-id' command. > + > +standard_testfile > + > +if {[prepare_for_testing "failed to prepare" $testfile \ > + $srcfile {debug}]} { > + return -1 > +} > + > +if ![runto_main] then { > + return -1 > +} > + > +gdb_breakpoint foo > +gdb_continue_to_breakpoint "run to foo" > + > +proc get_frame_id { level } { > + set id "**unknown**" > + > + gdb_test_multiple "maint print frame-id ${level}" "" { > + -re "^maint print frame-id\[^\r\n\]+\r\n" { > + exp_continue > + } > + > + -wrap -re "^frame-id for frame #\[0-9\]+: (\[^\r\n\]+)" { > + set id $expect_out(1,string) > + pass $gdb_test_name > + } > + } > + > + return $id > +} > + > +# Get the frame-id for each frame using the frame level. > +array set ids {} > +with_test_prefix "get id by level" { > + for { set i 0 } { $i < 4 } { incr i } { > + set ids($i) [get_frame_id $i] > + } > +} > + > +# Now get the frame-id of the currently selected frame, and check it > +# matches the frame-id we got earlier. Then move up the stack, > +# selecting a new frame. > +for { set i 0 } { $i < 4 } { incr i } { > + with_test_prefix "frame $i is current" { > + set id [get_frame_id ""] > + gdb_assert { [string equal $id $ids($i)] } \ > + "check frame-id matches" > + } > + gdb_test "up" ".*" \ > + "move up from frame $i" > +} LGTM. I think it's very useful.