From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.104]) by sourceware.org (Postfix) with ESMTPS id 990F93898C42 for ; Sat, 28 Mar 2020 19:22:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 990F93898C42 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 gateway23.websitewelcome.com (Postfix) with ESMTP id 26F75239A for ; Sat, 28 Mar 2020 14:22:11 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH23jzbozAGTXIH23jNzyG; Sat, 28 Mar 2020 14:22:11 -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=M6OzlTp17DKoUWoxNu3SnS4Wz3npXRvbcfKSR8talt8=; b=k52A7XNog9NaEzwEEFyAYblMJk vDEZtboLDzHrqNQxdxYI3+r3X/fvfzFhaufirmVvOwOz0C+cXwzkCkz+hTLIQGb9fDS4QsSk1J9Ml QWEYMROWfRWSuyPI9fScE1suu; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:55190 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jIH22-003oZR-UN; Sat, 28 Mar 2020 13:22:11 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 04/20] Change some uses of DW_STRING to string method Date: Sat, 28 Mar 2020 13:21:52 -0600 Message-Id: <20200328192208.11324-5-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200328192208.11324-1-tom@tromey.com> References: <20200328192208.11324-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: 97.118.117.21 X-Source-L: No X-Exim-ID: 1jIH22-003oZR-UN X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:55190 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-21.5 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, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A 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, 28 Mar 2020 19:22:13 -0000 This changes some of the simpler spots to use attribute::string rather than DW_STRING. 2020-03-28 Tom Tromey * dwarf2/read.c (partial_die_info::read) (dwarf2_const_value_attr, anonymous_struct_prefix, ) (dwarf2_name, dwarf2_fetch_constant_bytes): Use attribute::string. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 52 +++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d2b274a6e3a..eb5ee98de60 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17879,14 +17879,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.string (); break; default: { struct objfile *objfile = dwarf2_per_objfile->objfile; name - = dwarf2_canonicalize_name (DW_STRING (&attr), cu, objfile); + = dwarf2_canonicalize_name (attr.string (), cu, objfile); } break; } @@ -20482,7 +20482,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->string (); break; case DW_FORM_block1: case DW_FORM_block2: @@ -20930,21 +20930,21 @@ 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) + if (attr == NULL || attr->string () == 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->string (), ':'); + if (base == NULL || base == attr->string () || 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->string (), + &base[-1] - attr->string ()); } /* Return the name of the namespace/class that DIE is defined within, @@ -21214,7 +21214,7 @@ 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)) + if ((!attr || !attr->string ()) && die->tag != DW_TAG_namespace && die->tag != DW_TAG_class_type && die->tag != DW_TAG_interface_type @@ -21232,11 +21232,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->string (); case DW_TAG_namespace: - if (attr != NULL && DW_STRING (attr) != NULL) - return DW_STRING (attr); + if (attr != NULL && attr->string () != NULL) + return attr->string (); return CP_ANONYMOUS_NAMESPACE_STR; case DW_TAG_class_type: @@ -21247,25 +21247,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), "string () + && (startswith (attr->string (), "._") + || startswith (attr->string (), "string () == NULL) { attr = dw2_linkage_name_attr (die, cu); - if (attr == NULL || DW_STRING (attr) == NULL) + if (attr == NULL || attr->string () == NULL) return NULL; - /* Avoid demangling DW_STRING (attr) the second time on a second + /* Avoid demangling attr->string () the second time on a second call for the same DIE. */ if (!DW_STRING_IS_CANONICAL (attr)) { gdb::unique_xmalloc_ptr demangled - (gdb_demangle (DW_STRING (attr), DMGL_TYPES)); + (gdb_demangle (attr->string (), DMGL_TYPES)); if (demangled == nullptr) return nullptr; @@ -21275,11 +21275,11 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) /* 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] == ':') + const char *base = strrchr (attr->string (), ':'); + if (base && base > attr->string () && base[-1] == ':') return &base[1]; else - return DW_STRING (attr); + return attr->string (); } break; @@ -21289,11 +21289,11 @@ 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->string (), cu, objfile); DW_STRING_IS_CANONICAL (attr) = 1; } - return DW_STRING (attr); + return attr->string (); } /* Return the die that this die in an extension of, or NULL if there @@ -21801,8 +21801,8 @@ 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)); + result = (const gdb_byte *) attr->string (); + *len = strlen (attr->string ()); break; case DW_FORM_block1: case DW_FORM_block2: -- 2.17.2