llvmbot wrote:

@llvm/pr-subscribers-lldb

<details>
<summary>Changes</summary>

Using:
black --exclude "third_party/" ./lldb/
--

Patch is 108.25 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66053.diff

17 Files Affected:

- (modified) lldb/scripts/analyze-project-deps.py (+42-24) 
- (modified) lldb/scripts/android/host_art_bt.py (+146-83) 
- (modified) lldb/scripts/install_custom_python.py (+72-74) 
- (modified) lldb/scripts/reproducer-replay.py (+50-48) 
- (modified) lldb/scripts/use_lldb_suite.py (+3-1) 
- (modified) lldb/scripts/verify_api.py (+57-42) 
- (modified) lldb/utils/lldb-repro/lldb-repro.py (+17-13) 
- (modified) lldb/utils/lui/breakwin.py (+7-7) 
- (modified) lldb/utils/lui/commandwin.py (+16-19) 
- (modified) lldb/utils/lui/cui.py (+25-30) 
- (modified) lldb/utils/lui/debuggerdriver.py (+40-36) 
- (modified) lldb/utils/lui/eventwin.py (+1-2) 
- (modified) lldb/utils/lui/lldbutil.py (+204-168) 
- (modified) lldb/utils/lui/lui.py (+25-29) 
- (modified) lldb/utils/lui/sandbox.py (+6-6) 
- (modified) lldb/utils/lui/sourcewin.py (+37-25) 
- (modified) lldb/utils/lui/statuswin.py (+6-6) 


<pre>
diff --git a/lldb/scripts/analyze-project-deps.py 
b/lldb/scripts/analyze-project-deps.py
index 89da3dc9df7b3c6..4724367e2e722d0 100755
--- a/lldb/scripts/analyze-project-deps.py
+++ b/lldb/scripts/analyze-project-deps.py
@@ -10,12 +10,21 @@
 from use_lldb_suite import lldb_root
 
 parser = argparse.ArgumentParser(
-    description='Analyze LLDB project #include dependencies.')
-parser.add_argument('--show-counts', default=False, action='store_true', 
-    help='When true, show the number of dependencies from each subproject')
-parser.add_argument('--discover-cycles', default=False, action='store_true',
-    help='When true, find and display all project dependency cycles.  Note,'
-         'this option is very slow')
+    description="Analyze LLDB project #include dependencies."
+)
+parser.add_argument(
+    "--show-counts",
+    default=False,
+    action="store_true",
+    help="When true, show the number of dependencies from each subproject",
+)
+parser.add_argument(
+    "--discover-cycles",
+    default=False,
+    action="store_true",
+    help="When true, find and display all project dependency cycles.  Note,"
+    "this option is very slow",
+)
 
 args = parser.parse_args()
 
@@ -24,12 +33,14 @@
 
 src_map = {}
 
-include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"')
+include_regex = re.compile('#include "((lldb|Plugins|clang)(.*/)+).*"')
+
 
 def is_sublist(small, big):
     it = iter(big)
     return all(c in it for c in small)
 
+
 def normalize_host(str):
     if str.startswith("lldb/Host"):
         return "lldb/Host"
@@ -39,6 +50,7 @@ def normalize_host(str):
         return str.replace("lldb/../../source", "lldb")
     return str
 
+
 def scan_deps(this_dir, file):
     global src_map
     deps = {}
@@ -62,7 +74,8 @@ def scan_deps(this_dir, file):
     if this_dir not in src_map and len(deps) > 0:
         src_map[this_dir] = deps
 
-for (base, dirs, files) in os.walk(inc_dir):
+
+for base, dirs, files in os.walk(inc_dir):
     dir = os.path.basename(base)
     relative = os.path.relpath(base, inc_dir)
     inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]]
@@ -71,7 +84,7 @@ def scan_deps(this_dir, file):
         inc_path = os.path.join(base, inc)
         scan_deps(relative, inc_path)
 
