win32-low.h 5.5 KB

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