From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway36.websitewelcome.com (gateway36.websitewelcome.com [192.185.199.121]) by sourceware.org (Postfix) with ESMTPS id B035D385E038 for ; Sat, 28 Mar 2020 19:22:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B035D385E038 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 cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway36.websitewelcome.com (Postfix) with ESMTP id D4D6E40342DC2 for ; Sat, 28 Mar 2020 13:38:46 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH25jhU96VQh0IH25juv3N; Sat, 28 Mar 2020 14:22:13 -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=MUN+B6hSvHbyEiCNlXjfd/2TwGTKtk7bEnLqLeLCZ+Y=; b=sY6YrZs1SdbHhz6zVp8Oz/pqFa jQ0W5lY3d43IvIj7k/OnUQl0HX6bT/dWxogy+O5mPJxayrqYND5vVHJguM391wAIYb3f28zf7PShi CGOfcZMO820gATI95Ued5ZmPV; 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 1jIH25-003oZR-5a; Sat, 28 Mar 2020 13:22:13 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 15/20] Add attribute::get_unsigned method Date: Sat, 28 Mar 2020 13:22:03 -0600 Message-Id: <20200328192208.11324-16-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: 1jIH25-003oZR-5a 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: 18 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-21.3 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, 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:16 -0000 This introduces a new attribute::get_unsigned method and changes a few spots to use it. gdb/ChangeLog 2020-03-28 Tom Tromey * dwarf2/read.c (dw2_get_file_names_reader) (dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list) (dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton) (dwarf2_symbol_mark_computed): Use get_unsigned. * dwarf2/attribute.h (struct attribute) : New method. : Update comment. --- gdb/ChangeLog | 10 ++++++++++ gdb/dwarf2/attribute.h | 11 ++++++++++- gdb/dwarf2/read.c | 22 +++++++++++----------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 9b387e5df05..546156283b3 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -82,9 +82,18 @@ struct attribute return u.unsnd; } + /* Return the unsigned value. Requires that the form be an unsigned + form, and that reprocessing not be needed. */ + ULONGEST get_unsigned () const + { + gdb_assert (form_is_unsigned ()); + gdb_assert (!requires_reprocessing); + return u.unsnd; + } + /* Return non-zero if ATTR's value is a section offset --- classes lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. - You may use DW_UNSND (attr) to retrieve such offsets. + You may use the get_unsigned method to retrieve such offsets. Section 7.5.4, "Attribute Encodings", explains that no attribute may have a value that belongs to more than one of these classes; it diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index efa59fcab4d..abeb0e1a4e9 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3046,11 +3046,11 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, sect_offset line_offset {}; attr = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, cu); - if (attr != nullptr) + if (attr != nullptr && attr->form_is_unsigned ()) { struct quick_file_names find_entry; - line_offset = (sect_offset) DW_UNSND (attr); + line_offset = (sect_offset) attr->get_unsigned (); /* We may have already read in this line header (TU line header sharing). If we have we're done. */ @@ -5892,8 +5892,8 @@ dwarf2_build_include_psymtabs (struct dwarf2_cu *cu, struct attribute *attr; attr = dwarf2_attr (die, DW_AT_stmt_list, cu); - if (attr != nullptr) - lh = dwarf_decode_line_header ((sect_offset) DW_UNSND (attr), cu); + if (attr != nullptr && attr->form_is_unsigned ()) + lh = dwarf_decode_line_header ((sect_offset) attr->get_unsigned (), cu); if (lh == NULL) return; /* No linetable, so no includes. */ @@ -10560,10 +10560,10 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, gdb_assert (! cu->per_cu->is_debug_types); attr = dwarf2_attr (die, DW_AT_stmt_list, cu); - if (attr == NULL) + if (attr == NULL || !attr->form_is_unsigned ()) return; - sect_offset line_offset = (sect_offset) DW_UNSND (attr); + sect_offset line_offset = (sect_offset) attr->get_unsigned (); /* The line header hash table is only created if needed (it exists to prevent redundant reading of the line table for partial_units). @@ -10752,9 +10752,9 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) /* We have to handle the case of both a missing DW_AT_stmt_list or bad debug info. */ line_header_up lh; - if (attr != NULL) + if (attr != NULL && attr->form_is_unsigned ()) { - sect_offset line_offset = (sect_offset) DW_UNSND (attr); + sect_offset line_offset = (sect_offset) attr->get_unsigned (); lh = dwarf_decode_line_header (line_offset, this); } if (lh == NULL) @@ -22526,8 +22526,8 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, gdb_assert (baton->per_cu); /* We don't know how long the location list is, but make sure we don't run off the edge of the section. */ - baton->size = section->size - DW_UNSND (attr); - baton->data = section->buffer + DW_UNSND (attr); + baton->size = section->size - attr->get_unsigned (); + baton->data = section->buffer + attr->get_unsigned (); if (cu->base_address.has_value ()) baton->base_address = *cu->base_address; else @@ -22548,7 +22548,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, /* .debug_loc{,.dwo} may not exist at all, or the offset may be outside the section. If so, fall through to the complaint in the other branch. */ - && DW_UNSND (attr) < section->get_size (objfile)) + && attr->get_unsigned () < section->get_size (objfile)) { struct dwarf2_loclist_baton *baton; -- 2.17.2