From patchwork Fri Nov 17 21:01:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 80186 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B235E3858416 for ; Fri, 17 Nov 2023 21:02:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C3FE43858D28 for ; Fri, 17 Nov 2023 21:01:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3FE43858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C3FE43858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700254912; cv=none; b=DDrMqXSwbBYN/HuZBTv0nGH80eMiNHIqRh+njG3Rpgv5ew9zjDCpNBPqKPpXXYQJtovP3Hpjo4K541s+XE8GLbVlZDYWw8tog9BnDw0ushabWtmVORzRLiEwz+wD9vuIdkLIUSK7IZcYyVkfRW98sGZWEftAUy1qE5jNdrOrdRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700254912; c=relaxed/simple; bh=HREcpiL9jfH7iaODkJtpR0xGFetxv90+Vi3jpC0Rc7U=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Z7cgBe6OtwZuzCB41/P3YaiU1uM0bSSTSW1dwxAiCmLhL4N5IMa/xeFaKUroZGRrTJIoI/tuCONkktk4yskk601vjvP0c8/JogRqldCM27QzupWv8g0KOpIFRsq7G0H7f66bVk+VHAtypzR7/7jYOGsQKZe8hy8KjcbdmVFgrns= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9409E1E00F; Fri, 17 Nov 2023 16:01:48 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: remove address space numbers Date: Fri, 17 Nov 2023 16:01:37 -0500 Message-ID: <20231117210138.10925-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1173.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org highest_address_space_num is reset when connecting to a remote target (init_address_spaces is called by update_address_spaces, which is called by remote_target::start_remote_1). This can result in potentially non-unique address space numbers if, let's say, you connect to a remote target while already debugging something natively. The address space number concept is not used, except when printing an address space in target-debug.h. A fix would be to make the highest_address_space_num counter per-process target, or just never reset the counter. But since it's not useful, I think it's better just to remove it, and rely on the pointer value if we need a unique identifier, since that simplifies the code. Change-Id: I643f3a070e29c7bc12a2e874219b522a1ddad252 --- gdb/progspace.c | 24 ------------------------ gdb/progspace.h | 12 +----------- gdb/target-debug.h | 2 +- 3 files changed, 2 insertions(+), 36 deletions(-) base-commit: 413366203156a0483d06a97b3f02b64ba6a215cc diff --git a/gdb/progspace.c b/gdb/progspace.c index 839707e9d71f..517677ad1a7a 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -39,18 +39,6 @@ std::vector program_spaces; /* Pointer to the current program space. */ struct program_space *current_program_space; -/* The last address space number assigned. */ -static int highest_address_space_num; - - - -/* Create a new address space object, and add it to the list. */ - -address_space::address_space () - : m_num (++highest_address_space_num) -{ -} - /* Maybe create a new address space object, and add it to the list, or return a pointer to an existing address space, in case inferiors share an address space on this target system. */ @@ -70,16 +58,6 @@ maybe_new_address_space (void) return new address_space (); } -/* Start counting over from scratch. */ - -static void -init_address_spaces (void) -{ - highest_address_space_num = 0; -} - - - /* Remove a program space from the program spaces list. */ static void @@ -407,8 +385,6 @@ update_address_spaces (void) int shared_aspace = gdbarch_has_shared_address_space (current_inferior ()->arch ()); - init_address_spaces (); - if (shared_aspace) { struct address_space *aspace = new address_space (); diff --git a/gdb/progspace.h b/gdb/progspace.h index a22e427400e9..0e3cefd66400 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -386,21 +386,11 @@ struct program_space associating caches to each address space. */ struct address_space { - /* Create a new address space object, and add it to the list. */ - address_space (); + address_space () = default; DISABLE_COPY_AND_ASSIGN (address_space); - /* Returns the integer address space id of this address space. */ - int num () const - { - return m_num; - } - /* Per aspace data-pointers required by other GDB modules. */ registry registry_fields; - -private: - int m_num; }; /* The list of all program spaces. There's always at least one. */ diff --git a/gdb/target-debug.h b/gdb/target-debug.h index 431f99ed3b1d..15977c0901d6 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -89,7 +89,7 @@ #define target_debug_print_LONGEST_p(X) \ target_debug_do_print (phex (*(X), 0)) #define target_debug_print_address_space_p(X) \ - target_debug_do_print (plongest ((X)->num ())) + target_debug_do_print (host_address_to_string (X)) #define target_debug_print_bp_target_info_p(X) \ target_debug_do_print (core_addr_to_string ((X)->placed_address)) #define target_debug_print_expression_p(X) \