Skip to content

Commit 38be2c6

Browse files
committedJun 14, 2019
Make crashlog.py less noisy
For end-users there is no point in printing dSYM load errors for system frameworks, since they will all fail and there's nothing they can do about it. This patch hides them by default and shows them when --verbose is present. Differential Revision: https://reviews.llvm.org/D63310 llvm-svn: 363412
1 parent 75312aa commit 38be2c6

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed
 

‎lldb/examples/python/crashlog.py

+27-9
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ def __init__(
246246
identifier,
247247
version,
248248
uuid,
249-
path):
249+
path,
250+
verbose):
250251
symbolication.Image.__init__(self, path, uuid)
251252
self.add_section(
252253
symbolication.Section(
@@ -255,6 +256,17 @@ def __init__(
255256
"__TEXT"))
256257
self.identifier = identifier
257258
self.version = version
259+
self.verbose = verbose
260+
261+
def show_symbol_progress(self):
262+
"""
263+
Hide progress output and errors from system frameworks as they are plentiful.
264+
"""
265+
if self.verbose:
266+
return True
267+
return not (self.path.startswith("/System/Library/") or
268+
self.path.startswith("/usr/lib/"))
269+
258270

259271
def find_matching_slice(self):
260272
dwarfdump_cmd_output = subprocess.check_output(
@@ -271,8 +283,9 @@ def find_matching_slice(self):
271283
return True
272284
if not self.resolved_path:
273285
self.unavailable = True
274-
print(("error\n error: unable to locate '%s' with UUID %s"
275-
% (self.path, self.get_normalized_uuid_string())))
286+
if self.show_symbol_progress():
287+
print(("error\n error: unable to locate '%s' with UUID %s"
288+
% (self.path, self.get_normalized_uuid_string())))
276289
return False
277290

278291
def locate_module_and_debug_symbols(self):
@@ -282,7 +295,8 @@ def locate_module_and_debug_symbols(self):
282295
# Mark this as resolved so we don't keep trying
283296
self.resolved = True
284297
uuid_str = self.get_normalized_uuid_string()
285-
print('Getting symbols for %s %s...' % (uuid_str, self.path), end=' ')
298+
if self.show_symbol_progress():
299+
print('Getting symbols for %s %s...' % (uuid_str, self.path), end=' ')
286300
if os.path.exists(self.dsymForUUIDBinary):
287301
dsym_for_uuid_command = '%s %s' % (
288302
self.dsymForUUIDBinary, uuid_str)
@@ -332,7 +346,7 @@ def locate_module_and_debug_symbols(self):
332346
self.unavailable = True
333347
return False
334348

335-
def __init__(self, path):
349+
def __init__(self, path, verbose):
336350
"""CrashLog constructor that take a path to a darwin crash log file"""
337351
symbolication.Symbolicator.__init__(self)
338352
self.path = os.path.expanduser(path)
@@ -345,6 +359,7 @@ def __init__(self, path):
345359
self.version = -1
346360
self.error = None
347361
self.target = None
362+
self.verbose = verbose
348363
# With possible initial component of ~ or ~user replaced by that user's
349364
# home directory.
350365
try:
@@ -491,7 +506,8 @@ def __init__(self, path):
491506
img_name.strip(),
492507
img_version.strip()
493508
if img_version else "",
494-
uuid.UUID(img_uuid), img_path)
509+
uuid.UUID(img_uuid), img_path,
510+
self.verbose)
495511
self.images.append(image)
496512
else:
497513
print("error: image regex failed for: %s" % line)
@@ -557,7 +573,9 @@ def create_target(self):
557573
if self.target:
558574
return self.target # success
559575
print('crashlog.create_target()...4')
560-
print('error: unable to locate any executables from the crash log')
576+
print('error: Unable to locate any executables from the crash log.')
577+
print(' Try loading the executable into lldb before running crashlog')
578+
print(' and/or make sure the .dSYM bundles can be found by Spotlight.')
561579
return self.target
562580

563581
def get_target(self):
@@ -683,7 +701,7 @@ def interactive_crashlogs(options, args):
683701
crash_logs = list()
684702
for crash_log_file in crash_log_files:
685703
# print 'crash_log_file = "%s"' % crash_log_file
686-
crash_log = CrashLog(crash_log_file)
704+
crash_log = CrashLog(crash_log_file, options.verbose)
687705
if crash_log.error:
688706
print(crash_log.error)
689707
continue
@@ -1022,7 +1040,7 @@ def SymbolicateCrashLogs(command_args):
10221040
interactive_crashlogs(options, args)
10231041
else:
10241042
for crash_log_file in args:
1025-
crash_log = CrashLog(crash_log_file)
1043+
crash_log = CrashLog(crash_log_file, options.verbose)
10261044
SymbolicateCrashLog(crash_log, options)
10271045
if __name__ == '__main__':
10281046
# Create a new debugger instance

0 commit comments

Comments
 (0)
Please sign in to comment.