Skip to content

Commit c7aa624

Browse files
committed
[lldb/crashlog] Add --no-parallel-image-loading hidden flag (llvm#94513)
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]> (cherry picked from commit 68a9cb7)
1 parent fe0e757 commit c7aa624

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lldb/examples/python/crashlog.py

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

554554
futures = []
555555
with tempfile.TemporaryDirectory() as obj_dir:
556-
with concurrent.futures.ThreadPoolExecutor() as executor:
557556

558-
def add_module(image, target, obj_dir):
559-
return image, image.add_module(target, obj_dir)
557+
def add_module(image, target, obj_dir):
558+
return image, image.add_module(target, obj_dir)
560559

560+
max_worker = None
561+
if options.no_parallel_image_loading:
562+
max_worker = 1
563+
564+
with concurrent.futures.ThreadPoolExecutor(max_worker) as executor:
561565
for image in images_to_load:
562566
if image not in loaded_images:
563567
if image.uuid == uuid.UUID(int=0):
@@ -1526,6 +1530,7 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
15261530
"file_path": crashlog_path,
15271531
"load_all_images": options.load_all_images,
15281532
"crashed_only": options.crashed_only,
1533+
"no_parallel_image_loading": options.no_parallel_image_loading,
15291534
}
15301535
)
15311536
)
@@ -1718,6 +1723,13 @@ def CreateSymbolicateCrashLogOptions(
17181723
help="show source for all threads, not just the crashed thread",
17191724
default=False,
17201725
)
1726+
arg_parser.add_argument(
1727+
"--no-parallel-image-loading",
1728+
dest="no_parallel_image_loading",
1729+
action="store_true",
1730+
help=argparse.SUPPRESS,
1731+
default=False,
1732+
)
17211733
if add_interactive_options:
17221734
arg_parser.add_argument(
17231735
"-i",

lldb/examples/python/crashlog_scripted_process.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def set_crashlog(self, crashlog):
5353
class CrashLogOptions:
5454
load_all_images = False
5555
crashed_only = True
56+
no_parallel_image_loading = False
5657

5758
def __init__(self, exe_ctx: lldb.SBExecutionContext, args: lldb.SBStructuredData):
5859
super().__init__(exe_ctx, args)
@@ -84,6 +85,13 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: lldb.SBStructuredData
8485
if crashed_only.GetType() == lldb.eStructuredDataTypeBoolean:
8586
self.options.crashed_only = crashed_only.GetBooleanValue()
8687

88+
no_parallel_image_loading = args.GetValueForKey("no_parallel_image_loading")
89+
if no_parallel_image_loading and no_parallel_image_loading.IsValid():
90+
if no_parallel_image_loading.GetType() == lldb.eStructuredDataTypeBoolean:
91+
self.options.no_parallel_image_loading = (
92+
no_parallel_image_loading.GetBooleanValue()
93+
)
94+
8795
self.pid = super().get_process_id()
8896
self.crashed_thread_idx = 0
8997
self.exception = None

0 commit comments

Comments
 (0)