2020-04-09 04:33:35 +08:00
|
|
|
/* Internal interfaces for the Windows code
|
2024-01-12 23:30:44 +08:00
|
|
|
Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef NAT_WINDOWS_NAT_H
|
|
|
|
#define NAT_WINDOWS_NAT_H
|
|
|
|
|
|
|
|
#include <windows.h>
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#include <psapi.h>
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2023-10-13 17:27:48 +08:00
|
|
|
#include <optional>
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
#include "target/waitstatus.h"
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2020-04-09 22:33:20 +08:00
|
|
|
#define STATUS_WX86_BREAKPOINT 0x4000001F
|
|
|
|
#define STATUS_WX86_SINGLE_STEP 0x4000001E
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
namespace windows_nat
|
|
|
|
{
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* Thread information structure used to track extra information about
|
|
|
|
each thread. */
|
|
|
|
struct windows_thread_info
|
|
|
|
{
|
2020-04-09 04:33:35 +08:00
|
|
|
windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
|
|
|
|
: tid (tid_),
|
|
|
|
h (h_),
|
|
|
|
thread_local_base (tlb)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DISABLE_COPY_AND_ASSIGN (windows_thread_info);
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* Ensure that this thread has been suspended. */
|
|
|
|
void suspend ();
|
|
|
|
|
|
|
|
/* Resume the thread if it has been suspended. */
|
|
|
|
void resume ();
|
|
|
|
|
2022-04-13 22:45:34 +08:00
|
|
|
/* Return the thread's name, or nullptr if not known. The name is
|
|
|
|
stored in this thread and is guaranteed to live until at least
|
|
|
|
the next call. */
|
|
|
|
const char *thread_name ();
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* The Win32 thread identifier. */
|
|
|
|
DWORD tid;
|
|
|
|
|
|
|
|
/* The handle to the thread. */
|
|
|
|
HANDLE h;
|
|
|
|
|
|
|
|
/* Thread Information Block address. */
|
|
|
|
CORE_ADDR thread_local_base;
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* This keeps track of whether SuspendThread was called on this
|
|
|
|
thread. -1 means there was a failure or that the thread was
|
|
|
|
explicitly not suspended, 1 means it was called, and 0 means it
|
|
|
|
was not. */
|
2020-04-09 04:33:35 +08:00
|
|
|
int suspended = 0;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
|
|
|
/* The context of the thread, including any manipulations. */
|
|
|
|
union
|
|
|
|
{
|
2020-04-09 04:33:35 +08:00
|
|
|
CONTEXT context {};
|
2020-04-09 04:33:35 +08:00
|
|
|
#ifdef __x86_64__
|
|
|
|
WOW64_CONTEXT wow64_context;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Whether debug registers changed since we last set CONTEXT back to
|
|
|
|
the thread. */
|
2020-04-09 04:33:35 +08:00
|
|
|
bool debug_registers_changed = false;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
|
|
|
/* Nonzero if CONTEXT is invalidated and must be re-read from the
|
|
|
|
inferior thread. */
|
2020-04-09 04:33:35 +08:00
|
|
|
bool reload_context = false;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
Handle pending stops from the Windows kernel
PR gdb/22992 concerns an assertion failure in gdb when debugging a
certain inferior:
int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
Initially the investigation centered on the discovery that gdb was not
suspending other threads when attempting to single-step. This
oversight is corrected in this patch: now, when stepping a thread, gdb
will call SuspendThread on all other threads.
However, the bug persisted even after this change. In particular,
WaitForDebugEvent could see a stop for a thread that was ostensibly
suspended. Our theory of what is happening here is that there are
actually simultaneous breakpoint hits, and the Windows kernel queues
the events, causing the second stop to be reported on a suspended
thread.
In Windows 10 or later gdb could use the DBG_REPLY_LATER flag to
ContinueDebugEvent to request that such events be re-reported later.
However, relying on that did not seem advisable, so this patch instead
arranges to queue such "pending" stops, and then to report them later,
once the step has completed.
In the PR, Pedro pointed out that it's best in this scenario to
implement the stopped_by_sw_breakpoint method, so this patch does this
as well.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
PR gdb/22992
* windows-nat.c (current_event): Update comment.
(last_wait_event, desired_stop_thread_id): New globals.
(struct pending_stop): New.
(pending_stops): New global.
(windows_nat_target) <stopped_by_sw_breakpoint>
<supports_stopped_by_sw_breakpoint>: New methods.
(windows_fetch_one_register): Add assertions. Adjust PC.
(windows_continue): Handle pending stops. Suspend other threads
when stepping. Use last_wait_event
(wait_for_debug_event): New function.
(get_windows_debug_event): Use wait_for_debug_event. Handle
pending stops. Queue spurious stops.
(windows_nat_target::wait): Set stopped_at_software_breakpoint.
(windows_nat_target::kill): Use wait_for_debug_event.
* nat/windows-nat.h (struct windows_thread_info)
<stopped_at_software_breakpoint>: New field.
* nat/windows-nat.c (windows_thread_info::resume): Clear
stopped_at_software_breakpoint.
2020-04-09 04:33:35 +08:00
|
|
|
/* True if this thread is currently stopped at a software
|
|
|
|
breakpoint. This is used to offset the PC when needed. */
|
|
|
|
bool stopped_at_software_breakpoint = false;
|
|
|
|
|
2020-04-24 20:48:01 +08:00
|
|
|
/* True if we've adjusted the PC after hitting a software
|
|
|
|
breakpoint, false otherwise. This lets us avoid multiple
|
|
|
|
adjustments if the registers are read multiple times. */
|
|
|
|
bool pc_adjusted = false;
|
|
|
|
|
2022-04-13 04:25:44 +08:00
|
|
|
/* The name of the thread. */
|
2020-04-09 04:33:35 +08:00
|
|
|
gdb::unique_xmalloc_ptr<char> name;
|
2020-04-09 04:33:35 +08:00
|
|
|
};
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
|
|
|
|
/* Possible values to pass to 'thread_rec'. */
|
|
|
|
enum thread_disposition_type
|
|
|
|
{
|
|
|
|
/* Do not invalidate the thread's context, and do not suspend the
|
|
|
|
thread. */
|
|
|
|
DONT_INVALIDATE_CONTEXT,
|
|
|
|
/* Invalidate the context, but do not suspend the thread. */
|
|
|
|
DONT_SUSPEND,
|
|
|
|
/* Invalidate the context and suspend the thread. */
|
|
|
|
INVALIDATE_CONTEXT
|
|
|
|
};
|
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* A single pending stop. See "pending_stops" for more
|
|
|
|
information. */
|
|
|
|
struct pending_stop
|
|
|
|
{
|
|
|
|
/* The thread id. */
|
|
|
|
DWORD thread_id;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* The target waitstatus we computed. */
|
|
|
|
target_waitstatus status;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* The event. A few fields of this can be referenced after a stop,
|
|
|
|
and it seemed simplest to store the entire event. */
|
|
|
|
DEBUG_EVENT event;
|
|
|
|
};
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-28 04:32:49 +08:00
|
|
|
enum handle_exception_result
|
2022-04-01 03:41:02 +08:00
|
|
|
{
|
|
|
|
HANDLE_EXCEPTION_UNHANDLED = 0,
|
|
|
|
HANDLE_EXCEPTION_HANDLED,
|
|
|
|
HANDLE_EXCEPTION_IGNORED
|
2022-04-28 04:32:49 +08:00
|
|
|
};
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* A single Windows process. An object of this type (or subclass) is
|
|
|
|
created by the client. Some methods must be provided by the client
|
|
|
|
as well. */
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
struct windows_process_info
|
|
|
|
{
|
|
|
|
/* The process handle */
|
|
|
|
HANDLE handle = 0;
|
|
|
|
DWORD main_thread_id = 0;
|
|
|
|
enum gdb_signal last_sig = GDB_SIGNAL_0;
|
|
|
|
|
|
|
|
/* The current debug event from WaitForDebugEvent or from a pending
|
|
|
|
stop. */
|
|
|
|
DEBUG_EVENT current_event {};
|
|
|
|
|
|
|
|
/* The ID of the thread for which we anticipate a stop event.
|
|
|
|
Normally this is -1, meaning we'll accept an event in any
|
|
|
|
thread. */
|
|
|
|
DWORD desired_stop_thread_id = -1;
|
|
|
|
|
|
|
|
/* A vector of pending stops. Sometimes, Windows will report a stop
|
|
|
|
on a thread that has been ostensibly suspended. We believe what
|
|
|
|
happens here is that two threads hit a breakpoint simultaneously,
|
|
|
|
and the Windows kernel queues the stop events. However, this can
|
|
|
|
result in the strange effect of trying to single step thread A --
|
|
|
|
leaving all other threads suspended -- and then seeing a stop in
|
|
|
|
thread B. To handle this scenario, we queue all such "pending"
|
|
|
|
stops here, and then process them once the step has completed. See
|
|
|
|
PR gdb/22992. */
|
|
|
|
std::vector<pending_stop> pending_stops;
|
|
|
|
|
|
|
|
/* Contents of $_siginfo */
|
|
|
|
EXCEPTION_RECORD siginfo_er {};
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
#ifdef __x86_64__
|
|
|
|
/* The target is a WOW64 process */
|
|
|
|
bool wow64_process = false;
|
|
|
|
/* Ignore first breakpoint exception of WOW64 process */
|
|
|
|
bool ignore_first_breakpoint = false;
|
|
|
|
#endif
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2021-05-01 00:22:23 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Find a thread record given a thread id. THREAD_DISPOSITION
|
|
|
|
controls whether the thread is suspended, and whether the context
|
|
|
|
is invalidated.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function must be supplied by the embedding application. */
|
2022-04-06 03:22:16 +08:00
|
|
|
virtual windows_thread_info *thread_rec (ptid_t ptid,
|
|
|
|
thread_disposition_type disposition) = 0;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Handle OUTPUT_DEBUG_STRING_EVENT from child process. Updates
|
|
|
|
OURSTATUS and returns the thread id if this represents a thread
|
|
|
|
change (this is specific to Cygwin), otherwise 0.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
Cygwin prepends its messages with a "cygwin:". Interpret this as
|
|
|
|
a Cygwin signal. Otherwise just print the string as a warning.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function must be supplied by the embedding application. */
|
2022-04-06 03:22:16 +08:00
|
|
|
virtual int handle_output_debug_string (struct target_waitstatus *ourstatus) = 0;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Handle a DLL load event.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function assumes that the current event did not occur during
|
|
|
|
inferior initialization.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
DLL_NAME is the name of the library. BASE is the base load
|
|
|
|
address.
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function must be supplied by the embedding application. */
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-06 03:22:16 +08:00
|
|
|
virtual void handle_load_dll (const char *dll_name, LPVOID base) = 0;
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Handle a DLL unload event.
|
2020-04-16 21:24:57 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function assumes that this event did not occur during inferior
|
|
|
|
initialization.
|
2020-04-16 21:24:57 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
This function must be supplied by the embedding application. */
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-06 03:22:16 +08:00
|
|
|
virtual void handle_unload_dll () = 0;
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* When EXCEPTION_ACCESS_VIOLATION is processed, we give the embedding
|
|
|
|
application a chance to change it to be considered "unhandled".
|
|
|
|
This function must be supplied by the embedding application. If it
|
|
|
|
returns true, then the exception is "unhandled". */
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-06 03:22:16 +08:00
|
|
|
virtual bool handle_access_violation (const EXCEPTION_RECORD *rec) = 0;
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
handle_exception_result handle_exception
|
|
|
|
(struct target_waitstatus *ourstatus, bool debug_exceptions);
|
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Call to indicate that a DLL was loaded. */
|
2020-04-09 22:33:20 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
void dll_loaded_event ();
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Iterate over all DLLs currently mapped by our inferior, and
|
|
|
|
add them to our list of solibs. */
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
void add_all_dlls ();
|
2021-05-01 00:22:23 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Return true if there is a pending stop matching
|
|
|
|
desired_stop_thread_id. If DEBUG_EVENTS is true, logging will be
|
|
|
|
enabled. */
|
2021-05-01 00:22:23 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
bool matching_pending_stop (bool debug_events);
|
2021-05-01 00:22:23 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* See if a pending stop matches DESIRED_STOP_THREAD_ID. If so,
|
|
|
|
remove it from the list of pending stops, set 'current_event', and
|
|
|
|
return it. Otherwise, return an empty optional. */
|
2021-05-01 00:22:23 +08:00
|
|
|
|
2023-10-13 17:27:48 +08:00
|
|
|
std::optional<pending_stop> fetch_pending_stop (bool debug_events);
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-27 04:16:57 +08:00
|
|
|
const char *pid_to_exec_file (int);
|
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
private:
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-13 04:25:44 +08:00
|
|
|
/* Handle MS_VC_EXCEPTION when processing a stop. MS_VC_EXCEPTION is
|
|
|
|
somewhat undocumented but is used to tell the debugger the name of
|
|
|
|
a thread.
|
|
|
|
|
|
|
|
Return true if the exception was handled; return false otherwise. */
|
|
|
|
|
|
|
|
bool handle_ms_vc_exception (const EXCEPTION_RECORD *rec);
|
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
/* Iterate over all DLLs currently mapped by our inferior, looking for
|
|
|
|
a DLL which is loaded at LOAD_ADDR. If found, add the DLL to our
|
|
|
|
list of solibs; otherwise do nothing. LOAD_ADDR NULL means add all
|
|
|
|
DLLs to the list of solibs; this is used when the inferior finishes
|
|
|
|
its initialization, and all the DLLs it statically depends on are
|
|
|
|
presumed loaded. */
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2022-04-01 03:41:02 +08:00
|
|
|
void add_dll (LPVOID load_addr);
|
2022-04-27 04:16:57 +08:00
|
|
|
|
|
|
|
/* Try to determine the executable filename.
|
|
|
|
|
|
|
|
EXE_NAME_RET is a pointer to a buffer whose size is EXE_NAME_MAX_LEN.
|
|
|
|
|
|
|
|
Upon success, the filename is stored inside EXE_NAME_RET, and
|
|
|
|
this function returns nonzero.
|
|
|
|
|
|
|
|
Otherwise, this function returns zero and the contents of
|
|
|
|
EXE_NAME_RET is undefined. */
|
|
|
|
|
|
|
|
int get_exec_module_filename (char *exe_name_ret, size_t exe_name_max_len);
|
2022-04-01 03:41:02 +08:00
|
|
|
};
|
2020-04-09 04:33:35 +08:00
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* A simple wrapper for ContinueDebugEvent that continues the last
|
|
|
|
waited-for event. If DEBUG_EVENTS is true, logging will be
|
|
|
|
enabled. */
|
|
|
|
|
|
|
|
extern BOOL continue_last_debug_event (DWORD continue_status,
|
|
|
|
bool debug_events);
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
/* A simple wrapper for WaitForDebugEvent that also sets the internal
|
2020-04-09 04:33:35 +08:00
|
|
|
'last_wait_event' on success. */
|
|
|
|
|
|
|
|
extern BOOL wait_for_debug_event (DEBUG_EVENT *event, DWORD timeout);
|
|
|
|
|
2021-09-08 22:20:29 +08:00
|
|
|
/* Wrappers for CreateProcess. These exist primarily so that the
|
|
|
|
"disable randomization" feature can be implemented in a single
|
|
|
|
place. */
|
2021-09-08 04:41:52 +08:00
|
|
|
|
|
|
|
extern BOOL create_process (const char *image, char *command_line,
|
|
|
|
DWORD flags, void *environment,
|
|
|
|
const char *cur_dir,
|
2021-09-08 22:20:29 +08:00
|
|
|
bool no_randomization,
|
2021-09-08 04:41:52 +08:00
|
|
|
STARTUPINFOA *startup_info,
|
|
|
|
PROCESS_INFORMATION *process_info);
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
extern BOOL create_process (const wchar_t *image, wchar_t *command_line,
|
|
|
|
DWORD flags, void *environment,
|
|
|
|
const wchar_t *cur_dir,
|
2021-09-08 22:20:29 +08:00
|
|
|
bool no_randomization,
|
2021-09-08 04:41:52 +08:00
|
|
|
STARTUPINFOW *startup_info,
|
|
|
|
PROCESS_INFORMATION *process_info);
|
|
|
|
#endif /* __CYGWIN__ */
|
|
|
|
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
|
|
|
|
#define DebugActiveProcessStop dyn_DebugActiveProcessStop
|
|
|
|
#define DebugBreakProcess dyn_DebugBreakProcess
|
|
|
|
#define DebugSetProcessKillOnExit dyn_DebugSetProcessKillOnExit
|
2021-09-08 22:20:29 +08:00
|
|
|
#undef EnumProcessModules
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define EnumProcessModules dyn_EnumProcessModules
|
2021-09-08 22:20:29 +08:00
|
|
|
#undef EnumProcessModulesEx
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define EnumProcessModulesEx dyn_EnumProcessModulesEx
|
2021-09-08 22:20:29 +08:00
|
|
|
#undef GetModuleInformation
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define GetModuleInformation dyn_GetModuleInformation
|
2021-09-08 22:20:29 +08:00
|
|
|
#undef GetModuleFileNameExA
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define GetModuleFileNameExA dyn_GetModuleFileNameExA
|
2021-09-08 22:20:29 +08:00
|
|
|
#undef GetModuleFileNameExW
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
#define GetModuleFileNameExW dyn_GetModuleFileNameExW
|
|
|
|
#define LookupPrivilegeValueA dyn_LookupPrivilegeValueA
|
|
|
|
#define OpenProcessToken dyn_OpenProcessToken
|
|
|
|
#define GetConsoleFontSize dyn_GetConsoleFontSize
|
|
|
|
#define GetCurrentConsoleFont dyn_GetCurrentConsoleFont
|
|
|
|
#define Wow64SuspendThread dyn_Wow64SuspendThread
|
|
|
|
#define Wow64GetThreadContext dyn_Wow64GetThreadContext
|
|
|
|
#define Wow64SetThreadContext dyn_Wow64SetThreadContext
|
|
|
|
#define Wow64GetThreadSelectorEntry dyn_Wow64GetThreadSelectorEntry
|
Use nat/windows-nat function indirection code
This changes gdbserver to use the function indirection code that was
just moved into nat/windows-nat.[ch]. One additional function is used
by gdbserver that was not used by gdb.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* nat/windows-nat.h (GenerateConsoleCtrlEvent): New define.
(GenerateConsoleCtrlEvent_ftype, GenerateConsoleCtrlEvent):
Declare.
* nat/windows-nat.c (GenerateConsoleCtrlEvent): Define.
(initialize_loadable): Initialize GenerateConsoleCtrlEvent.
gdbserver/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* win32-low.cc (GETPROCADDRESS): Remove.
(winapi_DebugActiveProcessStop, winapi_DebugSetProcessKillOnExit)
(winapi_DebugBreakProcess, winapi_GenerateConsoleCtrlEvent)
(winapi_Wow64SetThreadContext, win32_Wow64GetThreadContext)
(win32_Wow64SetThreadContext): Remove.
(win32_set_thread_context, do_initial_child_stuff)
(win32_process_target::attach, win32_process_target::detach):
Update.
(winapi_EnumProcessModules, winapi_EnumProcessModulesEx)
(winapi_GetModuleInformation, winapi_GetModuleInformationA):
Remove.
(win32_EnumProcessModules, win32_EnumProcessModulesEx)
(win32_GetModuleInformation, win32_GetModuleInformationA):
Remove.
(load_psapi): Remove.
(win32_add_dll, win32_process_target::request_interrupt): Update.
(initialize_low): Call initialize_loadable.
2021-05-01 00:22:23 +08:00
|
|
|
#define GenerateConsoleCtrlEvent dyn_GenerateConsoleCtrlEvent
|
2021-09-08 22:20:29 +08:00
|
|
|
#define InitializeProcThreadAttributeList dyn_InitializeProcThreadAttributeList
|
|
|
|
#define UpdateProcThreadAttribute dyn_UpdateProcThreadAttribute
|
|
|
|
#define DeleteProcThreadAttributeList dyn_DeleteProcThreadAttributeList
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
|
|
|
|
typedef BOOL WINAPI (AdjustTokenPrivileges_ftype) (HANDLE, BOOL,
|
|
|
|
PTOKEN_PRIVILEGES,
|
|
|
|
DWORD, PTOKEN_PRIVILEGES,
|
|
|
|
PDWORD);
|
|
|
|
extern AdjustTokenPrivileges_ftype *AdjustTokenPrivileges;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (DebugActiveProcessStop_ftype) (DWORD);
|
|
|
|
extern DebugActiveProcessStop_ftype *DebugActiveProcessStop;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (DebugBreakProcess_ftype) (HANDLE);
|
|
|
|
extern DebugBreakProcess_ftype *DebugBreakProcess;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (DebugSetProcessKillOnExit_ftype) (BOOL);
|
|
|
|
extern DebugSetProcessKillOnExit_ftype *DebugSetProcessKillOnExit;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (EnumProcessModules_ftype) (HANDLE, HMODULE *, DWORD,
|
|
|
|
LPDWORD);
|
|
|
|
extern EnumProcessModules_ftype *EnumProcessModules;
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
typedef BOOL WINAPI (EnumProcessModulesEx_ftype) (HANDLE, HMODULE *, DWORD,
|
|
|
|
LPDWORD, DWORD);
|
|
|
|
extern EnumProcessModulesEx_ftype *EnumProcessModulesEx;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (GetModuleInformation_ftype) (HANDLE, HMODULE,
|
|
|
|
LPMODULEINFO, DWORD);
|
|
|
|
extern GetModuleInformation_ftype *GetModuleInformation;
|
|
|
|
|
|
|
|
typedef DWORD WINAPI (GetModuleFileNameExA_ftype) (HANDLE, HMODULE, LPSTR,
|
|
|
|
DWORD);
|
|
|
|
extern GetModuleFileNameExA_ftype *GetModuleFileNameExA;
|
|
|
|
|
|
|
|
typedef DWORD WINAPI (GetModuleFileNameExW_ftype) (HANDLE, HMODULE,
|
|
|
|
LPWSTR, DWORD);
|
|
|
|
extern GetModuleFileNameExW_ftype *GetModuleFileNameExW;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (LookupPrivilegeValueA_ftype) (LPCSTR, LPCSTR, PLUID);
|
|
|
|
extern LookupPrivilegeValueA_ftype *LookupPrivilegeValueA;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (OpenProcessToken_ftype) (HANDLE, DWORD, PHANDLE);
|
|
|
|
extern OpenProcessToken_ftype *OpenProcessToken;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (GetCurrentConsoleFont_ftype) (HANDLE, BOOL,
|
|
|
|
CONSOLE_FONT_INFO *);
|
|
|
|
extern GetCurrentConsoleFont_ftype *GetCurrentConsoleFont;
|
|
|
|
|
|
|
|
typedef COORD WINAPI (GetConsoleFontSize_ftype) (HANDLE, DWORD);
|
|
|
|
extern GetConsoleFontSize_ftype *GetConsoleFontSize;
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
typedef DWORD WINAPI (Wow64SuspendThread_ftype) (HANDLE);
|
|
|
|
extern Wow64SuspendThread_ftype *Wow64SuspendThread;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (Wow64GetThreadContext_ftype) (HANDLE, PWOW64_CONTEXT);
|
|
|
|
extern Wow64GetThreadContext_ftype *Wow64GetThreadContext;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (Wow64SetThreadContext_ftype) (HANDLE,
|
|
|
|
const WOW64_CONTEXT *);
|
|
|
|
extern Wow64SetThreadContext_ftype *Wow64SetThreadContext;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (Wow64GetThreadSelectorEntry_ftype) (HANDLE, DWORD,
|
|
|
|
PLDT_ENTRY);
|
|
|
|
extern Wow64GetThreadSelectorEntry_ftype *Wow64GetThreadSelectorEntry;
|
|
|
|
#endif
|
|
|
|
|
Use nat/windows-nat function indirection code
This changes gdbserver to use the function indirection code that was
just moved into nat/windows-nat.[ch]. One additional function is used
by gdbserver that was not used by gdb.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* nat/windows-nat.h (GenerateConsoleCtrlEvent): New define.
(GenerateConsoleCtrlEvent_ftype, GenerateConsoleCtrlEvent):
Declare.
* nat/windows-nat.c (GenerateConsoleCtrlEvent): Define.
(initialize_loadable): Initialize GenerateConsoleCtrlEvent.
gdbserver/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* win32-low.cc (GETPROCADDRESS): Remove.
(winapi_DebugActiveProcessStop, winapi_DebugSetProcessKillOnExit)
(winapi_DebugBreakProcess, winapi_GenerateConsoleCtrlEvent)
(winapi_Wow64SetThreadContext, win32_Wow64GetThreadContext)
(win32_Wow64SetThreadContext): Remove.
(win32_set_thread_context, do_initial_child_stuff)
(win32_process_target::attach, win32_process_target::detach):
Update.
(winapi_EnumProcessModules, winapi_EnumProcessModulesEx)
(winapi_GetModuleInformation, winapi_GetModuleInformationA):
Remove.
(win32_EnumProcessModules, win32_EnumProcessModulesEx)
(win32_GetModuleInformation, win32_GetModuleInformationA):
Remove.
(load_psapi): Remove.
(win32_add_dll, win32_process_target::request_interrupt): Update.
(initialize_low): Call initialize_loadable.
2021-05-01 00:22:23 +08:00
|
|
|
typedef BOOL WINAPI (GenerateConsoleCtrlEvent_ftype) (DWORD, DWORD);
|
|
|
|
extern GenerateConsoleCtrlEvent_ftype *GenerateConsoleCtrlEvent;
|
|
|
|
|
2021-09-08 22:20:29 +08:00
|
|
|
/* We use a local typedef for this type to avoid depending on
|
|
|
|
Windows 8. */
|
|
|
|
typedef void *gdb_lpproc_thread_attribute_list;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (InitializeProcThreadAttributeList_ftype)
|
|
|
|
(gdb_lpproc_thread_attribute_list lpAttributeList,
|
|
|
|
DWORD dwAttributeCount, DWORD dwFlags, PSIZE_T lpSize);
|
|
|
|
extern InitializeProcThreadAttributeList_ftype *InitializeProcThreadAttributeList;
|
|
|
|
|
|
|
|
typedef BOOL WINAPI (UpdateProcThreadAttribute_ftype)
|
|
|
|
(gdb_lpproc_thread_attribute_list lpAttributeList,
|
|
|
|
DWORD dwFlags, DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize,
|
|
|
|
PVOID lpPreviousValue, PSIZE_T lpReturnSize);
|
|
|
|
extern UpdateProcThreadAttribute_ftype *UpdateProcThreadAttribute;
|
|
|
|
|
|
|
|
typedef void WINAPI (DeleteProcThreadAttributeList_ftype)
|
|
|
|
(gdb_lpproc_thread_attribute_list lpAttributeList);
|
|
|
|
extern DeleteProcThreadAttributeList_ftype *DeleteProcThreadAttributeList;
|
|
|
|
|
|
|
|
/* Return true if it's possible to disable randomization on this
|
|
|
|
host. */
|
|
|
|
|
|
|
|
extern bool disable_randomization_available ();
|
|
|
|
|
Move function indirection code to nat/windows-nat
gdb and gdbserver both look for functions in some Windows DLLs at
runtime. This patch moves this code out of gdb and into
nat/windows-nat, so it can be shared by both programs.
gdb/ChangeLog
2021-04-30 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Move code to nat/windows-nat.[ch].
(_initialize_windows_nat): Call initialize_loadable.
* nat/windows-nat.h (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation)
(GetModuleFileNameExA, GetModuleFileNameExW)
(LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize)
(GetCurrentConsoleFont, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Move from windows-nat.c.
(AdjustTokenPrivileges_ftype)
(DebugActiveProcessStop_ftype, DebugBreakProcess_ftype)
(DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype)
(EnumProcessModulesEx_ftype, GetModuleInformation_ftype)
(GetModuleFileNameExA_ftype, GetModuleFileNameExW_ftype)
(LookupPrivilegeValueA_ftype, OpenProcessToken_ftype)
(GetConsoleFontSize_ftype)
(GetCurrentConsoleFont_ftype, Wow64SuspendThread_ftype)
(Wow64GetThreadContext_ftype, Wow64SetThreadContext_ftype)
(Wow64GetThreadSelectorEntry_ftype): Likewise.
(initialize_loadable): Declare.
* nat/windows-nat.c (AdjustTokenPrivileges)
(DebugActiveProcessStop, DebugBreakProcess)
(DebugSetProcessKillOnExit, EnumProcessModules)
(EnumProcessModulesEx, GetModuleInformation, GetModuleFileNameExA)
(GetModuleFileNameExW, LookupPrivilegeValueA, OpenProcessToken)
(GetCurrentConsoleFont, GetConsoleFontSize, Wow64SuspendThread)
(Wow64GetThreadContext, Wow64SetThreadContext)
(Wow64GetThreadSelectorEntry): Define.
(bad, bad_GetCurrentConsoleFont, bad_GetConsoleFontSize): Move
from windows-nat.c.
(initialize_loadable): Likewise, and rename.
2021-05-01 00:22:23 +08:00
|
|
|
/* Load any functions which may not be available in ancient versions
|
|
|
|
of Windows. */
|
|
|
|
|
|
|
|
extern bool initialize_loadable ();
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
}
|
|
|
|
|
2020-04-09 04:33:35 +08:00
|
|
|
#endif
|