remote.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Remote target communications for serial-line targets in custom GDB protocol
  2. Copyright (C) 1999-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 REMOTE_H
  15. #define REMOTE_H
  16. #include "remote-notif.h"
  17. struct target_desc;
  18. struct remote_target;
  19. class process_stratum_target;
  20. /* True when printing "remote" debug statements is enabled. */
  21. extern bool remote_debug;
  22. /* Print a "remote" debug statement. */
  23. #define remote_debug_printf(fmt, ...) \
  24. debug_prefixed_printf_cond (remote_debug, "remote", fmt, ##__VA_ARGS__)
  25. /* Same as the above, but don't include the function name. */
  26. #define remote_debug_printf_nofunc(fmt, ...) \
  27. debug_prefixed_printf_cond_nofunc (remote_debug, "remote", \
  28. fmt, ##__VA_ARGS__)
  29. /* Print "remote" enter/exit debug statements. */
  30. #define REMOTE_SCOPED_DEBUG_ENTER_EXIT \
  31. scoped_debug_enter_exit (remote_debug, "remote")
  32. /* Read a packet from the remote machine, with error checking, and
  33. store it in *BUF. Resize *BUF using xrealloc if necessary to hold
  34. the result, and update *SIZEOF_BUF. If FOREVER, wait forever
  35. rather than timing out; this is used (in synchronous mode) to wait
  36. for a target that is is executing user code to stop. */
  37. extern void getpkt (remote_target *remote,
  38. char **buf, long *sizeof_buf, int forever);
  39. /* Send a packet to the remote machine, with error checking. The data
  40. of the packet is in BUF. The string in BUF can be at most PBUFSIZ
  41. - 5 to account for the $, # and checksum, and for a possible /0 if
  42. we are debugging (remote_debug) and want to print the sent packet
  43. as a string. */
  44. extern int putpkt (remote_target *remote, const char *buf);
  45. void register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
  46. const struct target_desc *tdesc);
  47. void register_remote_support_xml (const char *);
  48. void remote_file_put (const char *local_file, const char *remote_file,
  49. int from_tty);
  50. void remote_file_get (const char *remote_file, const char *local_file,
  51. int from_tty);
  52. void remote_file_delete (const char *remote_file, int from_tty);
  53. extern int remote_register_number_and_offset (struct gdbarch *gdbarch,
  54. int regnum, int *pnum,
  55. int *poffset);
  56. extern void remote_notif_get_pending_events (remote_target *remote,
  57. struct notif_client *np);
  58. extern bool remote_target_is_non_stop_p (remote_target *t);
  59. /* An abstract class that represents the set of callbacks that are made
  60. from the send_remote_packet function (declared below). */
  61. struct send_remote_packet_callbacks
  62. {
  63. /* The SENDING callback is called once send_remote_packet has performed
  64. its error checking and setup, just before the packet is sent to the
  65. remote target. BUF is the content of the packet that will be sent
  66. (before any of the protocol specific prefix, suffix, or escaping is
  67. applied). */
  68. virtual void sending (gdb::array_view<const char> &buf) = 0;
  69. /* The RECEIVED callback is called once a reply has been received from
  70. the remote target. The content of the reply is in BUF which can't be
  71. modified, and which is not guaranteed to remain valid after the
  72. RECEIVED call has returned. If you need to preserve the contents of
  73. BUF then a copy should be taken. */
  74. virtual void received (gdb::array_view<const char> &buf) = 0;
  75. };
  76. /* Send BUF to the current remote target. If BUF points to an empty
  77. string, either zero length, or the first character is the null
  78. character, then an error is thrown. If the current target is not a
  79. remote target then an error is thrown.
  80. Calls CALLBACKS->sending() just before the packet is sent to the remote
  81. target, and calls CALLBACKS->received() with the reply once this is
  82. received from the remote target. */
  83. extern void send_remote_packet (gdb::array_view<const char> &buf,
  84. send_remote_packet_callbacks *callbacks);
  85. /* Return true if TARGET is a remote, or extended-remote target, otherwise,
  86. return false. */
  87. extern bool is_remote_target (process_stratum_target *target);
  88. #endif