GDBserver
Defines | Typedefs | Functions | Variables
/home/stan/gdb/src/gdb/gdbserver/win32-low.c File Reference
#include "server.h"
#include "regcache.h"
#include "gdb/signals.h"
#include "gdb/fileio.h"
#include "mem-break.h"
#include "win32-low.h"
#include "gdbthread.h"
#include "dll.h"
#include "hostio.h"
#include <stdint.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.

Defines

#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 void win32_resume (struct thread_resume *resume_info, size_t n)
static ptid_t current_inferior_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 win32_thread_infothread_rec (ptid_t ptid, int get_context)
static win32_thread_infochild_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_insert_point (char type, CORE_ADDR addr, int len)
static int win32_remove_point (char type, CORE_ADDR addr, int len)
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)
static int psapi_get_dll_name (LPVOID BaseAddress, char *dll_name_ret)
typedef HANDLE (WINAPI *winapi_CreateToolhelp32Snapshot)(DWORD
static BOOL load_toolhelp (void)
static int toolhelp_get_dll_name (LPVOID BaseAddress, char *dll_name_ret)
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 ptid_t win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
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 int soft_interrupt_requested = 0
static int faked_breakpoint = 0
struct target_descwin32_tdesc
typedef HMODULE
typedef LPMODULEINFO
typedef LPSTR
static winapi_EnumProcessModules win32_EnumProcessModules
static winapi_GetModuleInformation win32_GetModuleInformation
static winapi_GetModuleFileNameExA win32_GetModuleFileNameExA
typedef LPMODULEENTRY32
static
winapi_CreateToolhelp32Snapshot 
win32_CreateToolhelp32Snapshot
static winapi_Module32First win32_Module32First
static winapi_Module32Next win32_Module32Next
static struct target_ops win32_target_ops

Define Documentation

#define _T (   x)    TEXT (x)

Definition at line 56 of file win32-low.c.

Referenced by load_toolhelp(), win32_attach(), win32_detach(), and win32_request_interrupt().

#define COUNTOF (   STR)    (sizeof (STR) / sizeof ((STR)[0]))

Definition at line 60 of file win32-low.c.

Referenced by strwinerror().

#define GETPROCADDRESS (   DLL,
  PROC 
)    ((winapi_ ## PROC) GetProcAddress (DLL, #PROC))
#define NUM_REGS   (the_low_target.num_regs)

Definition at line 93 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)
#define OUTMSG2 (   X)
Value:
do                                              \
    {                                           \
      if (debug_threads)                        \
        {                                       \
          printf X;                             \
          fflush (stderr);                      \
        }                                       \
    } while (0)

Definition at line 45 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

Typedef Documentation

typedef DWORD

Definition at line 999 of file win32-low.c.

typedef HMODULE LPDWORD

Definition at line 999 of file win32-low.c.


Function Documentation

typedef BOOL ( WINAPI *  winapi_DebugActiveProcessStop)
static win32_thread_info* child_add_thread ( DWORD  pid,
DWORD  tid,
HANDLE  h,
void *  tlb 
) [static]
static BOOL child_continue ( DWORD  continue_status,
int  thread_id 
) [static]
static void child_delete_thread ( DWORD  pid,
DWORD  tid 
) [static]
static void child_fetch_inferior_registers ( struct regcache regcache,
int  r 
) [static]
static void child_init_thread_list ( void  ) [static]

Definition at line 312 of file win32-low.c.

References all_threads, delete_thread_info(), and for_each_inferior().

Referenced by do_initial_child_stuff().

static void child_store_inferior_registers ( struct regcache regcache,
int  r 
) [static]

Definition at line 403 of file win32-low.c.

References current_inferior_ptid(), NUM_REGS, the_low_target, and thread_rec().

Referenced by win32_store_inferior_registers().

static int child_xfer_memory ( CORE_ADDR  memaddr,
char *  our,
int  len,
int  write,
struct target_ops target 
) [static]

Definition at line 280 of file win32-low.c.

References BOOL(), and current_process_handle.

Referenced by win32_read_inferior_memory(), and win32_write_inferior_memory().

static int continue_one_thread ( struct inferior_list_entry this_thread,
void *  id_ptr 
) [static]
static BOOL create_process ( const char *  program,
char *  args,
DWORD  flags,
PROCESS_INFORMATION *  pi 
) [static]

Definition at line 470 of file win32-low.c.

References BOOL().

Referenced by win32_create_inferior().

static ptid_t current_inferior_ptid ( void  ) [static]

Definition at line 105 of file win32-low.c.

References current_inferior.

Referenced by child_fetch_inferior_registers(), and child_store_inferior_registers().

static ptid_t debug_event_ptid ( DEBUG_EVENT *  event) [static]

Definition at line 112 of file win32-low.c.

References ptid_build().

Referenced by get_child_debug_event(), win32_resume(), and win32_wait().

static void delete_thread_info ( struct inferior_list_entry thread) [static]
static void do_initial_child_stuff ( HANDLE  proch,
DWORD  pid,
int  attached 
) [static]
typedef DWORD ( WINAPI *  winapi_GetModuleFileNameExA)
static void fake_breakpoint_event ( void  ) [static]
static int get_child_debug_event ( struct target_waitstatus *  ourstatus) [static]
static char* get_image_name ( HANDLE  h,
void *  address,
int  unicode 
) [static]

Definition at line 951 of file win32-low.c.

Referenced by handle_load_dll().

typedef HANDLE ( WINAPI *  winapi_CreateToolhelp32Snapshot)
static void handle_exception ( struct target_waitstatus *  ourstatus) [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 void handle_load_dll ( void  ) [static]
static void handle_output_debug_string ( struct target_waitstatus *  ourstatus) [static]
static void handle_unload_dll ( void  ) [static]

Definition at line 1227 of file win32-low.c.

References current_event, and unloaded_dll().

Referenced by get_child_debug_event().

void initialize_low ( void  )
static BOOL load_psapi ( void  ) [static]

Definition at line 1011 of file win32-low.c.

References GETPROCADDRESS.

Referenced by psapi_get_dll_name().

static BOOL load_toolhelp ( void  ) [static]

Definition at line 1115 of file win32-low.c.

References _T, and GETPROCADDRESS.

Referenced by toolhelp_get_dll_name().

static int psapi_get_dll_name ( LPVOID  BaseAddress,
char *  dll_name_ret 
) [static]

Definition at line 1036 of file win32-low.c.

References BOOL(), current_process_handle, error(), HMODULE, load_psapi(), and strwinerror().

Referenced by handle_load_dll().

char* strwinerror ( DWORD  error)
static void suspend_one_thread ( struct inferior_list_entry entry) [static]
static win32_thread_info* thread_rec ( ptid_t  ptid,
int  get_context 
) [static]
static int toolhelp_get_dll_name ( LPVOID  BaseAddress,
char *  dll_name_ret 
) [static]

Definition at line 1151 of file win32-low.c.

References current_event, load_toolhelp(), and win32_CreateToolhelp32Snapshot.

Referenced by handle_load_dll().

static void win32_add_one_solib ( const char *  name,
CORE_ADDR  load_addr 
) [static]

Definition at line 895 of file win32-low.c.

References HANDLE(), loaded_dll(), and strrchr().

Referenced by handle_load_dll().

static int win32_attach ( unsigned long  pid) [static]
static void win32_clear_inferiors ( void  ) [static]
static int win32_create_inferior ( char *  program,
char **  program_args 
) [static]
static int win32_detach ( int  pid) [static]
static void win32_fetch_inferior_registers ( struct regcache regcache,
int  regno 
) [static]

Definition at line 1646 of file win32-low.c.

References child_fetch_inferior_registers().

static void win32_get_thread_context ( win32_thread_info th) [static]

Definition at line 120 of file win32-low.c.

References win32_thread_info::context, current_event, memcpy(), memset(), and the_low_target.

Referenced by thread_rec().

static int win32_get_tib_address ( ptid_t  ptid,
CORE_ADDR addr 
) [static]

Definition at line 1775 of file win32-low.c.

References win32_thread_info::thread_local_base, and thread_rec().

static int win32_insert_point ( char  type,
CORE_ADDR  addr,
int  len 
) [static]

Definition at line 240 of file win32-low.c.

References linux_target_ops::insert_point, and the_low_target.

static void win32_join ( int  pid) [static]

Definition at line 789 of file win32-low.c.

References HANDLE().

static int win32_kill ( int  pid) [static]
static void win32_mourn ( struct process_info process) [static]

Definition at line 782 of file win32-low.c.

References remove_process().

static int win32_read_inferior_memory ( CORE_ADDR  memaddr,
unsigned char *  myaddr,
int  len 
) [static]

Definition at line 1663 of file win32-low.c.

References child_xfer_memory().

static int win32_remove_point ( char  type,
CORE_ADDR  addr,
int  len 
) [static]

Definition at line 250 of file win32-low.c.

References linux_target_ops::remove_point, and the_low_target.

static void win32_request_interrupt ( void  ) [static]
static void win32_resume ( struct thread_resume resume_info,
size_t  n 
) [static]
static void win32_set_thread_context ( win32_thread_info th) [static]

Definition at line 132 of file win32-low.c.

References win32_thread_info::context, current_event, memcmp(), and the_low_target.

Referenced by continue_one_thread(), and win32_resume().

static int win32_stopped_by_watchpoint ( void  ) [static]

Definition at line 260 of file win32-low.c.

References linux_target_ops::stopped_by_watchpoint, and the_low_target.

static CORE_ADDR win32_stopped_data_address ( void  ) [static]

Definition at line 269 of file win32-low.c.

References linux_target_ops::stopped_data_address, and the_low_target.

static void win32_store_inferior_registers ( struct regcache regcache,
int  regno 
) [static]

Definition at line 1654 of file win32-low.c.

References child_store_inferior_registers().

static int win32_thread_alive ( ptid_t  ptid) [static]

Definition at line 801 of file win32-low.c.

References all_threads, and find_inferior_id().

static ptid_t win32_wait ( ptid_t  ptid,
struct target_waitstatus *  ourstatus,
int  options 
) [static]
static int win32_write_inferior_memory ( CORE_ADDR  memaddr,
const unsigned char *  myaddr,
int  len 
) [static]

Definition at line 1673 of file win32-low.c.

References child_xfer_memory().


Variable Documentation

int attaching = 0 [static]

Definition at line 74 of file win32-low.c.

Referenced by get_child_debug_event(), win32_attach(), and win32_create_inferior().

DEBUG_EVENT current_event [static]
HANDLE current_process_handle = NULL [static]
DWORD current_process_id = 0 [static]
int faked_breakpoint = 0 [static]

Definition at line 89 of file win32-low.c.

Referenced by child_continue(), do_initial_child_stuff(), and fake_breakpoint_event().

typedef HMODULE

Definition at line 1001 of file win32-low.c.

Referenced by psapi_get_dll_name(), win32_attach(), and win32_detach().

enum gdb_signal last_sig = GDB_SIGNAL_0 [static]
typedef LPMODULEENTRY32

Definition at line 1103 of file win32-low.c.

typedef LPMODULEINFO

Definition at line 1001 of file win32-low.c.

typedef LPSTR

Definition at line 1003 of file win32-low.c.

DWORD main_thread_id = 0 [static]
int soft_interrupt_requested = 0 [static]
int using_threads = 1

Definition at line 71 of file win32-low.c.

winapi_CreateToolhelp32Snapshot win32_CreateToolhelp32Snapshot [static]

Definition at line 1106 of file win32-low.c.

Referenced by toolhelp_get_dll_name().

winapi_EnumProcessModules win32_EnumProcessModules [static]

Definition at line 1006 of file win32-low.c.

winapi_GetModuleFileNameExA win32_GetModuleFileNameExA [static]

Definition at line 1008 of file win32-low.c.

winapi_GetModuleInformation win32_GetModuleInformation [static]

Definition at line 1007 of file win32-low.c.

winapi_Module32First win32_Module32First [static]

Definition at line 1107 of file win32-low.c.

winapi_Module32Next win32_Module32Next [static]

Definition at line 1108 of file win32-low.c.

struct target_ops win32_target_ops [static]

Definition at line 1786 of file win32-low.c.

Definition at line 91 of file win32-low.c.

Referenced by arm_arch_setup(), do_initial_child_stuff(), and i386_arch_setup().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines