[Lldb-commits] [lldb] r135221 - in /lldb/trunk/include/lldb/API: SBProcess.h SBTarget.h SBThread.h

Johnny Chen johnny.chen at apple.com
Thu Jul 14 16:56:51 PDT 2011


Author: johnny
Date: Thu Jul 14 18:56:51 2011
New Revision: 135221

URL: http://llvm.org/viewvc/llvm-project?rev=135221&view=rev
Log:
Add usage docstrings to SBTarget, SBProcess, and SBThread.

Modified:
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/API/SBThread.h

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=135221&r1=135220&r2=135221&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Thu Jul 14 18:56:51 2011
@@ -21,7 +21,27 @@
 
 #ifdef SWIG
 %feature("docstring",
-         "Represents the process associated with the target program."
+"Represents the process associated with the target program.
+
+SBProcess supports thread iteration. For example (from test/lldbutil.py),
+
+# ==================================================
+# Utility functions related to Threads and Processes
+# ==================================================
+
+def get_stopped_threads(process, reason):
+    '''Returns the thread(s) with the specified stop reason in a list.
+
+    The list can be empty if no such thread exists.
+    '''
+    threads = []
+    for t in process:
+        if t.GetStopReason() == reason:
+            threads.append(t)
+    return threads
+
+...
+"
          ) SBProcess;
 #endif
 class SBProcess

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=135221&r1=135220&r2=135221&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Thu Jul 14 18:56:51 2011
@@ -20,7 +20,32 @@
 
 #ifdef SWIG
 %feature("docstring",
-         "Represents the target program running under the debugger."
+"Represents the target program running under the debugger.
+
+SBTarget supports module and breakpoint iterations. For example,
+
+    for m in target.module_iter():
+        print m
+
+produces:
+
+(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
+(x86_64) /usr/lib/dyld
+(x86_64) /usr/lib/libstdc++.6.dylib
+(x86_64) /usr/lib/libSystem.B.dylib
+(x86_64) /usr/lib/system/libmathCommon.A.dylib
+(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
+
+and,
+
+    for b in target.breakpoint_iter():
+        print b
+
+produces:
+
+SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
+SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
+"
          ) SBTarget;
 #endif
 class SBTarget

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=135221&r1=135220&r2=135221&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Thu Jul 14 18:56:51 2011
@@ -22,24 +22,25 @@
 %feature("docstring",
 "Represents a thread of execution. SBProcess contains SBThread(s).
 
-For example (from test/lldbutil.py),
+SBThread supports frame iteration. For example (from test/python_api/
+lldbutil/iter/TestLLDBIterator.py),
 
-# ==================================================
-# Utility functions related to Threads and Processes
-# ==================================================
-
-def get_stopped_threads(process, reason):
-    '''Returns the thread(s) with the specified stop reason in a list.
-
-    The list can be empty if no such thread exists.
-    '''
-    threads = []
-    for t in process:
-        if t.GetStopReason() == reason:
-            threads.append(t)
-    return threads
+        from lldbutil import print_stacktrace
+        stopped_due_to_breakpoint = False
+        for thread in process:
+            if self.TraceOn():
+                print_stacktrace(thread)
+            ID = thread.GetThreadID()
+            if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
+                stopped_due_to_breakpoint = True
+            for frame in thread:
+                self.assertTrue(frame.GetThread().GetThreadID() == ID)
+                if self.TraceOn():
+                    print frame
 
-...
+        self.assertTrue(stopped_due_to_breakpoint)
+
+See also SBProcess and SBFrame.
 "
          ) SBThread;
 #endif





More information about the lldb-commits mailing list