Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 1 | //===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_GDBRemoteCommunicationClient_h_ |
| 11 | #define liblldb_GDBRemoteCommunicationClient_h_ |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
Greg Clayton | adc00cb | 2011-05-20 23:38:13 +0000 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 17 | // Other libraries and framework includes |
| 18 | // Project includes |
| 19 | #include "lldb/Core/ArchSpec.h" |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 20 | #include "lldb/Target/Process.h" |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 21 | |
| 22 | #include "GDBRemoteCommunication.h" |
| 23 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 24 | typedef enum |
| 25 | { |
| 26 | eBreakpointSoftware = 0, |
| 27 | eBreakpointHardware, |
| 28 | eWatchpointWrite, |
| 29 | eWatchpointRead, |
| 30 | eWatchpointReadWrite |
| 31 | } GDBStoppointType; |
| 32 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 33 | class GDBRemoteCommunicationClient : public GDBRemoteCommunication |
| 34 | { |
| 35 | public: |
| 36 | //------------------------------------------------------------------ |
| 37 | // Constructors and Destructors |
| 38 | //------------------------------------------------------------------ |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 39 | GDBRemoteCommunicationClient(bool is_platform); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 40 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 41 | ~GDBRemoteCommunicationClient(); |
| 42 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 43 | //------------------------------------------------------------------ |
| 44 | // After connecting, send the handshake to the server to make sure |
| 45 | // we are communicating with it. |
| 46 | //------------------------------------------------------------------ |
| 47 | bool |
| 48 | HandshakeWithServer (lldb_private::Error *error_ptr); |
| 49 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 50 | PacketResult |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 51 | SendPacketAndWaitForResponse (const char *send_payload, |
| 52 | StringExtractorGDBRemote &response, |
| 53 | bool send_async); |
| 54 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 55 | PacketResult |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 56 | SendPacketAndWaitForResponse (const char *send_payload, |
| 57 | size_t send_length, |
| 58 | StringExtractorGDBRemote &response, |
| 59 | bool send_async); |
| 60 | |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 61 | // For packets which specify a range of output to be returned, |
| 62 | // return all of the output via a series of request packets of the form |
| 63 | // <prefix>0,<size> |
| 64 | // <prefix><size>,<size> |
| 65 | // <prefix><size>*2,<size> |
| 66 | // <prefix><size>*3,<size> |
| 67 | // ... |
| 68 | // until a "$l..." packet is received, indicating the end. |
| 69 | // (size is in hex; this format is used by a standard gdbserver to |
| 70 | // return the given portion of the output specified by <prefix>; |
| 71 | // for example, "qXfer:libraries-svr4:read::fff,1000" means |
| 72 | // "return a chunk of the xml description file for shared |
| 73 | // library load addresses, where the chunk starts at offset 0xfff |
| 74 | // and continues for 0x1000 bytes"). |
| 75 | // Concatenate the resulting server response packets together and |
| 76 | // return in response_string. If any packet fails, the return value |
| 77 | // indicates that failure and the returned string value is undefined. |
| 78 | PacketResult |
| 79 | SendPacketsAndConcatenateResponses (const char *send_payload_prefix, |
| 80 | std::string &response_string); |
| 81 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 82 | lldb::StateType |
| 83 | SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process, |
| 84 | const char *packet_payload, |
| 85 | size_t packet_length, |
| 86 | StringExtractorGDBRemote &response); |
| 87 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 88 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 89 | GetThreadSuffixSupported (); |
| 90 | |
Greg Clayton | fb90931 | 2013-11-23 01:58:15 +0000 | [diff] [blame] | 91 | // This packet is usually sent first and the boolean return value |
| 92 | // indicates if the packet was send and any response was received |
| 93 | // even in the response is UNIMPLEMENTED. If the packet failed to |
| 94 | // get a response, then false is returned. This quickly tells us |
| 95 | // if we were able to connect and communicte with the remote GDB |
| 96 | // server |
| 97 | bool |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 98 | QueryNoAckModeSupported (); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 99 | |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 100 | void |
| 101 | GetListThreadsInStopReplySupported (); |
| 102 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 103 | bool |
| 104 | SendAsyncSignal (int signo); |
| 105 | |
| 106 | bool |
| 107 | SendInterrupt (lldb_private::Mutex::Locker &locker, |
| 108 | uint32_t seconds_to_wait_for_stop, |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 109 | bool &timed_out); |
| 110 | |
| 111 | lldb::pid_t |
| 112 | GetCurrentProcessID (); |
| 113 | |
| 114 | bool |
| 115 | GetLaunchSuccess (std::string &error_str); |
| 116 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 117 | uint16_t |
Greg Clayton | dbf0457 | 2013-12-04 19:40:33 +0000 | [diff] [blame] | 118 | LaunchGDBserverAndGetPort (lldb::pid_t &pid, const char *remote_accept_hostname); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 119 | |
| 120 | bool |
| 121 | KillSpawnedProcess (lldb::pid_t pid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 122 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 123 | //------------------------------------------------------------------ |
| 124 | /// Sends a GDB remote protocol 'A' packet that delivers program |
| 125 | /// arguments to the remote server. |
| 126 | /// |
| 127 | /// @param[in] argv |
| 128 | /// A NULL terminated array of const C strings to use as the |
| 129 | /// arguments. |
| 130 | /// |
| 131 | /// @return |
| 132 | /// Zero if the response was "OK", a positive value if the |
| 133 | /// the response was "Exx" where xx are two hex digits, or |
| 134 | /// -1 if the call is unsupported or any other unexpected |
| 135 | /// response was received. |
| 136 | //------------------------------------------------------------------ |
| 137 | int |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 138 | SendArgumentsPacket (const lldb_private::ProcessLaunchInfo &launch_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 139 | |
| 140 | //------------------------------------------------------------------ |
| 141 | /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the |
| 142 | /// environment that will get used when launching an application |
| 143 | /// in conjunction with the 'A' packet. This function can be called |
| 144 | /// multiple times in a row in order to pass on the desired |
| 145 | /// environment that the inferior should be launched with. |
| 146 | /// |
| 147 | /// @param[in] name_equal_value |
| 148 | /// A NULL terminated C string that contains a single environment |
| 149 | /// in the format "NAME=VALUE". |
| 150 | /// |
| 151 | /// @return |
| 152 | /// Zero if the response was "OK", a positive value if the |
| 153 | /// the response was "Exx" where xx are two hex digits, or |
| 154 | /// -1 if the call is unsupported or any other unexpected |
| 155 | /// response was received. |
| 156 | //------------------------------------------------------------------ |
| 157 | int |
| 158 | SendEnvironmentPacket (char const *name_equal_value); |
| 159 | |
Greg Clayton | c4103b3 | 2011-05-08 04:53:50 +0000 | [diff] [blame] | 160 | int |
| 161 | SendLaunchArchPacket (const char *arch); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 162 | |
| 163 | int |
| 164 | SendLaunchEventDataPacket (const char *data, bool *was_supported = NULL); |
| 165 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 166 | //------------------------------------------------------------------ |
| 167 | /// Sends a "vAttach:PID" where PID is in hex. |
| 168 | /// |
| 169 | /// @param[in] pid |
| 170 | /// A process ID for the remote gdb server to attach to. |
| 171 | /// |
| 172 | /// @param[out] response |
| 173 | /// The response received from the gdb server. If the return |
| 174 | /// value is zero, \a response will contain a stop reply |
| 175 | /// packet. |
| 176 | /// |
| 177 | /// @return |
| 178 | /// Zero if the attach was successful, or an error indicating |
| 179 | /// an error code. |
| 180 | //------------------------------------------------------------------ |
| 181 | int |
| 182 | SendAttach (lldb::pid_t pid, |
| 183 | StringExtractorGDBRemote& response); |
| 184 | |
| 185 | |
| 186 | //------------------------------------------------------------------ |
| 187 | /// Sets the path to use for stdin/out/err for a process |
| 188 | /// that will be launched with the 'A' packet. |
| 189 | /// |
| 190 | /// @param[in] path |
| 191 | /// The path to use for stdin/out/err |
| 192 | /// |
| 193 | /// @return |
| 194 | /// Zero if the for success, or an error code for failure. |
| 195 | //------------------------------------------------------------------ |
| 196 | int |
| 197 | SetSTDIN (char const *path); |
| 198 | int |
| 199 | SetSTDOUT (char const *path); |
| 200 | int |
| 201 | SetSTDERR (char const *path); |
| 202 | |
| 203 | //------------------------------------------------------------------ |
| 204 | /// Sets the disable ASLR flag to \a enable for a process that will |
| 205 | /// be launched with the 'A' packet. |
| 206 | /// |
| 207 | /// @param[in] enable |
Jim Ingham | 106d028 | 2014-06-25 02:32:56 +0000 | [diff] [blame] | 208 | /// A boolean value indicating whether to disable ASLR or not. |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 209 | /// |
| 210 | /// @return |
| 211 | /// Zero if the for success, or an error code for failure. |
| 212 | //------------------------------------------------------------------ |
| 213 | int |
| 214 | SetDisableASLR (bool enable); |
Jim Ingham | 106d028 | 2014-06-25 02:32:56 +0000 | [diff] [blame] | 215 | |
| 216 | //------------------------------------------------------------------ |
| 217 | /// Sets the DetachOnError flag to \a enable for the process controlled by the stub. |
| 218 | /// |
| 219 | /// @param[in] enable |
| 220 | /// A boolean value indicating whether to detach on error or not. |
| 221 | /// |
| 222 | /// @return |
| 223 | /// Zero if the for success, or an error code for failure. |
| 224 | //------------------------------------------------------------------ |
| 225 | int |
| 226 | SetDetachOnError (bool enable); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 227 | |
| 228 | //------------------------------------------------------------------ |
| 229 | /// Sets the working directory to \a path for a process that will |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 230 | /// be launched with the 'A' packet for non platform based |
| 231 | /// connections. If this packet is sent to a GDB server that |
| 232 | /// implements the platform, it will change the current working |
| 233 | /// directory for the platform process. |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 234 | /// |
| 235 | /// @param[in] path |
| 236 | /// The path to a directory to use when launching our processs |
| 237 | /// |
| 238 | /// @return |
| 239 | /// Zero if the for success, or an error code for failure. |
| 240 | //------------------------------------------------------------------ |
| 241 | int |
| 242 | SetWorkingDir (char const *path); |
| 243 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 244 | //------------------------------------------------------------------ |
| 245 | /// Gets the current working directory of a remote platform GDB |
| 246 | /// server. |
| 247 | /// |
| 248 | /// @param[out] cwd |
| 249 | /// The current working directory on the remote platform. |
| 250 | /// |
| 251 | /// @return |
| 252 | /// Boolean for success |
| 253 | //------------------------------------------------------------------ |
| 254 | bool |
| 255 | GetWorkingDir (std::string &cwd); |
| 256 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 257 | lldb::addr_t |
| 258 | AllocateMemory (size_t size, uint32_t permissions); |
| 259 | |
| 260 | bool |
| 261 | DeallocateMemory (lldb::addr_t addr); |
| 262 | |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 263 | lldb_private::Error |
| 264 | Detach (bool keep_stopped); |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 265 | |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 266 | lldb_private::Error |
| 267 | GetMemoryRegionInfo (lldb::addr_t addr, |
| 268 | lldb_private::MemoryRegionInfo &range_info); |
| 269 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 270 | lldb_private::Error |
| 271 | GetWatchpointSupportInfo (uint32_t &num); |
| 272 | |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 273 | lldb_private::Error |
| 274 | GetWatchpointSupportInfo (uint32_t &num, bool& after); |
| 275 | |
| 276 | lldb_private::Error |
| 277 | GetWatchpointsTriggerAfterInstruction (bool &after); |
| 278 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 279 | const lldb_private::ArchSpec & |
| 280 | GetHostArchitecture (); |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 281 | |
| 282 | uint32_t |
| 283 | GetHostDefaultPacketTimeout(); |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 284 | |
| 285 | const lldb_private::ArchSpec & |
| 286 | GetProcessArchitecture (); |
| 287 | |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 288 | void |
| 289 | GetRemoteQSupported(); |
| 290 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 291 | bool |
| 292 | GetVContSupported (char flavor); |
| 293 | |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 294 | bool |
Sean Callanan | b1de114 | 2013-09-04 23:24:15 +0000 | [diff] [blame] | 295 | GetpPacketSupported (lldb::tid_t tid); |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 296 | |
| 297 | bool |
Jason Molenda | bdc4f12 | 2014-05-06 02:59:39 +0000 | [diff] [blame] | 298 | GetxPacketSupported (); |
| 299 | |
| 300 | bool |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 301 | GetVAttachOrWaitSupported (); |
| 302 | |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 303 | bool |
| 304 | GetSyncThreadStateSupported(); |
| 305 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 306 | void |
| 307 | ResetDiscoverableSettings(); |
| 308 | |
| 309 | bool |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 310 | GetHostInfo (bool force = false); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 311 | |
| 312 | bool |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 313 | GetOSVersion (uint32_t &major, |
| 314 | uint32_t &minor, |
| 315 | uint32_t &update); |
| 316 | |
| 317 | bool |
| 318 | GetOSBuildString (std::string &s); |
| 319 | |
| 320 | bool |
| 321 | GetOSKernelDescription (std::string &s); |
| 322 | |
| 323 | lldb_private::ArchSpec |
| 324 | GetSystemArchitecture (); |
| 325 | |
| 326 | bool |
| 327 | GetHostname (std::string &s); |
| 328 | |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 329 | lldb::addr_t |
| 330 | GetShlibInfoAddr(); |
| 331 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 332 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 333 | GetSupportsThreadSuffix (); |
| 334 | |
| 335 | bool |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 336 | GetProcessInfo (lldb::pid_t pid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 337 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 338 | |
| 339 | uint32_t |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 340 | FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info, |
| 341 | lldb_private::ProcessInstanceInfoList &process_infos); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 342 | |
| 343 | bool |
| 344 | GetUserName (uint32_t uid, std::string &name); |
| 345 | |
| 346 | bool |
| 347 | GetGroupName (uint32_t gid, std::string &name); |
| 348 | |
| 349 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 350 | HasFullVContSupport () |
| 351 | { |
| 352 | return GetVContSupported ('A'); |
| 353 | } |
| 354 | |
| 355 | bool |
| 356 | HasAnyVContSupport () |
| 357 | { |
| 358 | return GetVContSupported ('a'); |
| 359 | } |
| 360 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 361 | bool |
| 362 | GetStopReply (StringExtractorGDBRemote &response); |
| 363 | |
| 364 | bool |
Greg Clayton | f402f78 | 2012-10-13 02:11:55 +0000 | [diff] [blame] | 365 | GetThreadStopInfo (lldb::tid_t tid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 366 | StringExtractorGDBRemote &response); |
| 367 | |
| 368 | bool |
| 369 | SupportsGDBStoppointPacket (GDBStoppointType type) |
| 370 | { |
| 371 | switch (type) |
| 372 | { |
| 373 | case eBreakpointSoftware: return m_supports_z0; |
| 374 | case eBreakpointHardware: return m_supports_z1; |
| 375 | case eWatchpointWrite: return m_supports_z2; |
| 376 | case eWatchpointRead: return m_supports_z3; |
| 377 | case eWatchpointReadWrite: return m_supports_z4; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 378 | } |
| 379 | return false; |
| 380 | } |
| 381 | uint8_t |
| 382 | SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint |
| 383 | bool insert, // Insert or remove? |
| 384 | lldb::addr_t addr, // Address of breakpoint or watchpoint |
| 385 | uint32_t length); // Byte Size of breakpoint or watchpoint |
| 386 | |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 387 | void |
| 388 | TestPacketSpeed (const uint32_t num_packets); |
| 389 | |
| 390 | // This packet is for testing the speed of the interface only. Both |
| 391 | // the client and server need to support it, but this allows us to |
| 392 | // measure the packet speed without any other work being done on the |
| 393 | // other end and avoids any of that work affecting the packet send |
| 394 | // and response times. |
| 395 | bool |
| 396 | SendSpeedTestPacket (uint32_t send_size, |
| 397 | uint32_t recv_size); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 398 | |
| 399 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 400 | SetCurrentThread (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 401 | |
| 402 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 403 | SetCurrentThreadForRun (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 404 | |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 405 | bool |
Steve Pucci | 03904ac | 2014-03-04 23:18:46 +0000 | [diff] [blame] | 406 | GetQXferAuxvReadSupported (); |
| 407 | |
| 408 | bool |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 409 | GetQXferLibrariesReadSupported (); |
| 410 | |
| 411 | bool |
| 412 | GetQXferLibrariesSVR4ReadSupported (); |
| 413 | |
| 414 | uint64_t |
| 415 | GetRemoteMaxPacketSize(); |
| 416 | |
| 417 | bool |
| 418 | GetAugmentedLibrariesSVR4ReadSupported (); |
| 419 | |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 420 | lldb_private::LazyBool |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 421 | SupportsAllocDeallocMemory () // const |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 422 | { |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 423 | // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets. |
| 424 | // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 425 | return m_supports_alloc_dealloc_memory; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 426 | } |
| 427 | |
Greg Clayton | adc00cb | 2011-05-20 23:38:13 +0000 | [diff] [blame] | 428 | size_t |
| 429 | GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids, |
| 430 | bool &sequence_mutex_unavailable); |
| 431 | |
Greg Clayton | 2687cd1 | 2012-03-29 01:55:41 +0000 | [diff] [blame] | 432 | bool |
| 433 | GetInterruptWasSent () const |
| 434 | { |
| 435 | return m_interrupt_sent; |
| 436 | } |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 437 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 438 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 439 | OpenFile (const lldb_private::FileSpec& file_spec, |
| 440 | uint32_t flags, |
| 441 | mode_t mode, |
| 442 | lldb_private::Error &error); |
| 443 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 444 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 445 | CloseFile (lldb::user_id_t fd, |
| 446 | lldb_private::Error &error); |
| 447 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 448 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 449 | GetFileSize (const lldb_private::FileSpec& file_spec); |
| 450 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 451 | lldb_private::Error |
| 452 | GetFilePermissions(const char *path, uint32_t &file_permissions); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 453 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 454 | lldb_private::Error |
| 455 | SetFilePermissions(const char *path, uint32_t file_permissions); |
| 456 | |
| 457 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 458 | ReadFile (lldb::user_id_t fd, |
| 459 | uint64_t offset, |
| 460 | void *dst, |
| 461 | uint64_t dst_len, |
| 462 | lldb_private::Error &error); |
| 463 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 464 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 465 | WriteFile (lldb::user_id_t fd, |
| 466 | uint64_t offset, |
| 467 | const void* src, |
| 468 | uint64_t src_len, |
| 469 | lldb_private::Error &error); |
| 470 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 471 | lldb_private::Error |
| 472 | CreateSymlink (const char *src, |
| 473 | const char *dst); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 474 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 475 | lldb_private::Error |
| 476 | Unlink (const char *path); |
| 477 | |
| 478 | lldb_private::Error |
| 479 | MakeDirectory (const char *path, |
| 480 | uint32_t mode); |
| 481 | |
| 482 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 483 | GetFileExists (const lldb_private::FileSpec& file_spec); |
| 484 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 485 | lldb_private::Error |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 486 | RunShellCommand (const char *command, // Shouldn't be NULL |
| 487 | const char *working_dir, // Pass NULL to use the current working directory |
| 488 | int *status_ptr, // Pass NULL if you don't want the process exit status |
| 489 | int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit |
| 490 | std::string *command_output, // Pass NULL if you don't want the command output |
| 491 | uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish |
| 492 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 493 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 494 | CalculateMD5 (const lldb_private::FileSpec& file_spec, |
| 495 | uint64_t &high, |
| 496 | uint64_t &low); |
| 497 | |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 498 | std::string |
| 499 | HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process, |
| 500 | StringExtractorGDBRemote &inputStringExtractor); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 501 | |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 502 | bool |
| 503 | ReadRegister(lldb::tid_t tid, |
| 504 | uint32_t reg_num, |
| 505 | StringExtractorGDBRemote &response); |
| 506 | |
| 507 | bool |
| 508 | ReadAllRegisters (lldb::tid_t tid, |
| 509 | StringExtractorGDBRemote &response); |
| 510 | |
| 511 | bool |
| 512 | SaveRegisterState (lldb::tid_t tid, uint32_t &save_id); |
| 513 | |
| 514 | bool |
| 515 | RestoreRegisterState (lldb::tid_t tid, uint32_t save_id); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 516 | |
| 517 | const char * |
| 518 | GetGDBServerProgramName(); |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 519 | |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 520 | uint32_t |
| 521 | GetGDBServerProgramVersion(); |
| 522 | |
| 523 | bool |
| 524 | AvoidGPackets(ProcessGDBRemote *process); |
| 525 | |
Jason Molenda | 705b180 | 2014-06-13 02:37:02 +0000 | [diff] [blame] | 526 | bool |
| 527 | GetThreadExtendedInfoSupported(); |
| 528 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 529 | protected: |
| 530 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 531 | PacketResult |
| 532 | SendPacketAndWaitForResponseNoLock (const char *payload, |
| 533 | size_t payload_length, |
| 534 | StringExtractorGDBRemote &response); |
| 535 | |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 536 | bool |
| 537 | GetCurrentProcessInfo (); |
| 538 | |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 539 | bool |
| 540 | GetGDBServerVersion(); |
| 541 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 542 | //------------------------------------------------------------------ |
| 543 | // Classes that inherit from GDBRemoteCommunicationClient can see and modify these |
| 544 | //------------------------------------------------------------------ |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 545 | lldb_private::LazyBool m_supports_not_sending_acks; |
| 546 | lldb_private::LazyBool m_supports_thread_suffix; |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 547 | lldb_private::LazyBool m_supports_threads_in_stop_reply; |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 548 | lldb_private::LazyBool m_supports_vCont_all; |
| 549 | lldb_private::LazyBool m_supports_vCont_any; |
| 550 | lldb_private::LazyBool m_supports_vCont_c; |
| 551 | lldb_private::LazyBool m_supports_vCont_C; |
| 552 | lldb_private::LazyBool m_supports_vCont_s; |
| 553 | lldb_private::LazyBool m_supports_vCont_S; |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 554 | lldb_private::LazyBool m_qHostInfo_is_valid; |
Todd Fiala | 9f72b3a | 2014-05-07 19:28:21 +0000 | [diff] [blame] | 555 | lldb_private::LazyBool m_curr_pid_is_valid; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 556 | lldb_private::LazyBool m_qProcessInfo_is_valid; |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 557 | lldb_private::LazyBool m_qGDBServerVersion_is_valid; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 558 | lldb_private::LazyBool m_supports_alloc_dealloc_memory; |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 559 | lldb_private::LazyBool m_supports_memory_region_info; |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 560 | lldb_private::LazyBool m_supports_watchpoint_support_info; |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 561 | lldb_private::LazyBool m_supports_detach_stay_stopped; |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 562 | lldb_private::LazyBool m_watchpoints_trigger_after_instruction; |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 563 | lldb_private::LazyBool m_attach_or_wait_reply; |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 564 | lldb_private::LazyBool m_prepare_for_reg_writing_reply; |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 565 | lldb_private::LazyBool m_supports_p; |
Jason Molenda | bdc4f12 | 2014-05-06 02:59:39 +0000 | [diff] [blame] | 566 | lldb_private::LazyBool m_supports_x; |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 567 | lldb_private::LazyBool m_avoid_g_packets; |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 568 | lldb_private::LazyBool m_supports_QSaveRegisterState; |
Steve Pucci | 03904ac | 2014-03-04 23:18:46 +0000 | [diff] [blame] | 569 | lldb_private::LazyBool m_supports_qXfer_auxv_read; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 570 | lldb_private::LazyBool m_supports_qXfer_libraries_read; |
| 571 | lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read; |
| 572 | lldb_private::LazyBool m_supports_augmented_libraries_svr4_read; |
Jason Molenda | 705b180 | 2014-06-13 02:37:02 +0000 | [diff] [blame] | 573 | lldb_private::LazyBool m_supports_jThreadExtendedInfo; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 574 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 575 | bool |
| 576 | m_supports_qProcessInfoPID:1, |
| 577 | m_supports_qfProcessInfo:1, |
| 578 | m_supports_qUserName:1, |
| 579 | m_supports_qGroupName:1, |
| 580 | m_supports_qThreadStopInfo:1, |
| 581 | m_supports_z0:1, |
| 582 | m_supports_z1:1, |
| 583 | m_supports_z2:1, |
| 584 | m_supports_z3:1, |
Greg Clayton | 8960058 | 2013-10-10 17:53:50 +0000 | [diff] [blame] | 585 | m_supports_z4:1, |
| 586 | m_supports_QEnvironment:1, |
| 587 | m_supports_QEnvironmentHexEncoded:1; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 588 | |
Todd Fiala | 9f72b3a | 2014-05-07 19:28:21 +0000 | [diff] [blame] | 589 | lldb::pid_t m_curr_pid; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 590 | lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations |
| 591 | lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc |
| 592 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 593 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 594 | uint32_t m_num_supported_hardware_watchpoints; |
| 595 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 596 | // If we need to send a packet while the target is running, the m_async_XXX |
| 597 | // member variables take care of making this happen. |
| 598 | lldb_private::Mutex m_async_mutex; |
| 599 | lldb_private::Predicate<bool> m_async_packet_predicate; |
| 600 | std::string m_async_packet; |
Jim Ingham | a6195b7 | 2013-12-18 01:24:33 +0000 | [diff] [blame] | 601 | PacketResult m_async_result; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 602 | StringExtractorGDBRemote m_async_response; |
| 603 | int m_async_signal; // We were asked to deliver a signal to the inferior process. |
Greg Clayton | 2687cd1 | 2012-03-29 01:55:41 +0000 | [diff] [blame] | 604 | bool m_interrupt_sent; |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 605 | std::string m_partial_profile_data; |
| 606 | std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 607 | |
Greg Clayton | d314e81 | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 608 | lldb_private::ArchSpec m_host_arch; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 609 | lldb_private::ArchSpec m_process_arch; |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 610 | uint32_t m_os_version_major; |
| 611 | uint32_t m_os_version_minor; |
| 612 | uint32_t m_os_version_update; |
| 613 | std::string m_os_build; |
| 614 | std::string m_os_kernel; |
| 615 | std::string m_hostname; |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 616 | std::string m_gdb_server_name; // from reply to qGDBServerVersion, empty if qGDBServerVersion is not supported |
| 617 | uint32_t m_gdb_server_version; // from reply to qGDBServerVersion, zero if qGDBServerVersion is not supported |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 618 | uint32_t m_default_packet_timeout; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 619 | uint64_t m_max_packet_size; // as returned by qSupported |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 620 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 621 | bool |
| 622 | DecodeProcessInfoResponse (StringExtractorGDBRemote &response, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 623 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 624 | private: |
| 625 | //------------------------------------------------------------------ |
| 626 | // For GDBRemoteCommunicationClient only |
| 627 | //------------------------------------------------------------------ |
| 628 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient); |
| 629 | }; |
| 630 | |
| 631 | #endif // liblldb_GDBRemoteCommunicationClient_h_ |