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 | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 50 | size_t |
| 51 | SendPacketAndWaitForResponse (const char *send_payload, |
| 52 | StringExtractorGDBRemote &response, |
| 53 | bool send_async); |
| 54 | |
| 55 | size_t |
| 56 | SendPacketAndWaitForResponse (const char *send_payload, |
| 57 | size_t send_length, |
| 58 | StringExtractorGDBRemote &response, |
| 59 | bool send_async); |
| 60 | |
| 61 | lldb::StateType |
| 62 | SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process, |
| 63 | const char *packet_payload, |
| 64 | size_t packet_length, |
| 65 | StringExtractorGDBRemote &response); |
| 66 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 67 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 68 | GetThreadSuffixSupported (); |
| 69 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 70 | void |
| 71 | QueryNoAckModeSupported (); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 72 | |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 73 | void |
| 74 | GetListThreadsInStopReplySupported (); |
| 75 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 76 | bool |
| 77 | SendAsyncSignal (int signo); |
| 78 | |
| 79 | bool |
| 80 | SendInterrupt (lldb_private::Mutex::Locker &locker, |
| 81 | uint32_t seconds_to_wait_for_stop, |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 82 | bool &timed_out); |
| 83 | |
| 84 | lldb::pid_t |
| 85 | GetCurrentProcessID (); |
| 86 | |
| 87 | bool |
| 88 | GetLaunchSuccess (std::string &error_str); |
| 89 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 90 | uint16_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 91 | LaunchGDBserverAndGetPort (lldb::pid_t &pid); |
| 92 | |
| 93 | bool |
| 94 | KillSpawnedProcess (lldb::pid_t pid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 95 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 96 | //------------------------------------------------------------------ |
| 97 | /// Sends a GDB remote protocol 'A' packet that delivers program |
| 98 | /// arguments to the remote server. |
| 99 | /// |
| 100 | /// @param[in] argv |
| 101 | /// A NULL terminated array of const C strings to use as the |
| 102 | /// arguments. |
| 103 | /// |
| 104 | /// @return |
| 105 | /// Zero if the response was "OK", a positive value if the |
| 106 | /// the response was "Exx" where xx are two hex digits, or |
| 107 | /// -1 if the call is unsupported or any other unexpected |
| 108 | /// response was received. |
| 109 | //------------------------------------------------------------------ |
| 110 | int |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 111 | SendArgumentsPacket (const lldb_private::ProcessLaunchInfo &launch_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 112 | |
| 113 | //------------------------------------------------------------------ |
| 114 | /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the |
| 115 | /// environment that will get used when launching an application |
| 116 | /// in conjunction with the 'A' packet. This function can be called |
| 117 | /// multiple times in a row in order to pass on the desired |
| 118 | /// environment that the inferior should be launched with. |
| 119 | /// |
| 120 | /// @param[in] name_equal_value |
| 121 | /// A NULL terminated C string that contains a single environment |
| 122 | /// in the format "NAME=VALUE". |
| 123 | /// |
| 124 | /// @return |
| 125 | /// Zero if the response was "OK", a positive value if the |
| 126 | /// the response was "Exx" where xx are two hex digits, or |
| 127 | /// -1 if the call is unsupported or any other unexpected |
| 128 | /// response was received. |
| 129 | //------------------------------------------------------------------ |
| 130 | int |
| 131 | SendEnvironmentPacket (char const *name_equal_value); |
| 132 | |
Greg Clayton | c4103b3 | 2011-05-08 04:53:50 +0000 | [diff] [blame] | 133 | int |
| 134 | SendLaunchArchPacket (const char *arch); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 135 | //------------------------------------------------------------------ |
| 136 | /// Sends a "vAttach:PID" where PID is in hex. |
| 137 | /// |
| 138 | /// @param[in] pid |
| 139 | /// A process ID for the remote gdb server to attach to. |
| 140 | /// |
| 141 | /// @param[out] response |
| 142 | /// The response received from the gdb server. If the return |
| 143 | /// value is zero, \a response will contain a stop reply |
| 144 | /// packet. |
| 145 | /// |
| 146 | /// @return |
| 147 | /// Zero if the attach was successful, or an error indicating |
| 148 | /// an error code. |
| 149 | //------------------------------------------------------------------ |
| 150 | int |
| 151 | SendAttach (lldb::pid_t pid, |
| 152 | StringExtractorGDBRemote& response); |
| 153 | |
| 154 | |
| 155 | //------------------------------------------------------------------ |
| 156 | /// Sets the path to use for stdin/out/err for a process |
| 157 | /// that will be launched with the 'A' packet. |
| 158 | /// |
| 159 | /// @param[in] path |
| 160 | /// The path to use for stdin/out/err |
| 161 | /// |
| 162 | /// @return |
| 163 | /// Zero if the for success, or an error code for failure. |
| 164 | //------------------------------------------------------------------ |
| 165 | int |
| 166 | SetSTDIN (char const *path); |
| 167 | int |
| 168 | SetSTDOUT (char const *path); |
| 169 | int |
| 170 | SetSTDERR (char const *path); |
| 171 | |
| 172 | //------------------------------------------------------------------ |
| 173 | /// Sets the disable ASLR flag to \a enable for a process that will |
| 174 | /// be launched with the 'A' packet. |
| 175 | /// |
| 176 | /// @param[in] enable |
| 177 | /// A boolean value indicating wether to disable ASLR or not. |
| 178 | /// |
| 179 | /// @return |
| 180 | /// Zero if the for success, or an error code for failure. |
| 181 | //------------------------------------------------------------------ |
| 182 | int |
| 183 | SetDisableASLR (bool enable); |
| 184 | |
| 185 | //------------------------------------------------------------------ |
| 186 | /// Sets the working directory to \a path for a process that will |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 187 | /// be launched with the 'A' packet for non platform based |
| 188 | /// connections. If this packet is sent to a GDB server that |
| 189 | /// implements the platform, it will change the current working |
| 190 | /// directory for the platform process. |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 191 | /// |
| 192 | /// @param[in] path |
| 193 | /// The path to a directory to use when launching our processs |
| 194 | /// |
| 195 | /// @return |
| 196 | /// Zero if the for success, or an error code for failure. |
| 197 | //------------------------------------------------------------------ |
| 198 | int |
| 199 | SetWorkingDir (char const *path); |
| 200 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 201 | //------------------------------------------------------------------ |
| 202 | /// Gets the current working directory of a remote platform GDB |
| 203 | /// server. |
| 204 | /// |
| 205 | /// @param[out] cwd |
| 206 | /// The current working directory on the remote platform. |
| 207 | /// |
| 208 | /// @return |
| 209 | /// Boolean for success |
| 210 | //------------------------------------------------------------------ |
| 211 | bool |
| 212 | GetWorkingDir (std::string &cwd); |
| 213 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 214 | lldb::addr_t |
| 215 | AllocateMemory (size_t size, uint32_t permissions); |
| 216 | |
| 217 | bool |
| 218 | DeallocateMemory (lldb::addr_t addr); |
| 219 | |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 220 | lldb_private::Error |
| 221 | Detach (bool keep_stopped); |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 222 | |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 223 | lldb_private::Error |
| 224 | GetMemoryRegionInfo (lldb::addr_t addr, |
| 225 | lldb_private::MemoryRegionInfo &range_info); |
| 226 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 227 | lldb_private::Error |
| 228 | GetWatchpointSupportInfo (uint32_t &num); |
| 229 | |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 230 | lldb_private::Error |
| 231 | GetWatchpointSupportInfo (uint32_t &num, bool& after); |
| 232 | |
| 233 | lldb_private::Error |
| 234 | GetWatchpointsTriggerAfterInstruction (bool &after); |
| 235 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 236 | const lldb_private::ArchSpec & |
| 237 | GetHostArchitecture (); |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 238 | |
| 239 | uint32_t |
| 240 | GetHostDefaultPacketTimeout(); |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 241 | |
| 242 | const lldb_private::ArchSpec & |
| 243 | GetProcessArchitecture (); |
| 244 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 245 | bool |
| 246 | GetVContSupported (char flavor); |
| 247 | |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 248 | bool |
Sean Callanan | b1de114 | 2013-09-04 23:24:15 +0000 | [diff] [blame] | 249 | GetpPacketSupported (lldb::tid_t tid); |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 250 | |
| 251 | bool |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 252 | GetVAttachOrWaitSupported (); |
| 253 | |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 254 | bool |
| 255 | GetSyncThreadStateSupported(); |
| 256 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 257 | void |
| 258 | ResetDiscoverableSettings(); |
| 259 | |
| 260 | bool |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 261 | GetHostInfo (bool force = false); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 262 | |
| 263 | bool |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 264 | GetOSVersion (uint32_t &major, |
| 265 | uint32_t &minor, |
| 266 | uint32_t &update); |
| 267 | |
| 268 | bool |
| 269 | GetOSBuildString (std::string &s); |
| 270 | |
| 271 | bool |
| 272 | GetOSKernelDescription (std::string &s); |
| 273 | |
| 274 | lldb_private::ArchSpec |
| 275 | GetSystemArchitecture (); |
| 276 | |
| 277 | bool |
| 278 | GetHostname (std::string &s); |
| 279 | |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 280 | lldb::addr_t |
| 281 | GetShlibInfoAddr(); |
| 282 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 283 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 284 | GetSupportsThreadSuffix (); |
| 285 | |
| 286 | bool |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 287 | GetProcessInfo (lldb::pid_t pid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 288 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 289 | |
| 290 | uint32_t |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 291 | FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info, |
| 292 | lldb_private::ProcessInstanceInfoList &process_infos); |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 293 | |
| 294 | bool |
| 295 | GetUserName (uint32_t uid, std::string &name); |
| 296 | |
| 297 | bool |
| 298 | GetGroupName (uint32_t gid, std::string &name); |
| 299 | |
| 300 | bool |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 301 | HasFullVContSupport () |
| 302 | { |
| 303 | return GetVContSupported ('A'); |
| 304 | } |
| 305 | |
| 306 | bool |
| 307 | HasAnyVContSupport () |
| 308 | { |
| 309 | return GetVContSupported ('a'); |
| 310 | } |
| 311 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 312 | bool |
| 313 | GetStopReply (StringExtractorGDBRemote &response); |
| 314 | |
| 315 | bool |
Greg Clayton | f402f78 | 2012-10-13 02:11:55 +0000 | [diff] [blame] | 316 | GetThreadStopInfo (lldb::tid_t tid, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 317 | StringExtractorGDBRemote &response); |
| 318 | |
| 319 | bool |
| 320 | SupportsGDBStoppointPacket (GDBStoppointType type) |
| 321 | { |
| 322 | switch (type) |
| 323 | { |
| 324 | case eBreakpointSoftware: return m_supports_z0; |
| 325 | case eBreakpointHardware: return m_supports_z1; |
| 326 | case eWatchpointWrite: return m_supports_z2; |
| 327 | case eWatchpointRead: return m_supports_z3; |
| 328 | case eWatchpointReadWrite: return m_supports_z4; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 329 | } |
| 330 | return false; |
| 331 | } |
| 332 | uint8_t |
| 333 | SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint |
| 334 | bool insert, // Insert or remove? |
| 335 | lldb::addr_t addr, // Address of breakpoint or watchpoint |
| 336 | uint32_t length); // Byte Size of breakpoint or watchpoint |
| 337 | |
Greg Clayton | 9b1e1cd | 2011-04-04 18:18:57 +0000 | [diff] [blame] | 338 | void |
| 339 | TestPacketSpeed (const uint32_t num_packets); |
| 340 | |
| 341 | // This packet is for testing the speed of the interface only. Both |
| 342 | // the client and server need to support it, but this allows us to |
| 343 | // measure the packet speed without any other work being done on the |
| 344 | // other end and avoids any of that work affecting the packet send |
| 345 | // and response times. |
| 346 | bool |
| 347 | SendSpeedTestPacket (uint32_t send_size, |
| 348 | uint32_t recv_size); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 349 | |
| 350 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 351 | SetCurrentThread (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 352 | |
| 353 | bool |
Jason Molenda | e9ca4af | 2013-02-23 02:04:45 +0000 | [diff] [blame] | 354 | SetCurrentThreadForRun (uint64_t tid); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 355 | |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 356 | lldb_private::LazyBool |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 357 | SupportsAllocDeallocMemory () // const |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 358 | { |
Jim Ingham | 372787f | 2012-04-07 00:00:41 +0000 | [diff] [blame] | 359 | // Uncomment this to have lldb pretend the debug server doesn't respond to alloc/dealloc memory packets. |
| 360 | // m_supports_alloc_dealloc_memory = lldb_private::eLazyBoolNo; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 361 | return m_supports_alloc_dealloc_memory; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 362 | } |
| 363 | |
Greg Clayton | adc00cb | 2011-05-20 23:38:13 +0000 | [diff] [blame] | 364 | size_t |
| 365 | GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids, |
| 366 | bool &sequence_mutex_unavailable); |
| 367 | |
Greg Clayton | 2687cd1 | 2012-03-29 01:55:41 +0000 | [diff] [blame] | 368 | bool |
| 369 | GetInterruptWasSent () const |
| 370 | { |
| 371 | return m_interrupt_sent; |
| 372 | } |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 373 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 374 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 375 | OpenFile (const lldb_private::FileSpec& file_spec, |
| 376 | uint32_t flags, |
| 377 | mode_t mode, |
| 378 | lldb_private::Error &error); |
| 379 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 380 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 381 | CloseFile (lldb::user_id_t fd, |
| 382 | lldb_private::Error &error); |
| 383 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 384 | lldb::user_id_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 385 | GetFileSize (const lldb_private::FileSpec& file_spec); |
| 386 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 387 | lldb_private::Error |
| 388 | GetFilePermissions(const char *path, uint32_t &file_permissions); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 389 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 390 | lldb_private::Error |
| 391 | SetFilePermissions(const char *path, uint32_t file_permissions); |
| 392 | |
| 393 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 394 | ReadFile (lldb::user_id_t fd, |
| 395 | uint64_t offset, |
| 396 | void *dst, |
| 397 | uint64_t dst_len, |
| 398 | lldb_private::Error &error); |
| 399 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 400 | uint64_t |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 401 | WriteFile (lldb::user_id_t fd, |
| 402 | uint64_t offset, |
| 403 | const void* src, |
| 404 | uint64_t src_len, |
| 405 | lldb_private::Error &error); |
| 406 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 407 | lldb_private::Error |
| 408 | CreateSymlink (const char *src, |
| 409 | const char *dst); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 410 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 411 | lldb_private::Error |
| 412 | Unlink (const char *path); |
| 413 | |
| 414 | lldb_private::Error |
| 415 | MakeDirectory (const char *path, |
| 416 | uint32_t mode); |
| 417 | |
| 418 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 419 | GetFileExists (const lldb_private::FileSpec& file_spec); |
| 420 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 421 | lldb_private::Error |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 422 | RunShellCommand (const char *command, // Shouldn't be NULL |
| 423 | const char *working_dir, // Pass NULL to use the current working directory |
| 424 | int *status_ptr, // Pass NULL if you don't want the process exit status |
| 425 | int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit |
| 426 | std::string *command_output, // Pass NULL if you don't want the command output |
| 427 | uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish |
| 428 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame^] | 429 | bool |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 430 | CalculateMD5 (const lldb_private::FileSpec& file_spec, |
| 431 | uint64_t &high, |
| 432 | uint64_t &low); |
| 433 | |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 434 | std::string |
| 435 | HarmonizeThreadIdsForProfileData (ProcessGDBRemote *process, |
| 436 | StringExtractorGDBRemote &inputStringExtractor); |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 437 | |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 438 | bool |
| 439 | ReadRegister(lldb::tid_t tid, |
| 440 | uint32_t reg_num, |
| 441 | StringExtractorGDBRemote &response); |
| 442 | |
| 443 | bool |
| 444 | ReadAllRegisters (lldb::tid_t tid, |
| 445 | StringExtractorGDBRemote &response); |
| 446 | |
| 447 | bool |
| 448 | SaveRegisterState (lldb::tid_t tid, uint32_t &save_id); |
| 449 | |
| 450 | bool |
| 451 | RestoreRegisterState (lldb::tid_t tid, uint32_t save_id); |
| 452 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 453 | protected: |
| 454 | |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 455 | bool |
| 456 | GetCurrentProcessInfo (); |
| 457 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 458 | //------------------------------------------------------------------ |
| 459 | // Classes that inherit from GDBRemoteCommunicationClient can see and modify these |
| 460 | //------------------------------------------------------------------ |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 461 | lldb_private::LazyBool m_supports_not_sending_acks; |
| 462 | lldb_private::LazyBool m_supports_thread_suffix; |
Greg Clayton | 4463399 | 2012-04-10 03:22:03 +0000 | [diff] [blame] | 463 | lldb_private::LazyBool m_supports_threads_in_stop_reply; |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 464 | lldb_private::LazyBool m_supports_vCont_all; |
| 465 | lldb_private::LazyBool m_supports_vCont_any; |
| 466 | lldb_private::LazyBool m_supports_vCont_c; |
| 467 | lldb_private::LazyBool m_supports_vCont_C; |
| 468 | lldb_private::LazyBool m_supports_vCont_s; |
| 469 | lldb_private::LazyBool m_supports_vCont_S; |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 470 | lldb_private::LazyBool m_qHostInfo_is_valid; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 471 | lldb_private::LazyBool m_qProcessInfo_is_valid; |
Greg Clayton | 70b5765 | 2011-05-15 01:25:55 +0000 | [diff] [blame] | 472 | lldb_private::LazyBool m_supports_alloc_dealloc_memory; |
Greg Clayton | 46fb558 | 2011-11-18 07:03:08 +0000 | [diff] [blame] | 473 | lldb_private::LazyBool m_supports_memory_region_info; |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 474 | lldb_private::LazyBool m_supports_watchpoint_support_info; |
Jim Ingham | acff895 | 2013-05-02 00:27:30 +0000 | [diff] [blame] | 475 | lldb_private::LazyBool m_supports_detach_stay_stopped; |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 476 | lldb_private::LazyBool m_watchpoints_trigger_after_instruction; |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 477 | lldb_private::LazyBool m_attach_or_wait_reply; |
Jim Ingham | 279ceec | 2012-07-25 21:12:43 +0000 | [diff] [blame] | 478 | lldb_private::LazyBool m_prepare_for_reg_writing_reply; |
Hafiz Abid Qadeer | 9a78cdf | 2013-08-29 09:09:45 +0000 | [diff] [blame] | 479 | lldb_private::LazyBool m_supports_p; |
Greg Clayton | f74cf86 | 2013-11-13 23:28:31 +0000 | [diff] [blame] | 480 | lldb_private::LazyBool m_supports_QSaveRegisterState; |
Jim Ingham | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 481 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 482 | bool |
| 483 | m_supports_qProcessInfoPID:1, |
| 484 | m_supports_qfProcessInfo:1, |
| 485 | m_supports_qUserName:1, |
| 486 | m_supports_qGroupName:1, |
| 487 | m_supports_qThreadStopInfo:1, |
| 488 | m_supports_z0:1, |
| 489 | m_supports_z1:1, |
| 490 | m_supports_z2:1, |
| 491 | m_supports_z3:1, |
Greg Clayton | 8960058 | 2013-10-10 17:53:50 +0000 | [diff] [blame] | 492 | m_supports_z4:1, |
| 493 | m_supports_QEnvironment:1, |
| 494 | m_supports_QEnvironmentHexEncoded:1; |
Greg Clayton | 2a48f52 | 2011-05-14 01:50:35 +0000 | [diff] [blame] | 495 | |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 496 | |
| 497 | lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations |
| 498 | lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc |
| 499 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 500 | |
Johnny Chen | 6463720 | 2012-05-23 21:09:52 +0000 | [diff] [blame] | 501 | uint32_t m_num_supported_hardware_watchpoints; |
| 502 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 503 | // If we need to send a packet while the target is running, the m_async_XXX |
| 504 | // member variables take care of making this happen. |
| 505 | lldb_private::Mutex m_async_mutex; |
| 506 | lldb_private::Predicate<bool> m_async_packet_predicate; |
| 507 | std::string m_async_packet; |
| 508 | StringExtractorGDBRemote m_async_response; |
| 509 | 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] | 510 | bool m_interrupt_sent; |
Han Ming Ong | 4b6459f | 2013-01-18 23:11:53 +0000 | [diff] [blame] | 511 | std::string m_partial_profile_data; |
| 512 | 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] | 513 | |
Greg Clayton | d314e81 | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 514 | lldb_private::ArchSpec m_host_arch; |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 515 | lldb_private::ArchSpec m_process_arch; |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 516 | uint32_t m_os_version_major; |
| 517 | uint32_t m_os_version_minor; |
| 518 | uint32_t m_os_version_update; |
| 519 | std::string m_os_build; |
| 520 | std::string m_os_kernel; |
| 521 | std::string m_hostname; |
Greg Clayton | 9ac6d2d | 2013-10-25 18:13:17 +0000 | [diff] [blame] | 522 | uint32_t m_default_packet_timeout; |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 523 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 524 | bool |
| 525 | DecodeProcessInfoResponse (StringExtractorGDBRemote &response, |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 526 | lldb_private::ProcessInstanceInfo &process_info); |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 527 | private: |
| 528 | //------------------------------------------------------------------ |
| 529 | // For GDBRemoteCommunicationClient only |
| 530 | //------------------------------------------------------------------ |
| 531 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationClient); |
| 532 | }; |
| 533 | |
| 534 | #endif // liblldb_GDBRemoteCommunicationClient_h_ |