Skip to content

Commit eb62de9

Browse files
committed
[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 <[email protected]>
1 parent 7aa382f commit eb62de9

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lldb/examples/python/crashlog.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,15 @@ def load_images(self, options, loaded_images=None):
555555

556556
futures = []
557557
with tempfile.TemporaryDirectory() as obj_dir:
558-
with concurrent.futures.ThreadPoolExecutor() as executor:
559558

560-
def add_module(image, target, obj_dir):
561-
return image, image.add_module(target, obj_dir)
559+
def add_module(image, target, obj_dir):
560+
return image, image.add_module(target, obj_dir)
562561

562+
max_worker = None
563+
if options.no_parallel_image_loading:
564+
max_worker = 1
565+
566+
with concurrent.futures.ThreadPoolExecutor(max_worker) as executor:
563567
for image in images_to_load:
564568
if image not in loaded_images:
565569
if image.uuid == uuid.UUID(int=0):
@@ -1528,6 +1532,7 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
15281532
"file_path": crashlog_path,
15291533
"load_all_images": options.load_all_images,
15301534
"crashed_only": options.crashed_only,
1535+
"no_parallel_image_loading": options.no_parallel_image_loading,
15311536
}
15321537
)
15331538
)
@@ -1720,6 +1725,13 @@ def CreateSymbolicateCrashLogOptions(
17201725
help="show source for all threads, not just the crashed thread",
17211726
default=False,
17221727
)
1728+
arg_parser.add_argument(
1729+
"--no-parallel-image-loading",
1730+
dest="no_parallel_image_loading",
1731+
action="store_true",
1732+
help=argparse.SUPPRESS,
1733+
default=False,
1734+
)
17231735
if add_interactive_options:
17241736
arg_parser.add_argument(
17251737
"-i",

lldb/examples/python/crashlog_scripted_process.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: lldb.SBStructuredData
8484
if crashed_only.GetType() == lldb.eStructuredDataTypeBoolean:
8585
self.options.crashed_only = crashed_only.GetBooleanValue()
8686

87+
parallel_image_loading = args.GetValueForKey("parallel_image_loading")
88+
if parallel_image_loading and parallel_image_loading.IsValid():
89+
if parallel_image_loading.GetType() == lldb.eStructuredDataTypeBoolean:
90+
self.options.parallel_image_loading = (
91+
parallel_image_loading.GetBooleanValue()
92+
)
93+
8794
self.pid = super().get_process_id()
8895
self.crashed_thread_idx = 0
8996
self.exception = None

0 commit comments

Comments
 (0)