From patchwork Thu Mar 1 11:40:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 26132 Received: (qmail 49003 invoked by alias); 1 Mar 2018 11:40:49 -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 48993 invoked by uid 89); 1 Mar 2018 11:40:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30049.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Mar 2018 11:40:47 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0689.eurprd08.prod.outlook.com (10.163.189.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.527.15; Thu, 1 Mar 2018 11:40:44 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::fc60:4b4d:7de8:f8b7]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::fc60:4b4d:7de8:f8b7%16]) with mapi id 15.20.0527.022; Thu, 1 Mar 2018 11:40:44 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH v3 5/8] Add tdesc osabi and architecture functions Date: Thu, 1 Mar 2018 11:40:44 +0000 Message-ID: <4EAFFAAB-950F-4D3E-BDB2-7B3AC704BB45@arm.com> References: <757A8B89-2EF0-46BD-BAA6-6E668538B17F@arm.com> In-Reply-To: <757A8B89-2EF0-46BD-BAA6-6E668538B17F@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0689; 7:ZbvKZ18CvYNEljSfsJBvMeKHgV9GxxD+DxcbnXlMMzNze7njPYpCR+syj7XEO5bBjU0bmVta1vp/v7bjM2H4PP20lsH3m0MeZycfBWeBxkeA6wxZAeNLuCFu1RzZyAo8nD5bLDkY6Dq8c7iDNq6xEAVubFeg+xuBtj/72owzWDFQp8JO0YA3JSUBSdKRM1fko+ltFKDat+mBYFmg+1Ehw3B7dzecOdasv49wh7DfwT6lSANOjMXQp56xP5f6l+Lf x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 6c42cebc-2e01-4b09-7c67-08d57f6944df x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:AM3PR08MB0689; x-ms-traffictypediagnostic: AM3PR08MB0689: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(3231220)(944501227)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041288)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:AM3PR08MB0689; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0689; x-forefront-prvs: 05986C03E0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(366004)(376002)(39380400002)(377424004)(189003)(199004)(5640700003)(6512007)(14454004)(86362001)(575784001)(25786009)(26005)(4743002)(66066001)(2950100002)(5250100002)(2900100001)(2501003)(305945005)(97736004)(3660700001)(4326008)(83716003)(7736002)(6506007)(59450400001)(106356001)(76176011)(99286004)(2906002)(68736007)(53936002)(82746002)(102836004)(5660300001)(3280700002)(72206003)(316002)(478600001)(6436002)(8676002)(186003)(6486002)(81156014)(2351001)(81166006)(8936002)(33656002)(6916009)(105586002)(36756003)(6116002)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0689; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: uSJyyHdyh6o84+eCF/2wDV5bU53i71ovOCIm0vxGNuqySBjfbaGyrGBatBG8YG1v3SnpfmLbLNEBC+4Y2g49+QR48Ln5J3UYOXCkEtW7zvw0qM+5G7AR+cJXhLX2D+ytcMyjLiD3V/0du4i0FNpEZiTSzoKowVRlNewM6xFJ3ug= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c42cebc-2e01-4b09-7c67-08d57f6944df X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2018 11:40:44.5490 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0689 X-IsSubscribed: yes Add functions to access to printable names for osabi and architecture in target_desc. I wanted to add these as member functions of target_desc, but cannot until target_desc is moved into the header files. Alan. 2018-03-01 Alan Hayward gdb/ * common/tdesc.h (tdesc_architecture_name): Add new declaration. (tdesc_osabi_name): Likewise. * target-descriptions.c (tdesc_architecture_name): Add new function. (tdesc_osabi_name): Likewise. gdb/gdbserver/ * tdesc.c (tdesc_architecture_name): Add new function. (tdesc_osabi_name): Likewise. (tdesc_get_features_xml): Use new functions. diff --git a/gdb/common/tdesc.h b/gdb/common/tdesc.h index 14f7bc3a8f248adff04089438ad61c16e83385d0..c0d2a10b0f7ba4e7b836e3b163d229f1608b02d8 100644 --- a/gdb/common/tdesc.h +++ b/gdb/common/tdesc.h @@ -304,9 +304,18 @@ target_desc *allocate_target_description (void); void set_tdesc_architecture (target_desc *target_desc, const char *name); +/* Return the architecture associated with this target description as a string, + or NULL if no architecture was specified. */ +const char *tdesc_architecture_name (const struct target_desc *target_desc); + /* Set TARGET_DESC's osabi by NAME. */ void set_tdesc_osabi (target_desc *target_desc, const char *name); +/* Return the osabi associated with this target description as a string, + or NULL if no osabi was specified. */ +const char * +tdesc_osabi_name (const struct target_desc *target_desc); + /* Return the type associated with ID in the context of FEATURE, or NULL if none. */ struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature, diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c index 1d9aeed217da37fee7220845ff96085dde877876..e11344762a3a4114ed9aa459d7d739bd96a90ae5 100644 --- a/gdb/gdbserver/tdesc.c +++ b/gdb/gdbserver/tdesc.c @@ -127,6 +127,14 @@ current_target_desc (void) /* See common/tdesc.h. */ +const char * +tdesc_architecture_name (const struct target_desc *target_desc) +{ + return target_desc->arch; +} + +/* See common/tdesc.h. */ + void set_tdesc_architecture (struct target_desc *target_desc, const char *name) @@ -136,6 +144,14 @@ set_tdesc_architecture (struct target_desc *target_desc, /* See common/tdesc.h. */ +const char * +tdesc_osabi_name (const struct target_desc *target_desc) +{ + return target_desc->osabi; +} + +/* See common/tdesc.h. */ + void set_tdesc_osabi (struct target_desc *target_desc, const char *name) { @@ -160,13 +176,14 @@ tdesc_get_features_xml (target_desc *tdesc) buffer += ""; buffer += ""; buffer += ""; - buffer += tdesc->arch; + buffer += tdesc_architecture_name (tdesc); buffer += ""; - if (tdesc->osabi != nullptr) + const char *osabi = tdesc_osabi_name (tdesc); + if (osabi != nullptr) { buffer += ""; - buffer += tdesc->osabi; + buffer += osabi; buffer += ""; } diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 2782ffaab9355e5a74da45e326ad468ff6bed796..da2c1ce34531c1b23281c42f2dacbc85444ef544 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -628,6 +628,14 @@ tdesc_architecture (const struct target_desc *target_desc) return target_desc->arch; } +/* See common/tdesc.h. */ + +const char * +tdesc_architecture_name (const struct target_desc *target_desc) +{ + return target_desc->arch->printable_name; +} + /* Return the OSABI associated with this target description, or GDB_OSABI_UNKNOWN if no osabi was specified. */ @@ -637,7 +645,16 @@ tdesc_osabi (const struct target_desc *target_desc) return target_desc->osabi; } - +/* See common/tdesc.h. */ + +const char * +tdesc_osabi_name (const struct target_desc *target_desc) +{ + enum gdb_osabi osabi = tdesc_osabi (target_desc); + if (osabi > GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) + return gdbarch_osabi_name (osabi); + return nullptr; +} /* Return 1 if this target description includes any registers. */