From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 5A6DD3858C53 for ; Thu, 9 Nov 2023 14:59:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A6DD3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5A6DD3858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699541942; cv=none; b=oSJ0iOtRkxTxpuAkoO9x/TFqnnDQnZSPnbVuphypqyYINjA9CV6B8RNLVeaEtEX5GTyJ2KBVCJ8/OPoAAmMdaY9TML6+mcKshClwmvyQIMg9SpF+40Nv7UuyhyTP6fgwe0M2tajK4UlkkqXiwMOVSKLjPVGNKezx7aBCgAlPTzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699541942; c=relaxed/simple; bh=kgLeS7eyk9tqWUOSi13hrxxrM/M6EQ3ec78iFA2tYkU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=glFVrrtCA8GkN0hdT8+pgL8KMHXzV3lRNKapF9mjFqFj039Nc1qsXE+PJVzShm6ixD4/fTsm0tx+ZIWoDYs0DNSBBhCcEVTU2znmpopb8Fr1CQYSSi1gcX0ZW3EhOXD/bmAlE2HQNrYRImzvOUEZgsFaacNuML20XUg8a9yIPl4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (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 905B11F8B8 for ; Thu, 9 Nov 2023 14:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699541940; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+KCIkPDCzk4/5Jt1paXFGZR4Y4zh9FSNCqLNtVAZLOQ=; b=Sbu4dMzwkDzoDbdjaD/UEfWiCtJLA8mSdbLhglZgI6Wy3nUptmYcLxNO7cboji2Lm4o0tv 7ZylAPkxq33dkMdhpRQB/x4qyHTPCfONrNqcXUMUCaFs81mtdgWTkeKTlPX4GpYEFEHPZe UbhRZRyYTptvt5v/InHm/bQflLYHb44= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699541940; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+KCIkPDCzk4/5Jt1paXFGZR4Y4zh9FSNCqLNtVAZLOQ=; b=AgkvKqEVu7XCJYA3hyTSy2UlTNBcC/54V19rFSbiPqi3i+ANzVA9zzjrrIVlMrmyzg4Rka UiWIVZk4Io0AexDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (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 imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7FD4013524 for ; Thu, 9 Nov 2023 14:59:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YPZEHrTzTGWHfAAAMHmgww (envelope-from ) for ; Thu, 09 Nov 2023 14:59:00 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v3 2/3] [gdb] Eliminate local var pspace in inferior.c Date: Thu, 9 Nov 2023 16:00:20 +0100 Message-Id: <20231109150021.5504-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231109150021.5504-1-tdevries@suse.de> References: <20231109150021.5504-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Eliminate local var pspace from functions add_inferior_with_spaces and clone_inferior_command. This interchanges the order of the new program space / new inferior events. Update test-case gdb.python/py-progspace-events.exp to reflect that. Tested on top of trunk on x86_64-linux and ppc64le-linux. Tested on top of gdb-14-branch on ppc64-linux. Suggested-By: Simon Marchi --- gdb/inferior.c | 20 +++++++------------ .../gdb.python/py-progspace-events.exp | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index 37b4fad6e44..e0c5567579f 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -843,16 +843,13 @@ remove_inferior_command (const char *args, int from_tty) struct inferior * add_inferior_with_spaces (void) { - struct program_space *pspace; - struct inferior *inf; + struct inferior *inf = add_inferior (0); /* If all inferiors share an address space on this system, this doesn't really return a new address space; otherwise, it really does. */ - pspace = new program_space (maybe_new_address_space ()); - inf = add_inferior (0); - inf->pspace = pspace; - inf->aspace = pspace->aspace; + inf->pspace = new program_space (maybe_new_address_space ()); + inf->aspace = inf->pspace->aspace; /* Setup the inferior's initial arch, based on information obtained from the global "set ..." options. */ @@ -1012,16 +1009,13 @@ clone_inferior_command (const char *args, int from_tty) for (i = 0; i < copies; ++i) { - struct program_space *pspace; - struct inferior *inf; + struct inferior *inf = add_inferior (0); /* If all inferiors share an address space on this system, this doesn't really return a new address space; otherwise, it really does. */ - pspace = new program_space (maybe_new_address_space ()); - inf = add_inferior (0); - inf->pspace = pspace; - inf->aspace = pspace->aspace; + inf->pspace = new program_space (maybe_new_address_space ()); + inf->aspace = inf->pspace->aspace; inf->set_arch (orginf->arch ()); switch_to_inferior_and_push_target (inf, no_connection, orginf); @@ -1031,7 +1025,7 @@ clone_inferior_command (const char *args, int from_tty) if (inf->tdesc_info.from_user_p ()) inf->tdesc_info = orginf->tdesc_info; - clone_program_space (pspace, orginf->pspace); + clone_program_space (inf->pspace, orginf->pspace); /* Copy properties from the original inferior to the new one. */ inf->set_args (orginf->args ()); diff --git a/gdb/testsuite/gdb.python/py-progspace-events.exp b/gdb/testsuite/gdb.python/py-progspace-events.exp index 60ae290c0b2..fb3e3e86899 100644 --- a/gdb/testsuite/gdb.python/py-progspace-events.exp +++ b/gdb/testsuite/gdb.python/py-progspace-events.exp @@ -118,8 +118,8 @@ gdb_continue_to_end # manually added and removed. gdb_test "add-inferior" \ [multi_line \ - "^NewProgspaceEvent: " \ - "\\\[New inferior 3\\\]" \ + "^\\\[New inferior 3\\\]" \ + "NewProgspaceEvent: " \ "Added inferior 3\[^\r\n\]*"] gdb_test "remove-inferior 3" \ "^FreeProgspaceEvent: " -- 2.35.3