From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 30F1C3858D20 for ; Sun, 14 Jan 2024 18:31:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30F1C3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 30F1C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705257072; cv=none; b=FFNWMcrSqpSzbhemAdMWM81MKUZ1K5tR0L6F5vv+Ai8WVPaAEklhUTn8hHu3BepVSEAy9visdmj7JnxNohkBni+rhgO2JMkOQqLNYXdQxSaPYZwzIEVFsNKwviI6pjH+jwSKQptPC6avlIOt+BIsUXjT60jCDC/0P26JW/1e4wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705257072; c=relaxed/simple; bh=47/xNefMaAlkb6dtEQAAMr7J8Z12ZzF0SE6HKmT9vX8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SDK5kjdFgDrNOlCU0lUSGS7MksN8OvAosFcr742n/odiaaWfDiNqZUv+GNIPyuX1UX+BH287Y8Wbic/sN1LXBEOP7Ih5XIRPLheNDsaTMdDrLxTJkBH3z21JBmA4B77A+aQePnYQxG41r3dCrS7b05gOBKxwhVW1Gfk5kLLNwbw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTPS id P2kpr26gF9gG6P5GGry0K6; Sun, 14 Jan 2024 18:31:08 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id P5GFrRyNyl5UwP5GFrO4pG; Sun, 14 Jan 2024 18:31:07 +0000 X-Authority-Analysis: v=2.4 cv=daKTYFbe c=1 sm=1 tr=0 ts=65a4286b a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=voXJnQw4ZPHvn1KXWEMA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KV30C2cxx68EmvFYdq0/fhduHAhlRw1062VOEmfB+MY=; b=oDSpD5XZYDkukLGJI89g0LtcEh Q77Zm8bTRAExO7WeBCVaBMHBIMDTLnTsztnxFWw8Jr1B6+9KCCMW/ICHNuTEEjo4eVaruxJ92dVOP z3Vy2vmx7HF8qMRDisF+Nd+rs; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:35294 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rP5GE-001TzR-2T; Sun, 14 Jan 2024 11:31:06 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove addrmap_fixed::set_entry Date: Sun, 14 Jan 2024 11:30:56 -0700 Message-ID: <20240114183056.1999705-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.122.68.157 X-Source-L: No X-Exim-ID: 1rP5GE-001TzR-2T X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net (localhost.localdomain) [97.122.68.157]:35294 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCB+7AjXk9TVi4mIzEAqWzTSECJ+DixK0l8IR+Df+paIcejB1tIXyLwSOnoRIC97pyGsz1oH4OA8e7449GiETl8ZJjMiS3YAJ6WfWbmuLpICf/AanE8c GGXm0J63j2ooDWf+rhOTLBoFvDzfiZ+GuoD0wowuKR8Zo/jjd+HFmcMFM30F/o0a+8cvPUH+vhiSgp4dry8TsPdXUm4BEd2AXQs= X-Spam-Status: No, score=-3022.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: It occurred to me that there is no reason for addrmap_fixed::set_entry to exist. This patch removes it and removes the abstract virtual function from the base class. This then required a few minor changes in the DWARF reader. I consider this a type-safety improvement. Tested by rebuilding. --- gdb/addrmap.c | 9 ----- gdb/addrmap.h | 81 +++++++++++++++++++++----------------------- gdb/dwarf2/aranges.c | 2 +- gdb/dwarf2/aranges.h | 4 +-- gdb/dwarf2/read.c | 8 ++--- 5 files changed, 45 insertions(+), 59 deletions(-) diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 2753f85e0a6..162ab84763b 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -30,15 +30,6 @@ static_assert (sizeof (splay_tree_value) >= sizeof (void *)); /* Fixed address maps. */ -void -addrmap_fixed::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, - void *obj) -{ - internal_error ("addrmap_fixed_set_empty: " - "fixed addrmaps can't be changed\n"); -} - - void * addrmap_fixed::do_find (CORE_ADDR addr) const { diff --git a/gdb/addrmap.h b/gdb/addrmap.h index c6417169443..ba83607ad8c 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -46,46 +46,6 @@ struct addrmap { virtual ~addrmap () = default; - /* In the mutable address map MAP, associate the addresses from START - to END_INCLUSIVE that are currently associated with NULL with OBJ - instead. Addresses mapped to an object other than NULL are left - unchanged. - - As the name suggests, END_INCLUSIVE is also mapped to OBJ. This - convention is unusual, but it allows callers to accurately specify - ranges that abut the top of the address space, and ranges that - cover the entire address space. - - This operation seems a bit complicated for a primitive: if it's - needed, why not just have a simpler primitive operation that sets a - range to a value, wiping out whatever was there before, and then - let the caller construct more complicated operations from that, - along with some others for traversal? - - It turns out this is the mutation operation we want to use all the - time, at least for now. Our immediate use for address maps is to - represent lexical blocks whose address ranges are not contiguous. - We walk the tree of lexical blocks present in the debug info, and - only create 'struct block' objects after we've traversed all a - block's children. If a lexical block declares no local variables - (and isn't the lexical block for a function's body), we omit it - from GDB's data structures entirely. - - However, this means that we don't decide to create a block (and - thus record it in the address map) until after we've traversed its - children. If we do decide to create the block, we do so at a time - when all its children have already been recorded in the map. So - this operation --- change only those addresses left unset --- is - actually the operation we want to use every time. - - It seems simpler to let the code which operates on the - representation directly deal with the hair of implementing these - semantics than to provide an interface which allows it to be - implemented efficiently, but doesn't reveal too much of the - representation. */ - virtual void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, - void *obj) = 0; - /* Return the object associated with ADDR in MAP. */ const void *find (CORE_ADDR addr) const { return this->do_find (addr); } @@ -127,8 +87,6 @@ struct addrmap_fixed : public addrmap, addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut); DISABLE_COPY_AND_ASSIGN (addrmap_fixed); - void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, - void *obj) override; void relocate (CORE_ADDR offset) override; private: @@ -165,8 +123,45 @@ struct addrmap_mutable : public addrmap ~addrmap_mutable (); DISABLE_COPY_AND_ASSIGN (addrmap_mutable); + /* In the mutable address map MAP, associate the addresses from START + to END_INCLUSIVE that are currently associated with NULL with OBJ + instead. Addresses mapped to an object other than NULL are left + unchanged. + + As the name suggests, END_INCLUSIVE is also mapped to OBJ. This + convention is unusual, but it allows callers to accurately specify + ranges that abut the top of the address space, and ranges that + cover the entire address space. + + This operation seems a bit complicated for a primitive: if it's + needed, why not just have a simpler primitive operation that sets a + range to a value, wiping out whatever was there before, and then + let the caller construct more complicated operations from that, + along with some others for traversal? + + It turns out this is the mutation operation we want to use all the + time, at least for now. Our immediate use for address maps is to + represent lexical blocks whose address ranges are not contiguous. + We walk the tree of lexical blocks present in the debug info, and + only create 'struct block' objects after we've traversed all a + block's children. If a lexical block declares no local variables + (and isn't the lexical block for a function's body), we omit it + from GDB's data structures entirely. + + However, this means that we don't decide to create a block (and + thus record it in the address map) until after we've traversed its + children. If we do decide to create the block, we do so at a time + when all its children have already been recorded in the map. So + this operation --- change only those addresses left unset --- is + actually the operation we want to use every time. + + It seems simpler to let the code which operates on the + representation directly deal with the hair of implementing these + semantics than to provide an interface which allows it to be + implemented efficiently, but doesn't reveal too much of the + representation. */ void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, - void *obj) override; + void *obj); void relocate (CORE_ADDR offset) override; private: diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c index 0a4ae63801d..4287a5a884b 100644 --- a/gdb/dwarf2/aranges.c +++ b/gdb/dwarf2/aranges.c @@ -26,7 +26,7 @@ bool read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, dwarf2_section_info *section, - addrmap *mutable_map, + addrmap_mutable *mutable_map, deferred_warnings *warn) { /* Caller must ensure that the section has already been read. */ diff --git a/gdb/dwarf2/aranges.h b/gdb/dwarf2/aranges.h index d923e2d4905..2ba8a05620d 100644 --- a/gdb/dwarf2/aranges.h +++ b/gdb/dwarf2/aranges.h @@ -22,7 +22,7 @@ class dwarf2_per_objfile; class dwarf2_section_info; -class addrmap; +class addrmap_mutable; /* Read the address map data from DWARF-5 .debug_aranges, and use it to populate given addrmap. Returns true on success, false on @@ -30,7 +30,7 @@ class addrmap; extern bool read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, dwarf2_section_info *section, - addrmap *mutable_map, + addrmap_mutable *mutable_map, deferred_warnings *warn); #endif /* GDB_DWARF2_ARANGES_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a50248c4d56..1b5e566bb01 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -907,7 +907,7 @@ static enum pc_bounds_kind dwarf2_get_pc_bounds (struct die_info *, unrelocated_addr *, unrelocated_addr *, struct dwarf2_cu *, - addrmap *, + addrmap_mutable *, void *); static void get_scope_pc_bounds (struct die_info *, @@ -11013,7 +11013,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, static int dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return, unrelocated_addr *high_return, struct dwarf2_cu *cu, - addrmap *map, void *datum, dwarf_tag tag) + addrmap_mutable *map, void *datum, dwarf_tag tag) { dwarf2_per_objfile *per_objfile = cu->per_objfile; int low_set = 0; @@ -11123,7 +11123,7 @@ dwarf2_get_pc_bounds_entry_point (die_info *die, unrelocated_addr *low, static pc_bounds_kind dwarf_get_pc_bounds_ranges_or_highlow_pc (die_info *die, unrelocated_addr *low, unrelocated_addr *high, dwarf2_cu *cu, - addrmap *map, void *datum) + addrmap_mutable *map, void *datum) { gdb_assert (low != nullptr); gdb_assert (high != nullptr); @@ -11192,7 +11192,7 @@ dwarf_get_pc_bounds_ranges_or_highlow_pc (die_info *die, unrelocated_addr *low, static enum pc_bounds_kind dwarf2_get_pc_bounds (struct die_info *die, unrelocated_addr *lowpc, unrelocated_addr *highpc, struct dwarf2_cu *cu, - addrmap *map, void *datum) + addrmap_mutable *map, void *datum) { dwarf2_per_objfile *per_objfile = cu->per_objfile; -- 2.43.0