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); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 162 | //------------------------------------------------------------------ |
| 163 | /// Sends a "vAttach:PID" where PID is in hex. |
| 164 | /// |
| 165 | /// @param[in] pid |
| 166 | /// A process ID for the remote gdb server to attach to. |
| 167 | /// |
| 168 | /// @param[out] response |
| 169 | /// The response received from the gdb server. If the return |
| 170 | /// value is zero, \a response will contain a stop reply |
| 171 | /// packet. |
| 172 | /// |
| 173 | /// @return |
| 174 | /// Zero if the attach was successful, or an error indicating |
| 175 | /// an error code. |
| 176 | //------------------------------------------------------------------ |
| 177 | int |
| 178 | SendAttach (lldb::pid_t pid, |
| 179 | StringExtractorGDBRemote& response); |
| 180 | |
| 181 | |
| 182 | //------------------------------------------------------------------ |
| 183 | /// Sets the path to use for stdin/out/err for a process |
| 184 | /// that will be launched with the 'A' packet. |
| 185 | /// |
| 186 | /// @param[in] path |
| 187 | /// The path to use for stdin/out/err |
| 188 | /// |
| 189 | /// @return |
| 190 | /// Zero if the for success, or an error code for failure. |
| 191 | //------------------------------------------------------------------ |
| 192 | int |
| 193 | SetSTDIN (char const *path); |
| 194 | int |
| 195 | SetSTDOUT (char const *path); |
| 196 | int |
| 197 | SetSTDERR (char const *path); |
| 198 | |
| 199 | //------------------------------------------------------------------ |
| 200 | /// Sets the disable ASLR flag to \a enable for a process that will |
| 201 | /// be launched with the 'A' packet. |
| 202 | /// |
| 203 | /// @param[in] enable |
| 204 | /// A boolean value indicating wether to disable ASLR or not. |
| 205 | /// |
| 206 | /// @return |
| 207 | /// Zero if the for success, or an error code for failure. |
| 208 | //------------------------------------------------------------------ |
| 209 | int |
| 210 | SetDisableASLR (bool enable); |
| 211 | |
| 212 | //------------------------------------------------------------------ |
| 213 | /// Sets the working directory to \a path for a process that will |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 214 | /// be launched with the 'A' packet for non platform based |
| 215 | /// connections. If this packet is sent to a GDB server that |
| 216 | /// implements the platform, it will change the current working |
| 217 | /// directory for the platform process. |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 218 | /// |
| 219 | /// @param[in] path |
| 220 | /// The path to a directory to use when launching our processs |
| 221 | /// |
| 222 | /// @return |
| 223 | /// Zero if the for success, or an error code for failure. |
| 224 | //------------------------------------------------------------------ |
| 225 | int |
| 226 | SetWorkingDir (char const *path); |
| 227 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 228 | //------------------------------------------------------------------ |
| 229 | /// Gets the current working directory of a remote platform GDB |
| 230 | /// server. |
| 231 | /// |
| 232 | /// @param[out] cwd |
| 233 | /// The current working directory on the remote platform. |
| 234 | /// |
| 235 | /// @return |
| 236 | /// Boolean for success |
| 237 | //------------------------------------------------------------------ |
| 238 | bool |
| 239 | GetWorkingDir (std::string &cwd); |
| 240 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 241 | lldb::addr_t |
| 242 | AllocateMemory (size_t size, uint32_t permissions); |
| 243 | |
| 244 | bool |
| 245 | DeallocateMemory (lldb::addr_t addr); |
| 246 | |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 247 | lldb_private::Error |
| 248 | Detach (bool keep_stopped); |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 249 | |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 250 | lldb_private::Error |
| 251 | GetMemoryRegionInfo (lldb::addr_t addr, |
| 252 | lldb_private::MemoryRegionInfo &range_info); |
| 253 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 254 | lldb_private::Error |
| 255 | GetWatchpointSupportInfo (uint32_t &num); |
| 256 | |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 257 | lldb_private::Error |
| 258 | GetWatchpointSupportInfo (uint32_t &num, bool& after); |
| 259 | |
| 260 | lldb_private::Error |
| 261 | GetWatchpointsTriggerAfterInstruction (bool &after); |
| 262 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 263 | const lldb_private::ArchSpec & |
| 264 | GetHostArchitecture (); |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 265 | |
| 266 | uint32_t |
| 267 | GetHostDefaultPacketTimeout(); |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 268 | |
| 269 | const lldb_private::ArchSpec & |
| 270 | GetProcessArchitecture (); |
| 271 | |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 272 | void |
| 273 | GetRemoteQSupported(); |
| 274 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 275 | bool |
| 276 | GetVContSupported (char flavor); |
| 277 | |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 278 | bool |
Sean Callanan | b1de114 | 2013-09-04 23:24:15 +0000 | [diff] [blame] | 279 | GetpPacketSupported (lldb::tid_t tid); |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 280 | |
| 281 | bool |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 282 | GetVAttachOrWaitSupported (); |
| 283 | |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 284 | bool |
| 285 | GetSyncThreadStateSupported(); |
| 286 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 287 | void |
| 288 | ResetDiscoverableSettings(); |
| 289 | |
| 290 | bool |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 291 | GetHostInfo (bool force = false); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 292 | |
| 293 | bool |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 294 | GetOSVersion (uint32_t &major, |
| 295 | uint32_t &minor, |
| 296 | uint32_t &update); |
| 297 | |
| 298 | bool |
| 299 | GetOSBuildString (std::string &s); |
| 300 | |
| 301 | bool |
| 302 | GetOSKernelDescription (std::string &s); |
| 303 | |
| 304 | lldb_private::ArchSpec |
| 305 | GetSystemArchitecture (); |
| 306 | |
| 307 | bool |
| 308 | GetHostname (std::string &s); |
| 309 | |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 310 | lldb::addr_t |
| 311 | GetShlibInfoAddr(); |
| 312 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 313 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 314 | GetSupportsThreadSuffix (); |
| 315 | |
| 316 | bool |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 317 | GetProcessInfo (lldb::pid_t pid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 318 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 319 | |
| 320 | uint32_t |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 321 | FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info, |
| 322 | lldb_private::ProcessInstanceInfoList &process_infos); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 323 | |
| 324 | bool |
| 325 | GetUserName (uint32_t uid, std::string &name); |
| 326 | |
| 327 | bool |
| 328 | GetGroupName (uint32_t gid, std::string &name); |
| 329 | |
| 330 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 331 | HasFullVContSupport () |
| 332 | { |
| 333 | return GetVContSupported ('A'); |
| 334 | } |
| 335 | |
| 336 | bool |
| 337 | HasAnyVContSupport () |
| 338 | { |
| 339 | return GetVContSupported ('a'); |
| 340 | } |
| 341 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 342 | bool |
| 343 | GetStopReply (StringExtractorGDBRemote &response); |
| 344 | |
| 345 | bool |
Greg Clayton | f402f78 | 2012-10-13 02:11:55 +0000 | [diff] [blame] | 346 | GetThreadStopInfo (lldb::tid_t tid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 347 | StringExtractorGDBRemote &response); |
| 348 | |
| 349 | bool |
| 350 | SupportsGDBStoppointPacket (GDBStoppointType type) |
| 351 | { |
| 352 | switch (type) |
| 353 | { |
| 354 | case eBreakpointSoftware: return m_supports_z0; |
| 355 | case eBreakpointHardware: return m_supports_z1; |
| 356 | case eWatchpointWrite: return m_supports_z2; |
| 357 | case eWatchpointRead: return m_supports_z3; |
| 358 | case eWatchpointReadWrite: return m_supports_z4; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 359 | } |
| 360 | return false; |
| 361 | } |
| 362 | uint8_t |
| 363 | SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint |
| 364 | bool insert, // Insert or remove? |
| 365 | lldb::addr_t addr, // Address of breakpoint or watchpoint |
| 366 | uint32_t length); // Byte Size of breakpoint or watchpoint |
| 367 | |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 368 | void |
| 369 | TestPacketSpeed (const uint32_t num_packets); |
| 370 | |
| 371 | // This packet is for testing the speed of the interface only. Both |
| 372 | // the client and server need to support it, but this allows us to |
| 373 | // measure the packet speed without any other work being done on the |
| 374 | // other end and avoids any of that work affecting the packet send |
| 375 | // and response times. |
| 376 | bool |
| 377 | SendSpeedTestPacket (uint32_t send_size, |
| 378 | uint32_t recv_size); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 379 | |
| 380 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 381 | SetCurrentThread (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 382 | |
| 383 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 384 | SetCurrentThreadForRun (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 385 | |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 386 | bool |
Steve Pucci | 03904ac | 2014-03-04 23:18:46 +0000 | [diff] [blame^] | 387 | GetQXferAuxvReadSupported (); |
| 388 | |
| 389 | bool |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 390 | GetQXferLibrariesReadSupported (); |
| 391 | |
| 392 | bool |
| 393 | GetQXferLibrariesSVR4ReadSupported (); |
| 394 | |
| 395 | uint64_t |
| 396 | GetRemoteMaxPacketSize(); |
| 397 | |
| 398 | bool |
| 399 | GetAugmentedLibrariesSVR4ReadSupported (); |
| 400 | |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 401 | lldb_private::LazyBool |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 402 | SupportsAllocDeallocMemory () // const |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 403 | { |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 404 | // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets. |
| 405 | // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 406 | return m_supports_alloc_dealloc_memory; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Greg Clayton | adc00cb | 2011-05-20 23:38:13 +0000 | [diff] [blame] | 409 | size_t |
| 410 | GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids, |
| 411 | bool &sequence_mutex_unavailable); |
| 412 | |
Greg Clayton | 2687cd1 | 2012-03-29 01:55:41 +0000 | [diff] [blame] | 413 | bool |
| 414 | GetInterruptWasSent () const |
| 415 | { |
| 416 | return m_interrupt_sent; |
| 417 | } |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 418 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 419 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 420 | OpenFile (const lldb_private::FileSpec& file_spec, |
| 421 | uint32_t flags, |
| 422 | mode_t mode, |
| 423 | lldb_private::Error &error); |
| 424 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 425 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 426 | CloseFile (lldb::user_id_t fd, |
| 427 | lldb_private::Error &error); |
| 428 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 429 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 430 | GetFileSize (const lldb_private::FileSpec& file_spec); |
| 431 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 432 | lldb_private::Error |
| 433 | GetFilePermissions(const char *path, uint32_t &file_permissions); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 434 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 435 | lldb_private::Error |
| 436 | SetFilePermissions(const char *path, uint32_t file_permissions); |
| 437 | |
| 438 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 439 | ReadFile (lldb::user_id_t fd, |
| 440 | uint64_t offset, |
| 441 | void *dst, |
| 442 | uint64_t dst_len, |
| 443 | lldb_private::Error &error); |
| 444 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 445 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 446 | WriteFile (lldb::user_id_t fd, |
| 447 | uint64_t offset, |
| 448 | const void* src, |
| 449 | uint64_t src_len, |
| 450 | lldb_private::Error &error); |
| 451 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 452 | lldb_private::Error |
| 453 | CreateSymlink (const char *src, |
| 454 | const char *dst); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 455 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 456 | lldb_private::Error |
| 457 | Unlink (const char *path); |
| 458 | |
| 459 | lldb_private::Error |
| 460 | MakeDirectory (const char *path, |
| 461 | uint32_t mode); |
| 462 | |
| 463 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 464 | GetFileExists (const lldb_private::FileSpec& file_spec); |
| 465 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 466 | lldb_private::Error |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 467 | RunShellCommand (const char *command, // Shouldn't be NULL |
| 468 | const char *working_dir, // Pass NULL to use the current working directory |
| 469 | int *status_ptr, // Pass NULL if you don't want the process exit status |
| 470 | int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit |
| 471 | std::string *command_output, // Pass NULL if you don't want the command output |
| 472 | uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish |
| 473 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 474 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 475 | CalculateMD5 (const lldb_private::FileSpec& file_spec, |
| 476 | uint64_t &high, |
| 477 | uint64_t &low); |
| 478 | |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 479 | std::string |
| 480 | HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process, |
| 481 | StringExtractorGDBRemote &inputStringExtractor); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 482 | |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 483 | bool |
| 484 | ReadRegister(lldb::tid_t tid, |
| 485 | uint32_t reg_num, |
| 486 | StringExtractorGDBRemote &response); |
| 487 | |
| 488 | bool |
| 489 | ReadAllRegisters (lldb::tid_t tid, |
| 490 | StringExtractorGDBRemote &response); |
| 491 | |
| 492 | bool |
| 493 | SaveRegisterState (lldb::tid_t tid, uint32_t &save_id); |
| 494 | |
| 495 | bool |
| 496 | RestoreRegisterState (lldb::tid_t tid, uint32_t save_id); |
| 497 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 498 | protected: |
| 499 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 500 | PacketResult |
| 501 | SendPacketAndWaitForResponseNoLock (const char *payload, |
| 502 | size_t payload_length, |
| 503 | StringExtractorGDBRemote &response); |
| 504 | |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 505 | bool |
| 506 | GetCurrentProcessInfo (); |
| 507 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 508 | //------------------------------------------------------------------ |
| 509 | // Classes that inherit from GDBRemoteCommunicationClient can see and modify these |
| 510 | //------------------------------------------------------------------ |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 511 | lldb_private::LazyBool m_supports_not_sending_acks; |
| 512 | lldb_private::LazyBool m_supports_thread_suffix; |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 513 | lldb_private::LazyBool m_supports_threads_in_stop_reply; |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 514 | lldb_private::LazyBool m_supports_vCont_all; |
| 515 | lldb_private::LazyBool m_supports_vCont_any; |
| 516 | lldb_private::LazyBool m_supports_vCont_c; |
| 517 | lldb_private::LazyBool m_supports_vCont_C; |
| 518 | lldb_private::LazyBool m_supports_vCont_s; |
| 519 | lldb_private::LazyBool m_supports_vCont_S; |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 520 | lldb_private::LazyBool m_qHostInfo_is_valid; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 521 | lldb_private::LazyBool m_qProcessInfo_is_valid; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 522 | lldb_private::LazyBool m_supports_alloc_dealloc_memory; |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 523 | lldb_private::LazyBool m_supports_memory_region_info; |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 524 | lldb_private::LazyBool m_supports_watchpoint_support_info; |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 525 | lldb_private::LazyBool m_supports_detach_stay_stopped; |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 526 | lldb_private::LazyBool m_watchpoints_trigger_after_instruction; |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 527 | lldb_private::LazyBool m_attach_or_wait_reply; |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 528 | lldb_private::LazyBool m_prepare_for_reg_writing_reply; |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 529 | lldb_private::LazyBool m_supports_p; |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 530 | lldb_private::LazyBool m_supports_QSaveRegisterState; |
Steve Pucci | 03904ac | 2014-03-04 23:18:46 +0000 | [diff] [blame^] | 531 | lldb_private::LazyBool m_supports_qXfer_auxv_read; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 532 | lldb_private::LazyBool m_supports_qXfer_libraries_read; |
| 533 | lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read; |
| 534 | lldb_private::LazyBool m_supports_augmented_libraries_svr4_read; |
| 535 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 536 | bool |
| 537 | m_supports_qProcessInfoPID:1, |
| 538 | m_supports_qfProcessInfo:1, |
| 539 | m_supports_qUserName:1, |
| 540 | m_supports_qGroupName:1, |
| 541 | m_supports_qThreadStopInfo:1, |
| 542 | m_supports_z0:1, |
| 543 | m_supports_z1:1, |
| 544 | m_supports_z2:1, |
| 545 | m_supports_z3:1, |
Greg Clayton | 8960058 | 2013-10-10 17:53:50 +0000 | [diff] [blame] | 546 | m_supports_z4:1, |
| 547 | m_supports_QEnvironment:1, |
| 548 | m_supports_QEnvironmentHexEncoded:1; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 549 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 550 | |
| 551 | lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations |
| 552 | lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc |
| 553 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 554 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 555 | uint32_t m_num_supported_hardware_watchpoints; |
| 556 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 557 | // If we need to send a packet while the target is running, the m_async_XXX |
| 558 | // member variables take care of making this happen. |
| 559 | lldb_private::Mutex m_async_mutex; |
| 560 | lldb_private::Predicate<bool> m_async_packet_predicate; |
| 561 | std::string m_async_packet; |
Jim Ingham | a6195b7 | 2013-12-18 01:24:33 +0000 | [diff] [blame] | 562 | PacketResult m_async_result; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 563 | StringExtractorGDBRemote m_async_response; |
| 564 | 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] | 565 | bool m_interrupt_sent; |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 566 | std::string m_partial_profile_data; |
| 567 | 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] | 568 | |
Greg Clayton | d314e81 | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 569 | lldb_private::ArchSpec m_host_arch; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 570 | lldb_private::ArchSpec m_process_arch; |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 571 | uint32_t m_os_version_major; |
| 572 | uint32_t m_os_version_minor; |
| 573 | uint32_t m_os_version_update; |
| 574 | std::string m_os_build; |
| 575 | std::string m_os_kernel; |
| 576 | std::string m_hostname; |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 577 | uint32_t m_default_packet_timeout; |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 578 | uint64_t m_max_packet_size; // as returned by qSupported |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 579 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 580 | bool |
| 581 | DecodeProcessInfoResponse (StringExtractorGDBRemote &response, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 582 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 583 | private: |
| 584 | //------------------------------------------------------------------ |
| 585 | // For GDBRemoteCommunicationClient only |
| 586 | //------------------------------------------------------------------ |
| 587 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient); |
| 588 | }; |
| 589 | |
| 590 | #endif // liblldb_GDBRemoteCommunicationClient_h_ |