1061da546Spatrick //===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===// 2061da546Spatrick // 3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6061da546Spatrick // 7061da546Spatrick //===----------------------------------------------------------------------===// 8061da546Spatrick 9061da546Spatrick namespace lldb { 10061da546Spatrick 11061da546Spatrick %feature("docstring", 12061da546Spatrick "Represents the process associated with the target program. 13061da546Spatrick 14be691f3bSpatrick SBProcess supports thread iteration. For example (from test/lldbutil.py), :: 15061da546Spatrick 16061da546Spatrick # ================================================== 17061da546Spatrick # Utility functions related to Threads and Processes 18061da546Spatrick # ================================================== 19061da546Spatrick 20061da546Spatrick def get_stopped_threads(process, reason): 21061da546Spatrick '''Returns the thread(s) with the specified stop reason in a list. 22061da546Spatrick 23061da546Spatrick The list can be empty if no such thread exists. 24061da546Spatrick ''' 25061da546Spatrick threads = [] 26061da546Spatrick for t in process: 27061da546Spatrick if t.GetStopReason() == reason: 28061da546Spatrick threads.append(t) 29061da546Spatrick return threads 30061da546Spatrick " 31061da546Spatrick ) SBProcess; 32061da546Spatrick class SBProcess 33061da546Spatrick { 34061da546Spatrick public: 35061da546Spatrick enum 36061da546Spatrick { 37061da546Spatrick eBroadcastBitStateChanged = (1 << 0), 38061da546Spatrick eBroadcastBitInterrupt = (1 << 1), 39061da546Spatrick eBroadcastBitSTDOUT = (1 << 2), 40061da546Spatrick eBroadcastBitSTDERR = (1 << 3), 41061da546Spatrick eBroadcastBitProfileData = (1 << 4), 42061da546Spatrick eBroadcastBitStructuredData = (1 << 5) 43061da546Spatrick }; 44061da546Spatrick 45061da546Spatrick SBProcess (); 46061da546Spatrick 47061da546Spatrick SBProcess (const lldb::SBProcess& rhs); 48061da546Spatrick 49061da546Spatrick ~SBProcess(); 50061da546Spatrick 51061da546Spatrick static const char * 52061da546Spatrick GetBroadcasterClassName (); 53061da546Spatrick 54061da546Spatrick const char * 55061da546Spatrick GetPluginName (); 56061da546Spatrick 57061da546Spatrick const char * 58061da546Spatrick GetShortPluginName (); 59061da546Spatrick 60061da546Spatrick void 61061da546Spatrick Clear (); 62061da546Spatrick 63061da546Spatrick bool 64061da546Spatrick IsValid() const; 65061da546Spatrick 66061da546Spatrick explicit operator bool() const; 67061da546Spatrick 68061da546Spatrick lldb::SBTarget 69061da546Spatrick GetTarget() const; 70061da546Spatrick 71061da546Spatrick lldb::ByteOrder 72061da546Spatrick GetByteOrder() const; 73061da546Spatrick 74061da546Spatrick %feature("autodoc", " 75061da546Spatrick Writes data into the current process's stdin. API client specifies a Python 76061da546Spatrick string as the only argument.") PutSTDIN; 77061da546Spatrick size_t 78061da546Spatrick PutSTDIN (const char *src, size_t src_len); 79061da546Spatrick 80061da546Spatrick %feature("autodoc", " 81061da546Spatrick Reads data from the current process's stdout stream. API client specifies 82061da546Spatrick the size of the buffer to read data into. It returns the byte buffer in a 83061da546Spatrick Python string.") GetSTDOUT; 84061da546Spatrick size_t 85061da546Spatrick GetSTDOUT (char *dst, size_t dst_len) const; 86061da546Spatrick 87061da546Spatrick %feature("autodoc", " 88061da546Spatrick Reads data from the current process's stderr stream. API client specifies 89061da546Spatrick the size of the buffer to read data into. It returns the byte buffer in a 90061da546Spatrick Python string.") GetSTDERR; 91061da546Spatrick size_t 92061da546Spatrick GetSTDERR (char *dst, size_t dst_len) const; 93061da546Spatrick 94061da546Spatrick size_t 95061da546Spatrick GetAsyncProfileData(char *dst, size_t dst_len) const; 96061da546Spatrick 97061da546Spatrick void 98061da546Spatrick ReportEventState (const lldb::SBEvent &event, SBFile out) const; 99061da546Spatrick 100061da546Spatrick void 101061da546Spatrick ReportEventState (const lldb::SBEvent &event, FileSP BORROWED) const; 102061da546Spatrick 103061da546Spatrick void 104061da546Spatrick AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); 105061da546Spatrick 106061da546Spatrick %feature("docstring", " 107061da546Spatrick Remote connection related functions. These will fail if the 108061da546Spatrick process is not in eStateConnected. They are intended for use 109061da546Spatrick when connecting to an externally managed debugserver instance.") RemoteAttachToProcessWithID; 110061da546Spatrick bool 111061da546Spatrick RemoteAttachToProcessWithID (lldb::pid_t pid, 112061da546Spatrick lldb::SBError& error); 113061da546Spatrick 114061da546Spatrick %feature("docstring", 115061da546Spatrick "See SBTarget.Launch for argument description and usage." 116061da546Spatrick ) RemoteLaunch; 117061da546Spatrick bool 118061da546Spatrick RemoteLaunch (char const **argv, 119061da546Spatrick char const **envp, 120061da546Spatrick const char *stdin_path, 121061da546Spatrick const char *stdout_path, 122061da546Spatrick const char *stderr_path, 123061da546Spatrick const char *working_directory, 124061da546Spatrick uint32_t launch_flags, 125061da546Spatrick bool stop_at_entry, 126061da546Spatrick lldb::SBError& error); 127061da546Spatrick 128061da546Spatrick //------------------------------------------------------------------ 129061da546Spatrick // Thread related functions 130061da546Spatrick //------------------------------------------------------------------ 131061da546Spatrick uint32_t 132061da546Spatrick GetNumThreads (); 133061da546Spatrick 134061da546Spatrick %feature("autodoc", " 135061da546Spatrick Returns the INDEX'th thread from the list of current threads. The index 136061da546Spatrick of a thread is only valid for the current stop. For a persistent thread 137061da546Spatrick identifier use either the thread ID or the IndexID. See help on SBThread 138061da546Spatrick for more details.") GetThreadAtIndex; 139061da546Spatrick lldb::SBThread 140061da546Spatrick GetThreadAtIndex (size_t index); 141061da546Spatrick 142061da546Spatrick %feature("autodoc", " 143061da546Spatrick Returns the thread with the given thread ID.") GetThreadByID; 144061da546Spatrick lldb::SBThread 145061da546Spatrick GetThreadByID (lldb::tid_t sb_thread_id); 146061da546Spatrick 147061da546Spatrick %feature("autodoc", " 148061da546Spatrick Returns the thread with the given thread IndexID.") GetThreadByIndexID; 149061da546Spatrick lldb::SBThread 150061da546Spatrick GetThreadByIndexID (uint32_t index_id); 151061da546Spatrick 152061da546Spatrick %feature("autodoc", " 153061da546Spatrick Returns the currently selected thread.") GetSelectedThread; 154061da546Spatrick lldb::SBThread 155061da546Spatrick GetSelectedThread () const; 156061da546Spatrick 157061da546Spatrick %feature("autodoc", " 158061da546Spatrick Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it.") CreateOSPluginThread; 159061da546Spatrick lldb::SBThread 160061da546Spatrick CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); 161061da546Spatrick 162061da546Spatrick bool 163061da546Spatrick SetSelectedThread (const lldb::SBThread &thread); 164061da546Spatrick 165061da546Spatrick bool 166061da546Spatrick SetSelectedThreadByID (lldb::tid_t tid); 167061da546Spatrick 168061da546Spatrick bool 169061da546Spatrick SetSelectedThreadByIndexID (uint32_t index_id); 170061da546Spatrick 171061da546Spatrick //------------------------------------------------------------------ 172061da546Spatrick // Queue related functions 173061da546Spatrick //------------------------------------------------------------------ 174061da546Spatrick uint32_t 175061da546Spatrick GetNumQueues (); 176061da546Spatrick 177061da546Spatrick lldb::SBQueue 178061da546Spatrick GetQueueAtIndex (uint32_t index); 179061da546Spatrick 180061da546Spatrick //------------------------------------------------------------------ 181061da546Spatrick // Stepping related functions 182061da546Spatrick //------------------------------------------------------------------ 183061da546Spatrick 184061da546Spatrick lldb::StateType 185061da546Spatrick GetState (); 186061da546Spatrick 187061da546Spatrick int 188061da546Spatrick GetExitStatus (); 189061da546Spatrick 190061da546Spatrick const char * 191061da546Spatrick GetExitDescription (); 192061da546Spatrick 193061da546Spatrick %feature("autodoc", " 194061da546Spatrick Returns the process ID of the process.") GetProcessID; 195061da546Spatrick lldb::pid_t 196061da546Spatrick GetProcessID (); 197061da546Spatrick 198061da546Spatrick %feature("autodoc", " 199061da546Spatrick 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.") GetUniqueID; 200061da546Spatrick uint32_t 201061da546Spatrick GetUniqueID(); 202061da546Spatrick 203061da546Spatrick uint32_t 204061da546Spatrick GetAddressByteSize() const; 205061da546Spatrick 206061da546Spatrick %feature("docstring", " 207061da546Spatrick Kills the process and shuts down all threads that were spawned to 208061da546Spatrick track and monitor process.") Destroy; 209061da546Spatrick lldb::SBError 210061da546Spatrick Destroy (); 211061da546Spatrick 212061da546Spatrick lldb::SBError 213061da546Spatrick Continue (); 214061da546Spatrick 215061da546Spatrick lldb::SBError 216061da546Spatrick Stop (); 217061da546Spatrick 218061da546Spatrick %feature("docstring", "Same as Destroy(self).") Destroy; 219061da546Spatrick lldb::SBError 220061da546Spatrick Kill (); 221061da546Spatrick 222061da546Spatrick lldb::SBError 223061da546Spatrick Detach (); 224061da546Spatrick 225061da546Spatrick %feature("docstring", "Sends the process a unix signal.") Signal; 226061da546Spatrick lldb::SBError 227061da546Spatrick Signal (int signal); 228061da546Spatrick 229061da546Spatrick lldb::SBUnixSignals 230061da546Spatrick GetUnixSignals(); 231061da546Spatrick 232061da546Spatrick %feature("docstring", " 233061da546Spatrick Returns a stop id that will increase every time the process executes. If 234061da546Spatrick include_expression_stops is true, then stops caused by expression evaluation 235061da546Spatrick will cause the returned value to increase, otherwise the counter returned will 236061da546Spatrick only increase when execution is continued explicitly by the user. Note, the value 237061da546Spatrick will always increase, but may increase by more than one per stop.") GetStopID; 238061da546Spatrick uint32_t 239061da546Spatrick GetStopID(bool include_expression_stops = false); 240061da546Spatrick 241061da546Spatrick void 242061da546Spatrick SendAsyncInterrupt(); 243061da546Spatrick 244061da546Spatrick %feature("autodoc", " 245061da546Spatrick Reads memory from the current process's address space and removes any 246061da546Spatrick traps that may have been inserted into the memory. It returns the byte 247be691f3bSpatrick buffer in a Python string. Example: :: 248061da546Spatrick 249061da546Spatrick # Read 4 bytes from address 'addr' and assume error.Success() is True. 250061da546Spatrick content = process.ReadMemory(addr, 4, error) 251061da546Spatrick new_bytes = bytearray(content)") ReadMemory; 252061da546Spatrick size_t 253061da546Spatrick ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); 254061da546Spatrick 255061da546Spatrick %feature("autodoc", " 256061da546Spatrick Writes memory to the current process's address space and maintains any 257be691f3bSpatrick traps that might be present due to software breakpoints. Example: :: 258061da546Spatrick 259061da546Spatrick # Create a Python string from the byte array. 260061da546Spatrick new_value = str(bytes) 261061da546Spatrick result = process.WriteMemory(addr, new_value, error) 262061da546Spatrick if not error.Success() or result != len(bytes): 263061da546Spatrick print('SBProcess.WriteMemory() failed!')") WriteMemory; 264061da546Spatrick size_t 265061da546Spatrick WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); 266061da546Spatrick 267061da546Spatrick %feature("autodoc", " 268061da546Spatrick Reads a NULL terminated C string from the current process's address space. 269061da546Spatrick It returns a python string of the exact length, or truncates the string if 270be691f3bSpatrick the maximum character limit is reached. Example: :: 271061da546Spatrick 272061da546Spatrick # Read a C string of at most 256 bytes from address '0x1000' 273061da546Spatrick error = lldb.SBError() 274061da546Spatrick cstring = process.ReadCStringFromMemory(0x1000, 256, error) 275061da546Spatrick if error.Success(): 276061da546Spatrick print('cstring: ', cstring) 277061da546Spatrick else 278061da546Spatrick print('error: ', error)") ReadCStringFromMemory; 279061da546Spatrick 280061da546Spatrick size_t 281061da546Spatrick ReadCStringFromMemory (addr_t addr, void *char_buf, size_t size, lldb::SBError &error); 282061da546Spatrick 283061da546Spatrick %feature("autodoc", " 284061da546Spatrick Reads an unsigned integer from memory given a byte size and an address. 285be691f3bSpatrick Returns the unsigned integer that was read. Example: :: 286061da546Spatrick 287061da546Spatrick # Read a 4 byte unsigned integer from address 0x1000 288061da546Spatrick error = lldb.SBError() 289061da546Spatrick uint = ReadUnsignedFromMemory(0x1000, 4, error) 290061da546Spatrick if error.Success(): 291061da546Spatrick print('integer: %u' % uint) 292061da546Spatrick else 293061da546Spatrick print('error: ', error)") ReadUnsignedFromMemory; 294061da546Spatrick 295061da546Spatrick uint64_t 296061da546Spatrick ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); 297061da546Spatrick 298061da546Spatrick %feature("autodoc", " 299be691f3bSpatrick Reads a pointer from memory from an address and returns the value. Example: :: 300061da546Spatrick 301061da546Spatrick # Read a pointer from address 0x1000 302061da546Spatrick error = lldb.SBError() 303061da546Spatrick ptr = ReadPointerFromMemory(0x1000, error) 304061da546Spatrick if error.Success(): 305061da546Spatrick print('pointer: 0x%x' % ptr) 306061da546Spatrick else 307061da546Spatrick print('error: ', error)") ReadPointerFromMemory; 308061da546Spatrick 309061da546Spatrick lldb::addr_t 310061da546Spatrick ReadPointerFromMemory (addr_t addr, lldb::SBError &error); 311061da546Spatrick 312061da546Spatrick 313061da546Spatrick // Events 314061da546Spatrick static lldb::StateType 315061da546Spatrick GetStateFromEvent (const lldb::SBEvent &event); 316061da546Spatrick 317061da546Spatrick static bool 318061da546Spatrick GetRestartedFromEvent (const lldb::SBEvent &event); 319061da546Spatrick 320061da546Spatrick static size_t 321061da546Spatrick GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event); 322061da546Spatrick 323061da546Spatrick static const char * 324061da546Spatrick GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx); 325061da546Spatrick 326061da546Spatrick static lldb::SBProcess 327061da546Spatrick GetProcessFromEvent (const lldb::SBEvent &event); 328061da546Spatrick 329061da546Spatrick static bool 330061da546Spatrick GetInterruptedFromEvent (const lldb::SBEvent &event); 331061da546Spatrick 332061da546Spatrick static lldb::SBStructuredData 333061da546Spatrick GetStructuredDataFromEvent (const lldb::SBEvent &event); 334061da546Spatrick 335061da546Spatrick static bool 336061da546Spatrick EventIsProcessEvent (const lldb::SBEvent &event); 337061da546Spatrick 338061da546Spatrick static bool 339061da546Spatrick EventIsStructuredDataEvent (const lldb::SBEvent &event); 340061da546Spatrick 341061da546Spatrick lldb::SBBroadcaster 342061da546Spatrick GetBroadcaster () const; 343061da546Spatrick 344061da546Spatrick bool 345061da546Spatrick GetDescription (lldb::SBStream &description); 346061da546Spatrick 347dda28197Spatrick %feature("autodoc", " 348dda28197Spatrick Returns the process' extended crash information.") GetExtendedCrashInformation; 349dda28197Spatrick lldb::SBStructuredData 350dda28197Spatrick GetExtendedCrashInformation (); 351dda28197Spatrick 352061da546Spatrick uint32_t 353061da546Spatrick GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; 354061da546Spatrick 355061da546Spatrick uint32_t 356061da546Spatrick LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); 357061da546Spatrick 358061da546Spatrick %feature("autodoc", " 359061da546Spatrick Load the library whose filename is given by image_spec looking in all the 360061da546Spatrick paths supplied in the paths argument. If successful, return a token that 361061da546Spatrick can be passed to UnloadImage and fill loaded_path with the path that was 362061da546Spatrick successfully loaded. On failure, return 363061da546Spatrick lldb.LLDB_INVALID_IMAGE_TOKEN.") LoadImageUsingPaths; 364061da546Spatrick uint32_t 365061da546Spatrick LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, 366061da546Spatrick SBStringList &paths, 367061da546Spatrick lldb::SBFileSpec &loaded_path, 368061da546Spatrick SBError &error); 369061da546Spatrick 370061da546Spatrick lldb::SBError 371061da546Spatrick UnloadImage (uint32_t image_token); 372061da546Spatrick 373061da546Spatrick lldb::SBError 374061da546Spatrick SendEventData (const char *event_data); 375061da546Spatrick 376061da546Spatrick %feature("autodoc", " 377061da546Spatrick Return the number of different thread-origin extended backtraces 378061da546Spatrick this process can support as a uint32_t. 379061da546Spatrick When the process is stopped and you have an SBThread, lldb may be 380061da546Spatrick able to show a backtrace of when that thread was originally created, 381061da546Spatrick or the work item was enqueued to it (in the case of a libdispatch 382061da546Spatrick queue).") GetNumExtendedBacktraceTypes; 383061da546Spatrick 384061da546Spatrick uint32_t 385061da546Spatrick GetNumExtendedBacktraceTypes (); 386061da546Spatrick 387061da546Spatrick %feature("autodoc", " 388061da546Spatrick Takes an index argument, returns the name of one of the thread-origin 389061da546Spatrick extended backtrace methods as a str.") GetExtendedBacktraceTypeAtIndex; 390061da546Spatrick 391061da546Spatrick const char * 392061da546Spatrick GetExtendedBacktraceTypeAtIndex (uint32_t idx); 393061da546Spatrick 394061da546Spatrick lldb::SBThreadCollection 395061da546Spatrick GetHistoryThreads (addr_t addr); 396061da546Spatrick 397061da546Spatrick bool 398061da546Spatrick IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); 399061da546Spatrick 400061da546Spatrick lldb::SBError 401*f6aab3d8Srobert SaveCore(const char *file_name, const char *flavor, lldb::SaveCoreStyle core_style); 402*f6aab3d8Srobert 403*f6aab3d8Srobert lldb::SBError 404061da546Spatrick SaveCore(const char *file_name); 405061da546Spatrick 406061da546Spatrick lldb::SBError 407061da546Spatrick GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info); 408061da546Spatrick 409061da546Spatrick lldb::SBMemoryRegionInfoList 410061da546Spatrick GetMemoryRegions(); 411061da546Spatrick 412061da546Spatrick %feature("autodoc", " 413061da546Spatrick Get information about the process. 414061da546Spatrick Valid process info will only be returned when the process is alive, 415be691f3bSpatrick use IsValid() to check if the info returned is valid. :: 416061da546Spatrick 417061da546Spatrick process_info = process.GetProcessInfo() 418061da546Spatrick if process_info.IsValid(): 419061da546Spatrick process_info.GetProcessID()") GetProcessInfo; 420061da546Spatrick lldb::SBProcessInfo 421061da546Spatrick GetProcessInfo(); 422061da546Spatrick 423be691f3bSpatrick %feature("autodoc", " 424be691f3bSpatrick Allocates a block of memory within the process, with size and 425*f6aab3d8Srobert access permissions specified in the arguments. The permissions 426be691f3bSpatrick argument is an or-combination of zero or more of 427be691f3bSpatrick lldb.ePermissionsWritable, lldb.ePermissionsReadable, and 428be691f3bSpatrick lldb.ePermissionsExecutable. Returns the address 429be691f3bSpatrick of the allocated buffer in the process, or 430be691f3bSpatrick lldb.LLDB_INVALID_ADDRESS if the allocation failed.") AllocateMemory; 431be691f3bSpatrick 432be691f3bSpatrick lldb::addr_t 433be691f3bSpatrick AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &error); 434be691f3bSpatrick 435be691f3bSpatrick %feature("autodoc", " 436be691f3bSpatrick Deallocates the block of memory (previously allocated using 437be691f3bSpatrick AllocateMemory) given in the argument.") DeallocateMemory; 438be691f3bSpatrick 439be691f3bSpatrick lldb::SBError 440be691f3bSpatrick DeallocateMemory(lldb::addr_t ptr); 441be691f3bSpatrick 442061da546Spatrick STRING_EXTENSION(SBProcess) 443061da546Spatrick 444061da546Spatrick #ifdef SWIGPYTHON 445061da546Spatrick %pythoncode %{ 446061da546Spatrick def __get_is_alive__(self): 447061da546Spatrick '''Returns "True" if the process is currently alive, "False" otherwise''' 448061da546Spatrick s = self.GetState() 449061da546Spatrick if (s == eStateAttaching or 450061da546Spatrick s == eStateLaunching or 451061da546Spatrick s == eStateStopped or 452061da546Spatrick s == eStateRunning or 453061da546Spatrick s == eStateStepping or 454061da546Spatrick s == eStateCrashed or 455061da546Spatrick s == eStateSuspended): 456061da546Spatrick return True 457061da546Spatrick return False 458061da546Spatrick 459061da546Spatrick def __get_is_running__(self): 460061da546Spatrick '''Returns "True" if the process is currently running, "False" otherwise''' 461061da546Spatrick state = self.GetState() 462061da546Spatrick if state == eStateRunning or state == eStateStepping: 463061da546Spatrick return True 464061da546Spatrick return False 465061da546Spatrick 466061da546Spatrick def __get_is_stopped__(self): 467061da546Spatrick '''Returns "True" if the process is currently stopped, "False" otherwise''' 468061da546Spatrick state = self.GetState() 469061da546Spatrick if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: 470061da546Spatrick return True 471061da546Spatrick return False 472061da546Spatrick 473061da546Spatrick class threads_access(object): 474061da546Spatrick '''A helper object that will lazily hand out thread for a process when supplied an index.''' 475061da546Spatrick def __init__(self, sbprocess): 476061da546Spatrick self.sbprocess = sbprocess 477061da546Spatrick 478061da546Spatrick def __len__(self): 479061da546Spatrick if self.sbprocess: 480061da546Spatrick return int(self.sbprocess.GetNumThreads()) 481061da546Spatrick return 0 482061da546Spatrick 483061da546Spatrick def __getitem__(self, key): 484061da546Spatrick if type(key) is int and key < len(self): 485061da546Spatrick return self.sbprocess.GetThreadAtIndex(key) 486061da546Spatrick return None 487061da546Spatrick 488061da546Spatrick def get_threads_access_object(self): 489061da546Spatrick '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.''' 490061da546Spatrick return self.threads_access (self) 491061da546Spatrick 492061da546Spatrick def get_process_thread_list(self): 493061da546Spatrick '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.''' 494061da546Spatrick threads = [] 495061da546Spatrick accessor = self.get_threads_access_object() 496061da546Spatrick for idx in range(len(accessor)): 497061da546Spatrick threads.append(accessor[idx]) 498061da546Spatrick return threads 499061da546Spatrick 500061da546Spatrick def __iter__(self): 501061da546Spatrick '''Iterate over all threads in a lldb.SBProcess object.''' 502061da546Spatrick return lldb_iter(self, 'GetNumThreads', 'GetThreadAtIndex') 503061da546Spatrick 504061da546Spatrick def __len__(self): 505061da546Spatrick '''Return the number of threads in a lldb.SBProcess object.''' 506061da546Spatrick return self.GetNumThreads() 507061da546Spatrick 508061da546Spatrick 509061da546Spatrick threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') 510061da546Spatrick 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]).''') 511061da546Spatrick 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.''') 512061da546Spatrick 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.''') 513061da546Spatrick 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.''') 514061da546Spatrick id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') 515061da546Spatrick target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') 516061da546Spatrick num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') 517061da546Spatrick 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.''') 518061da546Spatrick 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.).''') 519061da546Spatrick 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.''') 520061da546Spatrick 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.''') 521061da546Spatrick broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') 522061da546Spatrick %} 523061da546Spatrick #endif 524061da546Spatrick 525061da546Spatrick }; 526061da546Spatrick 527061da546Spatrick } // namespace lldb 528