From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by sourceware.org (Postfix) with ESMTPS id DBFBC38460B2 for ; Tue, 7 May 2024 23:44:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBFBC38460B2 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 DBFBC38460B2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125456; cv=none; b=dbQ/ZFC3oEQqByaCIsawWUcbejZ+xnMi0r7wuEtnCjkrstsbwUbpLt58scpNoXwYJdoONzSKP4W6vSu1qizYkWp8EiRQe+sm5vTpo3qNvSEv0GD5GE/iqeSVks/9XLdXjOWXl2z0JlERVV1vxPp/wA7ROj3F3/t8LpgpmOXR124= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125456; c=relaxed/simple; bh=aI/6shtPRNxynoa6QvahpR8JlFz/gPzdje2VlIsq1CQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=KGS5xjrp2jnyFT1/3+nfSi/H9hYO5E/8Vkoc9PfG2bdFAca/xWAB2wri8bvgkpX0k7b8xE2aLdo8eF08qYyVywwVUNJK9z+UpY5cKV8+A3i2XEo3vIDSEtjMI9b+JGeW9yWrrnYv8AXgyhThesQaeSV55c8uQFbuBkgj8Ka41Wo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41b2119da94so24398675e9.0 for ; Tue, 07 May 2024 16:44:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715125452; x=1715730252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5Ct1IwcLS0v91sQLKuJY8lER2z0jwKnEJQojrHCYFo=; b=tVNQ/iQCksSyBVFHS8P3lHmSjWBtT/aHJ0IEmZ3MmTgKkAsaUWE7/9gDPFLpnpElvA GypYoKb2zq2LdbTBxWY9h94+wAVOGsGPIOKdJazy/GAnNk1cZgGuZbUDxCdHPQ1JItRo XNq5DHXc0NZ6B4aXGq6EEpc7yaOgoMAe+oGBardgntZkBRRI1Mkb76jR7+yChB/XUMiE C3h8bh5a8fwoAdwVBsWX6pLBf7POy4X05pjDUwdRmrdVDaByMbpXHtXfac1mOrMiyoLT Za3/EiZIJU/xLcLJF4V96E6dCJSsZ6SUaUir7YTOE/nvRHWrCNNtyRgsFKEojxwSdTaO 1jNw== X-Gm-Message-State: AOJu0Yxb8CUzQchUtHUnhBSdbLXDJBjChnZFLIhR+hnvlaNBYLTdj00L NayLrZ7qJJ9E6ueXrAXmpSI4RVqEhum2Ws9vtR6PTouS7ba5aAA4bqQLfYSb X-Google-Smtp-Source: AGHT+IH8XgrPXpMK0AFjAOkVRo6JZ86241B4T2EUmYOx5d40bBhMM8Y5Z7uPq5jJGPIpjwNjNDn66A== X-Received: by 2002:a05:600c:350a:b0:419:b1d3:1261 with SMTP id 5b1f17b1804b1-41f723a0cc5mr7766065e9.27.1715125452550; Tue, 07 May 2024 16:44:12 -0700 (PDT) Received: from localhost ([2001:8a0:f908:4900:2dd1:1a0d:2b75:dc42]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-41f88208cb8sm1868475e9.47.2024.05.07.16.44.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 16:44:12 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 24/34] Add backpointer from windows_thread_info to windows_process_info Date: Wed, 8 May 2024 00:42:23 +0100 Message-ID: <20240507234233.371123-25-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240507234233.371123-1-pedro@palves.net> References: <20240507234233.371123-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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: 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. 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 86ad8d02e3c..26b1eaea95a 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -42,13 +42,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) { @@ -67,6 +70,9 @@ struct windows_thread_info the next call. */ const char *thread_name (); + /* The process this thread belongs to. */ + windows_process_info *proc; + /* The Win32 thread identifier. */ DWORD tid; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 510820d862d..0e77614b4f4 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -612,7 +612,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 55600910ffe..985c6a0a0ed 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -167,7 +167,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); add_thread (ptid, th); -- 2.43.2