From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fCgpKyVXCWE4cgAAWB0awg (envelope-from ) for ; Tue, 03 Aug 2021 10:48:05 -0400 Received: by simark.ca (Postfix, from userid 112) id A0B7D1EDFB; Tue, 3 Aug 2021 10:48:05 -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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 DB6411E4A3 for ; Tue, 3 Aug 2021 10:48:03 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B5093959C34 for ; Tue, 3 Aug 2021 14:48:03 +0000 (GMT) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 635F23955416 for ; Tue, 3 Aug 2021 14:47:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 635F23955416 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7D0CD20032 for ; Tue, 3 Aug 2021 14:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1628002020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=VhkPqF/C0idtVSari1IGHnfqibuRNErOZox0N0IVVK4=; b=gBKVlfqugiCeTGKDpVgC9YtzZe9vjPl9bEzNBGz8leO1gP321dGxFKj27a4+AMZ0BWML+L htR4QUMCLPSg/1MGP2tfUZSZToixsFJIuBVBXN7K6Z4hLO840vYze/wwmNBu0+G29GUPS3 bhEHmQKECrVkWIas2LDD1+Sery2VBl8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1628002020; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=VhkPqF/C0idtVSari1IGHnfqibuRNErOZox0N0IVVK4=; b=zx1G8FTX//51O//uaetblL9/wMLe1CVyUMEJXg6dfzQ8MVx/j9VL1Q5tL6LT1IbGjkp1VR wgDRKkvSJjqrIUAg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 6A96313B74 for ; Tue, 3 Aug 2021 14:47:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id FIXwGORWCWFjbAAAGKfGzw (envelope-from ) for ; Tue, 03 Aug 2021 14:47:00 +0000 Date: Tue, 3 Aug 2021 16:46:58 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Implement addrmap_mutable_find Message-ID: <20210803144656.GA8040@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, Currently addrmap_mutable_find is not implemented: ... static void * addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr) { /* Not needed yet. */ internal_error (__FILE__, __LINE__, _("addrmap_find is not implemented yet " "for mutable addrmaps")); } ... I implemented this because I needed this during debugging, to be able to do: ... (gdb) p ((dwarf2_psymtab *)addrmap_find (map, addr))->filename ... before and after a call to addrmap_set_empty. Rebuild on x86_64-linux, tested by using it during debugging session. Any comments? Thanks, - Tom [gdb/symtab] Implement addrmap_mutable_find gdb/ChangeLog: 2021-08-03 Tom de Vries * addrmap.c (addrmap_mutable_find): Implement. --- gdb/addrmap.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 9bd924e8382..1df20076be8 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -390,10 +390,22 @@ addrmap_mutable_set_empty (struct addrmap *self, static void * addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr) { - /* Not needed yet. */ - internal_error (__FILE__, __LINE__, - _("addrmap_find is not implemented yet " - "for mutable addrmaps")); + struct addrmap_mutable *map = (struct addrmap_mutable *) self; + splay_tree_node n = addrmap_splay_tree_lookup (map, addr); + if (n != nullptr) + { + gdb_assert (addrmap_node_key (n) == addr); + return addrmap_node_value (n); + } + + n = addrmap_splay_tree_predecessor (map, addr); + if (n != nullptr) + { + gdb_assert (addrmap_node_key (n) < addr); + return addrmap_node_value (n); + } + + return nullptr; }