[llvm-branch-commits] [lldb] 7e9e6ac - [lldb][docs] Fix some RST formatting errors related to code examples.

Raphael Isemann via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jan 17 08:46:18 PST 2021


Author: Raphael Isemann
Date: 2021-01-17T17:41:05+01:00
New Revision: 7e9e6ac526ebd90fe8ec0b8d2bb6edd3516ab908

URL: https://github.com/llvm/llvm-project/commit/7e9e6ac526ebd90fe8ec0b8d2bb6edd3516ab908
DIFF: https://github.com/llvm/llvm-project/commit/7e9e6ac526ebd90fe8ec0b8d2bb6edd3516ab908.diff

LOG: [lldb][docs] Fix some RST formatting errors related to code examples.

Mostly just making sure the indentation is right (SBDebugger had 0 spaces
as it was still plain text, the others had too much indentation or other
minor issues).

Added: 
    

Modified: 
    lldb/bindings/interface/SBBroadcaster.i
    lldb/bindings/interface/SBCommandInterpreterRunOptions.i
    lldb/bindings/interface/SBDebugger.i
    lldb/bindings/interface/SBProcess.i
    lldb/bindings/interface/SBStructuredData.i
    lldb/bindings/interface/SBType.i

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/interface/SBBroadcaster.i b/lldb/bindings/interface/SBBroadcaster.i
index 79100e171b49..dd6de1feff42 100644
--- a/lldb/bindings/interface/SBBroadcaster.i
+++ b/lldb/bindings/interface/SBBroadcaster.i
@@ -11,7 +11,7 @@ namespace lldb {
 %feature("docstring",
 "Represents an entity which can broadcast events. A default broadcaster is
 associated with an SBCommandInterpreter, SBProcess, and SBTarget.  For
-example, use
+example, use ::
 
     broadcaster = process.GetBroadcaster()
 

diff  --git a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
index bad099205724..1a618a228bbe 100644
--- a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
+++ b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
@@ -12,6 +12,7 @@ namespace lldb {
 "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
 
 A default SBCommandInterpreterRunOptions object has:
+
 * StopOnContinue: false
 * StopOnError:    false
 * StopOnCrash:    false

diff  --git a/lldb/bindings/interface/SBDebugger.i b/lldb/bindings/interface/SBDebugger.i
index f2e23a7ed780..78d737b48c23 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -12,108 +12,108 @@ namespace lldb {
 "SBDebugger is the primordial object that creates SBTargets and provides
 access to them.  It also manages the overall debugging experiences.
 
-For example (from example/disasm.py),
-
-import lldb
-import os
-import sys
-
-def disassemble_instructions (insts):
-    for i in insts:
-        print i
-
-...
-
-# Create a new debugger instance
-debugger = lldb.SBDebugger.Create()
-
-# When we step or continue, don't return from the function until the process
-# stops. We do this by setting the async mode to false.
-debugger.SetAsync (False)
-
-# Create a target from a file and arch
-print('Creating a target for \'%s\'' % exe)
-
-target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
-
-if target:
-    # If the target is valid set a breakpoint at main
-    main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
-
-    print main_bp
-
-    # Launch the process. Since we specified synchronous mode, we won't return
-    # from this function until we hit the breakpoint at main
-    process = target.LaunchSimple (None, None, os.getcwd())
-
-    # Make sure the launch went ok
-    if process:
-        # Print some simple process info
-        state = process.GetState ()
-        print process
-        if state == lldb.eStateStopped:
-            # Get the first thread
-            thread = process.GetThreadAtIndex (0)
-            if thread:
-                # Print some simple thread info
-                print thread
-                # Get the first frame
-                frame = thread.GetFrameAtIndex (0)
-                if frame:
-                    # Print some simple frame info
-                    print frame
-                    function = frame.GetFunction()
-                    # See if we have debug info (a function)
-                    if function:
-                        # We do have a function, print some info for the function
-                        print function
-                        # Now get all instructions for this function and print them
-                        insts = function.GetInstructions(target)
-                        disassemble_instructions (insts)
-                    else:
-                        # See if we have a symbol in the symbol table for where we stopped
-                        symbol = frame.GetSymbol();
-                        if symbol:
-                            # We do have a symbol, print some info for the symbol
-                            print symbol
-                            # Now get all instructions for this symbol and print them
-                            insts = symbol.GetInstructions(target)
+For example (from example/disasm.py),::
+
+    import lldb
+    import os
+    import sys
+
+    def disassemble_instructions (insts):
+        for i in insts:
+            print i
+
+    ...
+
+    # Create a new debugger instance
+    debugger = lldb.SBDebugger.Create()
+
+    # When we step or continue, don't return from the function until the process
+    # stops. We do this by setting the async mode to false.
+    debugger.SetAsync (False)
+
+    # Create a target from a file and arch
+    print('Creating a target for \'%s\'' % exe)
+
+    target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
+
+    if target:
+        # If the target is valid set a breakpoint at main
+        main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
+
+        print main_bp
+
+        # Launch the process. Since we specified synchronous mode, we won't return
+        # from this function until we hit the breakpoint at main
+        process = target.LaunchSimple (None, None, os.getcwd())
+
+        # Make sure the launch went ok
+        if process:
+            # Print some simple process info
+            state = process.GetState ()
+            print process
+            if state == lldb.eStateStopped:
+                # Get the first thread
+                thread = process.GetThreadAtIndex (0)
+                if thread:
+                    # Print some simple thread info
+                    print thread
+                    # Get the first frame
+                    frame = thread.GetFrameAtIndex (0)
+                    if frame:
+                        # Print some simple frame info
+                        print frame
+                        function = frame.GetFunction()
+                        # See if we have debug info (a function)
+                        if function:
+                            # We do have a function, print some info for the function
+                            print function
+                            # Now get all instructions for this function and print them
+                            insts = function.GetInstructions(target)
                             disassemble_instructions (insts)
-
-                    registerList = frame.GetRegisters()
-                    print('Frame registers (size of register set = %d):' % registerList.GetSize())
-                    for value in registerList:
-                        #print value
-                        print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
-                        for child in value:
-                            print('Name: ', child.GetName(), ' Value: ', child.GetValue())
-
-            print('Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program')
-            next = sys.stdin.readline()
-            if not next or next.rstrip('\n') == 'quit':
-                print('Terminating the inferior process...')
-                process.Kill()
+                        else:
+                            # See if we have a symbol in the symbol table for where we stopped
+                            symbol = frame.GetSymbol();
+                            if symbol:
+                                # We do have a symbol, print some info for the symbol
+                                print symbol
+                                # Now get all instructions for this symbol and print them
+                                insts = symbol.GetInstructions(target)
+                                disassemble_instructions (insts)
+
+                        registerList = frame.GetRegisters()
+                        print('Frame registers (size of register set = %d):' % registerList.GetSize())
+                        for value in registerList:
+                            #print value
+                            print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
+                            for child in value:
+                                print('Name: ', child.GetName(), ' Value: ', child.GetValue())
+
+                print('Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program')
+                next = sys.stdin.readline()
+                if not next or next.rstrip('\\n') == 'quit':
+                    print('Terminating the inferior process...')
+                    process.Kill()
+                else:
+                    # Now continue to the program exit
+                    process.Continue()
+                    # When we return from the above function we will hopefully be at the
+                    # program exit. Print out some process info
+                    print process
+            elif state == lldb.eStateExited:
+                print('Didn\'t hit the breakpoint at main, program has exited...')
             else:
-                # Now continue to the program exit
-                process.Continue()
-                # When we return from the above function we will hopefully be at the
-                # program exit. Print out some process info
-                print process
-        elif state == lldb.eStateExited:
-            print('Didn\'t hit the breakpoint at main, program has exited...')
-        else:
-            print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
-            process.Kill()
+                print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
+                process.Kill()
 
 Sometimes you need to create an empty target that will get filled in later.  The most common use for this
 is to attach to a process by name or pid where you don't know the executable up front.  The most convenient way
-to do this is:
+to do this is: ::
 
-target = debugger.CreateTarget('')
-error = lldb.SBError()
-process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)
+    target = debugger.CreateTarget('')
+    error = lldb.SBError()
+    process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)
 
-or the equivalent arguments for AttachToProcessWithID.") SBDebugger;
+or the equivalent arguments for :py:class:`SBTarget.AttachToProcessWithID` .") SBDebugger;
 class SBDebugger
 {
 public:

diff  --git a/lldb/bindings/interface/SBProcess.i b/lldb/bindings/interface/SBProcess.i
index ef79016eda5c..6f4a5db27eb9 100644
--- a/lldb/bindings/interface/SBProcess.i
+++ b/lldb/bindings/interface/SBProcess.i
@@ -27,8 +27,6 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
             if t.GetStopReason() == reason:
                 threads.append(t)
         return threads
-
-...
 "
 ) SBProcess;
 class SBProcess

diff  --git a/lldb/bindings/interface/SBStructuredData.i b/lldb/bindings/interface/SBStructuredData.i
index c7601bf6cf95..5aba35229855 100644
--- a/lldb/bindings/interface/SBStructuredData.i
+++ b/lldb/bindings/interface/SBStructuredData.i
@@ -8,12 +8,11 @@
 
 namespace lldb {
 
-    %feature("docstring",
-             "A class representing a StructuredData event.
+%feature("docstring",
+ "A class representing a StructuredData event.
 
-              This class wraps the event type generated by StructuredData
-              features."
-             ) SBStructuredData;
+This class wraps the event type generated by StructuredData features."
+) SBStructuredData;
     class SBStructuredData
     {
     public:

diff  --git a/lldb/bindings/interface/SBType.i b/lldb/bindings/interface/SBType.i
index bcf4397b8c58..e7b3fd11e338 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -458,12 +458,12 @@ SBTypeList supports :py:class:`SBType` iteration. For example,
 
     # find_type.py:
 
-        # Get the type 'Task'.
-        type_list = target.FindTypes('Task')
-        self.assertTrue(len(type_list) == 1)
-        # To illustrate the SBType iteration.
-        for type in type_list:
-            # do something with type
+    # Get the type 'Task'.
+    type_list = target.FindTypes('Task')
+    self.assertTrue(len(type_list) == 1)
+    # To illustrate the SBType iteration.
+    for type in type_list:
+        # do something with type
 
 ") SBTypeList;
 class SBTypeList


        


More information about the llvm-branch-commits mailing list