-for (base, dirs, files) in os.walk(src_dir):
+for base, dirs, files in os.walk(src_dir):
     dir = os.path.basename(base)
     relative = os.path.relpath(base, src_dir)
     src_files = [x for x in files if os.path.splitext(x)[1] in [".cpp", ".h", 
".mm"]]
@@ -82,6 +95,7 @@ def scan_deps(this_dir, file):
         scan_deps(norm_base_path, src_path)
     pass
 
+
 def is_existing_cycle(path, cycles):
     # If we have a cycle like # A -> B -> C (with an implicit -> A at the end)
     # then we don't just want to check for an occurrence of A -> B -> C in the
@@ -90,12 +104,13 @@ def is_existing_cycle(path, cycles):
     # at the end), then A -> B -> C is also a cycle.  This is an important
     # optimization which reduces the search space by multiple orders of
     # magnitude.
-    for i in range(0,len(path)):
+    for i in range(0, len(path)):
         if any(is_sublist(x, path) for x in cycles):
             return True
         path = [path[-1]] + path[0:-1]
     return False
 
+
 def expand(path_queue, path_lengths, cycles, src_map):
     # We do a breadth first search, to make sure we visit all paths in order
     # of ascending length.  This is an important optimization to make sure that
@@ -127,54 +142,57 @@ def expand(path_queue, path_lengths, cycles, src_map):
             path_queue.append(cur_path + [item])
     pass
 
+
 cycles = []
 
 path_queue = [[x] for x in iter(src_map)]
 path_lens = [1] * len(path_queue)
 
 items = list(src_map.items())
-items.sort(key = lambda A : A[0])
+items.sort(key=lambda A: A[0])
 
-for (path, deps) in items:
+for path, deps in items:
     print(path + ":")
     sorted_deps = list(deps.items())
     if args.show_counts:
-        sorted_deps.sort(key = lambda A: (A[1], A[0]))
+        sorted_deps.sort(key=lambda A: (A[1], A[0]))
         for dep in sorted_deps:
             print("\t{} [{}]".format(dep[0], dep[1]))
     else:
-        sorted_deps.sort(key = lambda A: A[0])
+        sorted_deps.sort(key=lambda A: A[0])
         for dep in sorted_deps:
             print("\t{}".format(dep[0]))
 
+
 def iter_cycles(cycles):
     global src_map
     for cycle in cycles:
         cycle.append(cycle[0])
         zipper = list(zip(cycle[0:-1], cycle[1:]))
-        result = [(x, src_map[x][y], y) for (x,y) in zipper]
+        result = [(x, src_map[x][y], y) for (x, y) in zipper]
         total = 0
         smallest = result[0][1]
-        for (first, value, last) in result:
+        for first, value, last in result:
             total += value
             smallest = min(smallest, value)
         yield (total, smallest, result)
 
+
 if args.discover_cycles:
     print("Analyzing cycles...")
 
     expand(path_queue, path_lens, cycles, src_map)
 
-    average = sum([len(x)+1 for x in cycles]) / len(cycles)
+    average = sum([len(x) + 1 for x in cycles]) / len(cycles)
 
     print("Found {} cycles.  Average cycle length = {}.".format(len(cycles), 
average))
     counted = list(iter_cycles(cycles))
     if args.show_counts:
-        counted.sort(key = lambda A: A[0])
-        for (total, smallest, cycle) in counted:
+        counted.sort(key=lambda A: A[0])
+        for total, smallest, cycle in counted:
             sys.stdout.write("{} deps to break: ".format(total))
             sys.stdout.write(cycle[0][0])
-            for (first, count, last) in cycle:
+            for first, count, last in cycle:
                 sys.stdout.write(" [{}->] {}".format(count, last))
             sys.stdout.write("\n")
     else:
@@ -186,8 +204,8 @@ def iter_cycles(cycles):
     islands = []
     outgoing_counts = defaultdict(int)
     incoming_counts = defaultdict(int)
-    for (total, smallest, cycle) in counted:
-        for (first, count, last) in cycle:
+    for total, smallest, cycle in counted:
+        for first, count, last in cycle:
             outgoing_counts[first] += count
             incoming_counts[last] += count
     for cycle in cycles:
