Home | History | Annotate | Line # | Download | only in gdbserver
win32-low.h revision 1.1
      1  1.1  christos /* Internal interfaces for the Win32 specific target code for gdbserver.
      2  1.1  christos    Copyright (C) 2007-2020 Free Software Foundation, Inc.
      3  1.1  christos 
      4  1.1  christos    This file is part of GDB.
      5  1.1  christos 
      6  1.1  christos    This program is free software; you can redistribute it and/or modify
      7  1.1  christos    it under the terms of the GNU General Public License as published by
      8  1.1  christos    the Free Software Foundation; either version 3 of the License, or
      9  1.1  christos    (at your option) any later version.
     10  1.1  christos 
     11  1.1  christos    This program is distributed in the hope that it will be useful,
     12  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  1.1  christos    GNU General Public License for more details.
     15  1.1  christos 
     16  1.1  christos    You should have received a copy of the GNU General Public License
     17  1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     18  1.1  christos 
     19  1.1  christos #ifndef GDBSERVER_WIN32_LOW_H
     20  1.1  christos #define GDBSERVER_WIN32_LOW_H
     21  1.1  christos 
     22  1.1  christos #include <windows.h>
     23  1.1  christos #include "nat/windows-nat.h"
     24  1.1  christos 
     25  1.1  christos struct target_desc;
     26  1.1  christos 
     27  1.1  christos /* The inferior's target description.  This is a global because the
     28  1.1  christos    Windows ports support neither bi-arch nor multi-process.  */
     29  1.1  christos extern const struct target_desc *win32_tdesc;
     30  1.1  christos #ifdef __x86_64__
     31  1.1  christos extern const struct target_desc *wow64_win32_tdesc;
     32  1.1  christos 
     33  1.1  christos extern bool wow64_process;
     34  1.1  christos 
     35  1.1  christos typedef BOOL (WINAPI *winapi_Wow64GetThreadContext) (HANDLE, PWOW64_CONTEXT);
     36  1.1  christos extern winapi_Wow64GetThreadContext win32_Wow64GetThreadContext;
     37  1.1  christos #endif
     38  1.1  christos 
     39  1.1  christos struct win32_target_ops
     40  1.1  christos {
     41  1.1  christos   /* Architecture-specific setup.  */
     42  1.1  christos   void (*arch_setup) (void);
     43  1.1  christos 
     44  1.1  christos   /* The number of target registers.  */
     45  1.1  christos   int (*num_regs) (void);
     46  1.1  christos 
     47  1.1  christos   /* Perform initializations on startup.  */
     48  1.1  christos   void (*initial_stuff) (void);
     49  1.1  christos 
     50  1.1  christos   /* Fetch the context from the inferior.  */
     51  1.1  christos   void (*get_thread_context) (windows_nat::windows_thread_info *th);
     52  1.1  christos 
     53  1.1  christos   /* Called just before resuming the thread.  */
     54  1.1  christos   void (*prepare_to_resume) (windows_nat::windows_thread_info *th);
     55  1.1  christos 
     56  1.1  christos   /* Called when a thread was added.  */
     57  1.1  christos   void (*thread_added) (windows_nat::windows_thread_info *th);
     58  1.1  christos 
     59  1.1  christos   /* Fetch register from gdbserver regcache data.  */
     60  1.1  christos   void (*fetch_inferior_register) (struct regcache *regcache,
     61  1.1  christos 				   windows_nat::windows_thread_info *th,
     62  1.1  christos 				   int r);
     63  1.1  christos 
     64  1.1  christos   /* Store a new register value into the thread context of TH.  */
     65  1.1  christos   void (*store_inferior_register) (struct regcache *regcache,
     66  1.1  christos 				   windows_nat::windows_thread_info *th,
     67  1.1  christos 				   int r);
     68  1.1  christos 
     69  1.1  christos   void (*single_step) (windows_nat::windows_thread_info *th);
     70  1.1  christos 
     71  1.1  christos   const unsigned char *breakpoint;
     72  1.1  christos   int breakpoint_len;
     73  1.1  christos 
     74  1.1  christos   /* Amount by which to decrement the PC after a breakpoint is
     75  1.1  christos      hit.  */
     76  1.1  christos   int decr_pc_after_break;
     77  1.1  christos 
     78  1.1  christos   /* Get the PC register from REGCACHE.  */
     79  1.1  christos   CORE_ADDR (*get_pc) (struct regcache *regcache);
     80  1.1  christos   /* Set the PC register in REGCACHE.  */
     81  1.1  christos   void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc);
     82  1.1  christos 
     83  1.1  christos   /* Breakpoint/Watchpoint related functions.  See target.h for comments.  */
     84  1.1  christos   int (*supports_z_point_type) (char z_type);
     85  1.1  christos   int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
     86  1.1  christos 		       int size, struct raw_breakpoint *bp);
     87  1.1  christos   int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr,
     88  1.1  christos 		       int size, struct raw_breakpoint *bp);
     89  1.1  christos   int (*stopped_by_watchpoint) (void);
     90  1.1  christos   CORE_ADDR (*stopped_data_address) (void);
     91  1.1  christos };
     92  1.1  christos 
     93  1.1  christos extern struct win32_target_ops the_low_target;
     94  1.1  christos 
     95  1.1  christos /* Target ops definitions for a Win32 target.  */
     96  1.1  christos 
     97  1.1  christos class win32_process_target : public process_stratum_target
     98  1.1  christos {
     99  1.1  christos public:
    100  1.1  christos 
    101  1.1  christos   int create_inferior (const char *program,
    102  1.1  christos 		       const std::vector<char *> &program_args) override;
    103  1.1  christos 
    104  1.1  christos   int attach (unsigned long pid) override;
    105  1.1  christos 
    106  1.1  christos   int kill (process_info *proc) override;
    107  1.1  christos 
    108  1.1  christos   int detach (process_info *proc) override;
    109  1.1  christos 
    110  1.1  christos   void mourn (process_info *proc) override;
    111  1.1  christos 
    112  1.1  christos   void join (int pid) override;
    113  1.1  christos 
    114  1.1  christos   bool thread_alive (ptid_t pid) override;
    115  1.1  christos 
    116  1.1  christos   void resume (thread_resume *resume_info, size_t n) override;
    117  1.1  christos 
    118  1.1  christos   ptid_t wait (ptid_t ptid, target_waitstatus *status,
    119  1.1  christos 	       int options) override;
    120  1.1  christos 
    121  1.1  christos   void fetch_registers (regcache *regcache, int regno) override;
    122  1.1  christos 
    123  1.1  christos   void store_registers (regcache *regcache, int regno) override;
    124  1.1  christos 
    125  1.1  christos   int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
    126  1.1  christos 		   int len) override;
    127  1.1  christos 
    128  1.1  christos   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
    129  1.1  christos 		    int len) override;
    130  1.1  christos 
    131  1.1  christos   void request_interrupt () override;
    132  1.1  christos 
    133  1.1  christos   bool supports_z_point_type (char z_type) override;
    134  1.1  christos 
    135  1.1  christos   int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
    136  1.1  christos 		    int size, raw_breakpoint *bp) override;
    137  1.1  christos 
    138  1.1  christos   int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
    139  1.1  christos 		    int size, raw_breakpoint *bp) override;
    140  1.1  christos 
    141  1.1  christos   bool supports_hardware_single_step () override;
    142  1.1  christos 
    143  1.1  christos   bool stopped_by_watchpoint () override;
    144  1.1  christos 
    145  1.1  christos   CORE_ADDR stopped_data_address () override;
    146  1.1  christos 
    147  1.1  christos #ifdef _WIN32_WCE
    148  1.1  christos   void hostio_last_error (char *buf) override;
    149  1.1  christos #endif
    150  1.1  christos 
    151  1.1  christos   bool supports_qxfer_siginfo () override;
    152  1.1  christos 
    153  1.1  christos   int qxfer_siginfo (const char *annex, unsigned char *readbuf,
    154  1.1  christos 		     unsigned const char *writebuf,
    155  1.1  christos 		     CORE_ADDR offset, int len) override;
    156  1.1  christos 
    157  1.1  christos   bool supports_get_tib_address () override;
    158  1.1  christos 
    159  1.1  christos   int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override;
    160  1.1  christos 
    161  1.1  christos   const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
    162  1.1  christos 
    163  1.1  christos   CORE_ADDR read_pc (regcache *regcache) override;
    164  1.1  christos 
    165  1.1  christos   void write_pc (regcache *regcache, CORE_ADDR pc) override;
    166  1.1  christos 
    167  1.1  christos   bool stopped_by_sw_breakpoint () override;
    168  1.1  christos 
    169  1.1  christos   bool supports_stopped_by_sw_breakpoint () override;
    170  1.1  christos };
    171  1.1  christos 
    172  1.1  christos /* Retrieve the context for this thread, if not already retrieved.  */
    173  1.1  christos extern void win32_require_context (windows_nat::windows_thread_info *th);
    174  1.1  christos 
    175  1.1  christos /* Map the Windows error number in ERROR to a locale-dependent error
    176  1.1  christos    message string and return a pointer to it.  Typically, the values
    177  1.1  christos    for ERROR come from GetLastError.
    178  1.1  christos 
    179  1.1  christos    The string pointed to shall not be modified by the application,
    180  1.1  christos    but may be overwritten by a subsequent call to strwinerror
    181  1.1  christos 
    182  1.1  christos    The strwinerror function does not change the current setting
    183  1.1  christos    of GetLastError.  */
    184  1.1  christos extern char * strwinerror (DWORD error);
    185  1.1  christos 
    186  1.1  christos #endif /* GDBSERVER_WIN32_LOW_H */
    187