From patchwork Mon Oct 14 16:15:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34951 Received: (qmail 15688 invoked by alias); 14 Oct 2019 16:22:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15631 invoked by uid 89); 14 Oct 2019 16:22:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 16:22:40 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 17CC65604A; Mon, 14 Oct 2019 12:15:24 -0400 (EDT) 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 vSfS0rWyJqLN; Mon, 14 Oct 2019 12:15:24 -0400 (EDT) Received: from murgatroyd.Home (174-29-53-230.hlrn.qwest.net [174.29.53.230]) (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 B823556043; Mon, 14 Oct 2019 12:15:23 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/9] Share windows_thread_info between gdb and gdbserver Date: Mon, 14 Oct 2019 10:15:15 -0600 Message-Id: <20191014161520.13150-5-tromey@adacore.com> In-Reply-To: <20191014161520.13150-1-tromey@adacore.com> References: <20191014161520.13150-1-tromey@adacore.com> MIME-Version: 1.0 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 2019-10-14 Tom Tromey * windows-nat.c (struct windows_thread_info): Remove. * nat/windows-nat.h: New file. gdb/gdbserver/ChangeLog 2019-10-14 Tom Tromey * win32-low.h (struct windows_thread_info): Remove. --- gdb/ChangeLog | 5 ++++ gdb/gdbserver/ChangeLog | 4 +++ gdb/gdbserver/win32-low.h | 30 +------------------- gdb/nat/windows-nat.h | 58 +++++++++++++++++++++++++++++++++++++++ gdb/windows-nat.c | 14 +--------- 5 files changed, 69 insertions(+), 42 deletions(-) create mode 100644 gdb/nat/windows-nat.h diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h index 192e177aa71..342411d3956 100644 --- a/gdb/gdbserver/win32-low.h +++ b/gdb/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. */ diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h new file mode 100644 index 00000000000..30fce27de2f --- /dev/null +++ b/gdb/nat/windows-nat.h @@ -0,0 +1,58 @@ +/* Internal interfaces for the Windows code + Copyright (C) 1995-2019 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 + +/* 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; + + /* 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 7911afe80a2..010d6565330 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -69,6 +69,7 @@ #include "inf-child.h" #include "gdbsupport/gdb_tilde_expand.h" #include "gdbsupport/pathstuff.h" +#include "nat/windows-nat.h" #define AdjustTokenPrivileges dyn_AdjustTokenPrivileges #define DebugActiveProcessStop dyn_DebugActiveProcessStop @@ -213,19 +214,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; - CONTEXT context; - }; - static std::vector thread_list; /* The process and thread handles for the above context. */