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 <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 HMODULE | DWORD |
typedef HMODULE | LPDWORD |
Functions | |
typedef | BOOL (WINAPI *winapi_DebugActiveProcessStop)(DWORD dwProcessId) |
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 (struct inferior_list_entry *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 int | continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr) |
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 (char *program, char **program_args) |
static int | win32_attach (unsigned long pid) |
static void | handle_output_debug_string (struct target_waitstatus *ourstatus) |
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) |
typedef | DWORD (WINAPI *winapi_GetModuleFileNameExA)(HANDLE |
static BOOL | load_psapi (void) |
typedef | HANDLE (WINAPI *winapi_CreateToolhelp32Snapshot)(DWORD |
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 (struct inferior_list_entry *entry) |
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) |
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 |
typedef | HMODULE |
typedef | LPMODULEINFO |
typedef | LPSTR |
static winapi_EnumProcessModules | win32_EnumProcessModules |
static winapi_GetModuleInformation | win32_GetModuleInformation |
static winapi_GetModuleFileNameExA | win32_GetModuleFileNameExA |
typedef | LPMODULEENTRY32 |
static struct target_ops | win32_target_ops |
#define _T | ( | x | ) | TEXT (x) |
Definition at line 53 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 57 of file win32-low.c.
Referenced by strwinerror().
#define GETPROCADDRESS | ( | DLL, | |
PROC | |||
) | ((winapi_ ## PROC) GetProcAddress (DLL, #PROC)) |
Definition at line 64 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 95 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 40 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 42 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 DWORD |
Definition at line 1097 of file win32-low.c.
Definition at line 1097 of file win32-low.c.
typedef BOOL | ( | WINAPI * | winapi_DebugActiveProcessStop | ) |
Referenced by child_xfer_memory(), create_process(), win32_add_all_dlls(), and win32_create_inferior().
|
static |
Definition at line 209 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 xcalloc().
Referenced by get_child_debug_event().
Definition at line 463 of file win32-low.c.
References all_threads, continue_one_thread(), current_event, faked_breakpoint, and find_inferior().
Referenced by get_child_debug_event(), win32_kill(), win32_resume(), and win32_wait().
Definition at line 243 of file win32-low.c.
References all_threads, delete_thread_info(), find_inferior_id(), one_inferior_p(), and ptid_build().
Referenced by get_child_debug_event().
|
static |
Definition at line 480 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 345 of file win32-low.c.
References all_threads, delete_thread_info(), and for_each_inferior().
Referenced by do_initial_child_stuff().
|
static |
Definition at line 494 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 313 of file win32-low.c.
References BOOL(), and current_process_handle.
Referenced by win32_read_inferior_memory(), and win32_write_inferior_memory().
|
static |
Definition at line 431 of file win32-low.c.
References win32_thread_info::context, win32_thread_info::h, inferior_target_data(), OUTMSG, strwinerror(), win32_thread_info::suspended, win32_thread_info::tid, win32_prepare_to_resume(), and win32_set_thread_context().
Referenced by child_continue().
|
static |
Definition at line 561 of file win32-low.c.
References alloca(), and BOOL().
Referenced by win32_create_inferior().
|
static |
Definition at line 112 of file win32-low.c.
References current_ptid.
Referenced by child_fetch_inferior_registers(), and child_store_inferior_registers().
|
static |
Definition at line 119 of file win32-low.c.
References ptid_build().
Referenced by get_child_debug_event(), win32_resume(), and win32_wait().
|
static |
Definition at line 232 of file win32-low.c.
References win32_thread_info::h, inferior_target_data(), and remove_thread().
Referenced by child_delete_thread(), child_init_thread_list(), and win32_clear_inferiors().
Definition at line 355 of file win32-low.c.
References add_process(), cached_status, child_init_thread_list(), child_initialization_done, current_event, current_process_handle, current_process_id, faked_breakpoint, thread_resume::kind, last_sig, main_thread_id, minus_one_ptid, thread_resume::sig, soft_interrupt_requested, process_info::tdesc, the_low_target, thread_resume::thread, win32_add_all_dlls(), win32_resume(), win32_tdesc, and win32_wait().
Referenced by win32_attach(), and win32_create_inferior().
typedef DWORD | ( | WINAPI * | winapi_GetModuleFileNameExA | ) |
|
static |
Definition at line 1363 of file win32-low.c.
References all_threads, current_event, faked_breakpoint, for_each_inferior(), main_thread_id, OUTMSG2, and suspend_one_thread().
Referenced by get_child_debug_event().
|
static |
Definition at line 1389 of file win32-low.c.
References all_threads, 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_inferior_id(), handle_exception(), handle_load_dll(), handle_output_debug_string(), handle_unload_dll(), inferior_list::head, last_sig, main_thread_id, OUTMSG2, set_breakpoint_at(), and soft_interrupt_requested.
Referenced by win32_wait().
|
static |
typedef HANDLE | ( | WINAPI * | winapi_CreateToolhelp32Snapshot | ) |
Referenced by win32_add_one_solib(), win32_attach(), and win32_join().
|
static |
Definition at line 1236 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 1202 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 749 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 1223 of file win32-low.c.
References current_event, and unloaded_dll().
Referenced by get_child_debug_event().
void initialize_low | ( | void | ) |
Definition at line 1848 of file win32-low.c.
References linux_target_ops::arch_setup, linux_target_ops::breakpoint, linux_target_ops::breakpoint_len, initialize_low_arch(), linux_check_ptrace_features(), linux_init_signals(), linux_ptrace_init_warnings(), set_breakpoint_data(), set_target_ops(), sigchld_handler(), and the_low_target.
|
static |
Definition at line 1109 of file win32-low.c.
References GETPROCADDRESS.
Referenced by win32_add_all_dlls().
char* strwinerror | ( | DWORD | error | ) |
Definition at line 516 of file win32-low.c.
References COUNTOF.
Referenced by continue_one_thread(), perror(), suspend_one_thread(), win32_attach(), win32_create_inferior(), and win32_require_context().
|
static |
Definition at line 1344 of file win32-low.c.
References win32_thread_info::h, inferior_target_data(), OUTMSG, strwinerror(), and win32_thread_info::suspended.
Referenced by fake_breakpoint_event().
|
static |
Definition at line 192 of file win32-low.c.
References all_threads, find_inferior_id(), inferior_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 1139 of file win32-low.c.
References alloca(), BOOL(), current_process_handle, HMODULE, load_psapi(), and win32_add_one_solib().
Referenced by do_initial_child_stuff().
|
static |
Definition at line 988 of file win32-low.c.
References HANDLE(), and loaded_dll().
Referenced by handle_load_dll(), and win32_add_all_dlls().
|
static |
Definition at line 713 of file win32-low.c.
References _T, attaching, do_initial_child_stuff(), error(), GETPROCADDRESS, HANDLE(), HMODULE, and strwinerror().
|
static |
Definition at line 793 of file win32-low.c.
References all_threads, clear_inferiors(), current_process_handle, delete_thread_info(), and for_each_inferior().
Referenced by win32_detach(), win32_kill(), and win32_wait().
|
static |
Definition at line 616 of file win32-low.c.
References alloca(), attaching, BOOL(), create_process(), current_process_id, do_initial_child_stuff(), error(), OUTMSG2, and strwinerror().
|
static |
Definition at line 836 of file win32-low.c.
References _T, current_process_id, find_process_pid(), GETPROCADDRESS, HMODULE, thread_resume::kind, minus_one_ptid, remove_process(), thread_resume::sig, thread_resume::thread, win32_clear_inferiors(), and win32_resume().
|
static |
Definition at line 1646 of file win32-low.c.
References child_fetch_inferior_registers().
|
static |
Definition at line 127 of file win32-low.c.
References win32_thread_info::context, and the_low_target.
Referenced by win32_require_context().
Definition at line 1775 of file win32-low.c.
References win32_thread_info::thread_local_base, and thread_rec().
|
static |
Definition at line 271 of file win32-low.c.
References linux_target_ops::insert_point, and the_low_target.
|
static |
Definition at line 880 of file win32-low.c.
References HANDLE().
|
static |
Definition at line 804 of file win32-low.c.
References child_continue(), current_event, current_process_handle, find_process_pid(), handle_output_debug_string(), remove_process(), and win32_clear_inferiors().
|
static |
Definition at line 873 of file win32-low.c.
References remove_process().
|
static |
Definition at line 160 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 1663 of file win32-low.c.
References child_xfer_memory().
|
static |
Definition at line 282 of file win32-low.c.
References linux_target_ops::remove_point, and the_low_target.
|
static |
Definition at line 1681 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 169 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 908 of file win32-low.c.
References child_continue(), win32_thread_info::context, current_event, debug_event_ptid(), error(), 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 139 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 293 of file win32-low.c.
References linux_target_ops::stopped_by_watchpoint, and the_low_target.
|
static |
Definition at line 302 of file win32-low.c.
References linux_target_ops::stopped_data_address, and the_low_target.
|
static |
Definition at line 1654 of file win32-low.c.
References child_store_inferior_registers().
|
static |
Definition at line 264 of file win32-low.c.
References linux_target_ops::supports_z_point_type, and the_low_target.
|
static |
Definition at line 892 of file win32-low.c.
References all_threads, and find_inferior_id().
Definition at line 1596 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 1673 of file win32-low.c.
References child_xfer_memory().
|
static |
Definition at line 71 of file win32-low.c.
Referenced by get_child_debug_event(), win32_attach(), and win32_create_inferior().
|
static |
Definition at line 83 of file win32-low.c.
Referenced by do_initial_child_stuff(), and win32_wait().
|
static |
Definition at line 352 of file win32-low.c.
Referenced by do_initial_child_stuff(), and get_child_debug_event().
|
static |
Definition at line 78 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 72 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 73 of file win32-low.c.
Referenced by do_initial_child_stuff(), win32_create_inferior(), win32_detach(), and win32_request_interrupt().
|
static |
Definition at line 91 of file win32-low.c.
Referenced by child_continue(), do_initial_child_stuff(), and fake_breakpoint_event().
typedef HMODULE |
Definition at line 1099 of file win32-low.c.
Referenced by win32_add_all_dlls(), win32_attach(), and win32_detach().
|
static |
Definition at line 75 of file win32-low.c.
Referenced by do_initial_child_stuff(), get_child_debug_event(), handle_exception(), and win32_resume().
typedef LPMODULEENTRY32 |
Definition at line 1191 of file win32-low.c.
typedef LPMODULEINFO |
Definition at line 1099 of file win32-low.c.
typedef LPSTR |
Definition at line 1101 of file win32-low.c.
|
static |
Definition at line 74 of file win32-low.c.
Referenced by do_initial_child_stuff(), fake_breakpoint_event(), and get_child_debug_event().
|
static |
Definition at line 87 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 68 of file win32-low.c.
Referenced by prepare_resume_reply().
|
static |
Definition at line 1104 of file win32-low.c.
|
static |
Definition at line 1106 of file win32-low.c.
|
static |
Definition at line 1105 of file win32-low.c.
|
static |
Definition at line 1786 of file win32-low.c.
const struct target_desc* win32_tdesc |
Definition at line 93 of file win32-low.c.
Referenced by arm_arch_setup(), do_initial_child_stuff(), and i386_arch_setup().