From patchwork Thu Jan 23 00:56:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37481 Received: (qmail 80082 invoked by alias); 23 Jan 2020 00:57:30 -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 79812 invoked by uid 89); 23 Jan 2020 00:57:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=complaint, sk:attr_fo X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.62.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 00:57:21 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id BB061400C74CB for ; Wed, 22 Jan 2020 17:44:46 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id uQoBizIApERZguQoBirD8G; Wed, 22 Jan 2020 18:57:19 -0600 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=DVwR5UEZWiegH+73fW99Dvq6naGvh7UoZ2tTYDGi83I=; b=Sex5JYhxjk3/FTchlmZdGVp7lv h+uV/JsQ151aV53PWjw7HTAiQgU/XlCJrSBHl3IWHe4hyafrG6IRteOzg3KAPCMwNxg4piQG5gzg0 UlQyrgtf6f0q6uR9oJl+EmEhD; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:40800 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iuQoB-004Kfy-K6; Wed, 22 Jan 2020 17:57:19 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/38] Change attr_form_is_block to be a method Date: Wed, 22 Jan 2020 17:56:39 -0700 Message-Id: <20200123005710.7978-8-tom@tromey.com> In-Reply-To: <20200123005710.7978-1-tom@tromey.com> References: <20200123005710.7978-1-tom@tromey.com> This changes attr_form_is_block to be a method. This is done separately because, unlike the other attribute functions, attr_form_is_block had special handling for the case where the argument was NULL. This required auditing each call site; in most cases, NULL was already ruled out, but in a few spots, an additional check was needed. gdb/ChangeLog 2020-01-22 Tom Tromey * dwarf2read.c (read_call_site_scope) (handle_data_member_location, dwarf2_add_member_fn) (mark_common_block_symbol_computed, read_common_block) (attr_to_dynamic_prop, partial_die_info::read) (var_decode_location, dwarf2_fetch_die_loc_sect_off) (dwarf2_symbol_mark_computed, set_die_type): Update. * dwarf2/attribute.h (struct attribute) : Declare method. (attr_form_is_block): Don't declare. * dwarf2/attribute.c (attribute::form_is_block): Now a method. Change-Id: Idfb290c61d738301ab991666f43e0b9cf577b2ae --- gdb/ChangeLog | 13 +++++++++++++ gdb/dwarf2/attribute.c | 15 +++++++-------- gdb/dwarf2/attribute.h | 10 +++++----- gdb/dwarf2read.c | 40 ++++++++++++++++++++-------------------- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 6e51fff5362..6efff3e2c0a 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -59,15 +59,14 @@ attribute::value_as_address () const /* See attribute.h. */ -int -attr_form_is_block (const struct attribute *attr) +bool +attribute::form_is_block () const { - return (attr == NULL ? 0 : - attr->form == DW_FORM_block1 - || attr->form == DW_FORM_block2 - || attr->form == DW_FORM_block4 - || attr->form == DW_FORM_block - || attr->form == DW_FORM_exprloc); + return (form == DW_FORM_block1 + || form == DW_FORM_block2 + || form == DW_FORM_block4 + || form == DW_FORM_block + || form == DW_FORM_exprloc); } /* See attribute.h. */ diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 2e663f1560c..c2602310715 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -79,6 +79,11 @@ struct attribute bool form_is_ref () const; + /* Check if the attribute's form is a DW_FORM_block* + if so return true else false. */ + + bool form_is_block () const; + ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; @@ -110,9 +115,4 @@ struct attribute #define DW_ADDR(attr) ((attr)->u.addr) #define DW_SIGNATURE(attr) ((attr)->u.signature) -/* Check if the attribute's form is a DW_FORM_block* - if so return true else false. */ - -extern int attr_form_is_block (const struct attribute *attr); - #endif /* GDB_DWARF2_ATTRIBUTE_H */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 87b8aaaf679..d5fc8e294f1 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13738,9 +13738,9 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_abstract_origin, cu); } SET_FIELD_DWARF_BLOCK (call_site->target, NULL); - if (!attr || (attr_form_is_block (attr) && DW_BLOCK (attr)->size == 0)) + if (!attr || (attr->form_is_block () && DW_BLOCK (attr)->size == 0)) /* Keep NULL DWARF_BLOCK. */; - else if (attr_form_is_block (attr)) + else if (attr->form_is_block ()) { struct dwarf2_locexpr_baton *dlbaton; @@ -13846,7 +13846,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) parameter->u.param_cu_off = (cu_offset) (sect_off - cu->header.sect_off); } - else if (loc == NULL || origin != NULL || !attr_form_is_block (loc)) + else if (loc == NULL || origin != NULL || !loc->form_is_block ()) { complaint (_("No DW_FORM_block* DW_AT_location for " "DW_TAG_call_site child DIE %s [in module %s]"), @@ -13878,7 +13878,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (child_die, DW_AT_call_value, cu); if (attr == NULL) attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_value, cu); - if (!attr_form_is_block (attr)) + if (attr == NULL || !attr->form_is_block ()) { complaint (_("No DW_FORM_block* DW_AT_call_value for " "DW_TAG_call_site child DIE %s [in module %s]"), @@ -13899,7 +13899,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_data_value, cu); if (attr != nullptr) { - if (!attr_form_is_block (attr)) + if (!attr->form_is_block ()) complaint (_("No DW_FORM_block* DW_AT_call_data_value for " "DW_TAG_call_site child DIE %s [in module %s]"), sect_offset_str (child_die->sect_off), @@ -14672,7 +14672,7 @@ handle_data_member_location (struct die_info *die, struct dwarf2_cu *cu, *offset = dwarf2_get_attr_constant_value (attr, 0); else if (attr->form_is_section_offset ()) dwarf2_complex_location_expr_complaint (); - else if (attr_form_is_block (attr)) + else if (attr->form_is_block ()) *offset = decode_locdesc (DW_BLOCK (attr), cu); else dwarf2_complex_location_expr_complaint (); @@ -15250,7 +15250,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, attr = dwarf2_attr (die, DW_AT_vtable_elem_location, cu); if (attr != nullptr) { - if (attr_form_is_block (attr) && DW_BLOCK (attr)->size > 0) + if (attr->form_is_block () && DW_BLOCK (attr)->size > 0) { if (DW_BLOCK (attr)->data[0] == DW_OP_constu) { @@ -16461,8 +16461,8 @@ mark_common_block_symbol_computed (struct symbol *sym, LONGEST offset = 0; gdb_assert (common_loc && member_loc); - gdb_assert (attr_form_is_block (common_loc)); - gdb_assert (attr_form_is_block (member_loc) + gdb_assert (common_loc->form_is_block ()); + gdb_assert (member_loc->form_is_block () || member_loc->form_is_constant ()); baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); @@ -16523,7 +16523,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) if (attr != nullptr) { /* Support the .debug_loc offsets. */ - if (attr_form_is_block (attr)) + if (attr->form_is_block ()) { /* Ok. */ } @@ -16591,7 +16591,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu) if (member_loc->form_is_section_offset ()) dwarf2_complex_location_expr_complaint (); else if (member_loc->form_is_constant () - || attr_form_is_block (member_loc)) + || member_loc->form_is_block ()) { if (attr != nullptr) mark_common_block_symbol_computed (sym, die, attr, @@ -17575,7 +17575,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, if (attr == NULL || prop == NULL) return 0; - if (attr_form_is_block (attr)) + if (attr->form_is_block ()) { baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = default_type; @@ -17621,7 +17621,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, prop->kind = PROP_LOCLIST; gdb_assert (prop->data.baton != NULL); } - else if (attr_form_is_block (target_attr)) + else if (target_attr->form_is_block ()) { baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = die_type (target_die, target_cu); @@ -18531,7 +18531,7 @@ partial_die_info::read (const struct die_reader_specs *reader, break; case DW_AT_location: /* Support the .debug_loc offsets. */ - if (attr_form_is_block (&attr)) + if (attr.form_is_block ()) { d.locdesc = DW_BLOCK (&attr); } @@ -21174,7 +21174,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym, /* A DW_AT_location attribute with no contents indicates that a variable has been optimized away. */ - if (attr_form_is_block (attr) && DW_BLOCK (attr)->size == 0) + if (attr->form_is_block () && DW_BLOCK (attr)->size == 0) { SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT; return; @@ -21185,7 +21185,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym, specified. If this is just a DW_OP_addr, DW_OP_addrx, or DW_OP_GNU_addr_index then mark this symbol as LOC_STATIC. */ - if (attr_form_is_block (attr) + if (attr->form_is_block () && ((DW_BLOCK (attr)->data[0] == DW_OP_addr && DW_BLOCK (attr)->size == 1 + cu_header->addr_size) || ((DW_BLOCK (attr)->data[0] == DW_OP_GNU_addr_index @@ -23100,7 +23100,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, } else { - if (!attr_form_is_block (attr)) + if (!attr->form_is_block ()) error (_("Dwarf Error: DIE at %s referenced in module %s " "is neither DW_FORM_block* nor DW_FORM_exprloc"), sect_offset_str (sect_off), objfile_name (objfile)); @@ -24857,7 +24857,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); - if (attr_form_is_block (attr)) + if (attr->form_is_block ()) { /* Note that we're just copying the block's data pointer here, not the actual data. We're still pointing into the @@ -25257,7 +25257,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) /* Read DW_AT_allocated and set in type. */ attr = dwarf2_attr (die, DW_AT_allocated, cu); - if (attr_form_is_block (attr)) + if (attr != NULL && attr->form_is_block ()) { struct type *prop_type = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); @@ -25273,7 +25273,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) /* Read DW_AT_associated and set in type. */ attr = dwarf2_attr (die, DW_AT_associated, cu); - if (attr_form_is_block (attr)) + if (attr != NULL && attr->form_is_block ()) { struct type *prop_type = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);