@@ -201,8 +219,8 @@ def iter_cycles(cycles):
         sorted = []
         for node in island:
             sorted.append((node, incoming_counts[node], outgoing_counts[node]))
-        sorted.sort(key = lambda x: x[1]+x[2])
-        for (node, inc, outg) in sorted:
+        sorted.sort(key=lambda x: x[1] + x[2])
+        for node, inc, outg in sorted:
             print("  {} [{} in, {} out]".format(node, inc, outg))
     sys.stdout.flush()
 pass
diff --git a/lldb/scripts/android/host_art_bt.py 
b/lldb/scripts/android/host_art_bt.py
index 03797074aafdddd..d4c5af46d9e2f8e 100644
--- a/lldb/scripts/android/host_art_bt.py
+++ b/lldb/scripts/android/host_art_bt.py
@@ -20,45 +20,59 @@ def host_art_bt(debugger, command, result, internal_dict):
     thread = process.GetSelectedThread()
     while lldb_frame_index < thread.GetNumFrames():
         frame = thread.GetFrameAtIndex(lldb_frame_index)
-        if frame.GetModule() and re.match(r'JIT\(.*?\)',
-                                          
frame.GetModule().GetFileSpec().GetFilename()):
+        if frame.GetModule() and re.match(
+            r"JIT\(.*?\)", frame.GetModule().GetFileSpec().GetFilename()
+        ):
             # Compiled Java frame
 
             # Get function/filename/lineno from symbol context
             symbol = frame.GetSymbol()
             if not symbol:
-                print('No symbol info for compiled Java frame: ', frame)
+                print("No symbol info for compiled Java frame: ", frame)
                 sys.exit(1)
             line_entry = frame.GetLineEntry()
-            prettified_frames.append({
-                'function': symbol.GetName(),
-                'file': str(line_entry.GetFileSpec()) if line_entry else None,
-                'line': line_entry.GetLine() if line_entry else -1
-            })
+            prettified_frames.append(
+                {
+                    "function": symbol.GetName(),
+                    "file": str(line_entry.GetFileSpec()) if line_entry else 
None,
+                    "line": line_entry.GetLine() if line_entry else -1,
+                }
+            )
 
             # Skip art frames
             while True:
                 art_stack_visitor = frame.EvaluateExpression(
-                    """struct GetStackVisitor : public StackVisitor { 
GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), 
depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } 
else { return true; } } int depth; }; GetStackVisitor visitor(""" +
-                    str(art_frame_index) +
-                    """); visitor.WalkStack(true); visitor""")
+                    """struct GetStackVisitor : public StackVisitor { 
GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), 
depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } 
else { return true; } } int depth; }; GetStackVisitor visitor("""
+                    + str(art_frame_index)
+                    + """); visitor.WalkStack(true); visitor"""
+                )
                 art_method = frame.EvaluateExpression(
-                    art_stack_visitor.GetName() + """.GetMethod()""")
+                    art_stack_visitor.GetName() + """.GetMethod()"""
+                )
                 if art_method.GetValueAsUnsigned() != 0:
                     art_method_name = frame.EvaluateExpression(
-                        """art::PrettyMethod(""" + art_method.GetName() + """, 
true)""")
+                        """art::PrettyMethod(""" + art_method.GetName() + """, 
true)"""
+                    )
                     art_method_name_data = frame.EvaluateExpression(
-                        art_method_name.GetName() + 
""".c_str()""").GetValueAsUnsigned()
+                        art_method_name.GetName() + """.c_str()"""
+                    ).GetValueAsUnsigned()
                     art_method_name_size = frame.EvaluateExpression(
-                        art_method_name.GetName() + 
""".length()""").GetValueAsUnsigned()
+                        art_method_name.GetName() + """.length()"""
+                    ).GetValueAsUnsigned()
                     error = lldb.SBError()
                     art_method_name = process.ReadCStringFromMemory(
-                        art_method_name_data, art_method_name_size + 1, error)
+                        art_method_name_data, art_method_name_size + 1, error
+                    )
                     if not error.Success:
