From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway21.websitewelcome.com (gateway21.websitewelcome.com [192.185.45.43]) by sourceware.org (Postfix) with ESMTPS id 00D0F385DC1A for ; Sat, 4 Apr 2020 14:43:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00D0F385DC1A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 8E777400CBD0C for ; Sat, 4 Apr 2020 09:43:24 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Kk16jRXEYAGTXKk16jof2d; Sat, 04 Apr 2020 09:43:24 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ButzVEMNCy/nXj+1SBa0RuW9Jb3Q0/tirvaxH263wDM=; b=YK6jUpF3A4aHk9xooEl5XFgDE+ pGRNGiC1IRA6V6pGKwcDS0m8d85186ZVQPjMxYSxUwsoKMm7CEotZz/Fx1KRnOHUJtPfwROMWbmdP viPssQWF2+03zC301oVc7R/xi; Received: from 174-16-110-145.hlrn.qwest.net ([174.16.110.145]:58434 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jKk16-003j51-09; Sat, 04 Apr 2020 08:43:24 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 04/20] Change some uses of DW_STRING to string method Date: Sat, 4 Apr 2020 08:43:04 -0600 Message-Id: <20200404144320.18851-5-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200404144320.18851-1-tom@tromey.com> References: <20200404144320.18851-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.110.145 X-Source-L: No X-Exim-ID: 1jKk16-003j51-09 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-110-145.hlrn.qwest.net (bapiya.Home) [174.16.110.145]:58434 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-17.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Sat, 04 Apr 2020 14:43:26 -0000 This changes some of the simpler spots to use attribute::string rather than DW_STRING. gdb/ChangeLog 2020-04-04 Tom Tromey * dwarf2/read.c (partial_die_info::read) (dwarf2_const_value_attr, anonymous_struct_prefix, ) (dwarf2_name, dwarf2_fetch_constant_bytes): Use attribute::as_string. --- gdb/ChangeLog | 7 +++++ gdb/dwarf2/read.c | 66 ++++++++++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0d6ae4478ae..cd5ae3c07f6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17908,14 +17908,14 @@ partial_die_info::read (const struct die_reader_specs *reader, case DW_TAG_enumerator: /* These tags always have simple identifiers already; no need to canonicalize them. */ - name = DW_STRING (&attr); + name = attr.as_string (); break; default: { struct objfile *objfile = dwarf2_per_objfile->objfile; - name - = dwarf2_canonicalize_name (DW_STRING (&attr), cu, objfile); + name = dwarf2_canonicalize_name (attr.as_string (), + cu, objfile); } break; } @@ -20511,7 +20511,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, case DW_FORM_GNU_strp_alt: /* DW_STRING is already allocated on the objfile obstack, point directly to it. */ - *bytes = (const gdb_byte *) DW_STRING (attr); + *bytes = (const gdb_byte *) attr->as_string (); break; case DW_FORM_block1: case DW_FORM_block2: @@ -20959,21 +20959,22 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu) return NULL; attr = dw2_linkage_name_attr (die, cu); - if (attr == NULL || DW_STRING (attr) == NULL) + const char *attr_name = attr->as_string (); + if (attr == NULL || attr_name == NULL) return NULL; /* dwarf2_name had to be already called. */ gdb_assert (DW_STRING_IS_CANONICAL (attr)); /* Strip the base name, keep any leading namespaces/classes. */ - base = strrchr (DW_STRING (attr), ':'); - if (base == NULL || base == DW_STRING (attr) || base[-1] != ':') + base = strrchr (attr_name, ':'); + if (base == NULL || base == attr_name || base[-1] != ':') return ""; struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; return obstack_strndup (&objfile->per_bfd->storage_obstack, - DW_STRING (attr), - &base[-1] - DW_STRING (attr)); + attr_name, + &base[-1] - attr_name); } /* Return the name of the namespace/class that DIE is defined within, @@ -21243,7 +21244,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; attr = dwarf2_attr (die, DW_AT_name, cu); - if ((!attr || !DW_STRING (attr)) + const char *attr_name = attr == nullptr ? nullptr : attr->as_string (); + if (attr_name == nullptr && die->tag != DW_TAG_namespace && die->tag != DW_TAG_class_type && die->tag != DW_TAG_interface_type @@ -21261,11 +21263,11 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_enumerator: /* These tags always have simple identifiers already; no need to canonicalize them. */ - return DW_STRING (attr); + return attr_name; case DW_TAG_namespace: - if (attr != NULL && DW_STRING (attr) != NULL) - return DW_STRING (attr); + if (attr_name != nullptr) + return attr_name; return CP_ANONYMOUS_NAMESPACE_STR; case DW_TAG_class_type: @@ -21276,25 +21278,25 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) structures or unions. These were of the form "._%d" in GCC 4.1, or simply "" or "" in GCC 4.3 and GCC 4.4. We work around this problem by ignoring these. */ - if (attr && DW_STRING (attr) - && (startswith (DW_STRING (attr), "._") - || startswith (DW_STRING (attr), " demangled - (gdb_demangle (DW_STRING (attr), DMGL_TYPES)); + (gdb_demangle (attr_name, DMGL_TYPES)); if (demangled == nullptr) return nullptr; @@ -21302,13 +21304,14 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) DW_STRING_IS_CANONICAL (attr) = 1; } - /* Strip any leading namespaces/classes, keep only the base name. - DW_AT_name for named DIEs does not contain the prefixes. */ - const char *base = strrchr (DW_STRING (attr), ':'); - if (base && base > DW_STRING (attr) && base[-1] == ':') + /* Strip any leading namespaces/classes, keep only the + base name. DW_AT_name for named DIEs does not + contain the prefixes. */ + const char *base = strrchr (attr_name, ':'); + if (base && base > attr_name && base[-1] == ':') return &base[1]; else - return DW_STRING (attr); + return attr_name; } break; @@ -21318,11 +21321,13 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) if (!DW_STRING_IS_CANONICAL (attr)) { - DW_STRING (attr) = dwarf2_canonicalize_name (DW_STRING (attr), cu, + DW_STRING (attr) = dwarf2_canonicalize_name (attr_name, cu, objfile); DW_STRING_IS_CANONICAL (attr) = 1; } - return DW_STRING (attr); + + /* We might have changed it just above. */ + return attr->as_string (); } /* Return the die that this die in an extension of, or NULL if there @@ -21830,8 +21835,11 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, case DW_FORM_GNU_strp_alt: /* DW_STRING is already allocated on the objfile obstack, point directly to it. */ - result = (const gdb_byte *) DW_STRING (attr); - *len = strlen (DW_STRING (attr)); + { + const char *attr_name = attr->as_string (); + result = (const gdb_byte *) attr_name; + *len = strlen (attr_name); + } break; case DW_FORM_block1: case DW_FORM_block2: -- 2.17.2