Skip to content

Commit 68a9cb7

Browse files
authored
[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]>
1 parent 19bce17 commit 68a9cb7

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
@@ -557,11 +557,15 @@ def load_images(self, options, loaded_images=None):
557557

558558
futures = []
559559
with tempfile.TemporaryDirectory() as obj_dir:
560-
with concurrent.futures.ThreadPoolExecutor() as executor:
561560

562-
def add_module(image, target, obj_dir):
563-
return image, image.add_module(target, obj_dir)
561+
def add_module(image, target, obj_dir):
562+
return image, image.add_module(target, obj_dir)
564563

564+
max_worker = None
565+
if options.no_parallel_image_loading:
566+
max_worker = 1
567+
568+
with concurrent.futures.ThreadPoolExecutor(max_worker) as executor:
565569
for image in images_to_load:
566570
if image not in loaded_images:
567571
if image.uuid == uuid.UUID(int=0):
@@ -1530,6 +1534,7 @@ def load_crashlog_in_scripted_process(debugger, crashlog_path, options, result):
15301534
"file_path": crashlog_path,
15311535
"load_all_images": options.load_all_images,
15321536
"crashed_only": options.crashed_only,
1537+
"no_parallel_image_loading": options.no_parallel_image_loading,
15331538
}
15341539
)
15351540
)
@@ -1722,6 +1727,13 @@ def CreateSymbolicateCrashLogOptions(
17221727
help="show source for all threads, not just the crashed thread",
17231728
default=False,
17241729
)
1730+
arg_parser.add_argument(
1731+
"--no-parallel-image-loading",
1732+
dest="no_parallel_image_loading",
1733+
action="store_true",
1734+
help=argparse.SUPPRESS,
1735+
default=False,
1736+
)
17251737
if add_interactive_options:
17261738
arg_parser.add_argument(
17271739
"-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)