server.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* Common definitions for remote server for GDB.
  2. Copyright (C) 1993-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_SERVER_H
  15. #define GDBSERVER_SERVER_H
  16. #include "gdbsupport/common-defs.h"
  17. #undef PACKAGE
  18. #undef PACKAGE_NAME
  19. #undef PACKAGE_VERSION
  20. #undef PACKAGE_STRING
  21. #undef PACKAGE_TARNAME
  22. #include <config.h>
  23. gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (void *));
  24. #include "gdbsupport/version.h"
  25. #if !HAVE_DECL_PERROR
  26. #ifndef perror
  27. extern void perror (const char *);
  28. #endif
  29. #endif
  30. #if !HAVE_DECL_VASPRINTF
  31. extern int vasprintf(char **strp, const char *fmt, va_list ap);
  32. #endif
  33. #if !HAVE_DECL_VSNPRINTF
  34. int vsnprintf(char *str, size_t size, const char *format, va_list ap);
  35. #endif
  36. #ifdef IN_PROCESS_AGENT
  37. # define PROG "ipa"
  38. #else
  39. # define PROG "gdbserver"
  40. #endif
  41. #include "gdbsupport/buffer.h"
  42. #include "gdbsupport/xml-utils.h"
  43. #include "regcache.h"
  44. #include "gdbsupport/gdb_signals.h"
  45. #include "target.h"
  46. #include "mem-break.h"
  47. #include "gdbsupport/environ.h"
  48. /* Target-specific functions */
  49. void initialize_low ();
  50. /* Public variables in server.c */
  51. extern bool server_waiting;
  52. extern bool disable_packet_vCont;
  53. extern bool disable_packet_Tthread;
  54. extern bool disable_packet_qC;
  55. extern bool disable_packet_qfThreadInfo;
  56. extern bool disable_packet_T;
  57. extern bool run_once;
  58. extern bool non_stop;
  59. #include "gdbsupport/event-loop.h"
  60. /* Functions from server.c. */
  61. extern void handle_v_requests (char *own_buf, int packet_len,
  62. int *new_packet_len);
  63. extern void handle_serial_event (int err, gdb_client_data client_data);
  64. extern void handle_target_event (int err, gdb_client_data client_data);
  65. /* Get rid of the currently pending stop replies that match PTID. */
  66. extern void discard_queued_stop_replies (ptid_t ptid);
  67. /* Returns true if there's a pending stop reply that matches PTID in
  68. the vStopped notifications queue. */
  69. extern int in_queued_stop_replies (ptid_t ptid);
  70. #include "remote-utils.h"
  71. #include "utils.h"
  72. #include "debug.h"
  73. #include "gdbsupport/gdb_vecs.h"
  74. /* Maximum number of bytes to read/write at once. The value here
  75. is chosen to fill up a packet (the headers account for the 32). */
  76. #define MAXBUFBYTES(N) (((N)-32)/2)
  77. /* Buffer sizes for transferring memory, registers, etc. Set to a constant
  78. value to accomodate multiple register formats. This value must be at least
  79. as large as the largest register set supported by gdbserver. */
  80. #define PBUFSIZ 18432
  81. /* Definition for an unknown syscall, used basically in error-cases. */
  82. #define UNKNOWN_SYSCALL (-1)
  83. /* Definition for any syscall, used for unfiltered syscall reporting. */
  84. #define ANY_SYSCALL (-2)
  85. /* After fork_inferior has been called, we need to adjust a few
  86. signals and call startup_inferior to start the inferior and consume
  87. its first events. This is done here. PID is the pid of the new
  88. inferior and PROGRAM is its name. */
  89. extern void post_fork_inferior (int pid, const char *program);
  90. /* Get the gdb_environ being used in the current session. */
  91. extern gdb_environ *get_environ ();
  92. extern unsigned long signal_pid;
  93. /* Description of the client remote protocol state for the currently
  94. connected client. */
  95. struct client_state
  96. {
  97. client_state ():
  98. own_buf ((char *) xmalloc (PBUFSIZ + 1))
  99. {}
  100. /* The thread set with an `Hc' packet. `Hc' is deprecated in favor of
  101. `vCont'. Note the multi-process extensions made `vCont' a
  102. requirement, so `Hc pPID.TID' is pretty much undefined. So
  103. CONT_THREAD can be null_ptid for no `Hc' thread, minus_one_ptid for
  104. resuming all threads of the process (again, `Hc' isn't used for
  105. multi-process), or a specific thread ptid_t. */
  106. ptid_t cont_thread;
  107. /* The thread set with an `Hg' packet. */
  108. ptid_t general_thread;
  109. int multi_process = 0;
  110. int report_fork_events = 0;
  111. int report_vfork_events = 0;
  112. int report_exec_events = 0;
  113. int report_thread_events = 0;
  114. /* True if the "swbreak+" feature is active. In that case, GDB wants
  115. us to report whether a trap is explained by a software breakpoint
  116. and for the server to handle PC adjustment if necessary on this
  117. target. Only enabled if the target supports it. */
  118. int swbreak_feature = 0;
  119. /* True if the "hwbreak+" feature is active. In that case, GDB wants
  120. us to report whether a trap is explained by a hardware breakpoint.
  121. Only enabled if the target supports it. */
  122. int hwbreak_feature = 0;
  123. /* True if the "vContSupported" feature is active. In that case, GDB
  124. wants us to report whether single step is supported in the reply to
  125. "vCont?" packet. */
  126. int vCont_supported = 0;
  127. /* Whether we should attempt to disable the operating system's address
  128. space randomization feature before starting an inferior. */
  129. int disable_randomization = 1;
  130. int pass_signals[GDB_SIGNAL_LAST];
  131. int program_signals[GDB_SIGNAL_LAST];
  132. int program_signals_p = 0;
  133. /* Last status reported to GDB. */
  134. struct target_waitstatus last_status;
  135. ptid_t last_ptid;
  136. char *own_buf;
  137. /* If true, then GDB has requested noack mode. */
  138. int noack_mode = 0;
  139. /* If true, then we tell GDB to use noack mode by default. */
  140. int transport_is_reliable = 0;
  141. /* The traceframe to be used as the source of data to send back to
  142. GDB. A value of -1 means to get data from the live program. */
  143. int current_traceframe = -1;
  144. /* If true, memory tagging features are supported. */
  145. bool memory_tagging_feature = false;
  146. };
  147. client_state &get_client_state ();
  148. #include "gdbthread.h"
  149. #include "inferiors.h"
  150. #endif /* GDBSERVER_SERVER_H */