Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 1 | //===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef liblldb_GDBRemoteCommunicationClient_h_ |
| 10 | #define liblldb_GDBRemoteCommunicationClient_h_ |
| 11 | |
Pavel Labath | b42b48e | 2016-08-19 12:31:49 +0000 | [diff] [blame] | 12 | #include "GDBRemoteClientBase.h" |
| 13 | |
Pavel Labath | 8c1b6bd | 2016-08-09 12:04:46 +0000 | [diff] [blame] | 14 | #include <chrono> |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 15 | #include <map> |
Saleem Abdulrasool | 16ff860 | 2016-05-18 01:59:10 +0000 | [diff] [blame] | 16 | #include <mutex> |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 17 | #include <string> |
Greg Clayton | adc00cb | 2011-05-20 23:38:13 +0000 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 20 | #include "lldb/Target/Process.h" |
Pavel Labath | 5f19b90 | 2017-11-13 16:16:33 +0000 | [diff] [blame] | 21 | #include "lldb/Utility/ArchSpec.h" |
Ravitheja Addepally | e714c4f | 2017-05-26 11:46:27 +0000 | [diff] [blame] | 22 | #include "lldb/Utility/StreamGDBRemote.h" |
Pavel Labath | f2a8bcc | 2017-06-27 10:45:31 +0000 | [diff] [blame] | 23 | #include "lldb/Utility/StructuredData.h" |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 24 | |
Pavel Labath | 2f1fbae | 2016-09-08 10:07:04 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/Optional.h" |
| 26 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 27 | namespace lldb_private { |
| 28 | namespace process_gdb_remote { |
| 29 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 30 | class GDBRemoteCommunicationClient : public GDBRemoteClientBase { |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 31 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 32 | GDBRemoteCommunicationClient(); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 33 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | ~GDBRemoteCommunicationClient() override; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 35 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | // After connecting, send the handshake to the server to make sure |
| 37 | // we are communicating with it. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 38 | bool HandshakeWithServer(Status *error_ptr); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 39 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 40 | // For packets which specify a range of output to be returned, |
| 41 | // return all of the output via a series of request packets of the form |
| 42 | // <prefix>0,<size> |
| 43 | // <prefix><size>,<size> |
| 44 | // <prefix><size>*2,<size> |
| 45 | // <prefix><size>*3,<size> |
| 46 | // ... |
| 47 | // until a "$l..." packet is received, indicating the end. |
| 48 | // (size is in hex; this format is used by a standard gdbserver to |
| 49 | // return the given portion of the output specified by <prefix>; |
| 50 | // for example, "qXfer:libraries-svr4:read::fff,1000" means |
| 51 | // "return a chunk of the xml description file for shared |
| 52 | // library load addresses, where the chunk starts at offset 0xfff |
| 53 | // and continues for 0x1000 bytes"). |
| 54 | // Concatenate the resulting server response packets together and |
| 55 | // return in response_string. If any packet fails, the return value |
| 56 | // indicates that failure and the returned string value is undefined. |
| 57 | PacketResult |
| 58 | SendPacketsAndConcatenateResponses(const char *send_payload_prefix, |
| 59 | std::string &response_string); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 60 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | bool GetThreadSuffixSupported(); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 62 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 63 | // This packet is usually sent first and the boolean return value |
| 64 | // indicates if the packet was send and any response was received |
| 65 | // even in the response is UNIMPLEMENTED. If the packet failed to |
| 66 | // get a response, then false is returned. This quickly tells us |
| 67 | // if we were able to connect and communicate with the remote GDB |
| 68 | // server |
| 69 | bool QueryNoAckModeSupported(); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 70 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 71 | void GetListThreadsInStopReplySupported(); |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 72 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 73 | lldb::pid_t GetCurrentProcessID(bool allow_lazy = true); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 74 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 75 | bool GetLaunchSuccess(std::string &error_str); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 76 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 77 | bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid, |
| 78 | uint16_t &port, std::string &socket_name); |
Tamas Berghammer | ccd6cff | 2015-12-08 14:08:19 +0000 | [diff] [blame] | 79 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 80 | size_t QueryGDBServer( |
| 81 | std::vector<std::pair<uint16_t, std::string>> &connection_urls); |
Tamas Berghammer | ccd6cff | 2015-12-08 14:08:19 +0000 | [diff] [blame] | 82 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 83 | bool KillSpawnedProcess(lldb::pid_t pid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 84 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 85 | /// Sends a GDB remote protocol 'A' packet that delivers program |
| 86 | /// arguments to the remote server. |
| 87 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 88 | /// \param[in] argv |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 89 | /// A NULL terminated array of const C strings to use as the |
| 90 | /// arguments. |
| 91 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 92 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 93 | /// Zero if the response was "OK", a positive value if the |
| 94 | /// the response was "Exx" where xx are two hex digits, or |
| 95 | /// -1 if the call is unsupported or any other unexpected |
| 96 | /// response was received. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 97 | int SendArgumentsPacket(const ProcessLaunchInfo &launch_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 98 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 99 | /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the |
| 100 | /// environment that will get used when launching an application |
| 101 | /// in conjunction with the 'A' packet. This function can be called |
| 102 | /// multiple times in a row in order to pass on the desired |
| 103 | /// environment that the inferior should be launched with. |
| 104 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 105 | /// \param[in] name_equal_value |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 106 | /// A NULL terminated C string that contains a single environment |
| 107 | /// in the format "NAME=VALUE". |
| 108 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 109 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 110 | /// Zero if the response was "OK", a positive value if the |
| 111 | /// the response was "Exx" where xx are two hex digits, or |
| 112 | /// -1 if the call is unsupported or any other unexpected |
| 113 | /// response was received. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 114 | int SendEnvironmentPacket(char const *name_equal_value); |
Pavel Labath | 62930e5 | 2018-01-10 11:57:31 +0000 | [diff] [blame] | 115 | int SendEnvironment(const Environment &env); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 116 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 117 | int SendLaunchArchPacket(const char *arch); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 118 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 119 | int SendLaunchEventDataPacket(const char *data, |
| 120 | bool *was_supported = nullptr); |
Vince Harron | e0be425 | 2015-02-06 18:32:57 +0000 | [diff] [blame] | 121 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 122 | /// Sends a "vAttach:PID" where PID is in hex. |
| 123 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 124 | /// \param[in] pid |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 125 | /// A process ID for the remote gdb server to attach to. |
| 126 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 127 | /// \param[out] response |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 128 | /// The response received from the gdb server. If the return |
| 129 | /// value is zero, \a response will contain a stop reply |
| 130 | /// packet. |
| 131 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 132 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 133 | /// Zero if the attach was successful, or an error indicating |
| 134 | /// an error code. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 135 | int SendAttach(lldb::pid_t pid, StringExtractorGDBRemote &response); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 136 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 137 | /// Sends a GDB remote protocol 'I' packet that delivers stdin |
| 138 | /// data to the remote process. |
| 139 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 140 | /// \param[in] data |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 141 | /// A pointer to stdin data. |
| 142 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 143 | /// \param[in] data_len |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 144 | /// The number of bytes available at \a data. |
| 145 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 146 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 147 | /// Zero if the attach was successful, or an error indicating |
| 148 | /// an error code. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 149 | int SendStdinNotification(const char *data, size_t data_len); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 150 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 151 | /// Sets the path to use for stdin/out/err for a process |
| 152 | /// that will be launched with the 'A' packet. |
| 153 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 154 | /// \param[in] path |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 155 | /// The path to use for stdin/out/err |
| 156 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 157 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 158 | /// Zero if the for success, or an error code for failure. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 159 | int SetSTDIN(const FileSpec &file_spec); |
| 160 | int SetSTDOUT(const FileSpec &file_spec); |
| 161 | int SetSTDERR(const FileSpec &file_spec); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 162 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 163 | /// Sets the disable ASLR flag to \a enable for a process that will |
| 164 | /// be launched with the 'A' packet. |
| 165 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 166 | /// \param[in] enable |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 167 | /// A boolean value indicating whether to disable ASLR or not. |
| 168 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 169 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 170 | /// Zero if the for success, or an error code for failure. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 171 | int SetDisableASLR(bool enable); |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 172 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 173 | /// Sets the DetachOnError flag to \a enable for the process controlled by the |
| 174 | /// stub. |
| 175 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 176 | /// \param[in] enable |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 177 | /// A boolean value indicating whether to detach on error or not. |
| 178 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 179 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 180 | /// Zero if the for success, or an error code for failure. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 181 | int SetDetachOnError(bool enable); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 182 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 183 | /// Sets the working directory to \a path for a process that will |
| 184 | /// be launched with the 'A' packet for non platform based |
| 185 | /// connections. If this packet is sent to a GDB server that |
| 186 | /// implements the platform, it will change the current working |
| 187 | /// directory for the platform process. |
| 188 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 189 | /// \param[in] working_dir |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 190 | /// The path to a directory to use when launching our process |
| 191 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 192 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 193 | /// Zero if the for success, or an error code for failure. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 194 | int SetWorkingDir(const FileSpec &working_dir); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 195 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 196 | /// Gets the current working directory of a remote platform GDB |
| 197 | /// server. |
| 198 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 199 | /// \param[out] working_dir |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 200 | /// The current working directory on the remote platform. |
| 201 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 202 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 203 | /// Boolean for success |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 204 | bool GetWorkingDir(FileSpec &working_dir); |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 205 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 206 | lldb::addr_t AllocateMemory(size_t size, uint32_t permissions); |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 207 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 208 | bool DeallocateMemory(lldb::addr_t addr); |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 209 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 210 | Status Detach(bool keep_stopped); |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 211 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 212 | Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info); |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 213 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 214 | Status GetWatchpointSupportInfo(uint32_t &num); |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 215 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 216 | Status GetWatchpointSupportInfo(uint32_t &num, bool &after, |
| 217 | const ArchSpec &arch); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 218 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 219 | Status GetWatchpointsTriggerAfterInstruction(bool &after, |
| 220 | const ArchSpec &arch); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 221 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 222 | const ArchSpec &GetHostArchitecture(); |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 223 | |
Pavel Labath | 3aa0491 | 2016-10-31 17:19:42 +0000 | [diff] [blame] | 224 | std::chrono::seconds GetHostDefaultPacketTimeout(); |
Jason Molenda | bdc4f12 | 2014-05-06 02:59:39 +0000 | [diff] [blame] | 225 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 226 | const ArchSpec &GetProcessArchitecture(); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 227 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 228 | void GetRemoteQSupported(); |
Ewan Crawford | 78baa19 | 2015-05-13 09:18:18 +0000 | [diff] [blame] | 229 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 230 | bool GetVContSupported(char flavor); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 231 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 232 | bool GetpPacketSupported(lldb::tid_t tid); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 233 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 234 | bool GetxPacketSupported(); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 235 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 236 | bool GetVAttachOrWaitSupported(); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 237 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 238 | bool GetSyncThreadStateSupported(); |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 239 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 240 | void ResetDiscoverableSettings(bool did_exec); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 241 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 242 | bool GetHostInfo(bool force = false); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 243 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 244 | bool GetDefaultThreadId(lldb::tid_t &tid); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 245 | |
Pavel Labath | 2272c48 | 2018-06-18 15:02:23 +0000 | [diff] [blame] | 246 | llvm::VersionTuple GetOSVersion(); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 247 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 248 | bool GetOSBuildString(std::string &s); |
| 249 | |
| 250 | bool GetOSKernelDescription(std::string &s); |
| 251 | |
| 252 | ArchSpec GetSystemArchitecture(); |
| 253 | |
| 254 | bool GetHostname(std::string &s); |
| 255 | |
| 256 | lldb::addr_t GetShlibInfoAddr(); |
| 257 | |
| 258 | bool GetSupportsThreadSuffix(); |
| 259 | |
| 260 | bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info); |
| 261 | |
| 262 | uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, |
| 263 | ProcessInstanceInfoList &process_infos); |
| 264 | |
| 265 | bool GetUserName(uint32_t uid, std::string &name); |
| 266 | |
| 267 | bool GetGroupName(uint32_t gid, std::string &name); |
| 268 | |
| 269 | bool HasFullVContSupport() { return GetVContSupported('A'); } |
| 270 | |
| 271 | bool HasAnyVContSupport() { return GetVContSupported('a'); } |
| 272 | |
| 273 | bool GetStopReply(StringExtractorGDBRemote &response); |
| 274 | |
| 275 | bool GetThreadStopInfo(lldb::tid_t tid, StringExtractorGDBRemote &response); |
| 276 | |
| 277 | bool SupportsGDBStoppointPacket(GDBStoppointType type) { |
| 278 | switch (type) { |
| 279 | case eBreakpointSoftware: |
| 280 | return m_supports_z0; |
| 281 | case eBreakpointHardware: |
| 282 | return m_supports_z1; |
| 283 | case eWatchpointWrite: |
| 284 | return m_supports_z2; |
| 285 | case eWatchpointRead: |
| 286 | return m_supports_z3; |
| 287 | case eWatchpointReadWrite: |
| 288 | return m_supports_z4; |
| 289 | default: |
| 290 | return false; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 291 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 292 | } |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 293 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 294 | uint8_t SendGDBStoppointTypePacket( |
| 295 | GDBStoppointType type, // Type of breakpoint or watchpoint |
| 296 | bool insert, // Insert or remove? |
| 297 | lldb::addr_t addr, // Address of breakpoint or watchpoint |
| 298 | uint32_t length); // Byte Size of breakpoint or watchpoint |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 299 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 300 | bool SetNonStopMode(const bool enable); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 301 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 302 | void TestPacketSpeed(const uint32_t num_packets, uint32_t max_send, |
Pavel Labath | 2fd9a1e | 2016-11-04 11:49:06 +0000 | [diff] [blame] | 303 | uint32_t max_recv, uint64_t recv_amount, bool json, |
| 304 | Stream &strm); |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 305 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 306 | // This packet is for testing the speed of the interface only. Both |
| 307 | // the client and server need to support it, but this allows us to |
| 308 | // measure the packet speed without any other work being done on the |
| 309 | // other end and avoids any of that work affecting the packet send |
| 310 | // and response times. |
| 311 | bool SendSpeedTestPacket(uint32_t send_size, uint32_t recv_size); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 312 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 313 | bool SetCurrentThread(uint64_t tid); |
Ewan Crawford | 78baa19 | 2015-05-13 09:18:18 +0000 | [diff] [blame] | 314 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 315 | bool SetCurrentThreadForRun(uint64_t tid); |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 316 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 317 | bool GetQXferAuxvReadSupported(); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 318 | |
Ravitheja Addepally | dab1d5f | 2017-07-12 11:15:34 +0000 | [diff] [blame] | 319 | void EnableErrorStringInPacket(); |
| 320 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 321 | bool GetQXferLibrariesReadSupported(); |
Steve Pucci | 03904ac | 2014-03-04 23:18:46 +0000 | [diff] [blame] | 322 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 323 | bool GetQXferLibrariesSVR4ReadSupported(); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 324 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 325 | uint64_t GetRemoteMaxPacketSize(); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 326 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 327 | bool GetEchoSupported(); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 328 | |
Eugene Zemtsov | 7993cc5 | 2017-03-07 21:34:40 +0000 | [diff] [blame] | 329 | bool GetQPassSignalsSupported(); |
| 330 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 331 | bool GetAugmentedLibrariesSVR4ReadSupported(); |
Greg Clayton | b30c50c | 2015-05-29 00:01:55 +0000 | [diff] [blame] | 332 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 333 | bool GetQXferFeaturesReadSupported(); |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 334 | |
Pavel Labath | 16064d3 | 2018-03-20 11:56:24 +0000 | [diff] [blame] | 335 | bool GetQXferMemoryMapReadSupported(); |
| 336 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 337 | LazyBool SupportsAllocDeallocMemory() // const |
| 338 | { |
| 339 | // Uncomment this to have lldb pretend the debug server doesn't respond to |
| 340 | // alloc/dealloc memory packets. |
| 341 | // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; |
| 342 | return m_supports_alloc_dealloc_memory; |
| 343 | } |
Colin Riley | c3c95b2 | 2015-04-16 15:51:33 +0000 | [diff] [blame] | 344 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 345 | size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids, |
| 346 | bool &sequence_mutex_unavailable); |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 347 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 348 | lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 349 | mode_t mode, Status &error); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 350 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 351 | bool CloseFile(lldb::user_id_t fd, Status &error); |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 352 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 353 | lldb::user_id_t GetFileSize(const FileSpec &file_spec); |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 354 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 355 | Status GetFilePermissions(const FileSpec &file_spec, |
| 356 | uint32_t &file_permissions); |
Chaoren Lin | d3173f3 | 2015-05-29 19:52:29 +0000 | [diff] [blame] | 357 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 358 | Status SetFilePermissions(const FileSpec &file_spec, |
| 359 | uint32_t file_permissions); |
Chaoren Lin | d3173f3 | 2015-05-29 19:52:29 +0000 | [diff] [blame] | 360 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 361 | uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 362 | uint64_t dst_len, Status &error); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 363 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 364 | uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 365 | uint64_t src_len, Status &error); |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 366 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 367 | Status CreateSymlink(const FileSpec &src, const FileSpec &dst); |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 368 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 369 | Status Unlink(const FileSpec &file_spec); |
Pavel Labath | 56d7262 | 2016-08-17 08:53:31 +0000 | [diff] [blame] | 370 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 371 | Status MakeDirectory(const FileSpec &file_spec, uint32_t mode); |
Pavel Labath | 56d7262 | 2016-08-17 08:53:31 +0000 | [diff] [blame] | 372 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 373 | bool GetFileExists(const FileSpec &file_spec); |
Pavel Labath | 56d7262 | 2016-08-17 08:53:31 +0000 | [diff] [blame] | 374 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 375 | Status RunShellCommand( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 376 | const char *command, // Shouldn't be nullptr |
| 377 | const FileSpec &working_dir, // Pass empty FileSpec to use the current |
| 378 | // working directory |
| 379 | int *status_ptr, // Pass nullptr if you don't want the process exit status |
| 380 | int *signo_ptr, // Pass nullptr if you don't want the signal that caused |
| 381 | // the process to exit |
| 382 | std::string |
| 383 | *command_output, // Pass nullptr if you don't want the command output |
Pavel Labath | 19dd1a0 | 2018-05-10 10:46:03 +0000 | [diff] [blame] | 384 | const Timeout<std::micro> &timeout); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 385 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 386 | bool CalculateMD5(const FileSpec &file_spec, uint64_t &high, uint64_t &low); |
Pavel Labath | 27402d2 | 2016-08-18 12:32:41 +0000 | [diff] [blame] | 387 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 388 | lldb::DataBufferSP ReadRegister( |
| 389 | lldb::tid_t tid, |
| 390 | uint32_t |
| 391 | reg_num); // Must be the eRegisterKindProcessPlugin register number |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 392 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 393 | lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 394 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 395 | bool |
| 396 | WriteRegister(lldb::tid_t tid, |
| 397 | uint32_t reg_num, // eRegisterKindProcessPlugin register number |
| 398 | llvm::ArrayRef<uint8_t> data); |
Greg Clayton | 358cf1e | 2015-06-25 21:46:34 +0000 | [diff] [blame] | 399 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 400 | bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef<uint8_t> data); |
Jason Molenda | 705b180 | 2014-06-13 02:37:02 +0000 | [diff] [blame] | 401 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 402 | bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id); |
Jason Molenda | 20ee21b | 2015-07-10 23:15:22 +0000 | [diff] [blame] | 403 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 404 | bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id); |
Jason Molenda | 3739735 | 2016-07-22 00:17:55 +0000 | [diff] [blame] | 405 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 406 | bool SyncThreadState(lldb::tid_t tid); |
Oleksiy Vyalov | 6801be3 | 2015-02-25 22:15:44 +0000 | [diff] [blame] | 407 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 408 | const char *GetGDBServerProgramName(); |
Colin Riley | c3c95b2 | 2015-04-16 15:51:33 +0000 | [diff] [blame] | 409 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 410 | uint32_t GetGDBServerProgramVersion(); |
Greg Clayton | 0b90be1 | 2015-06-23 21:27:50 +0000 | [diff] [blame] | 411 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 412 | bool AvoidGPackets(ProcessGDBRemote *process); |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 413 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 414 | StructuredData::ObjectSP GetThreadsInfo(); |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 415 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 416 | bool GetThreadExtendedInfoSupported(); |
| 417 | |
| 418 | bool GetLoadedDynamicLibrariesInfosSupported(); |
| 419 | |
| 420 | bool GetSharedCacheInfoSupported(); |
| 421 | |
| 422 | bool GetModuleInfo(const FileSpec &module_file_spec, |
| 423 | const ArchSpec &arch_spec, ModuleSpec &module_spec); |
| 424 | |
Pavel Labath | 2f1fbae | 2016-09-08 10:07:04 +0000 | [diff] [blame] | 425 | llvm::Optional<std::vector<ModuleSpec>> |
| 426 | GetModulesInfo(llvm::ArrayRef<FileSpec> module_file_specs, |
| 427 | const llvm::Triple &triple); |
| 428 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 429 | bool ReadExtFeature(const lldb_private::ConstString object, |
| 430 | const lldb_private::ConstString annex, std::string &out, |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 431 | lldb_private::Status &err); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 432 | |
| 433 | void ServeSymbolLookups(lldb_private::Process *process); |
| 434 | |
Eugene Zemtsov | 7993cc5 | 2017-03-07 21:34:40 +0000 | [diff] [blame] | 435 | // Sends QPassSignals packet to the server with given signals to ignore. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 436 | Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals); |
Eugene Zemtsov | 7993cc5 | 2017-03-07 21:34:40 +0000 | [diff] [blame] | 437 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 438 | /// Return the feature set supported by the gdb-remote server. |
| 439 | /// |
| 440 | /// This method returns the remote side's response to the qSupported |
| 441 | /// packet. The response is the complete string payload returned |
| 442 | /// to the client. |
| 443 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 444 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 445 | /// The string returned by the server to the qSupported query. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 446 | const std::string &GetServerSupportedFeatures() const { |
| 447 | return m_qSupported_response; |
| 448 | } |
| 449 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 450 | /// Return the array of async JSON packet types supported by the remote. |
| 451 | /// |
| 452 | /// This method returns the remote side's array of supported JSON |
| 453 | /// packet types as a list of type names. Each of the results are |
| 454 | /// expected to have an Enable{type_name} command to enable and configure |
| 455 | /// the related feature. Each type_name for an enabled feature will |
| 456 | /// possibly send async-style packets that contain a payload of a |
| 457 | /// binhex-encoded JSON dictionary. The dictionary will have a |
| 458 | /// string field named 'type', that contains the type_name of the |
| 459 | /// supported packet type. |
| 460 | /// |
| 461 | /// There is a Plugin category called structured-data plugins. |
| 462 | /// A plugin indicates whether it knows how to handle a type_name. |
| 463 | /// If so, it can be used to process the async JSON packet. |
| 464 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 465 | /// \return |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 466 | /// The string returned by the server to the qSupported query. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 467 | lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins(); |
| 468 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 469 | /// Configure a StructuredData feature on the remote end. |
| 470 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 471 | /// \see \b Process::ConfigureStructuredData(...) for details. |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 472 | Status |
Adrian Prantl | 0e4c482 | 2019-03-06 21:22:25 +0000 | [diff] [blame] | 473 | ConfigureRemoteStructuredData(ConstString type_name, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 474 | const StructuredData::ObjectSP &config_sp); |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 475 | |
Ravitheja Addepally | e714c4f | 2017-05-26 11:46:27 +0000 | [diff] [blame] | 476 | lldb::user_id_t SendStartTracePacket(const TraceOptions &options, |
| 477 | Status &error); |
| 478 | |
| 479 | Status SendStopTracePacket(lldb::user_id_t uid, lldb::tid_t thread_id); |
| 480 | |
| 481 | Status SendGetDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, |
| 482 | llvm::MutableArrayRef<uint8_t> &buffer, |
| 483 | size_t offset = 0); |
| 484 | |
| 485 | Status SendGetMetaDataPacket(lldb::user_id_t uid, lldb::tid_t thread_id, |
| 486 | llvm::MutableArrayRef<uint8_t> &buffer, |
| 487 | size_t offset = 0); |
| 488 | |
| 489 | Status SendGetTraceConfigPacket(lldb::user_id_t uid, TraceOptions &options); |
| 490 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 491 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 492 | LazyBool m_supports_not_sending_acks; |
| 493 | LazyBool m_supports_thread_suffix; |
| 494 | LazyBool m_supports_threads_in_stop_reply; |
| 495 | LazyBool m_supports_vCont_all; |
| 496 | LazyBool m_supports_vCont_any; |
| 497 | LazyBool m_supports_vCont_c; |
| 498 | LazyBool m_supports_vCont_C; |
| 499 | LazyBool m_supports_vCont_s; |
| 500 | LazyBool m_supports_vCont_S; |
| 501 | LazyBool m_qHostInfo_is_valid; |
| 502 | LazyBool m_curr_pid_is_valid; |
| 503 | LazyBool m_qProcessInfo_is_valid; |
| 504 | LazyBool m_qGDBServerVersion_is_valid; |
| 505 | LazyBool m_supports_alloc_dealloc_memory; |
| 506 | LazyBool m_supports_memory_region_info; |
| 507 | LazyBool m_supports_watchpoint_support_info; |
| 508 | LazyBool m_supports_detach_stay_stopped; |
| 509 | LazyBool m_watchpoints_trigger_after_instruction; |
| 510 | LazyBool m_attach_or_wait_reply; |
| 511 | LazyBool m_prepare_for_reg_writing_reply; |
| 512 | LazyBool m_supports_p; |
| 513 | LazyBool m_supports_x; |
| 514 | LazyBool m_avoid_g_packets; |
| 515 | LazyBool m_supports_QSaveRegisterState; |
| 516 | LazyBool m_supports_qXfer_auxv_read; |
| 517 | LazyBool m_supports_qXfer_libraries_read; |
| 518 | LazyBool m_supports_qXfer_libraries_svr4_read; |
| 519 | LazyBool m_supports_qXfer_features_read; |
Pavel Labath | 16064d3 | 2018-03-20 11:56:24 +0000 | [diff] [blame] | 520 | LazyBool m_supports_qXfer_memory_map_read; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 521 | LazyBool m_supports_augmented_libraries_svr4_read; |
| 522 | LazyBool m_supports_jThreadExtendedInfo; |
| 523 | LazyBool m_supports_jLoadedDynamicLibrariesInfos; |
| 524 | LazyBool m_supports_jGetSharedCacheInfo; |
Eugene Zemtsov | 7993cc5 | 2017-03-07 21:34:40 +0000 | [diff] [blame] | 525 | LazyBool m_supports_QPassSignals; |
Ravitheja Addepally | dab1d5f | 2017-07-12 11:15:34 +0000 | [diff] [blame] | 526 | LazyBool m_supports_error_string_reply; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 527 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 528 | bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1, |
| 529 | m_supports_qUserName : 1, m_supports_qGroupName : 1, |
| 530 | m_supports_qThreadStopInfo : 1, m_supports_z0 : 1, m_supports_z1 : 1, |
| 531 | m_supports_z2 : 1, m_supports_z3 : 1, m_supports_z4 : 1, |
| 532 | m_supports_QEnvironment : 1, m_supports_QEnvironmentHexEncoded : 1, |
| 533 | m_supports_qSymbol : 1, m_qSymbol_requests_done : 1, |
Pavel Labath | 2f1fbae | 2016-09-08 10:07:04 +0000 | [diff] [blame] | 534 | m_supports_qModuleInfo : 1, m_supports_jThreadsInfo : 1, |
| 535 | m_supports_jModulesInfo : 1; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 536 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 537 | lldb::pid_t m_curr_pid; |
| 538 | lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all |
| 539 | // other operations |
| 540 | lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for |
| 541 | // continue, step, etc |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 542 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 543 | uint32_t m_num_supported_hardware_watchpoints; |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 544 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 545 | ArchSpec m_host_arch; |
| 546 | ArchSpec m_process_arch; |
Pavel Labath | 2272c48 | 2018-06-18 15:02:23 +0000 | [diff] [blame] | 547 | llvm::VersionTuple m_os_version; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 548 | std::string m_os_build; |
| 549 | std::string m_os_kernel; |
| 550 | std::string m_hostname; |
| 551 | std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if |
| 552 | // qGDBServerVersion is not supported |
| 553 | uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if |
| 554 | // qGDBServerVersion is not supported |
Pavel Labath | 3aa0491 | 2016-10-31 17:19:42 +0000 | [diff] [blame] | 555 | std::chrono::seconds m_default_packet_timeout; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 556 | uint64_t m_max_packet_size; // as returned by qSupported |
| 557 | std::string m_qSupported_response; // the complete response to qSupported |
Jason Molenda | 91ffe0a | 2015-06-18 21:46:06 +0000 | [diff] [blame] | 558 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 559 | bool m_supported_async_json_packets_is_valid; |
| 560 | lldb_private::StructuredData::ObjectSP m_supported_async_json_packets_sp; |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 561 | |
Pavel Labath | 16064d3 | 2018-03-20 11:56:24 +0000 | [diff] [blame] | 562 | std::vector<MemoryRegionInfo> m_qXfer_memory_map; |
| 563 | bool m_qXfer_memory_map_loaded; |
| 564 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 565 | bool GetCurrentProcessInfo(bool allow_lazy_pid = true); |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 566 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 567 | bool GetGDBServerVersion(); |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 568 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 569 | // Given the list of compression types that the remote debug stub can support, |
| 570 | // possibly enable compression if we find an encoding we can handle. |
| 571 | void MaybeEnableCompression(std::vector<std::string> supported_compressions); |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 572 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 573 | bool DecodeProcessInfoResponse(StringExtractorGDBRemote &response, |
| 574 | ProcessInstanceInfo &process_info); |
Pavel Labath | 8c1b6bd | 2016-08-09 12:04:46 +0000 | [diff] [blame] | 575 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 576 | void OnRunPacketSent(bool first) override; |
| 577 | |
| 578 | PacketResult SendThreadSpecificPacketAndWaitForResponse( |
| 579 | lldb::tid_t tid, StreamString &&payload, |
| 580 | StringExtractorGDBRemote &response, bool send_async); |
Pavel Labath | 4b6f959 | 2016-08-18 08:30:03 +0000 | [diff] [blame] | 581 | |
Ravitheja Addepally | e714c4f | 2017-05-26 11:46:27 +0000 | [diff] [blame] | 582 | Status SendGetTraceDataPacket(StreamGDBRemote &packet, lldb::user_id_t uid, |
| 583 | lldb::tid_t thread_id, |
| 584 | llvm::MutableArrayRef<uint8_t> &buffer, |
| 585 | size_t offset); |
| 586 | |
Pavel Labath | 16064d3 | 2018-03-20 11:56:24 +0000 | [diff] [blame] | 587 | Status LoadQXferMemoryMap(); |
| 588 | |
| 589 | Status GetQXferMemoryMapRegionInfo(lldb::addr_t addr, |
| 590 | MemoryRegionInfo ®ion); |
| 591 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 592 | private: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 593 | DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationClient); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 594 | }; |
| 595 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 596 | } // namespace process_gdb_remote |
| 597 | } // namespace lldb_private |
| 598 | |
Eugene Zelenko | edb35d9 | 2015-10-24 01:08:35 +0000 | [diff] [blame] | 599 | #endif // liblldb_GDBRemoteCommunicationClient_h_ |