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