From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4N7OOtsIjl+ERwAAWB0awg (envelope-from ) for ; Mon, 19 Oct 2020 17:44:59 -0400 Received: by simark.ca (Postfix, from userid 112) id EF0061EFBF; Mon, 19 Oct 2020 17:44:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6C4061EFBB for ; Mon, 19 Oct 2020 17:44:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 557E8388EC00; Mon, 19 Oct 2020 21:44:43 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id 3056C388EC04 for ; Mon, 19 Oct 2020 21:44:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3056C388EC04 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 gateway33.websitewelcome.com (Postfix) with ESMTP id 513E21269611 for ; Mon, 19 Oct 2020 16:44:32 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id UcxEkUB7aXp2AUcxEkGAJv; Mon, 19 Oct 2020 16:44:32 -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=tzWVt1+gX6rA/ohkeFzAjGPB88sv4GXuJK6X3zlGNJ0=; b=jw5TCbGkWQf7nla/RlfzRrFZp+ yoStX487fBvCqTLmkBXzv1b/ZsYM4tCP1Llyd5IrHOzJoJpuJji7Ea1IRTaWl09BFfkXSx5WDwDCd o/j8eC/Yn0rgQOkz/QyIZd6xy; Received: from 75-166-102-113.hlrn.qwest.net ([75.166.102.113]:45712 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kUcxE-004Oci-DI; Mon, 19 Oct 2020 15:44:32 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH v2 01/16] Add target_section constructor Date: Mon, 19 Oct 2020 15:44:14 -0600 Message-Id: <20201019214429.13815-2-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20201019214429.13815-1-tom@tromey.com> References: <20201019214429.13815-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: 75.166.102.113 X-Source-L: No X-Exim-ID: 1kUcxE-004Oci-DI X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-102-113.hlrn.qwest.net (bapiya.Home) [75.166.102.113]:45712 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This adds a constructor to target_section, simplifying the code that creates instances of this. gdb/ChangeLog 2020-10-19 Tom Tromey * target-section.h (struct target_section): Add constructor. * exec.c (build_section_table, add_target_sections_of_objfile): Update. * corelow.c (core_target::build_file_mappings): Update. --- gdb/ChangeLog | 7 +++++++ gdb/corelow.c | 7 +------ gdb/exec.c | 18 ++++++------------ gdb/target-section.h | 9 +++++++++ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index d557475e06f..d73cc5b4b14 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -266,12 +266,7 @@ core_target::build_file_mappings () bfd_set_section_alignment (sec, 2); /* Set target_section fields. */ - m_core_file_mappings.emplace_back (); - target_section &ts = m_core_file_mappings.back (); - ts.addr = start; - ts.endaddr = end; - ts.owner = nullptr; - ts.the_bfd_section = sec; + m_core_file_mappings.emplace_back (start, end, sec); }); normalize_mem_ranges (&m_core_unavailable_mappings); diff --git a/gdb/exec.c b/gdb/exec.c index dd322129139..0646a4df89b 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -598,12 +598,9 @@ build_section_table (struct bfd *some_bfd) if (!(aflag & SEC_ALLOC)) continue; - table.emplace_back (); - target_section § = table.back (); - sect.owner = NULL; - sect.the_bfd_section = asect; - sect.addr = bfd_section_vma (asect); - sect.endaddr = sect.addr + bfd_section_size (asect); + table.emplace_back (bfd_section_vma (asect), + bfd_section_vma (asect) + bfd_section_size (asect), + asect); } return table; @@ -662,12 +659,9 @@ add_target_sections_of_objfile (struct objfile *objfile) if (bfd_section_size (osect->the_bfd_section) == 0) continue; - table->emplace_back (); - target_section &ts = table->back (); - ts.addr = obj_section_addr (osect); - ts.endaddr = obj_section_endaddr (osect); - ts.the_bfd_section = osect->the_bfd_section; - ts.owner = (void *) objfile; + table->emplace_back (obj_section_addr (osect), + obj_section_endaddr (osect), + osect->the_bfd_section, (void *) objfile); } } diff --git a/gdb/target-section.h b/gdb/target-section.h index ec6932da0a6..b19bcf9e997 100644 --- a/gdb/target-section.h +++ b/gdb/target-section.h @@ -26,6 +26,15 @@ struct target_section { + target_section (CORE_ADDR addr_, CORE_ADDR end_, struct bfd_section *sect_, + void *owner_ = nullptr) + : addr (addr_), + endaddr (end_), + the_bfd_section (sect_), + owner (owner_) + { + } + /* Lowest address in section. */ CORE_ADDR addr; /* Highest address in section, plus 1. */ -- 2.17.2