|
GDBserver
|
#include "server.h"#include "regcache.h"#include "gdb/fileio.h"#include "mem-break.h"#include "win32-low.h"#include "gdbthread.h"#include "dll.h"#include "hostio.h"#include <windows.h>#include <winnt.h>#include <imagehlp.h>#include <tlhelp32.h>#include <psapi.h>#include <process.h>#include "gdb_tilde_expand.h"#include "common-inferior.h"#include <sys/cygwin.h>Go to the source code of this file.
Macros | |
| #define | OUTMSG(X) do { printf X; fflush (stderr); } while (0) |
| #define | OUTMSG2(X) |
| #define | _T(x) TEXT (x) |
| #define | COUNTOF(STR) (sizeof (STR) / sizeof ((STR)[0])) |
| #define | GETPROCADDRESS(DLL, PROC) ((winapi_ ## PROC) GetProcAddress (DLL, #PROC)) |
| #define | NUM_REGS (the_low_target.num_regs) |
| #define | READ_BUFFER_LEN 1024 |
Typedefs | |
| typedef BOOL(WINAPI * | winapi_DebugActiveProcessStop) (DWORD dwProcessId) |
| typedef BOOL(WINAPI * | winapi_DebugSetProcessKillOnExit) (BOOL KillOnExit) |
| typedef BOOL(WINAPI * | winapi_DebugBreakProcess) (HANDLE) |
| typedef BOOL(WINAPI * | winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD) |
| typedef BOOL(WINAPI * | winapi_EnumProcessModules) (HANDLE, HMODULE *, DWORD, LPDWORD) |
| typedef BOOL(WINAPI * | winapi_GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO, DWORD) |
| typedef DWORD(WINAPI * | winapi_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR, DWORD) |
| typedef HANDLE(WINAPI * | winapi_CreateToolhelp32Snapshot) (DWORD, DWORD) |
| typedef BOOL(WINAPI * | winapi_Module32First) (HANDLE, LPMODULEENTRY32) |
| typedef BOOL(WINAPI * | winapi_Module32Next) (HANDLE, LPMODULEENTRY32) |
Functions | |
| static ptid_t | win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) |
| static void | win32_resume (struct thread_resume *resume_info, size_t n) |
| static void | win32_add_all_dlls (void) |
| static ptid_t | current_thread_ptid (void) |
| static ptid_t | debug_event_ptid (DEBUG_EVENT *event) |
| static void | win32_get_thread_context (win32_thread_info *th) |
| static void | win32_set_thread_context (win32_thread_info *th) |
| static void | win32_prepare_to_resume (win32_thread_info *th) |
| void | win32_require_context (win32_thread_info *th) |
| static win32_thread_info * | thread_rec (ptid_t ptid, int get_context) |
| static win32_thread_info * | child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) |
| static void | delete_thread_info (thread_info *thread) |
| static void | child_delete_thread (DWORD pid, DWORD tid) |
| static int | win32_supports_z_point_type (char z_type) |
| static int | win32_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp) |
| static int | win32_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp) |
| static int | win32_stopped_by_watchpoint (void) |
| static CORE_ADDR | win32_stopped_data_address (void) |
| static int | child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write, struct target_ops *target) |
| static void | child_init_thread_list (void) |
| static void | do_initial_child_stuff (HANDLE proch, DWORD pid, int attached) |
| static void | continue_one_thread (thread_info *thread, int thread_id) |
| static BOOL | child_continue (DWORD continue_status, int thread_id) |
| static void | child_fetch_inferior_registers (struct regcache *regcache, int r) |
| static void | child_store_inferior_registers (struct regcache *regcache, int r) |
| char * | strwinerror (DWORD error) |
| static BOOL | create_process (const char *program, char *args, DWORD flags, PROCESS_INFORMATION *pi) |
| static int | win32_create_inferior (const char *program, const std::vector< char *> &program_args) |
| static int | win32_attach (unsigned long pid) |
| static void | handle_output_debug_string (void) |
| static void | win32_clear_inferiors (void) |
| static int | win32_kill (int pid) |
| static int | win32_detach (int pid) |
| static void | win32_mourn (struct process_info *process) |
| static void | win32_join (int pid) |
| static int | win32_thread_alive (ptid_t ptid) |
| static void | win32_add_one_solib (const char *name, CORE_ADDR load_addr) |
| static char * | get_image_name (HANDLE h, void *address, int unicode) |
| static BOOL | load_psapi (void) |
| static void | handle_load_dll (void) |
| static void | handle_unload_dll (void) |
| static void | handle_exception (struct target_waitstatus *ourstatus) |
| static void | suspend_one_thread (thread_info *thread) |
| static void | fake_breakpoint_event (void) |
| static int | get_child_debug_event (struct target_waitstatus *ourstatus) |
| static void | win32_fetch_inferior_registers (struct regcache *regcache, int regno) |
| static void | win32_store_inferior_registers (struct regcache *regcache, int regno) |
| static int | win32_read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) |
| static int | win32_write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) |
| static void | win32_request_interrupt (void) |
| static int | win32_get_tib_address (ptid_t ptid, CORE_ADDR *addr) |
| static const gdb_byte * | win32_sw_breakpoint_from_kind (int kind, int *size) |
| void | initialize_low (void) |
Variables | |
| int | using_threads = 1 |
| static int | attaching = 0 |
| static HANDLE | current_process_handle = NULL |
| static DWORD | current_process_id = 0 |
| static DWORD | main_thread_id = 0 |
| static enum gdb_signal | last_sig = GDB_SIGNAL_0 |
| static DEBUG_EVENT | current_event |
| static struct target_waitstatus | cached_status |
| static int | soft_interrupt_requested = 0 |
| static int | faked_breakpoint = 0 |
| const struct target_desc * | win32_tdesc |
| static int | child_initialization_done = 0 |
| static winapi_EnumProcessModules | win32_EnumProcessModules |
| static winapi_GetModuleInformation | win32_GetModuleInformation |
| static winapi_GetModuleFileNameExA | win32_GetModuleFileNameExA |
| static struct target_ops | win32_target_ops |
| #define _T | ( | x | ) | TEXT (x) |
Definition at line 55 of file win32-low.c.
Referenced by win32_attach(), win32_detach(), and win32_request_interrupt().
| #define COUNTOF | ( | STR | ) | (sizeof (STR) / sizeof ((STR)[0])) |
Definition at line 59 of file win32-low.c.
Referenced by strwinerror().
| #define GETPROCADDRESS | ( | DLL, | |
| PROC | |||
| ) | ((winapi_ ## PROC) GetProcAddress (DLL, #PROC)) |
Definition at line 66 of file win32-low.c.
Referenced by load_psapi(), win32_attach(), win32_detach(), and win32_request_interrupt().
| #define NUM_REGS (the_low_target.num_regs) |
Definition at line 97 of file win32-low.c.
Referenced by child_fetch_inferior_registers(), and child_store_inferior_registers().
| #define OUTMSG | ( | X | ) | do { printf X; fflush (stderr); } while (0) |
Definition at line 42 of file win32-low.c.
Referenced by continue_one_thread(), suspend_one_thread(), win32_require_context(), win32_resume(), and win32_wait().
| #define OUTMSG2 | ( | X | ) |
Definition at line 44 of file win32-low.c.
Referenced by fake_breakpoint_event(), get_child_debug_event(), handle_exception(), handle_output_debug_string(), win32_create_inferior(), and win32_wait().
| #define READ_BUFFER_LEN 1024 |
Referenced by handle_output_debug_string().
| typedef HANDLE(WINAPI * winapi_CreateToolhelp32Snapshot) (DWORD, DWORD) |
Definition at line 1181 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_DebugActiveProcessStop) (DWORD dwProcessId) |
Definition at line 99 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_DebugBreakProcess) (HANDLE) |
Definition at line 101 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_DebugSetProcessKillOnExit) (BOOL KillOnExit) |
Definition at line 100 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_EnumProcessModules) (HANDLE, HMODULE *, DWORD, LPDWORD) |
Definition at line 1088 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD) |
Definition at line 102 of file win32-low.c.
| typedef DWORD(WINAPI * winapi_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR, DWORD) |
Definition at line 1092 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO, DWORD) |
Definition at line 1090 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_Module32First) (HANDLE, LPMODULEENTRY32) |
Definition at line 1182 of file win32-low.c.
| typedef BOOL(WINAPI * winapi_Module32Next) (HANDLE, LPMODULEENTRY32) |
Definition at line 1183 of file win32-low.c.
|
static |
Definition at line 208 of file win32-low.c.
References add_thread(), win32_thread_info::h, ptid_build(), the_low_target, win32_thread_info::thread_local_base, thread_rec(), win32_thread_info::tid, and XCNEW.
Referenced by get_child_debug_event().
|
static |
Definition at line 454 of file win32-low.c.
References continue_one_thread(), current_event, faked_breakpoint, for_each_thread(), and thread_resume::thread.
Referenced by get_child_debug_event(), win32_kill(), win32_resume(), and win32_wait().
|
static |
Definition at line 242 of file win32-low.c.
References all_threads, delete_thread_info(), and find_thread_ptid().
Referenced by get_child_debug_event().
|
static |
Definition at line 474 of file win32-low.c.
References current_thread_ptid(), NUM_REGS, the_low_target, and thread_rec().
Referenced by win32_fetch_inferior_registers(), and win32_wait().
|
static |
Definition at line 340 of file win32-low.c.
References delete_thread_info(), and for_each_thread().
Referenced by do_initial_child_stuff().
|
static |
Definition at line 488 of file win32-low.c.
References current_thread_ptid(), NUM_REGS, the_low_target, and thread_rec().
Referenced by win32_store_inferior_registers().
|
static |
Definition at line 308 of file win32-low.c.
References current_process_handle.
Referenced by win32_read_inferior_memory(), and win32_write_inferior_memory().
|
static |
Definition at line 426 of file win32-low.c.
References win32_thread_info::context, win32_thread_info::h, OUTMSG, strwinerror(), win32_thread_info::suspended, thread_resume::thread, thread_target_data(), win32_thread_info::tid, win32_prepare_to_resume(), and win32_set_thread_context().
Referenced by child_continue().
|
static |
Definition at line 555 of file win32-low.c.
References _, alloca(), error(), gdb_tilde_expand(), get_inferior_cwd(), and string.
Referenced by win32_create_inferior().
|
static |
Definition at line 114 of file win32-low.c.
References current_ptid.
Referenced by child_fetch_inferior_registers(), and child_store_inferior_registers().
|
static |
Definition at line 121 of file win32-low.c.
References ptid_build().
Referenced by get_child_debug_event(), win32_resume(), and win32_wait().
|
static |
Definition at line 231 of file win32-low.c.
References free(), win32_thread_info::h, remove_thread(), and thread_target_data().
Referenced by child_delete_thread(), child_init_thread_list(), and win32_clear_inferiors().
|
static |
Definition at line 350 of file win32-low.c.
References add_process(), process_info::attached, cached_status, child_init_thread_list(), child_initialization_done, current_event, current_process_handle, current_process_id, faked_breakpoint, last_sig, main_thread_id, memset(), minus_one_ptid, process_info::pid, resume(), soft_interrupt_requested, process_info::tdesc, the_low_target, win32_add_all_dlls(), win32_resume(), win32_tdesc, and win32_wait().
Referenced by win32_attach(), and win32_create_inferior().
|
static |
Definition at line 1353 of file win32-low.c.
References current_event, faked_breakpoint, for_each_thread(), main_thread_id, memset(), OUTMSG2, and suspend_one_thread().
Referenced by get_child_debug_event().
|
static |
Definition at line 1379 of file win32-low.c.
References attaching, check_remote_input_interrupt_request(), child_add_thread(), child_continue(), child_delete_thread(), child_initialization_done, current_event, current_process_handle, current_thread, debug_event_ptid(), fake_breakpoint_event(), find_thread_ptid(), get_first_thread(), handle_exception(), handle_load_dll(), handle_output_debug_string(), handle_unload_dll(), last_sig, main_thread_id, OUTMSG2, set_breakpoint_at(), and soft_interrupt_requested.
Referenced by win32_wait().
|
static |
Definition at line 1040 of file win32-low.c.
Referenced by handle_load_dll().
|
static |
Definition at line 1227 of file win32-low.c.
References check_breakpoints(), current_event, last_sig, OUTMSG2, and phex_nz().
Referenced by get_child_debug_event().
|
static |
Definition at line 1193 of file win32-low.c.
References current_event, current_process_handle, get_image_name(), and win32_add_one_solib().
Referenced by get_child_debug_event().
|
static |
Definition at line 747 of file win32-low.c.
References current_event, monitor_output(), OUTMSG2, READ_BUFFER_LEN, read_inferior_memory(), server_waiting, and startswith().
Referenced by get_child_debug_event(), and win32_kill().
|
static |
Definition at line 1214 of file win32-low.c.
References current_event, and unloaded_dll().
Referenced by get_child_debug_event().
| void initialize_low | ( | void | ) |
Definition at line 1861 of file win32-low.c.
References linux_target_ops::arch_setup, initialize_low_arch(), linux_check_ptrace_features(), linux_ptrace_init_warnings(), memset(), set_target_ops(), sigchld_handler(), and the_low_target.
|
static |
Definition at line 1100 of file win32-low.c.
References GETPROCADDRESS, win32_EnumProcessModules, win32_GetModuleFileNameExA, and win32_GetModuleInformation.
Referenced by win32_add_all_dlls().
| char* strwinerror | ( | DWORD | error | ) |
Definition at line 510 of file win32-low.c.
References COUNTOF, and error().
Referenced by continue_one_thread(), perror(), suspend_one_thread(), win32_attach(), win32_create_inferior(), and win32_require_context().
|
static |
Definition at line 1335 of file win32-low.c.
References win32_thread_info::h, OUTMSG, strwinerror(), win32_thread_info::suspended, thread_resume::thread, and thread_target_data().
Referenced by fake_breakpoint_event().
|
static |
Definition at line 194 of file win32-low.c.
References find_thread_ptid(), thread_target_data(), and win32_require_context().
Referenced by child_add_thread(), child_fetch_inferior_registers(), child_store_inferior_registers(), win32_get_tib_address(), and win32_resume().
|
static |
Definition at line 1130 of file win32-low.c.
References alloca(), current_process_handle, load_psapi(), win32_add_one_solib(), win32_GetModuleFileNameExA, and win32_GetModuleInformation.
Referenced by do_initial_child_stuff().
|
static |
Definition at line 979 of file win32-low.c.
References loaded_dll(), and name.
Referenced by handle_load_dll(), and win32_add_all_dlls().
|
static |
Definition at line 711 of file win32-low.c.
References _T, attaching, do_initial_child_stuff(), error(), GETPROCADDRESS, and strwinerror().
|
static |
Definition at line 791 of file win32-low.c.
References clear_inferiors(), current_process_handle, delete_thread_info(), and for_each_thread().
Referenced by win32_detach(), win32_kill(), and win32_wait().
|
static |
Definition at line 624 of file win32-low.c.
References alloca(), attaching, create_process(), current_process_id, do_initial_child_stuff(), error(), OUTMSG2, program_args, string, stringify_argv(), and strwinerror().
|
static |
Definition at line 831 of file win32-low.c.
References _T, current_process_id, find_process_pid(), GETPROCADDRESS, minus_one_ptid, remove_process(), resume(), win32_clear_inferiors(), and win32_resume().
|
static |
Definition at line 1630 of file win32-low.c.
References child_fetch_inferior_registers().
|
static |
Definition at line 129 of file win32-low.c.
References win32_thread_info::context, memset(), and the_low_target.
Referenced by win32_require_context().
Definition at line 1759 of file win32-low.c.
References win32_thread_info::thread_local_base, and thread_rec().
|
static |
Definition at line 266 of file win32-low.c.
References linux_target_ops::insert_point, and the_low_target.
|
static |
Definition at line 875 of file win32-low.c.
|
static |
Definition at line 802 of file win32-low.c.
References child_continue(), current_event, current_process_handle, find_process_pid(), handle_output_debug_string(), process_info::pid, remove_process(), and win32_clear_inferiors().
|
static |
Definition at line 868 of file win32-low.c.
References remove_process().
|
static |
Definition at line 162 of file win32-low.c.
References linux_target_ops::prepare_to_resume, and the_low_target.
Referenced by continue_one_thread(), and win32_resume().
|
static |
Definition at line 1647 of file win32-low.c.
References child_xfer_memory().
|
static |
Definition at line 277 of file win32-low.c.
References linux_target_ops::remove_point, and the_low_target.
|
static |
Definition at line 1665 of file win32-low.c.
References _T, current_process_handle, current_process_id, GETPROCADDRESS, and soft_interrupt_requested.
| void win32_require_context | ( | win32_thread_info * | th | ) |
Definition at line 171 of file win32-low.c.
References win32_thread_info::context, win32_thread_info::h, OUTMSG, strwinerror(), win32_thread_info::suspended, and win32_get_thread_context().
Referenced by i386_prepare_to_resume(), thread_rec(), and win32_get_current_dr().
|
static |
Definition at line 897 of file win32-low.c.
References child_continue(), win32_thread_info::context, current_event, debug_event_ptid(), error(), gdb_signal_from_host(), gdb_signal_to_string(), thread_resume::kind, last_sig, minus_one_ptid, OUTMSG, ptid_equal(), regcache_invalidate(), thread_resume::sig, the_low_target, thread_resume::thread, thread_rec(), win32_prepare_to_resume(), and win32_set_thread_context().
Referenced by do_initial_child_stuff(), and win32_detach().
|
static |
Definition at line 141 of file win32-low.c.
References win32_thread_info::context, and win32_thread_info::h.
Referenced by continue_one_thread(), and win32_resume().
|
static |
Definition at line 288 of file win32-low.c.
References linux_target_ops::stopped_by_watchpoint, and the_low_target.
|
static |
Definition at line 297 of file win32-low.c.
References linux_target_ops::stopped_data_address, and the_low_target.
|
static |
Definition at line 1638 of file win32-low.c.
References child_store_inferior_registers().
|
static |
Definition at line 259 of file win32-low.c.
References linux_target_ops::supports_z_point_type, and the_low_target.
|
static |
Definition at line 1773 of file win32-low.c.
References the_low_target.
|
static |
Definition at line 887 of file win32-low.c.
References find_thread_ptid().
Definition at line 1581 of file win32-low.c.
References cached_status, child_continue(), child_fetch_inferior_registers(), current_event, current_thread, debug_event_ptid(), get_child_debug_event(), get_thread_regcache(), OUTMSG, OUTMSG2, pid_to_ptid(), and win32_clear_inferiors().
Referenced by do_initial_child_stuff().
|
static |
Definition at line 1657 of file win32-low.c.
References child_xfer_memory().
|
static |
Definition at line 73 of file win32-low.c.
Referenced by get_child_debug_event(), win32_attach(), and win32_create_inferior().
|
static |
Definition at line 85 of file win32-low.c.
Referenced by do_initial_child_stuff(), and win32_wait().
|
static |
Definition at line 347 of file win32-low.c.
Referenced by do_initial_child_stuff(), and get_child_debug_event().
|
static |
Definition at line 80 of file win32-low.c.
Referenced by child_continue(), do_initial_child_stuff(), fake_breakpoint_event(), get_child_debug_event(), handle_exception(), handle_load_dll(), handle_output_debug_string(), handle_unload_dll(), win32_kill(), win32_resume(), and win32_wait().
|
static |
Definition at line 74 of file win32-low.c.
Referenced by child_xfer_memory(), do_initial_child_stuff(), get_child_debug_event(), handle_load_dll(), win32_add_all_dlls(), win32_clear_inferiors(), win32_kill(), and win32_request_interrupt().
|
static |
Definition at line 75 of file win32-low.c.
Referenced by do_initial_child_stuff(), win32_create_inferior(), win32_detach(), and win32_request_interrupt().
|
static |
Definition at line 93 of file win32-low.c.
Referenced by child_continue(), do_initial_child_stuff(), and fake_breakpoint_event().
|
static |
Definition at line 77 of file win32-low.c.
Referenced by do_initial_child_stuff(), get_child_debug_event(), handle_exception(), and win32_resume().
|
static |
Definition at line 76 of file win32-low.c.
Referenced by do_initial_child_stuff(), fake_breakpoint_event(), and get_child_debug_event().
|
static |
Definition at line 89 of file win32-low.c.
Referenced by do_initial_child_stuff(), get_child_debug_event(), and win32_request_interrupt().
| int using_threads = 1 |
Definition at line 70 of file win32-low.c.
Referenced by prepare_resume_reply().
|
static |
Definition at line 1095 of file win32-low.c.
Referenced by load_psapi().
|
static |
Definition at line 1097 of file win32-low.c.
Referenced by load_psapi(), and win32_add_all_dlls().
|
static |
Definition at line 1096 of file win32-low.c.
Referenced by load_psapi(), and win32_add_all_dlls().
|
static |
Definition at line 1779 of file win32-low.c.
| const struct target_desc* win32_tdesc |
Definition at line 95 of file win32-low.c.
Referenced by arm_arch_setup(), do_initial_child_stuff(), and i386_arch_setup().
1.8.14