From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YbfVEsPW62m5UzkAWB0awg (envelope-from ) for ; Fri, 24 Apr 2026 16:46:59 -0400 Received: by simark.ca (Postfix, from userid 112) id 49F831E093; Fri, 24 Apr 2026 16:46:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 8CDF71E093 for ; Fri, 24 Apr 2026 16:46:58 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 2CF0B4B920BB for ; Fri, 24 Apr 2026 20:46:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CF0B4B920BB Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id 2228E4BB8F52 for ; Fri, 24 Apr 2026 20:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2228E4BB8F52 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 2228E4BB8F52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063579; cv=none; b=bea6aehdxGa/zfzOBXZT+tF7oljAIpKbvEgMU1vHZf0OlBXpAHd0mclCAZGiyc1CiX/MEMHKMUHBCTxqvM1Tm9GKbsxdRXJpgozpxxULBRq1a0zNcidOmGDl11PsL5VnMSSXqMFFz8eF6vrQFlu+w6EVTg3dfPLn1YN9Tt3vMgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063579; c=relaxed/simple; bh=6Zsfp6l+BvFAslr0ILZoNtjUYZX35tyEAj9sp1DVD/g=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=HGnDA8apGg7jruPAKow5HALg+EGUtqErsUh5mbK1okfIFNI71aBRr3RCADpePawm+SIkQgq9rWeG69VUckRBYcQtanvtJgJTKlrbkPkuck05/2+KWv2MAzJDWj2nvtfHXIKeslZTiL33G6d9N7XBtGbmHqHGjtw17LVtLt/DQ70= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2228E4BB8F52 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-43d70b3e159so4319321f8f.0 for ; Fri, 24 Apr 2026 13:46:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777063578; x=1777668378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pewkKIjOT6WW5+rZBTqTwIC8DE0KzmsglrGGyxUuozY=; b=SwwCAdXa90IShF2fQQKiK9Opyb3TOcCrGUx9AzaC7Lc1qUjUqyMypHGuNk7k3Elcow pH6Ae7k9frCHyTgvOjBFj1lffBVew7+jPXYBLzyaQg/LQOwZl2bBvoXlyMiOnHlzRj8J GEZXH16z4hikSSyf8S5zt10NXXctxxeOXHs9CE7Yz+jlg4cu1qBVBTXHI7dEjIJoaRYI 2SqL1DjewcamH1Tnmit1NFWc34TfC4eraFQG2/I5i+Lz1zktuA0t9mV/phN3f1fm2glt dOVSYvIN26vz4kl2bCGVCAD9tPNhL2DFEm+Nz76SNd5ivNlP70qODnE+zIkdsn9Y8NK3 vJmg== X-Gm-Message-State: AOJu0YypY8ETIyn7shZxGXLKR/PA2DnvcA3U0Y0pvx1mk9dQhhVIg9tK vveusjBtKFdtALYPbibICjvS9A/C1uSI4Tubu3qhV4XKUoQokGfTNauwHNg3k5nv X-Gm-Gg: AeBDiesBBppkELOnhfb/2qQwbjIRNqyARhMUzObbLyW52DwfhOYENzUuZvTuPJLgyOP ihVYJVVI4rWH9TVgCkdAow2HUOVlc2lXwISseYSVcFyejbIcnV2qJamJjvE9+wveNc9z35809WU 2LWHAj8ZX3UHickhbwUnwvT87FakfcLK+M4cIDfUfR9MHiMCY2Yd9znHhGaQPcvkTNxhuMQBXXh /E1yUfemTWkimZ/8pfXPWiSrIQ5rZbtga9NKBECJDbyIGwRgMGY29NtzfU7H+f96PVCI40vNFc0 40NPaTGBr5yn+qsQOer2uMdVeoHgYS4hzfJ1C2EI7N/R52fH+ZEOYZwGvI4MpbPksNIy4te02s9 n2R27Wn5L/IlNs3krarzFkDzQPhAoNAVwmKw+AUJ7wtR4pBGoKl1QikRksfy1SNlLNydJ0XzEb1 6bf57c11rtpAIYgKqbaVzqgJEbqFxYIDhe X-Received: by 2002:a05:600c:3b11:b0:48a:525b:e148 with SMTP id 5b1f17b1804b1-48a525be2f8mr275412495e9.4.1777063577702; Fri, 24 Apr 2026 13:46:17 -0700 (PDT) Received: from localhost ([2001:8a0:facb:a800:7315:8865:c664:fc06]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-488fc1c773fsm694647335e9.12.2026.04.24.13.46.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2026 13:46:17 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed 22/28] Add backpointer from windows_thread_info to windows_process_info Date: Fri, 24 Apr 2026 21:45:02 +0100 Message-ID: <20260424204508.1343973-23-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424204508.1343973-1-pedro@palves.net> References: <20260424204508.1343973-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 152410580f0..59662c3570c 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 1593524f900..143a5e487fd 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -322,7 +322,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 cc4a63319ef..bf3490542e2 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -144,7 +144,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.53.0