Skip to content

Commit cc40507

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 cc40507

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
@@ -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: 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)