[Lldb-commits] [lldb] [lldb/crashlog] Add `--no-parallel-image-loading` hidden flag (PR #94513)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 5 12:29:46 PDT 2024
https://github.com/medismailben updated https://github.com/llvm/llvm-project/pull/94513
>From eb62de94ceaf3ee440046a2884210fb4f8774edf Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani <ismail at bennani.ma>
Date: Wed, 5 Jun 2024 12:28:59 -0700
Subject: [PATCH] [lldb/crashlog] Add `--no-parallel-image-loading` hidden flag
This patch adds the `--no-parallel-image-loading` to the crashlog
command. By default, image loading will happen in parallel in the
crashlog script however, sometimes, when running tests or debugging the
crashlog script itself, it's better to load the images sequentially.
As its name suggests, this flag will disable the default image loading
behaviour to load all the images sequencially in the main thread.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
---
lldb/examples/python/crashlog.py | 18 +++++++++++++++---
.../python/crashlog_scripted_process.py | 7 +++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..e191bb4165259 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -555,11 +555,15 @@ def load_images(self, options, loaded_images=None):
futures = []
with tempfile.TemporaryDirectory() as obj_dir:
- with concurrent.futures.ThreadPoolExecutor() as executor:
- def add_module(image, target, obj_dir):
- return image, image.add_module(target, obj_dir)
+ def add_module(image, target, obj_dir):
+ return image, image.add_module(target, obj_dir)
+ max_worker = None
+ if options.no_parallel_image_loading:
+ max_worker = 1
+
+ with concurrent.futures.ThreadPoolExecutor(max_worker) as executor:
for image in images_to_load:
if image not in loaded_images:
if image.uuid == uuid.UUID(int=0):
@@ -1528,6 +1532,7 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
"file_path": crashlog_path,
"load_all_images": options.load_all_images,
"crashed_only": options.crashed_only,
+ "no_parallel_image_loading": options.no_parallel_image_loading,
}
)
)
@@ -1720,6 +1725,13 @@ def CreateSymbolicateCrashLogOptions(
help="show source for all threads, not just the crashed thread",
default=False,
)
+ arg_parser.add_argument(
+ "--no-parallel-image-loading",
+ dest="no_parallel_image_loading",
+ action="store_true",
+ help=argparse.SUPPRESS,
+ default=False,
+ )
if add_interactive_options:
arg_parser.add_argument(
"-i",
diff --git a/lldb/examples/python/crashlog_scripted_process.py b/lldb/examples/python/crashlog_scripted_process.py
index 26c5c37b7371d..ebce4834ef198 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -84,6 +84,13 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: lldb.SBStructuredData
if crashed_only.GetType() == lldb.eStructuredDataTypeBoolean:
self.options.crashed_only = crashed_only.GetBooleanValue()
+ parallel_image_loading = args.GetValueForKey("parallel_image_loading")
+ if parallel_image_loading and parallel_image_loading.IsValid():
+ if parallel_image_loading.GetType() == lldb.eStructuredDataTypeBoolean:
+ self.options.parallel_image_loading = (
+ parallel_image_loading.GetBooleanValue()
+ )
+
self.pid = super().get_process_id()
self.crashed_thread_idx = 0
self.exception = None
More information about the lldb-commits
mailing list