Skip to content

Commit 4f3d032

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 4f3d032

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

lldb/examples/python/crashlog.py

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -555,30 +555,44 @@ 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)
561+
562+
if options.parallel_image_loading:
563+
with concurrent.futures.ThreadPoolExecutor() as executor:
564+
for image in images_to_load:
565+
if image not in loaded_images:
566+
if image.uuid == uuid.UUID(int=0):
567+
continue
568+
futures.append(
569+
executor.submit(
570+
add_module,
571+
image=image,
572+
target=self.target,
573+
obj_dir=obj_dir,
574+
)
575+
)
562576

577+
for future in concurrent.futures.as_completed(futures):
578+
image, err = future.result()
579+
if err:
580+
print(err)
581+
else:
582+
loaded_images.append(image)
583+
else:
563584
for image in images_to_load:
564585
if image not in loaded_images:
565586
if image.uuid == uuid.UUID(int=0):
566587
continue
567-
futures.append(
568-
executor.submit(
569-
add_module,
570-
image=image,
571-
target=self.target,
572-
obj_dir=obj_dir,
573-
)
588+
image, err = add_module(
589+
image=image, target=self.target, obj_dir=obj_dir
574590
)
575591

576-
for future in concurrent.futures.as_completed(futures):
577-
image, err = future.result()
578-
if err:
579-
print(err)
580-
else:
581-
loaded_images.append(image)
592+
if err:
593+
print(err)
594+
else:
595+
loaded_images.append(image)
582596

583597

584598
class CrashLogFormatException(Exception):
@@ -1528,6 +1542,7 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
15281542
"file_path": crashlog_path,
15291543
"load_all_images": options.load_all_images,
15301544
"crashed_only": options.crashed_only,
1545+
"parallel_image_loading": options.parallel_image_loading,
15311546
}
15321547
)
15331548
)
@@ -1720,6 +1735,13 @@ def CreateSymbolicateCrashLogOptions(
17201735
help="show source for all threads, not just the crashed thread",
17211736
default=False,
17221737
)
1738+
arg_parser.add_argument(
1739+
"--no-parallel-image-loading",
1740+
dest="parallel_image_loading",
1741+
action="store_false",
1742+
help=argparse.SUPPRESS,
1743+
default=True,
1744+
)
17231745
if add_interactive_options:
17241746
arg_parser.add_argument(
17251747
"-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)