[Lldb-commits] [lldb] c615e46 - [lldb] Hoist TraceOn check out of loop (NFC)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Sun Aug 7 11:19:57 PDT 2022


Author: Dave Lee
Date: 2022-08-07T12:19:47-06:00
New Revision: c615e467dbaf5240e4f48f3536d4857ff58c7531

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

LOG: [lldb] Hoist TraceOn check out of loop (NFC)

Added: 
    

Modified: 
    lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py b/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
index 82a529494a680..7adc82f1a6396 100644
--- a/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
+++ b/lldb/test/API/lang/cpp/class_types/TestClassTypesDisassembly.py
@@ -48,24 +48,17 @@ def test_and_python_api(self):
         thread = lldbutil.get_stopped_thread(
             process, lldb.eStopReasonBreakpoint)
         self.assertIsNotNone(thread)
-        depth = thread.GetNumFrames()
-        for i in range(depth - 1):
-            frame = thread.GetFrameAtIndex(i)
-            function = frame.GetFunction()
-            # Print the function header.
-            if self.TraceOn():
-                print()
-                print(function)
-            if function:
-                # Get all instructions for this function and print them out.
-                insts = function.GetInstructions(target)
-                for inst in insts:
-                    # We could simply do 'print inst' to print out the disassembly.
-                    # But we want to print to stdout only if self.TraceOn() is
-                    # True.
-                    disasm = str(inst)
-                    if self.TraceOn():
-                        print(disasm)
+        if self.TraceOn():
+            for frame in thread.frames:
+                function = frame.GetFunction()
+                if function:
+                    # Print the function header.
+                    print()
+                    print(function)
+                    # Get all instructions for this function and print them out.
+                    insts = function.GetInstructions(target)
+                    for inst in insts:
+                        print(inst)
 
     def setUp(self):
         # Call super's setUp().


        


More information about the lldb-commits mailing list