From patchwork Tue Nov 26 17:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36211 Received: (qmail 92444 invoked by alias); 26 Nov 2019 17:11:45 -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 92375 invoked by uid 89); 26 Nov 2019 17:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=21319, preserves X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 17:11:42 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 0B3F420A7E; Tue, 26 Nov 2019 12:11:41 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 07880204BA; Tue, 26 Nov 2019 12:11:30 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id D929B28174; Tue, 26 Nov 2019 12:11:30 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Tue, 26 Nov 2019 12:11:28 -0500 From: "Tom Tromey (Code Review)" To: Luis Machado , Simon Marchi , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] Share windows_thread_info between gdb and gdbserver X-Gerrit-Change-Id: I9ba2d1b94be1550ea2e75e977d0808c7a27e2223 X-Gerrit-Change-Number: 407 X-Gerrit-ChangeURL: X-Gerrit-Commit: 196f01cd3f999a783e7d6ed304383a26fdbd79b1 In-Reply-To: References: Reply-To: tromey@sourceware.org, simon.marchi@polymtl.ca, luis.machado@linaro.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191126171130.D929B28174@gnutoolchain-gerrit.osci.io> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/407 ...................................................................... Share windows_thread_info between gdb and gdbserver 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-11-26 Tom Tromey * windows-nat.c (struct windows_thread_info): Remove. * nat/windows-nat.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey * win32-low.h (struct windows_thread_info): Remove. Change-Id: I9ba2d1b94be1550ea2e75e977d0808c7a27e2223 --- M gdb/ChangeLog M gdb/gdbserver/ChangeLog M gdb/gdbserver/win32-low.h A gdb/nat/windows-nat.h M gdb/windows-nat.c 5 files changed, 69 insertions(+), 42 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5eb664f..e24159a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2019-11-26 Tom Tromey + * windows-nat.c (struct windows_thread_info): Remove. + * nat/windows-nat.h: New file. + +2019-11-26 Tom Tromey + * windows-nat.c (struct windows_thread_info) : Rename from "id". (thread_rec, windows_add_thread, windows_delete_thread) (windows_continue): Update. diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 596bedb..8c0c8ba 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,9 @@ 2019-11-26 Tom Tromey + * win32-low.h (struct windows_thread_info): Remove. + +2019-11-26 Tom Tromey + * win32-low.h (struct windows_thread_info): Rename from win32_thread_info. Remove typedef. (struct win32_target_ops, win32_require_context): Update. diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h index 192e177..342411d 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 @@ 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 0000000..30fce27 --- /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 06514d0..f6d4010 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 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. */