From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 96A013AA8C1F for ; Fri, 13 Mar 2020 19:08:58 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 74BEB561B1; Fri, 13 Mar 2020 15:08:58 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kY3kXcuJ3eXi; Fri, 13 Mar 2020 15:08:58 -0400 (EDT) Received: from murgatroyd.Home (184-96-250-69.hlrn.qwest.net [184.96.250.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 319C5561B0; Fri, 13 Mar 2020 15:08:58 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 04/29] Share windows_thread_info between gdb and gdbserver Date: Fri, 13 Mar 2020 13:08:30 -0600 Message-Id: <20200313190855.28662-5-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200313190855.28662-1-tromey@adacore.com> References: <20200313190855.28662-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:08:59 -0000 This introduces a new file, nat/windows-nat.h, which holds the definition of windows_thread_info. This is now shared between gdb and gdbserver. Note that the two implementations different slightly. gdb had a couple of fields ("name" and "reload_context") that gdbserver did not; while gdbserver had one field ("base_context") that gdb did not, plus better comments. The new file preserves all the fields, and the comments. gdb/ChangeLog 2020-03-13 Tom Tromey * windows-nat.c (struct windows_thread_info): Remove. * nat/windows-nat.h: New file. gdbserver/ChangeLog 2020-03-13 Tom Tromey * win32-low.h (struct windows_thread_info): Remove. --- gdb/ChangeLog | 5 ++++ gdb/nat/windows-nat.h | 66 +++++++++++++++++++++++++++++++++++++++++++ gdb/windows-nat.c | 20 +------------ gdbserver/ChangeLog | 4 +++ gdbserver/win32-low.h | 30 +------------------- 5 files changed, 77 insertions(+), 48 deletions(-) create mode 100644 gdb/nat/windows-nat.h diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h new file mode 100644 index 00000000000..71df097ed0b --- /dev/null +++ b/gdb/nat/windows-nat.h @@ -0,0 +1,66 @@ +/* Internal interfaces for the Windows code + Copyright (C) 1995-2020 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef NAT_WINDOWS_NAT_H +#define NAT_WINDOWS_NAT_H + +#include + +/* Thread information structure used to track extra information about + each thread. */ +struct windows_thread_info +{ + /* The Win32 thread identifier. */ + DWORD tid; + + /* The handle to the thread. */ + HANDLE h; + + /* Thread Information Block address. */ + CORE_ADDR thread_local_base; + + /* Non zero if SuspendThread was called on this thread. */ + int suspended; + +#ifdef _WIN32_WCE + /* The context as retrieved right after suspending the thread. */ + CONTEXT base_context; +#endif + + /* The context of the thread, including any manipulations. */ + union + { + CONTEXT context; +#ifdef __x86_64__ + WOW64_CONTEXT wow64_context; +#endif + }; + + /* Whether debug registers changed since we last set CONTEXT back to + the thread. */ + int debug_registers_changed; + + /* Nonzero if CONTEXT is invalidated and must be re-read from the + inferior thread. */ + int reload_context; + + /* The name of the thread, allocated by xmalloc. */ + char *name; +}; + +#endif diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 69930b00a11..d2c4ecd6daf 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -70,6 +70,7 @@ #include "gdbsupport/gdb_tilde_expand.h" #include "gdbsupport/pathstuff.h" #include "gdbsupport/gdb_wait.h" +#include "nat/windows-nat.h" #define STATUS_WX86_BREAKPOINT 0x4000001F #define STATUS_WX86_SINGLE_STEP 0x4000001E @@ -244,25 +245,6 @@ static unsigned long cygwin_get_dr7 (void); static enum gdb_signal last_sig = GDB_SIGNAL_0; /* Set if a signal was received from the debugged process. */ -/* Thread information structure used to track information that is - not available in gdb's thread structure. */ -struct windows_thread_info - { - DWORD tid; - HANDLE h; - CORE_ADDR thread_local_base; - char *name; - int suspended; - int reload_context; - union - { - CONTEXT context; -#ifdef __x86_64__ - WOW64_CONTEXT wow64_context; -#endif - }; - }; - static std::vector thread_list; /* The process and thread handles for the above context. */ diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 2bd94e85288..28ac2b082d9 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -20,6 +20,7 @@ #define GDBSERVER_WIN32_LOW_H #include +#include "nat/windows-nat.h" struct target_desc; @@ -27,35 +28,6 @@ struct target_desc; Windows ports support neither bi-arch nor multi-process. */ extern const struct target_desc *win32_tdesc; -/* Thread information structure used to track extra information about - each thread. */ -struct windows_thread_info -{ - /* The Win32 thread identifier. */ - DWORD tid; - - /* The handle to the thread. */ - HANDLE h; - - /* Thread Information Block address. */ - CORE_ADDR thread_local_base; - - /* Non zero if SuspendThread was called on this thread. */ - int suspended; - -#ifdef _WIN32_WCE - /* The context as retrieved right after suspending the thread. */ - CONTEXT base_context; -#endif - - /* The context of the thread, including any manipulations. */ - CONTEXT context; - - /* Whether debug registers changed since we last set CONTEXT back to - the thread. */ - int debug_registers_changed; -}; - struct win32_target_ops { /* Architecture-specific setup. */ -- 2.21.1