-                        print('Failed to read method name')
+                        print("Failed to read method name")
                         sys.exit(1)
                     if art_method_name != symbol.GetName():
-                        print('Function names in native symbol and art runtime 
stack do not match: ', symbol.GetName(), ' != ', art_method_name)
+                        print(
+                            "Function names in native symbol and art runtime 
stack do not match: ",
+                            symbol.GetName(),
+                            " != ",
+                            art_method_name,
+                        )
                     art_frame_index = art_frame_index + 1
                     break
                 art_frame_index = art_frame_index + 1
@@ -68,53 +82,69 @@ def host_art_bt(debugger, command, result, internal_dict):
             if lldb_frame_index < thread.GetNumFrames():
                 frame = thread.GetFrameAtIndex(lldb_frame_index)
                 if frame.GetModule() and re.match(
-                        r'JIT\(.*?\)', 
frame.GetModule().GetFileSpec().GetFilename()):
+                    r"JIT\(.*?\)", 
frame.GetModule().GetFileSpec().GetFilename()
+                ):
                     # Another compile Java frame
                     # Don't skip; leave it to the next iteration
                     continue
-                elif frame.GetSymbol() and (frame.GetSymbol().GetName() == 
'art_quick_invoke_stub' or frame.GetSymbol().GetName() == 
'art_quick_invoke_static_stub'):
+                elif frame.GetSymbol() and (
+                    frame.GetSymbol().GetName() == "art_quick_invoke_stub"
+                    or frame.GetSymbol().GetName() == 
"art_quick_invoke_static_stub"
+                ):
                     # art_quick_invoke_stub / art_quick_invoke_static_stub
                     # Skip until we get past the next ArtMethod::Invoke()
                     while True:
                         lldb_frame_index = lldb_frame_index + 1
                         if lldb_frame_index >= thread.GetNumFrames():
-                            print('ArtMethod::Invoke not found below 
art_quick_invoke_stub/art_quick_invoke_static_stub')
+                            print(
+                                "ArtMethod::Invoke not found below 
art_quick_invoke_stub/art_quick_invoke_static_stub"
+                            )
                             sys.exit(1)
                         frame = thread.GetFrameAtIndex(lldb_frame_index)
-                        if frame.GetSymbol() and frame.GetSymbol().GetName(
-                        ) == 'art::mirror::ArtMethod::Invoke(art::Thread*, 
unsigned int*, unsigned int, art::JValue*, char const*)':
+                        if (
+                            frame.GetSymbol()
+                            and frame.GetSymbol().GetName()
+                            == "art::mirror::ArtMethod::Invoke(art::Thread*, 
unsigned int*, unsigned int, art::JValue*, char const*)"
+                        ):
                             lldb_frame_index = lldb_frame_index + 1
                             break
                 else:
