xref: /freebsd-src/contrib/llvm-project/lldb/bindings/interface/SBThreadDocstrings.i (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric %feature("docstring",
206c3fb27SDimitry Andric "Represents a thread of execution. :py:class:`SBProcess` contains SBThread(s).
306c3fb27SDimitry Andric 
406c3fb27SDimitry Andric SBThreads can be referred to by their ID, which maps to the system specific thread
506c3fb27SDimitry Andric identifier, or by IndexID.  The ID may or may not be unique depending on whether the
606c3fb27SDimitry Andric system reuses its thread identifiers.  The IndexID is a monotonically increasing identifier
706c3fb27SDimitry Andric that will always uniquely reference a particular thread, and when that thread goes
806c3fb27SDimitry Andric away it will not be reused.
906c3fb27SDimitry Andric 
1006c3fb27SDimitry Andric SBThread supports frame iteration. For example (from test/python_api/
1106c3fb27SDimitry Andric lldbutil/iter/TestLLDBIterator.py), ::
1206c3fb27SDimitry Andric 
1306c3fb27SDimitry Andric         from lldbutil import print_stacktrace
1406c3fb27SDimitry Andric         stopped_due_to_breakpoint = False
1506c3fb27SDimitry Andric         for thread in process:
1606c3fb27SDimitry Andric             if self.TraceOn():
1706c3fb27SDimitry Andric                 print_stacktrace(thread)
1806c3fb27SDimitry Andric             ID = thread.GetThreadID()
1906c3fb27SDimitry Andric             if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
2006c3fb27SDimitry Andric                 stopped_due_to_breakpoint = True
2106c3fb27SDimitry Andric             for frame in thread:
2206c3fb27SDimitry Andric                 self.assertTrue(frame.GetThread().GetThreadID() == ID)
2306c3fb27SDimitry Andric                 if self.TraceOn():
2406c3fb27SDimitry Andric                     print frame
2506c3fb27SDimitry Andric 
2606c3fb27SDimitry Andric         self.assertTrue(stopped_due_to_breakpoint)
2706c3fb27SDimitry Andric 
2806c3fb27SDimitry Andric See also :py:class:`SBFrame` ."
2906c3fb27SDimitry Andric ) lldb::SBThread;
3006c3fb27SDimitry Andric 
3106c3fb27SDimitry Andric %feature("docstring", "
3206c3fb27SDimitry Andric     Get the number of words associated with the stop reason.
3306c3fb27SDimitry Andric     See also GetStopReasonDataAtIndex()."
3406c3fb27SDimitry Andric ) lldb::SBThread::GetStopReasonDataCount;
3506c3fb27SDimitry Andric 
3606c3fb27SDimitry Andric %feature("docstring", "
3706c3fb27SDimitry Andric     Get information associated with a stop reason.
3806c3fb27SDimitry Andric 
3906c3fb27SDimitry Andric     Breakpoint stop reasons will have data that consists of pairs of
4006c3fb27SDimitry Andric     breakpoint IDs followed by the breakpoint location IDs (they always come
4106c3fb27SDimitry Andric     in pairs).
4206c3fb27SDimitry Andric 
4306c3fb27SDimitry Andric     Stop Reason              Count Data Type
4406c3fb27SDimitry Andric     ======================== ===== =========================================
4506c3fb27SDimitry Andric     eStopReasonNone          0
4606c3fb27SDimitry Andric     eStopReasonTrace         0
4706c3fb27SDimitry Andric     eStopReasonBreakpoint    N     duple: {breakpoint id, location id}
4806c3fb27SDimitry Andric     eStopReasonWatchpoint    1     watchpoint id
4906c3fb27SDimitry Andric     eStopReasonSignal        1     unix signal number
5006c3fb27SDimitry Andric     eStopReasonException     N     exception data
5106c3fb27SDimitry Andric     eStopReasonExec          0
5206c3fb27SDimitry Andric     eStopReasonFork          1     pid of the child process
5306c3fb27SDimitry Andric     eStopReasonVFork         1     pid of the child process
5406c3fb27SDimitry Andric     eStopReasonVForkDone     0
5506c3fb27SDimitry Andric     eStopReasonPlanComplete  0"
5606c3fb27SDimitry Andric ) lldb::SBThread::GetStopReasonDataAtIndex;
5706c3fb27SDimitry Andric 
58*0fca6ea1SDimitry Andric %feature("docstring", "
5906c3fb27SDimitry Andric     Collects a thread's stop reason extended information dictionary and prints it
6006c3fb27SDimitry Andric     into the SBStream in a JSON format. The format of this JSON dictionary depends
6106c3fb27SDimitry Andric     on the stop reason and is currently used only for instrumentation plugins."
6206c3fb27SDimitry Andric ) lldb::SBThread::GetStopReasonExtendedInfoAsJSON;
6306c3fb27SDimitry Andric 
64*0fca6ea1SDimitry Andric %feature("docstring", "
6506c3fb27SDimitry Andric     Returns a collection of historical stack traces that are significant to the
6606c3fb27SDimitry Andric     current stop reason. Used by ThreadSanitizer, where we provide various stack
6706c3fb27SDimitry Andric     traces that were involved in a data race or other type of detected issue."
6806c3fb27SDimitry Andric ) lldb::SBThread::GetStopReasonExtendedBacktraces;
6906c3fb27SDimitry Andric 
70*0fca6ea1SDimitry Andric %feature("docstring", "
7106c3fb27SDimitry Andric     Pass only an (int)length and expect to get a Python string describing the
7206c3fb27SDimitry Andric     stop reason."
7306c3fb27SDimitry Andric ) lldb::SBThread::GetStopDescription;
7406c3fb27SDimitry Andric 
75*0fca6ea1SDimitry Andric %feature("docstring", "
7606c3fb27SDimitry Andric     Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type)
7706c3fb27SDimitry Andric     for the current SBThread that will remain constant throughout the thread's
7806c3fb27SDimitry Andric     lifetime in this process and will not be reused by another thread during this
7906c3fb27SDimitry Andric     process lifetime.  On Mac OS X systems, this is a system-wide unique thread
8006c3fb27SDimitry Andric     identifier; this identifier is also used by other tools like sample which helps
8106c3fb27SDimitry Andric     to associate data from those tools with lldb.  See related GetIndexID."
8206c3fb27SDimitry Andric ) lldb::SBThread::GetThreadID;
8306c3fb27SDimitry Andric 
84*0fca6ea1SDimitry Andric %feature("docstring", "
8506c3fb27SDimitry Andric     Return the index number for this SBThread.  The index number is the same thing
8606c3fb27SDimitry Andric     that a user gives as an argument to 'thread select' in the command line lldb.
8706c3fb27SDimitry Andric     These numbers start at 1 (for the first thread lldb sees in a debug session)
8806c3fb27SDimitry Andric     and increments up throughout the process lifetime.  An index number will not be
8906c3fb27SDimitry Andric     reused for a different thread later in a process - thread 1 will always be
9006c3fb27SDimitry Andric     associated with the same thread.  See related GetThreadID.
9106c3fb27SDimitry Andric     This method returns a uint32_t index number, takes no arguments."
9206c3fb27SDimitry Andric ) lldb::SBThread::GetIndexID;
9306c3fb27SDimitry Andric 
94*0fca6ea1SDimitry Andric %feature("docstring", "
9506c3fb27SDimitry Andric     Return the queue name associated with this thread, if any, as a str.
9606c3fb27SDimitry Andric     For example, with a libdispatch (aka Grand Central Dispatch) queue."
9706c3fb27SDimitry Andric ) lldb::SBThread::GetQueueName;
9806c3fb27SDimitry Andric 
99*0fca6ea1SDimitry Andric %feature("docstring", "
10006c3fb27SDimitry Andric     Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t.
10106c3fb27SDimitry Andric     For example, with a libdispatch (aka Grand Central Dispatch) queue."
10206c3fb27SDimitry Andric ) lldb::SBThread::GetQueueID;
10306c3fb27SDimitry Andric 
10406c3fb27SDimitry Andric %feature("docstring", "
10506c3fb27SDimitry Andric     Takes a path string and a SBStream reference as parameters, returns a bool.
10606c3fb27SDimitry Andric     Collects the thread's 'info' dictionary from the remote system, uses the path
10706c3fb27SDimitry Andric     argument to descend into the dictionary to an item of interest, and prints
10806c3fb27SDimitry Andric     it into the SBStream in a natural format.  Return bool is to indicate if
10906c3fb27SDimitry Andric     anything was printed into the stream (true) or not (false)."
11006c3fb27SDimitry Andric ) lldb::SBThread::GetInfoItemByPathAsString;
11106c3fb27SDimitry Andric 
112*0fca6ea1SDimitry Andric %feature("docstring", "
11306c3fb27SDimitry Andric     Return the SBQueue for this thread.  If this thread is not currently associated
11406c3fb27SDimitry Andric     with a libdispatch queue, the SBQueue object's IsValid() method will return false.
11506c3fb27SDimitry Andric     If this SBThread is actually a HistoryThread, we may be able to provide QueueID
11606c3fb27SDimitry Andric     and QueueName, but not provide an SBQueue.  Those individual attributes may have
11706c3fb27SDimitry Andric     been saved for the HistoryThread without enough information to reconstitute the
11806c3fb27SDimitry Andric     entire SBQueue at that time.
11906c3fb27SDimitry Andric     This method takes no arguments, returns an SBQueue."
12006c3fb27SDimitry Andric ) lldb::SBThread::GetQueue;
12106c3fb27SDimitry Andric 
12206c3fb27SDimitry Andric %feature("docstring",
12306c3fb27SDimitry Andric     "Do a source level single step over in the currently selected thread."
12406c3fb27SDimitry Andric ) lldb::SBThread::StepOver;
12506c3fb27SDimitry Andric 
12606c3fb27SDimitry Andric %feature("docstring", "
12706c3fb27SDimitry Andric     Step the current thread from the current source line to the line given by end_line, stopping if
12806c3fb27SDimitry Andric     the thread steps into the function given by target_name.  If target_name is None, then stepping will stop
12906c3fb27SDimitry Andric     in any of the places we would normally stop."
13006c3fb27SDimitry Andric ) lldb::SBThread::StepInto;
13106c3fb27SDimitry Andric 
13206c3fb27SDimitry Andric %feature("docstring",
13306c3fb27SDimitry Andric     "Step out of the currently selected thread."
13406c3fb27SDimitry Andric ) lldb::SBThread::StepOut;
13506c3fb27SDimitry Andric 
13606c3fb27SDimitry Andric %feature("docstring",
13706c3fb27SDimitry Andric     "Step out of the specified frame."
13806c3fb27SDimitry Andric ) lldb::SBThread::StepOutOfFrame;
13906c3fb27SDimitry Andric 
14006c3fb27SDimitry Andric %feature("docstring",
14106c3fb27SDimitry Andric     "Do an instruction level single step in the currently selected thread."
14206c3fb27SDimitry Andric ) lldb::SBThread::StepInstruction;
14306c3fb27SDimitry Andric 
144*0fca6ea1SDimitry Andric %feature("docstring", "
14506c3fb27SDimitry Andric     Force a return from the frame passed in (and any frames younger than it)
14606c3fb27SDimitry Andric     without executing any more code in those frames.  If return_value contains
14706c3fb27SDimitry Andric     a valid SBValue, that will be set as the return value from frame.  Note, at
14806c3fb27SDimitry Andric     present only scalar return values are supported."
14906c3fb27SDimitry Andric ) lldb::SBThread::ReturnFromFrame;
15006c3fb27SDimitry Andric 
151*0fca6ea1SDimitry Andric %feature("docstring", "
15206c3fb27SDimitry Andric     Unwind the stack frames from the innermost expression evaluation.
15306c3fb27SDimitry Andric     This API is equivalent to 'thread return -x'."
15406c3fb27SDimitry Andric ) lldb::SBThread::UnwindInnermostExpression;
15506c3fb27SDimitry Andric 
15606c3fb27SDimitry Andric %feature("docstring", "
15706c3fb27SDimitry Andric     LLDB currently supports process centric debugging which means when any
15806c3fb27SDimitry Andric     thread in a process stops, all other threads are stopped. The Suspend()
15906c3fb27SDimitry Andric     call here tells our process to suspend a thread and not let it run when
16006c3fb27SDimitry Andric     the other threads in a process are allowed to run. So when
16106c3fb27SDimitry Andric     SBProcess::Continue() is called, any threads that aren't suspended will
16206c3fb27SDimitry Andric     be allowed to run. If any of the SBThread functions for stepping are
16306c3fb27SDimitry Andric     called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
16406c3fb27SDimitry Andric     thread will now be allowed to run and these functions will simply return.
16506c3fb27SDimitry Andric 
16606c3fb27SDimitry Andric     Eventually we plan to add support for thread centric debugging where
16706c3fb27SDimitry Andric     each thread is controlled individually and each thread would broadcast
16806c3fb27SDimitry Andric     its state, but we haven't implemented this yet.
16906c3fb27SDimitry Andric 
17006c3fb27SDimitry Andric     Likewise the SBThread::Resume() call will again allow the thread to run
17106c3fb27SDimitry Andric     when the process is continued.
17206c3fb27SDimitry Andric 
17306c3fb27SDimitry Andric     Suspend() and Resume() functions are not currently reference counted, if
17406c3fb27SDimitry Andric     anyone has the need for them to be reference counted, please let us
17506c3fb27SDimitry Andric     know."
17606c3fb27SDimitry Andric ) lldb::SBThread::Suspend;
17706c3fb27SDimitry Andric 
17806c3fb27SDimitry Andric %feature("docstring", "
17906c3fb27SDimitry Andric     Get the description strings for this thread that match what the
18006c3fb27SDimitry Andric     lldb driver will present, using the thread-format (stop_format==false)
18106c3fb27SDimitry Andric     or thread-stop-format (stop_format = true)."
18206c3fb27SDimitry Andric ) lldb::SBThread::GetDescription;
18306c3fb27SDimitry Andric 
184*0fca6ea1SDimitry Andric %feature("docstring","
18506c3fb27SDimitry Andric     Given an argument of str to specify the type of thread-origin extended
18606c3fb27SDimitry Andric     backtrace to retrieve, query whether the origin of this thread is
18706c3fb27SDimitry Andric     available.  An SBThread is retured; SBThread.IsValid will return true
18806c3fb27SDimitry Andric     if an extended backtrace was available.  The returned SBThread is not
18906c3fb27SDimitry Andric     a part of the SBProcess' thread list and it cannot be manipulated like
19006c3fb27SDimitry Andric     normal threads -- you cannot step or resume it, for instance -- it is
19106c3fb27SDimitry Andric     intended to used primarily for generating a backtrace.  You may request
19206c3fb27SDimitry Andric     the returned thread's own thread origin in turn."
19306c3fb27SDimitry Andric ) lldb::SBThread::GetExtendedBacktraceThread;
19406c3fb27SDimitry Andric 
195*0fca6ea1SDimitry Andric %feature("docstring","
19606c3fb27SDimitry Andric     If this SBThread is an ExtendedBacktrace thread, get the IndexID of the
19706c3fb27SDimitry Andric     original thread that this ExtendedBacktrace thread represents, if
19806c3fb27SDimitry Andric     available.  The thread that was running this backtrace in the past may
19906c3fb27SDimitry Andric     not have been registered with lldb's thread index (if it was created,
20006c3fb27SDimitry Andric     did its work, and was destroyed without lldb ever stopping execution).
20106c3fb27SDimitry Andric     In that case, this ExtendedBacktrace thread's IndexID will be returned."
20206c3fb27SDimitry Andric ) lldb::SBThread::GetExtendedBacktraceOriginatingIndexID;
20306c3fb27SDimitry Andric 
204*0fca6ea1SDimitry Andric %feature("docstring","
20506c3fb27SDimitry Andric     Returns an SBValue object represeting the current exception for the thread,
20606c3fb27SDimitry Andric     if there is any. Currently, this works for Obj-C code and returns an SBValue
20706c3fb27SDimitry Andric     representing the NSException object at the throw site or that's currently
20806c3fb27SDimitry Andric     being processes."
20906c3fb27SDimitry Andric ) lldb::SBThread::GetCurrentException;
21006c3fb27SDimitry Andric 
211*0fca6ea1SDimitry Andric %feature("docstring","
21206c3fb27SDimitry Andric     Returns a historical (fake) SBThread representing the stack trace of an
21306c3fb27SDimitry Andric     exception, if there is one for the thread. Currently, this works for Obj-C
21406c3fb27SDimitry Andric     code, and can retrieve the throw-site backtrace of an NSException object
21506c3fb27SDimitry Andric     even when the program is no longer at the throw site."
21606c3fb27SDimitry Andric ) lldb::SBThread::GetCurrentExceptionBacktrace;
21706c3fb27SDimitry Andric 
218*0fca6ea1SDimitry Andric %feature("docstring","
21906c3fb27SDimitry Andric     lldb may be able to detect that function calls should not be executed
22006c3fb27SDimitry Andric     on a given thread at a particular point in time.  It is recommended that
22106c3fb27SDimitry Andric     this is checked before performing an inferior function call on a given
22206c3fb27SDimitry Andric     thread."
22306c3fb27SDimitry Andric ) lldb::SBThread::SafeToCallFunctions;
22406c3fb27SDimitry Andric 
225*0fca6ea1SDimitry Andric %feature("docstring","
226*0fca6ea1SDimitry Andric     Returns a SBValue object representing the siginfo for the current signal.
22706c3fb27SDimitry Andric     "
22806c3fb27SDimitry Andric ) lldb::SBThread::GetSiginfo;
229