From patchwork Fri Aug 16 09:20:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 34137 Received: (qmail 14687 invoked by alias); 16 Aug 2019 09:21:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14677 invoked by uid 89); 16 Aug 2019 09:21:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=tdesc, encounter X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr140050.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (40.107.14.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Aug 2019 09:20:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WwPh4/x4GTHt4Jj5SORmsou2UiiRtsDUqryEn2zZPvI=; b=zuyfQEP/BYAaX70EUJM3PmuJv0EPvDBmbQveljNEofo6xicGOHDxP3572U3629fNzgGzozhxuNKTudSLgC+XBnjSXdfIimrn2Id4S/UnRUfnuSzVb2FMZfGOempi/HXQZQf3fQF68tHkF49PtOwIMxXmQ1kJ942LO6blfFdifo4= Received: from DB7PR08CA0059.eurprd08.prod.outlook.com (2603:10a6:10:26::36) by AM5PR0801MB1842.eurprd08.prod.outlook.com (2603:10a6:203:3c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.20; Fri, 16 Aug 2019 09:20:50 +0000 Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::204) by DB7PR08CA0059.outlook.office365.com (2603:10a6:10:26::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Fri, 16 Aug 2019 09:20:50 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Fri, 16 Aug 2019 09:20:49 +0000 Received: ("Tessian outbound 6d016ca6b65d:v26"); Fri, 16 Aug 2019 09:20:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 61f53a5991875afc X-CR-MTA-TID: 64aa7808 Received: from acaf967f26fd.1 (cr-mta-lb-1.cr-mta-net [104.47.12.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9D75E9B3-D8F4-4B88-9FBD-B7A25538D462.1; Fri, 16 Aug 2019 09:20:39 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2051.outbound.protection.outlook.com [104.47.12.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id acaf967f26fd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Fri, 16 Aug 2019 09:20:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNHPVdji4akpDh0vGJtff8Z0a9HecjcW1ZBmkw19Yifsib/80Z0rE/3QuTbWYL+Lh8JJaQVsb2ghmuSw8hBWs3Qae5XqdnVvNjrmpUAOnn0dWU1H26iVaY6Af33TFB92XFiyTqB3HNCeQSvJPjIXC3xS8SxtHtO6jTxsZwcngms+D1mZItk07pliA9dYS1QBK+OSPzJAROkdCKVyykVqJjFD2RpMEdvSR1PZhuW3toEkrb0vfHteM+KDXyS27vTlCeVIcWKldb+vV5cB4JOQD31EPQB3ZE2hiDA+y7hIT+jN1MtrqbabA1M5DvjMDs5YxrSExl/bN762CVdPyeaLqg== 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=WwPh4/x4GTHt4Jj5SORmsou2UiiRtsDUqryEn2zZPvI=; b=fA/wl+I/UyyfGUr+Ru3Jl9hGjuAGd3gIJj0hF152ONmn0ZvY8Eqw2Hx0hFdhVSBqSiW/OrsbP+ruuvcTyLIOS+XA4ZV5Cxg+PhTWnR/KGajXuGkdegnWxIEvMr7UwLzzIBZy3Hs3zltOvB/ky48MB4fHtBvc7TuJpE+C3Hj5ph8Min+FMk1qLML/t4uTnRLHOshk1xFC01MU6LkH63YjH/woWY3rckd/5irIw81DYMuwQMknG3VkDYrKItZnLJITUzvpv3VfKU0+KWHkpgJe80/wXMC95obcdNE0IJChRuwugdtsOaMru97C1/+v/J/MwXAjl+eFTgUxsaBsXM905g== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WwPh4/x4GTHt4Jj5SORmsou2UiiRtsDUqryEn2zZPvI=; b=zuyfQEP/BYAaX70EUJM3PmuJv0EPvDBmbQveljNEofo6xicGOHDxP3572U3629fNzgGzozhxuNKTudSLgC+XBnjSXdfIimrn2Id4S/UnRUfnuSzVb2FMZfGOempi/HXQZQf3fQF68tHkF49PtOwIMxXmQ1kJ942LO6blfFdifo4= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2437.eurprd08.prod.outlook.com (10.172.250.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Fri, 16 Aug 2019 09:20:38 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::5ce5:cf42:42dd:eda1]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::5ce5:cf42:42dd:eda1%6]) with mapi id 15.20.2157.022; Fri, 16 Aug 2019 09:20:38 +0000 From: Alan Hayward To: Pedro Alves , Eli Zaretskii CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Move [PAC] into a new MI field addr_flags Date: Fri, 16 Aug 2019 09:20:38 +0000 Message-ID: <7E5F26CA-6F63-405B-A969-A7AEBF92CA8C@arm.com> References: <20190812151349.61011-1-alan.hayward@arm.com> <991ed180-a76c-56aa-b53e-907006e81f1b@redhat.com> In-Reply-To: <991ed180-a76c-56aa-b53e-907006e81f1b@redhat.com> Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DB6PR0802MB2437; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:8273;OLM:8273; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(136003)(396003)(39850400004)(366004)(199004)(189003)(54534003)(14454004)(486006)(76116006)(102836004)(66066001)(186003)(6512007)(91956017)(478600001)(25786009)(66946007)(6436002)(86362001)(6486002)(76176011)(26005)(54906003)(446003)(11346002)(476003)(6506007)(2616005)(33656002)(229853002)(53546011)(8676002)(53936002)(81156014)(6116002)(81166006)(6246003)(50226002)(2906002)(66476007)(8936002)(316002)(57306001)(110136005)(5660300002)(14444005)(305945005)(256004)(71190400001)(99286004)(66446008)(71200400001)(3846002)(4326008)(36756003)(7736002)(66556008)(64756008); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2437; H:DB6PR0802MB2133.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: vubbwXVAxymGwC+8cDSfeIUOVK3xoOKlJxdKlyG+olGBXOkrObssPvIlZ5G3vZog47zFZMyFzxFq/3rasQUsurwWW0iLFA980Ki8jjGyKwwsndg14FfKBiOHop0gztqDyrsJCVkHbacjd9sn2lvygM4CBcJOz10pVjmLFVCaFtEo3uUOAuIsTko/T8y1lM/VeT4jAdDeMSA5+79hiLMb6W/RE4XjBsLWNArFRGzm2qzA2OTRH61PZBE9r4qz+tH5o52Tl3uBExaeaC+lByRUxCXSoRInV9IVz6iSbbsL3Jq+t+CCjVFfqlgszAgCqfZKcQgq7OLjgUZ1Q+1LPJEaP88e6cvg1Z73khv8Lj9ySZnD0tMrfVFkNPMVQNCh6XwdKOv6uFs+I1Oxk0tjbJN13nWpEshKkbW9mjFlvK6LcT4= x-ms-exchange-transport-forked: True Content-ID: <3E3DEEE941E6E740887553F8025E8A63@eurprd08.prod.outlook.com> MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; Return-Path: Alan.Hayward@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 73c63add-20e8-497b-bcfe-08d7222b00bd X-IsSubscribed: yes > On 13 Aug 2019, at 15:28, Eli Zaretskii wrote: > >> From: Alan Hayward >> CC: "gdb-patches@sourceware.org" , nd >> Date: Tue, 13 Aug 2019 09:19:26 +0000 >> How about this: >> >> >> * Other MI changes >> >> ** Backtraces and frames include a new optional field addr_flags which is >> given after the addr field. On AArch64 this contains PAC if the address >> has been masked in the frame. On all other targets the field is not >> present. > > LGTM. > >>>> +@item addr_flags >>>> +Optional field containing any flags related to the address. If there >>>> +are any flags defined for the current target then they are documented in >>>> +the @xref{Architectures} section. >>> >>> I suggest to reword: >>> >>> These flags are architecture-dependent; see @ref{Architectures} for >>> their meaning for a particular CPU. >> >> Maybe keep the first sentence? Giving: >> >> Optional field containing any flags related to the address. These flags are >> architecture-dependent; see @ref{Architectures} for their meaning for a >> particular CPU. > > Yes, I definitely meant to keep the first sentence. > > Thanks. > On 15 Aug 2019, at 18:39, Pedro Alves wrote: > > On 8/12/19 4:13 PM, Alan Hayward wrote: > >> gdb/ChangeLog: >> >> 2019-08-12 Alan Hayward >> >> * NEWS (Other MI changes): New subsection. >> * aarch64-tdep.c (aarch64_get_pc_address_flags): New function. >> (aarch64_gdbarch_init): Add aarch64_get_pc_address_flags. >> * arch-utils.c (default_get_pc_address_flags): New function. >> * arch-utils.h (default_get_pc_address_flags): New declaration. >> * gdbarch.sh: Add get_pc_address_flags. >> * gdbarch.c: Regenerate. >> * gdbarch.h: Likewise. >> * stack.c (print_pc): New function. >> (print_frame_info) (print_frame): Call print_pc. > > OK. > > Thanks, > Pedro Alves Pushed with the doc changes. Patch below. Thanks, Alan. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 151f78f2b8..08a77e8c82 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2019-08-16 Alan Hayward + + * NEWS (Other MI changes): New subsection. + * aarch64-tdep.c (aarch64_get_pc_address_flags): New function. + (aarch64_gdbarch_init): Add aarch64_get_pc_address_flags. + * arch-utils.c (default_get_pc_address_flags): New function. + * arch-utils.h (default_get_pc_address_flags): New declaration. + * gdbarch.sh: Add get_pc_address_flags. + * gdbarch.c: Regenerate. + * gdbarch.h: Likewise. + * stack.c (print_pc): New function. + (print_frame_info) (print_frame): Call print_pc. + 2019-08-16 Tom de Vries * maint.c (maintenance_info_sections): Also handle !ALLOBJ case using diff --git a/gdb/NEWS b/gdb/NEWS index 462247f486..0a4e0f260f 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -287,6 +287,13 @@ maint show test-options-completion-result These can be used to catch C++ exceptions in a similar fashion to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'. +* Other MI changes + + ** Backtraces and frames include a new optional field addr_flags which is + given after the addr field. On AArch64 this contains PAC if the address + has been masked in the frame. On all other targets the field is not + present. + * Testsuite The testsuite now creates the files gdb.cmd (containing the arguments diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 5e9f7b8ee0..e512118579 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -273,6 +273,17 @@ aarch64_frame_unmask_lr (struct gdbarch_tdep *tdep, return addr; } +/* Implement the "get_pc_address_flags" gdbarch method. */ + +static std::string +aarch64_get_pc_address_flags (frame_info *frame, CORE_ADDR pc) +{ + if (pc != 0 && get_frame_pc_masked (frame)) + return "PAC"; + + return ""; +} + /* Analyze a prologue, looking for a recognizable stack frame and frame pointer. Scan until we encounter a store that could clobber the stack frame unexpectedly, or an unknown instruction. */ @@ -3370,6 +3381,8 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_gen_return_address (gdbarch, aarch64_gen_return_address); + set_gdbarch_get_pc_address_flags (gdbarch, aarch64_get_pc_address_flags); + tdesc_use_registers (gdbarch, tdesc, tdesc_data); /* Add standard register aliases. */ diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index bfcb58207a..c61fa6f051 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -995,6 +995,14 @@ default_type_align (struct gdbarch *gdbarch, struct type *type) return 0; } +/* See arch-utils.h. */ + +std::string +default_get_pc_address_flags (frame_info *frame, CORE_ADDR pc) +{ + return ""; +} + void _initialize_gdbarch_utils (void) { diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 588e7c0762..e5bbcd1f95 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -272,4 +272,8 @@ extern bool default_in_indirect_branch_thunk (gdbarch *gdbarch, extern ULONGEST default_type_align (struct gdbarch *gdbarch, struct type *type); +/* Default implementation of gdbarch get_pc_address_flags method. */ +extern std::string default_get_pc_address_flags (frame_info *frame, + CORE_ADDR pc); + #endif /* ARCH_UTILS_H */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 971e9c311a..339f3375e0 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2019-08-16 Alan Hayward + + * gdb.texinfo (AArch64 Pointer Authentication) + (GDB/MI Breakpoint Information) (Frame Information): Document + addr_field. + 2019-08-12 Tom Tromey * gdb.texinfo (Configure Options): Document minimum version of diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 523e3d0bfe..bcf0420779 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -24397,7 +24397,8 @@ When @value{GDBN} is debugging the AArch64 architecture, and the program is using the v8.3-A feature Pointer Authentication (PAC), then whenever the link register @code{$lr} is pointing to an PAC function its value will be masked. When GDB prints a backtrace, any addresses that required unmasking will be -postfixed with the marker [PAC]. +postfixed with the marker [PAC]. When using the MI, this is printed as part +of the @code{addr_flags} field. @node i386 @subsection x86 Architecture-specific Issues @@ -28925,6 +28926,11 @@ breakpoint; or the string @samp{}, for a breakpoint with multiple locations. This field will not be present if no address can be determined. For example, a watchpoint does not have an address. +@item addr_flags +Optional field containing any flags related to the address. These flags are +architecture-dependent; see @ref{Architectures} for their meaning for a +particular CPU. + @item func If known, the function in which the breakpoint appears. If not known, this field is not present. @@ -29025,6 +29031,11 @@ Note that this is not the same as the field @code{enable}. @item addr The address of this location as an hexidecimal number. +@item addr_flags +Optional field containing any flags related to the address. These flags are +architecture-dependent; see @ref{Architectures} for their meaning for a +particular CPU. + @item func If known, the function in which the location appears. If not known, this field is not present. @@ -29077,6 +29088,11 @@ be absent if @value{GDBN} is unable to determine the function name. @item addr The code address for the frame. This field is always present. +@item addr_flags +Optional field containing any flags related to the address. These flags are +architecture-dependent; see @ref{Architectures} for their meaning for a +particular CPU. + @item file The name of the source files that correspond to the frame's code address. This field may be absent. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 725b98fcd9..7b93d003a7 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -358,6 +358,7 @@ struct gdbarch char ** disassembler_options; const disasm_options_and_args_t * valid_disassembler_options; gdbarch_type_align_ftype *type_align; + gdbarch_get_pc_address_flags_ftype *get_pc_address_flags; }; /* Create a new ``struct gdbarch'' based on information provided by @@ -473,6 +474,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->gnu_triplet_regexp = default_gnu_triplet_regexp; gdbarch->addressable_memory_unit_size = default_addressable_memory_unit_size; gdbarch->type_align = default_type_align; + gdbarch->get_pc_address_flags = default_get_pc_address_flags; /* gdbarch_alloc() */ return gdbarch; @@ -721,6 +723,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of disassembler_options, invalid_p == 0 */ /* Skip verify of valid_disassembler_options, invalid_p == 0 */ /* Skip verify of type_align, invalid_p == 0 */ + /* Skip verify of get_pc_address_flags, invalid_p == 0 */ if (!log.empty ()) internal_error (__FILE__, __LINE__, _("verify_gdbarch: the following are invalid ...%s"), @@ -1065,6 +1068,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: get_longjmp_target = <%s>\n", host_address_to_string (gdbarch->get_longjmp_target)); + fprintf_unfiltered (file, + "gdbarch_dump: get_pc_address_flags = <%s>\n", + host_address_to_string (gdbarch->get_pc_address_flags)); fprintf_unfiltered (file, "gdbarch_dump: gdbarch_get_siginfo_type_p() = %d\n", gdbarch_get_siginfo_type_p (gdbarch)); @@ -5156,6 +5162,23 @@ set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch->type_align = type_align; } +std::string +gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, frame_info *frame, CORE_ADDR pc) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->get_pc_address_flags != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_pc_address_flags called\n"); + return gdbarch->get_pc_address_flags (frame, pc); +} + +void +set_gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, + gdbarch_get_pc_address_flags_ftype get_pc_address_flags) +{ + gdbarch->get_pc_address_flags = get_pc_address_flags; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index c3556d3841..3c6efae895 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1640,6 +1640,12 @@ typedef ULONGEST (gdbarch_type_align_ftype) (struct gdbarch *gdbarch, struct typ extern ULONGEST gdbarch_type_align (struct gdbarch *gdbarch, struct type *type); extern void set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch_type_align_ftype *type_align); +/* Return a string containing any flags for the given PC in the given FRAME. */ + +typedef std::string (gdbarch_get_pc_address_flags_ftype) (frame_info *frame, CORE_ADDR pc); +extern std::string gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, frame_info *frame, CORE_ADDR pc); +extern void set_gdbarch_get_pc_address_flags (struct gdbarch *gdbarch, gdbarch_get_pc_address_flags_ftype *get_pc_address_flags); + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 2f9fbbc56c..d589b2c49a 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -1210,6 +1210,9 @@ v;const disasm_options_and_args_t *;valid_disassembler_options;;;0;0;;0;host_add # default rules as laid out in gdbtypes.c:type_align. m;ULONGEST;type_align;struct type *type;type;;default_type_align;;0 +# Return a string containing any flags for the given PC in the given FRAME. +f;std::string;get_pc_address_flags;frame_info *frame, CORE_ADDR pc;frame, pc;;default_get_pc_address_flags;;0 + EOF } diff --git a/gdb/stack.c b/gdb/stack.c index 49b9100485..06431ea354 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -923,6 +923,23 @@ print_frame_info_to_print_what (const char *print_frame_info) print_frame_info); } +/* Print the PC from FRAME, plus any flags, to UIOUT. */ + +static void +print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info *frame, + CORE_ADDR pc) +{ + uiout->field_core_addr ("addr", gdbarch, pc); + + std::string flags = gdbarch_get_pc_address_flags (gdbarch, frame, pc); + if (!flags.empty ()) + { + uiout->text (" ["); + uiout->field_string ("addr_flags", flags); + uiout->text ("]"); + } +} + /* See stack.h. */ void @@ -980,8 +997,7 @@ print_frame_info (const frame_print_options &fp_opts, if (uiout->is_mi_like_p ()) { annotate_frame_address (); - uiout->field_core_addr ("addr", - gdbarch, get_frame_pc (frame)); + print_pc (uiout, gdbarch, frame, get_frame_pc (frame)); annotate_frame_address_end (); } @@ -1065,8 +1081,7 @@ print_frame_info (const frame_print_options &fp_opts, ability to decide for themselves if it is desired. */ if (opts.addressprint && mid_statement) { - uiout->field_core_addr ("addr", - gdbarch, get_frame_pc (frame)); + print_pc (uiout, gdbarch, frame, get_frame_pc (frame)); uiout->text ("\t"); } @@ -1292,11 +1307,7 @@ print_frame (const frame_print_options &fp_opts, { annotate_frame_address (); if (pc_p) - { - uiout->field_core_addr ("addr", gdbarch, pc); - if (get_frame_pc_masked (frame)) - uiout->field_string ("pac", " [PAC]"); - } + print_pc (uiout, gdbarch, frame, pc); else uiout->field_string ("addr", "", ui_out_style_kind::ADDRESS);