From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OByJIiMzK2g2NyoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:33:23 -0400 Received: by simark.ca (Postfix, from userid 112) id 8B0391E11C; Mon, 19 May 2025 09:33:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D44A51E102 for ; Mon, 19 May 2025 09:33:22 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 885863857C6E for ; Mon, 19 May 2025 13:33:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 885863857C6E Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id B7DE23858408 for ; Mon, 19 May 2025 13:24:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7DE23858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B7DE23858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661083; cv=none; b=cT8cJ227myS+kTsr2mxgtSvWrNQu8qY5lJflikt8JOg7rxcTJ8AI09PhuIsOux3NZAgHaGjmb0uNjlWPdKighBd2COCvDa8Lkk16BeYvB/7Li5UJB/aF5pv5J8FO83e9i7tePVksMi1s44udZdLMYT5r3G0dZdNqwhQTxdZwm08= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661083; c=relaxed/simple; bh=i8MDkbmk4aJ4pRjBCrDi1b1Wc88XKxdNA1rRcZzZT88=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=jNwKzwGX0141aGNMZGELpxOijdXNT2py3/wz2jA8TOlYhbSA2nEWp58WXyaubO1mOFoWmunBgnhjRP0F2A858P7bBW7WsmOTxeS4E0ZAvT34G+45aNzoMkbS4TiIhxwdr5657mko+XFWTTmd9TRSHDQ+24euCXw0fktyhD+Tlgw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7DE23858408 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a3771c0f8cso138004f8f.3 for ; Mon, 19 May 2025 06:24:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661082; x=1748265882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jnd9Eq8D/T21jhXCYZ7G1iToSE67G24AlXd7qofeLoE=; b=YQcp0GaENEswc2nKTjUnSQl7oM2o3AtgAtn4a/Xqiw8omJmpJ1J7Y+AHbWnukj9uPx Mda3Czr4wqeyBDuXf7eZnVY6v75Y3XWweNbqvT/lMsYto2flfqxOZZLkow4vHhO268DR MBWMlsGuoqlMWJLr112DTGzezyRf85rPYooLZbnUNU3k5iBqAesrjyPyn/OJ19bqrjN3 R+06HCSLYrqk/Ak/Wvkt57UhzOxeMeS6tsopREYuM2wbt8hf+MAZTJ/5srTReo0jv/X7 Vm2ataxnjiO8mceuVqDf+lBKncWt2zEUdn9ewawtUVkQm1aw9SchfJMKaTHK5ID/cHW9 NcDw== X-Gm-Message-State: AOJu0YzaqdWTyf4dg4JZEwua9L+VJgJbvSTshchBROTQXEF08uH5WTa7 ANzrVyiA9Fr0tqZDULbm5SbnQcml9/4R20QFyNYSY7hIvW0RVP4Y57Rp+B29ptLX X-Gm-Gg: ASbGnctenDCmid6LlwUMlafrxfKe6DOjJcHb5niRjCZrAUydU4snzvik1nYJbdnimtK 10wNPlOXAOe8fGnnKfKrfMZvqjxYD46svZfNn5IJLA5aFj2meUSl8jBEw5rNXKhiuAk6GbXnHJi FIOd0THOhpZo6N8ofH9C1zGHvkeNVeMYSsCpxgje7EdtypxtY6GOi1QuoSyYlR5GX6kb2pFfo7L TTsB9bfeT1NooVAsDlMs6jrClE9j4WAbXLw9s2pXEE0o3G3wPg+xOO9IYvJf4rrrRYYly5BY9wW lUE1CTAKvFye3IP2+4XAXLr1SWPfGbi6pvMldJ28Ye0E+sISg7o= X-Google-Smtp-Source: AGHT+IGa4aXXQzt0M92VgWfITLEn6Bg4TpuCmMYceoyAsyG5te1tbCKe7Ttz8HrY6tPgmydsZP9XfQ== X-Received: by 2002:a05:6000:2908:b0:3a3:6c9e:1691 with SMTP id ffacd0b85a97d-3a36c9e17ffmr4210404f8f.53.1747661082362; Mon, 19 May 2025 06:24:42 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a361b04236sm11709438f8f.28.2025.05.19.06.24.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:24:41 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 29/47] Add backpointer from windows_thread_info to windows_process_info Date: Mon, 19 May 2025 14:22:50 +0100 Message-ID: <20250519132308.3553663-30-pedro@palves.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519132308.3553663-1-pedro@palves.net> References: <20250519132308.3553663-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org The next patch will move some duplicated code in gdb and gdbserver to gdb/nat/windows-nat.c, where it would be convenient to get at the Windows process info of a given Windows thread info, from within a windows_thread_info method. I first thought of passing down the windows_process_info pointer as argument to the windows_thread_info method, but that looked a bit odd. I think it looks better to just add a back pointer, so that's what this patch does. The following patch will then add a use of it. I suspect this will help moving more duplicated code to gdb/nat/windows-nat.c in the future, too. Approved-By: Tom Tromey Change-Id: I47fc0d3323be5b6f6fcfe912b768051a41910666 --- gdb/nat/windows-nat.h | 10 ++++++++-- gdb/windows-nat.c | 2 +- gdbserver/win32-low.cc | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 8da9ca6e78f..cba8098fb39 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -48,13 +48,16 @@ struct pending_stop target_waitstatus status; }; +struct windows_process_info; /* Thread information structure used to track extra information about each thread. */ struct windows_thread_info { - windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb) - : tid (tid_), + windows_thread_info (windows_process_info *proc_, + DWORD tid_, HANDLE h_, CORE_ADDR tlb) + : proc (proc_), + tid (tid_), h (h_), thread_local_base (tlb) { @@ -73,6 +76,9 @@ struct windows_thread_info the next call. */ const char *thread_name (); + /* The process this thread belongs to. */ + windows_process_info *const proc; + /* The Win32 thread identifier. */ DWORD tid; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 09c2d224fd0..1ced313d7b1 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -607,7 +607,7 @@ windows_nat_target::add_thread (ptid_t ptid, HANDLE h, void *tlb, if (windows_process.wow64_process) base += 0x2000; #endif - th = new windows_thread_info (ptid.lwp (), h, base); + th = new windows_thread_info (&windows_process, ptid.lwp (), h, base); windows_process.thread_list.emplace_back (th); /* Add this new thread to the list of threads. diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index c95ec112bf7..4e2d95bd059 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -149,7 +149,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) if (windows_process.wow64_process) base += 2 * 4096; /* page size = 4096 */ #endif - th = new windows_thread_info (tid, h, base); + th = new windows_thread_info (&windows_process, tid, h, base); find_process_pid (pid)->add_thread (ptid, th); -- 2.49.0