-                    print('Invalid frame below compiled Java frame: ', frame)
-        elif frame.GetSymbol() and frame.GetSymbol().GetName() == 
'art_quick_generic_jni_trampoline':
+                    print("Invalid frame below compiled Java frame: ", frame)
+        elif (
+            frame.GetSymbol()
+            and frame.GetSymbol().GetName() == 
"art_quick_generic_jni_trampoline"
+        ):
             # Interpreted JNI frame for x86_64
 
             # Skip art frames
             while True:
                 art_stack_visitor = frame.EvaluateExpression(
-                    """struct GetStackVisitor : public StackVisitor { 
GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), 
depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } 
else { return true; } } int depth; }; GetStackVisitor visitor(""" +
-                    str(art_frame_index) +
-                    """); visitor.WalkStack(true); visitor""")
+                    """struct GetStackVisitor : public StackVisitor { 
GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), 
depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } 
else { return true; } } int depth; }; GetStackVisitor visitor("""
+                    + str(art_frame_index)
+                    + """); visitor.WalkStack(true); visitor"""
+                )
                 art_method = frame.EvaluateExpression(
-                    art_stack_visitor.GetName() + """.GetMethod()""")
+                    art_stack_visitor.GetName() + """.GetMethod()"""
+                )
                 if art_method.GetValueAsUnsigned() != 0:
                     # Get function/filename/lineno from ART runtime
                     art_method_name = frame.EvaluateExpression(
-                        """art::PrettyMethod(""" + art_method.GetName() + """, 
true)""")
+                        """art::PrettyMethod(""" + art_method.GetName() + """, 
true)"""
+                    )
                     art_method_name_data = frame.EvaluateExpression(
-                        art_method_name.GetName() + 
""".c_str()""").GetValueAsUnsigned()
+                        art_method_name.GetName() + """.c_str()"""
+                    ).GetValueAsUnsigned()
                     art_method_name_size = frame.EvaluateExpression(
-                        art_method_name.GetName() + 
""".length()""").GetValueAsUnsigned()
+                        art_method_name.GetName() + """.length()"""
+                    ).GetValueAsUnsigned()
                     error = lldb.SBError()
                     function = process.ReadCStringFromMemory(
-                        art_method_name_data, art_method_name_size + 1, error)
+                        art_method_name_data, art_method_name_size + 1, error
+                    )
 
-                    prettified_frames.append({
-                        'function': function,
-                        'file': None,
-                        'line': -1
-                    })
+                    prettified_frames.append(
+                        {"function": function, "file": None, "line": -1}
+                    )
 
                     art_frame_index = art_frame_index + 1
                     break
@@ -124,78 +154,98 @@ def host_art_bt(debugger, command, result, internal_dict):
             lldb_frame_index = lldb_frame_index + 1
             if lldb_frame_index < thread.GetNumFrames():
                 frame = thread.GetFrameAtIndex(lldb_frame_index)
-                if frame.GetSymbol() and (frame.GetSymbol().GetName() ==
-                                          'art_quick_invoke_stub' or 
frame.GetSymbol().GetName() == 'art_quick_invoke_static_stub'):
+                if frame.GetSymbol() and (
+                    frame.GetSymbol().GetName() == "art_quick_invoke_stub"
+                    or frame.GetSymbol().GetName() == 
"art_quick_invoke_static_stub"
+                ):
                     # art_quick_invoke_stub / art_quick_invoke_static_stub
                     # Skip until we get past the next ArtMethod::Invoke()
                     while True:
                         lldb_frame_index = lldb_frame_index + 1
                         if lldb_frame_index >= thread.GetNumFrames():
-                            print('ArtMethod::Invoke not found below 
art_quick_invoke_stub/art_quick_invoke_static_stub')
+                            print(
+                                "ArtMethod::Invoke not found below 
art_quick_invoke_stub/art_quick_invoke_static_stub"
+                            )
                             sys.exit(1)
                         frame = thread.GetFrameAtIndex(lldb_frame_index)
-                        if frame.GetSymbol() and frame.GetSymbol().GetName(
-                        ) == 'art::mirror::ArtMethod::Invoke(art::Thread*, 
unsigned int*, unsigned int, art::JValue*, char const*)':
+                        if (
+                            frame.GetSymbol()
+                            and frame.GetSymbol().GetName()
+                            == "art::mirror::ArtMethod::Invoke(art::Thread*, 
unsigned int*, unsigned int, art::JValue*, char const*)"
+                        ):
                             lldb_frame_index = lldb_frame_index + 1
                             break
                 else:
-                    print('Invalid frame below compiled Java frame: ', frame)
-        elif frame.GetSymbol() and re.search(r'art::interpreter::', 
frame.GetSymbol().GetName()):
+                    print("Invalid frame below compiled Java frame: ", frame)
+        elif frame.GetSymbol() and re.search(
+            r"art::interpreter::", frame.GetSymbol().G...
<truncated>
</pre>

</details>

https://github.com/llvm/llvm-project/pull/66053
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to