Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 1 | //===-- SWIG Interface for SBProcess ----------------------------*- 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 | namespace lldb { |
| 11 | |
| 12 | %feature("docstring", |
| 13 | "Represents the process associated with the target program. |
| 14 | |
| 15 | SBProcess supports thread iteration. For example (from test/lldbutil.py), |
| 16 | |
| 17 | # ================================================== |
| 18 | # Utility functions related to Threads and Processes |
| 19 | # ================================================== |
| 20 | |
| 21 | def get_stopped_threads(process, reason): |
| 22 | '''Returns the thread(s) with the specified stop reason in a list. |
| 23 | |
| 24 | The list can be empty if no such thread exists. |
| 25 | ''' |
| 26 | threads = [] |
| 27 | for t in process: |
| 28 | if t.GetStopReason() == reason: |
| 29 | threads.append(t) |
| 30 | return threads |
| 31 | |
| 32 | ... |
| 33 | " |
| 34 | ) SBProcess; |
| 35 | class SBProcess |
| 36 | { |
| 37 | public: |
| 38 | //------------------------------------------------------------------ |
| 39 | /// Broadcaster event bits definitions. |
| 40 | //------------------------------------------------------------------ |
| 41 | enum |
| 42 | { |
| 43 | eBroadcastBitStateChanged = (1 << 0), |
| 44 | eBroadcastBitInterrupt = (1 << 1), |
| 45 | eBroadcastBitSTDOUT = (1 << 2), |
Han Ming Ong | ab3b8b2 | 2012-11-17 00:21:04 +0000 | [diff] [blame] | 46 | eBroadcastBitSTDERR = (1 << 3), |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 47 | eBroadcastBitProfileData = (1 << 4), |
| 48 | eBroadcastBitStructuredData = (1 << 5) |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | SBProcess (); |
| 52 | |
| 53 | SBProcess (const lldb::SBProcess& rhs); |
| 54 | |
| 55 | ~SBProcess(); |
| 56 | |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 57 | static const char * |
| 58 | GetBroadcasterClassName (); |
| 59 | |
Jim Ingham | d7b30ef | 2012-10-26 19:18:04 +0000 | [diff] [blame] | 60 | const char * |
| 61 | GetPluginName (); |
| 62 | |
| 63 | const char * |
| 64 | GetShortPluginName (); |
| 65 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 66 | void |
| 67 | Clear (); |
| 68 | |
| 69 | bool |
| 70 | IsValid() const; |
| 71 | |
| 72 | lldb::SBTarget |
| 73 | GetTarget() const; |
| 74 | |
| 75 | lldb::ByteOrder |
| 76 | GetByteOrder() const; |
| 77 | |
Johnny Chen | 49cb85d | 2011-11-28 21:39:07 +0000 | [diff] [blame] | 78 | %feature("autodoc", " |
| 79 | Writes data into the current process's stdin. API client specifies a Python |
| 80 | string as the only argument. |
| 81 | ") PutSTDIN; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 82 | size_t |
| 83 | PutSTDIN (const char *src, size_t src_len); |
| 84 | |
Johnny Chen | d80e5e9 | 2011-11-28 19:12:25 +0000 | [diff] [blame] | 85 | %feature("autodoc", " |
| 86 | Reads data from the current process's stdout stream. API client specifies |
| 87 | the size of the buffer to read data into. It returns the byte buffer in a |
| 88 | Python string. |
| 89 | ") GetSTDOUT; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 90 | size_t |
| 91 | GetSTDOUT (char *dst, size_t dst_len) const; |
| 92 | |
Johnny Chen | d80e5e9 | 2011-11-28 19:12:25 +0000 | [diff] [blame] | 93 | %feature("autodoc", " |
| 94 | Reads data from the current process's stderr stream. API client specifies |
| 95 | the size of the buffer to read data into. It returns the byte buffer in a |
| 96 | Python string. |
| 97 | ") GetSTDERR; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 98 | size_t |
| 99 | GetSTDERR (char *dst, size_t dst_len) const; |
| 100 | |
Han Ming Ong | ab3b8b2 | 2012-11-17 00:21:04 +0000 | [diff] [blame] | 101 | size_t |
| 102 | GetAsyncProfileData(char *dst, size_t dst_len) const; |
| 103 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 104 | void |
| 105 | ReportEventState (const lldb::SBEvent &event, FILE *out) const; |
| 106 | |
| 107 | void |
| 108 | AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); |
| 109 | |
| 110 | %feature("docstring", " |
| 111 | //------------------------------------------------------------------ |
| 112 | /// Remote connection related functions. These will fail if the |
| 113 | /// process is not in eStateConnected. They are intended for use |
| 114 | /// when connecting to an externally managed debugserver instance. |
| 115 | //------------------------------------------------------------------ |
| 116 | ") RemoteAttachToProcessWithID; |
| 117 | bool |
| 118 | RemoteAttachToProcessWithID (lldb::pid_t pid, |
| 119 | lldb::SBError& error); |
| 120 | |
| 121 | %feature("docstring", |
| 122 | "See SBTarget.Launch for argument description and usage." |
| 123 | ) RemoteLaunch; |
| 124 | bool |
| 125 | RemoteLaunch (char const **argv, |
| 126 | char const **envp, |
| 127 | const char *stdin_path, |
| 128 | const char *stdout_path, |
| 129 | const char *stderr_path, |
| 130 | const char *working_directory, |
| 131 | uint32_t launch_flags, |
| 132 | bool stop_at_entry, |
| 133 | lldb::SBError& error); |
| 134 | |
| 135 | //------------------------------------------------------------------ |
| 136 | // Thread related functions |
| 137 | //------------------------------------------------------------------ |
| 138 | uint32_t |
| 139 | GetNumThreads (); |
| 140 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 141 | %feature("autodoc", " |
| 142 | Returns the INDEX'th thread from the list of current threads. The index |
| 143 | of a thread is only valid for the current stop. For a persistent thread |
| 144 | identifier use either the thread ID or the IndexID. See help on SBThread |
| 145 | for more details. |
| 146 | ") GetThreadAtIndex; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 147 | lldb::SBThread |
| 148 | GetThreadAtIndex (size_t index); |
| 149 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 150 | %feature("autodoc", " |
| 151 | Returns the thread with the given thread ID. |
| 152 | ") GetThreadByID; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 153 | lldb::SBThread |
| 154 | GetThreadByID (lldb::tid_t sb_thread_id); |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 155 | |
| 156 | %feature("autodoc", " |
| 157 | Returns the thread with the given thread IndexID. |
| 158 | ") GetThreadByIndexID; |
| 159 | lldb::SBThread |
| 160 | GetThreadByIndexID (uint32_t index_id); |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 161 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 162 | %feature("autodoc", " |
| 163 | Returns the currently selected thread. |
| 164 | ") GetSelectedThread; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 165 | lldb::SBThread |
| 166 | GetSelectedThread () const; |
| 167 | |
Greg Clayton | a4d8747 | 2013-01-18 23:41:08 +0000 | [diff] [blame] | 168 | %feature("autodoc", " |
| 169 | Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it. |
| 170 | ") CreateOSPluginThread; |
| 171 | lldb::SBThread |
| 172 | CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); |
| 173 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 174 | bool |
| 175 | SetSelectedThread (const lldb::SBThread &thread); |
| 176 | |
| 177 | bool |
Greg Clayton | ea561dc | 2012-10-12 23:32:11 +0000 | [diff] [blame] | 178 | SetSelectedThreadByID (lldb::tid_t tid); |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 179 | |
Jim Ingham | 18b4689 | 2012-07-13 20:18:18 +0000 | [diff] [blame] | 180 | bool |
| 181 | SetSelectedThreadByIndexID (uint32_t index_id); |
| 182 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 183 | //------------------------------------------------------------------ |
Jason Molenda | 5e8dce4 | 2013-12-13 00:29:16 +0000 | [diff] [blame] | 184 | // Queue related functions |
| 185 | //------------------------------------------------------------------ |
| 186 | uint32_t |
| 187 | GetNumQueues (); |
| 188 | |
| 189 | lldb::SBQueue |
| 190 | GetQueueAtIndex (uint32_t index); |
| 191 | |
| 192 | //------------------------------------------------------------------ |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 193 | // Stepping related functions |
| 194 | //------------------------------------------------------------------ |
| 195 | |
| 196 | lldb::StateType |
| 197 | GetState (); |
| 198 | |
| 199 | int |
| 200 | GetExitStatus (); |
| 201 | |
| 202 | const char * |
| 203 | GetExitDescription (); |
| 204 | |
Greg Clayton | 949e822 | 2013-01-16 17:29:04 +0000 | [diff] [blame] | 205 | %feature("autodoc", " |
| 206 | Returns the process ID of the process. |
| 207 | ") GetProcessID; |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 208 | lldb::pid_t |
| 209 | GetProcessID (); |
Greg Clayton | 949e822 | 2013-01-16 17:29:04 +0000 | [diff] [blame] | 210 | |
| 211 | %feature("autodoc", " |
| 212 | Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes. |
| 213 | ") GetUniqueID; |
| 214 | uint32_t |
| 215 | GetUniqueID(); |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 216 | |
| 217 | uint32_t |
| 218 | GetAddressByteSize() const; |
| 219 | |
| 220 | %feature("docstring", " |
| 221 | Kills the process and shuts down all threads that were spawned to |
| 222 | track and monitor process. |
| 223 | ") Destroy; |
| 224 | lldb::SBError |
| 225 | Destroy (); |
| 226 | |
| 227 | lldb::SBError |
| 228 | Continue (); |
| 229 | |
| 230 | lldb::SBError |
| 231 | Stop (); |
| 232 | |
| 233 | %feature("docstring", "Same as Destroy(self).") Destroy; |
| 234 | lldb::SBError |
| 235 | Kill (); |
| 236 | |
| 237 | lldb::SBError |
| 238 | Detach (); |
| 239 | |
| 240 | %feature("docstring", "Sends the process a unix signal.") Signal; |
| 241 | lldb::SBError |
| 242 | Signal (int signal); |
| 243 | |
Todd Fiala | 802dc402 | 2014-06-23 19:30:49 +0000 | [diff] [blame] | 244 | lldb::SBUnixSignals |
| 245 | GetUnixSignals(); |
| 246 | |
Jim Ingham | bf2956a2 | 2013-01-08 23:22:42 +0000 | [diff] [blame] | 247 | %feature("docstring", " |
| 248 | Returns a stop id that will increase every time the process executes. If |
| 249 | include_expression_stops is true, then stops caused by expression evaluation |
| 250 | will cause the returned value to increase, otherwise the counter returned will |
| 251 | only increase when execution is continued explicitly by the user. Note, the value |
| 252 | will always increase, but may increase by more than one per stop. |
| 253 | ") GetStopID; |
| 254 | uint32_t |
| 255 | GetStopID(bool include_expression_stops = false); |
| 256 | |
Jim Ingham | cfc0935 | 2012-07-27 23:57:19 +0000 | [diff] [blame] | 257 | void |
| 258 | SendAsyncInterrupt(); |
| 259 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 260 | %feature("autodoc", " |
| 261 | Reads memory from the current process's address space and removes any |
| 262 | traps that may have been inserted into the memory. It returns the byte |
| 263 | buffer in a Python string. Example: |
| 264 | |
| 265 | # Read 4 bytes from address 'addr' and assume error.Success() is True. |
| 266 | content = process.ReadMemory(addr, 4, error) |
Jason Molenda | c7e828e | 2013-08-24 00:16:19 +0000 | [diff] [blame] | 267 | new_bytes = bytearray(content) |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 268 | ") ReadMemory; |
| 269 | size_t |
| 270 | ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); |
| 271 | |
| 272 | %feature("autodoc", " |
| 273 | Writes memory to the current process's address space and maintains any |
| 274 | traps that might be present due to software breakpoints. Example: |
| 275 | |
| 276 | # Create a Python string from the byte array. |
| 277 | new_value = str(bytes) |
| 278 | result = process.WriteMemory(addr, new_value, error) |
| 279 | if not error.Success() or result != len(bytes): |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 280 | print('SBProcess.WriteMemory() failed!') |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 281 | ") WriteMemory; |
| 282 | size_t |
| 283 | WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); |
| 284 | |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 285 | %feature("autodoc", " |
| 286 | Reads a NULL terminated C string from the current process's address space. |
| 287 | It returns a python string of the exact length, or truncates the string if |
| 288 | the maximum character limit is reached. Example: |
| 289 | |
| 290 | # Read a C string of at most 256 bytes from address '0x1000' |
| 291 | error = lldb.SBError() |
Johnny Chen | 80e3e84 | 2011-12-15 22:34:59 +0000 | [diff] [blame] | 292 | cstring = process.ReadCStringFromMemory(0x1000, 256, error) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 293 | if error.Success(): |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 294 | print('cstring: ', cstring) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 295 | else |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 296 | print('error: ', error) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 297 | ") ReadCStringFromMemory; |
| 298 | |
| 299 | size_t |
Zachary Turner | 4407396 | 2016-01-25 23:21:18 +0000 | [diff] [blame] | 300 | ReadCStringFromMemory (addr_t addr, void *char_buf, size_t size, lldb::SBError &error); |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 301 | |
| 302 | %feature("autodoc", " |
| 303 | Reads an unsigned integer from memory given a byte size and an address. |
| 304 | Returns the unsigned integer that was read. Example: |
| 305 | |
| 306 | # Read a 4 byte unsigned integer from address 0x1000 |
| 307 | error = lldb.SBError() |
| 308 | uint = ReadUnsignedFromMemory(0x1000, 4, error) |
| 309 | if error.Success(): |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 310 | print('integer: %u' % uint) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 311 | else |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 312 | print('error: ', error) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 313 | |
| 314 | ") ReadUnsignedFromMemory; |
| 315 | |
| 316 | uint64_t |
| 317 | ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); |
| 318 | |
| 319 | %feature("autodoc", " |
| 320 | Reads a pointer from memory from an address and returns the value. Example: |
| 321 | |
| 322 | # Read a pointer from address 0x1000 |
| 323 | error = lldb.SBError() |
| 324 | ptr = ReadPointerFromMemory(0x1000, error) |
| 325 | if error.Success(): |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 326 | print('pointer: 0x%x' % ptr) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 327 | else |
Zachary Turner | 5f3fd80 | 2015-10-16 17:52:32 +0000 | [diff] [blame] | 328 | print('error: ', error) |
Greg Clayton | e91b795 | 2011-12-15 03:14:23 +0000 | [diff] [blame] | 329 | |
| 330 | ") ReadPointerFromMemory; |
| 331 | |
| 332 | lldb::addr_t |
| 333 | ReadPointerFromMemory (addr_t addr, lldb::SBError &error); |
| 334 | |
| 335 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 336 | // Events |
| 337 | static lldb::StateType |
| 338 | GetStateFromEvent (const lldb::SBEvent &event); |
| 339 | |
| 340 | static bool |
| 341 | GetRestartedFromEvent (const lldb::SBEvent &event); |
| 342 | |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 343 | static size_t |
| 344 | GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event); |
| 345 | |
| 346 | static const char * |
| 347 | GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx); |
| 348 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 349 | static lldb::SBProcess |
| 350 | GetProcessFromEvent (const lldb::SBEvent &event); |
| 351 | |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 352 | static bool |
Ilia K | 06d2855 | 2015-05-15 09:29:09 +0000 | [diff] [blame] | 353 | GetInterruptedFromEvent (const lldb::SBEvent &event); |
| 354 | |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 355 | static lldb::SBStructuredData |
| 356 | GetStructuredDataFromEvent (const lldb::SBEvent &event); |
| 357 | |
Ilia K | 06d2855 | 2015-05-15 09:29:09 +0000 | [diff] [blame] | 358 | static bool |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 359 | EventIsProcessEvent (const lldb::SBEvent &event); |
| 360 | |
Todd Fiala | 7593001 | 2016-08-19 04:21:48 +0000 | [diff] [blame] | 361 | static bool |
| 362 | EventIsStructuredDataEvent (const lldb::SBEvent &event); |
| 363 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 364 | lldb::SBBroadcaster |
| 365 | GetBroadcaster () const; |
| 366 | |
| 367 | bool |
| 368 | GetDescription (lldb::SBStream &description); |
| 369 | |
| 370 | uint32_t |
Johnny Chen | f9ef60d | 2012-05-23 22:34:34 +0000 | [diff] [blame] | 371 | GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; |
| 372 | |
| 373 | uint32_t |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 374 | LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); |
| 375 | |
| 376 | lldb::SBError |
| 377 | UnloadImage (uint32_t image_token); |
Jason Molenda | a332978 | 2014-03-29 18:54:20 +0000 | [diff] [blame] | 378 | |
| 379 | lldb::SBError |
| 380 | SendEventData (const char *event_data); |
Johnny Chen | 39c6d0f | 2012-01-06 00:46:12 +0000 | [diff] [blame] | 381 | |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 382 | %feature("autodoc", " |
| 383 | Return the number of different thread-origin extended backtraces |
| 384 | this process can support as a uint32_t. |
| 385 | When the process is stopped and you have an SBThread, lldb may be |
| 386 | able to show a backtrace of when that thread was originally created, |
| 387 | or the work item was enqueued to it (in the case of a libdispatch |
| 388 | queue). |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 389 | ") GetNumExtendedBacktraceTypes; |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 390 | |
| 391 | uint32_t |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 392 | GetNumExtendedBacktraceTypes (); |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 393 | |
| 394 | %feature("autodoc", " |
| 395 | Takes an index argument, returns the name of one of the thread-origin |
| 396 | extended backtrace methods as a str. |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 397 | ") GetExtendedBacktraceTypeAtIndex; |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 398 | |
| 399 | const char * |
Jason Molenda | 95d005c | 2013-11-06 03:07:33 +0000 | [diff] [blame] | 400 | GetExtendedBacktraceTypeAtIndex (uint32_t idx); |
Jason Molenda | 8c71337 | 2013-11-05 11:00:35 +0000 | [diff] [blame] | 401 | |
Kuba Brecka | a51ea38 | 2014-09-06 01:33:13 +0000 | [diff] [blame] | 402 | lldb::SBThreadCollection |
| 403 | GetHistoryThreads (addr_t addr); |
Kuba Brecka | 6392754 | 2014-10-11 01:59:32 +0000 | [diff] [blame] | 404 | |
| 405 | bool |
| 406 | IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); |
Kuba Brecka | a51ea38 | 2014-09-06 01:33:13 +0000 | [diff] [blame] | 407 | |
Adrian McCarthy | f7d1893 | 2015-11-20 23:09:11 +0000 | [diff] [blame] | 408 | lldb::SBError |
| 409 | SaveCore(const char *file_name); |
| 410 | |
Greg Clayton | 4d32eb6 | 2016-06-24 23:40:35 +0000 | [diff] [blame] | 411 | lldb::SBError |
| 412 | GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info); |
| 413 | |
| 414 | lldb::SBMemoryRegionInfoList |
| 415 | GetMemoryRegions(); |
| 416 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 417 | %pythoncode %{ |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 418 | def __get_is_alive__(self): |
| 419 | '''Returns "True" if the process is currently alive, "False" otherwise''' |
| 420 | s = self.GetState() |
| 421 | if (s == eStateAttaching or |
| 422 | s == eStateLaunching or |
| 423 | s == eStateStopped or |
| 424 | s == eStateRunning or |
| 425 | s == eStateStepping or |
| 426 | s == eStateCrashed or |
| 427 | s == eStateSuspended): |
| 428 | return True |
| 429 | return False |
| 430 | |
| 431 | def __get_is_running__(self): |
| 432 | '''Returns "True" if the process is currently running, "False" otherwise''' |
| 433 | state = self.GetState() |
| 434 | if state == eStateRunning or state == eStateStepping: |
| 435 | return True |
| 436 | return False |
| 437 | |
Greg Clayton | d458c4d | 2016-07-05 18:19:43 +0000 | [diff] [blame] | 438 | def __get_is_stopped__(self): |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 439 | '''Returns "True" if the process is currently stopped, "False" otherwise''' |
| 440 | state = self.GetState() |
| 441 | if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: |
| 442 | return True |
| 443 | return False |
| 444 | |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 445 | class threads_access(object): |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 446 | '''A helper object that will lazily hand out thread for a process when supplied an index.''' |
| 447 | def __init__(self, sbprocess): |
| 448 | self.sbprocess = sbprocess |
| 449 | |
| 450 | def __len__(self): |
Filipe Cabecinhas | 1a96ef8 | 2012-05-11 20:39:42 +0000 | [diff] [blame] | 451 | if self.sbprocess: |
| 452 | return int(self.sbprocess.GetNumThreads()) |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 453 | return 0 |
| 454 | |
| 455 | def __getitem__(self, key): |
| 456 | if type(key) is int and key < len(self): |
| 457 | return self.sbprocess.GetThreadAtIndex(key) |
| 458 | return None |
| 459 | |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 460 | def get_threads_access_object(self): |
| 461 | '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.''' |
| 462 | return self.threads_access (self) |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 463 | |
| 464 | def get_process_thread_list(self): |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 465 | '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.''' |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 466 | threads = [] |
Enrico Granata | beea93c | 2012-10-08 19:06:11 +0000 | [diff] [blame] | 467 | accessor = self.get_threads_access_object() |
| 468 | for idx in range(len(accessor)): |
| 469 | threads.append(accessor[idx]) |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 470 | return threads |
| 471 | |
| 472 | __swig_getmethods__["threads"] = get_process_thread_list |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 473 | if _newclass: threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 474 | |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 475 | __swig_getmethods__["thread"] = get_threads_access_object |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 476 | if _newclass: thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 477 | |
| 478 | __swig_getmethods__["is_alive"] = __get_is_alive__ |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 479 | if _newclass: is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 480 | |
| 481 | __swig_getmethods__["is_running"] = __get_is_running__ |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 482 | if _newclass: is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 483 | |
Greg Clayton | d458c4d | 2016-07-05 18:19:43 +0000 | [diff] [blame] | 484 | __swig_getmethods__["is_stopped"] = __get_is_stopped__ |
| 485 | if _newclass: is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 486 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 487 | __swig_getmethods__["id"] = GetProcessID |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 488 | if _newclass: id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 489 | |
| 490 | __swig_getmethods__["target"] = GetTarget |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 491 | if _newclass: target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 492 | |
| 493 | __swig_getmethods__["num_threads"] = GetNumThreads |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 494 | if _newclass: num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 495 | |
| 496 | __swig_getmethods__["selected_thread"] = GetSelectedThread |
| 497 | __swig_setmethods__["selected_thread"] = SetSelectedThread |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 498 | if _newclass: selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 499 | |
| 500 | __swig_getmethods__["state"] = GetState |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 501 | if _newclass: state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 502 | |
| 503 | __swig_getmethods__["exit_state"] = GetExitStatus |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 504 | if _newclass: exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 505 | |
| 506 | __swig_getmethods__["exit_description"] = GetExitDescription |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 507 | if _newclass: exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 508 | |
| 509 | __swig_getmethods__["broadcaster"] = GetBroadcaster |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 510 | if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 511 | %} |
| 512 | |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | } // namespace lldb |