From patchwork Mon Oct 14 16:15:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34947 Received: (qmail 124094 invoked by alias); 14 Oct 2019 16:16:13 -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 123452 invoked by uid 89); 14 Oct 2019 16:15:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=2107, th, suspended, HANDLE 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:15:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3E7E156048; Mon, 14 Oct 2019 12:15:23 -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 hGm0ap4aNbTx; Mon, 14 Oct 2019 12:15:23 -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 DC7D156043; Mon, 14 Oct 2019 12:15:22 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/9] Rename win32_thread_info to windows_thread_info Date: Mon, 14 Oct 2019 10:15:13 -0600 Message-Id: <20191014161520.13150-3-tromey@adacore.com> In-Reply-To: <20191014161520.13150-1-tromey@adacore.com> References: <20191014161520.13150-1-tromey@adacore.com> MIME-Version: 1.0 This renames win32_thread_info to windows_thread_info in gdbserver. This renaming helps make it possible to share some code between gdb and gdbserver. gdb/gdbserver/ChangeLog 2019-10-14 Tom Tromey * win32-low.h (struct windows_thread_info): Rename from win32_thread_info. Remove typedef. (struct win32_target_ops, win32_require_context): Update. * win32-low.c (win32_get_thread_context) (win32_set_thread_context, win32_prepare_to_resume) (win32_require_context, thread_rec, child_add_thread) (delete_thread_info, continue_one_thread) (child_fetch_inferior_registers, child_store_inferior_registers) (win32_resume, suspend_one_thread, win32_get_tib_address): Update. * win32-i386-low.c (update_debug_registers) (win32_get_current_dr, i386_get_thread_context) (i386_prepare_to_resume, i386_thread_added, i386_single_step) (i386_fetch_inferior_register, i386_store_inferior_register): Update. * win32-arm-low.c (arm_get_thread_context) (arm_fetch_inferior_register, arm_store_inferior_register): Update. --- gdb/gdbserver/ChangeLog | 21 +++++++++++++++++++++ gdb/gdbserver/win32-arm-low.c | 6 +++--- gdb/gdbserver/win32-i386-low.c | 18 +++++++++--------- gdb/gdbserver/win32-low.c | 32 ++++++++++++++++---------------- gdb/gdbserver/win32-low.h | 18 +++++++++--------- 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/gdb/gdbserver/win32-arm-low.c b/gdb/gdbserver/win32-arm-low.c index 2d7dfde35cd..c465aedda88 100644 --- a/gdb/gdbserver/win32-arm-low.c +++ b/gdb/gdbserver/win32-arm-low.c @@ -27,7 +27,7 @@ void init_registers_arm (void); extern const struct target_desc *tdesc_arm; static void -arm_get_thread_context (win32_thread_info *th) +arm_get_thread_context (windows_thread_info *th) { th->context.ContextFlags = \ CONTEXT_FULL | \ @@ -88,7 +88,7 @@ regptr (CONTEXT* c, int r) /* Fetch register from gdbserver regcache data. */ static void arm_fetch_inferior_register (struct regcache *regcache, - win32_thread_info *th, int r) + windows_thread_info *th, int r) { char *context_offset = regptr (&th->context, r); supply_register (regcache, r, context_offset); @@ -97,7 +97,7 @@ arm_fetch_inferior_register (struct regcache *regcache, /* Store a new register value into the thread context of TH. */ static void arm_store_inferior_register (struct regcache *regcache, - win32_thread_info *th, int r) + windows_thread_info *th, int r) { collect_register (regcache, r, regptr (&th->context, r)); } diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index 399520c11dc..3fc0cf1cd03 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -40,7 +40,7 @@ static struct x86_debug_reg_state debug_reg_state; static void update_debug_registers (thread_info *thread) { - win32_thread_info *th = (win32_thread_info *) thread_target_data (thread); + windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); /* The actual update is done later just before resuming the lwp, we just mark that the registers need updating. */ @@ -73,8 +73,8 @@ x86_dr_low_set_control (unsigned long control) static DWORD64 win32_get_current_dr (int dr) { - win32_thread_info *th - = (win32_thread_info *) thread_target_data (current_thread); + windows_thread_info *th + = (windows_thread_info *) thread_target_data (current_thread); win32_require_context (th); @@ -210,7 +210,7 @@ i386_initial_stuff (void) } static void -i386_get_thread_context (win32_thread_info *th) +i386_get_thread_context (windows_thread_info *th) { /* Requesting the CONTEXT_EXTENDED_REGISTERS register set fails if the system doesn't support extended registers. */ @@ -237,7 +237,7 @@ i386_get_thread_context (win32_thread_info *th) } static void -i386_prepare_to_resume (win32_thread_info *th) +i386_prepare_to_resume (windows_thread_info *th) { if (th->debug_registers_changed) { @@ -258,13 +258,13 @@ i386_prepare_to_resume (win32_thread_info *th) } static void -i386_thread_added (win32_thread_info *th) +i386_thread_added (windows_thread_info *th) { th->debug_registers_changed = 1; } static void -i386_single_step (win32_thread_info *th) +i386_single_step (windows_thread_info *th) { th->context.EFlags |= FLAG_TRACE_BIT; } @@ -398,7 +398,7 @@ static const int mappings[] = /* Fetch register from gdbserver regcache data. */ static void i386_fetch_inferior_register (struct regcache *regcache, - win32_thread_info *th, int r) + windows_thread_info *th, int r) { char *context_offset = (char *) &th->context + mappings[r]; @@ -420,7 +420,7 @@ i386_fetch_inferior_register (struct regcache *regcache, /* Store a new register value into the thread context of TH. */ static void i386_store_inferior_register (struct regcache *regcache, - win32_thread_info *th, int r) + windows_thread_info *th, int r) { char *context_offset = (char *) &th->context + mappings[r]; collect_register (regcache, r, context_offset); diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 7088ba4dd17..7120b1d4dd1 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -126,7 +126,7 @@ debug_event_ptid (DEBUG_EVENT *event) /* Get the thread context of the thread associated with TH. */ static void -win32_get_thread_context (win32_thread_info *th) +win32_get_thread_context (windows_thread_info *th) { memset (&th->context, 0, sizeof (CONTEXT)); (*the_low_target.get_thread_context) (th); @@ -138,7 +138,7 @@ win32_get_thread_context (win32_thread_info *th) /* Set the thread context of the thread associated with TH. */ static void -win32_set_thread_context (win32_thread_info *th) +win32_set_thread_context (windows_thread_info *th) { #ifdef _WIN32_WCE /* Calling SuspendThread on a thread that is running kernel code @@ -159,7 +159,7 @@ win32_set_thread_context (win32_thread_info *th) /* Set the thread context of the thread associated with TH. */ static void -win32_prepare_to_resume (win32_thread_info *th) +win32_prepare_to_resume (windows_thread_info *th) { if (the_low_target.prepare_to_resume != NULL) (*the_low_target.prepare_to_resume) (th); @@ -168,7 +168,7 @@ win32_prepare_to_resume (win32_thread_info *th) /* See win32-low.h. */ void -win32_require_context (win32_thread_info *th) +win32_require_context (windows_thread_info *th) { if (th->context.ContextFlags == 0) { @@ -190,30 +190,30 @@ win32_require_context (win32_thread_info *th) /* Find a thread record given a thread id. If GET_CONTEXT is set then also retrieve the context for this thread. */ -static win32_thread_info * +static windows_thread_info * thread_rec (ptid_t ptid, int get_context) { thread_info *thread = find_thread_ptid (ptid); if (thread == NULL) return NULL; - win32_thread_info *th = (win32_thread_info *) thread_target_data (thread); + windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); if (get_context) win32_require_context (th); return th; } /* Add a thread to the thread list. */ -static win32_thread_info * +static windows_thread_info * child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) { - win32_thread_info *th; + windows_thread_info *th; ptid_t ptid = ptid_t (pid, tid, 0); if ((th = thread_rec (ptid, FALSE))) return th; - th = XCNEW (win32_thread_info); + th = XCNEW (windows_thread_info); th->tid = tid; th->h = h; th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb; @@ -230,7 +230,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) static void delete_thread_info (thread_info *thread) { - win32_thread_info *th = (win32_thread_info *) thread_target_data (thread); + windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); remove_thread (thread); CloseHandle (th->h); @@ -425,7 +425,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached) static void continue_one_thread (thread_info *thread, int thread_id) { - win32_thread_info *th = (win32_thread_info *) thread_target_data (thread); + windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); if (thread_id == -1 || thread_id == th->tid) { @@ -474,7 +474,7 @@ static void child_fetch_inferior_registers (struct regcache *regcache, int r) { int regno; - win32_thread_info *th = thread_rec (current_thread_ptid (), TRUE); + windows_thread_info *th = thread_rec (current_thread_ptid (), TRUE); if (r == -1 || r > NUM_REGS) child_fetch_inferior_registers (regcache, NUM_REGS); else @@ -488,7 +488,7 @@ static void child_store_inferior_registers (struct regcache *regcache, int r) { int regno; - win32_thread_info *th = thread_rec (current_thread_ptid (), TRUE); + windows_thread_info *th = thread_rec (current_thread_ptid (), TRUE); if (r == -1 || r == 0 || r > NUM_REGS) child_store_inferior_registers (regcache, NUM_REGS); else @@ -900,7 +900,7 @@ win32_resume (struct thread_resume *resume_info, size_t n) DWORD tid; enum gdb_signal sig; int step; - win32_thread_info *th; + windows_thread_info *th; DWORD continue_status = DBG_CONTINUE; ptid_t ptid; @@ -1335,7 +1335,7 @@ handle_exception (struct target_waitstatus *ourstatus) static void suspend_one_thread (thread_info *thread) { - win32_thread_info *th = (win32_thread_info *) thread_target_data (thread); + windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); if (!th->suspended) { @@ -1759,7 +1759,7 @@ wince_hostio_last_error (char *buf) static int win32_get_tib_address (ptid_t ptid, CORE_ADDR *addr) { - win32_thread_info *th; + windows_thread_info *th; th = thread_rec (ptid, 0); if (th == NULL) return 0; diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h index 815c1b04669..192e177aa71 100644 --- a/gdb/gdbserver/win32-low.h +++ b/gdb/gdbserver/win32-low.h @@ -29,7 +29,7 @@ extern const struct target_desc *win32_tdesc; /* Thread information structure used to track extra information about each thread. */ -typedef struct win32_thread_info +struct windows_thread_info { /* The Win32 thread identifier. */ DWORD tid; @@ -54,7 +54,7 @@ typedef struct win32_thread_info /* Whether debug registers changed since we last set CONTEXT back to the thread. */ int debug_registers_changed; -} win32_thread_info; +}; struct win32_target_ops { @@ -68,23 +68,23 @@ struct win32_target_ops void (*initial_stuff) (void); /* Fetch the context from the inferior. */ - void (*get_thread_context) (win32_thread_info *th); + void (*get_thread_context) (windows_thread_info *th); /* Called just before resuming the thread. */ - void (*prepare_to_resume) (win32_thread_info *th); + void (*prepare_to_resume) (windows_thread_info *th); /* Called when a thread was added. */ - void (*thread_added) (win32_thread_info *th); + void (*thread_added) (windows_thread_info *th); /* Fetch register from gdbserver regcache data. */ void (*fetch_inferior_register) (struct regcache *regcache, - win32_thread_info *th, int r); + windows_thread_info *th, int r); /* Store a new register value into the thread context of TH. */ void (*store_inferior_register) (struct regcache *regcache, - win32_thread_info *th, int r); + windows_thread_info *th, int r); - void (*single_step) (win32_thread_info *th); + void (*single_step) (windows_thread_info *th); const unsigned char *breakpoint; int breakpoint_len; @@ -102,7 +102,7 @@ struct win32_target_ops extern struct win32_target_ops the_low_target; /* Retrieve the context for this thread, if not already retrieved. */ -extern void win32_require_context (win32_thread_info *th); +extern void win32_require_context (windows_thread_info *th); /* Map the Windows error number in ERROR to a locale-dependent error message string and return a pointer to it. Typically, the values