diff --git a/tools/get_about_memory.py b/tools/get_about_memory.py index d9a2879a..57c455e1 100755 --- a/tools/get_about_memory.py +++ b/tools/get_about_memory.py @@ -223,7 +223,13 @@ def do_work(): if f.startswith('memory-report-') or f.startswith('unified-memory-report-')] dmd_files = [f for f in new_files if f.startswith('dmd-')] - merged_reports_path = merge_files(out_dir, memory_report_files) + if memory_report_files: + merged_reports_path = os.path.abspath(merge_files(out_dir, memory_report_files)) + else: + # NB: It's possible this can happen if all child processes + # die/restart during measurement. + merged_reports_path = None + utils.pull_procrank_etc(out_dir) if not args.keep_individual_reports: @@ -231,7 +237,7 @@ def do_work(): os.remove(os.path.join(out_dir, f)) return (out_dir, - os.path.abspath(merged_reports_path), + merged_reports_path, [os.path.join(out_dir, f) for f in dmd_files]) return utils.run_and_delete_dir_on_exception(do_work, out_dir) @@ -243,42 +249,46 @@ def get_and_show_info(args): if dmd_files and not args.no_dmd: print('Got %d DMD dump(s).' % len(dmd_files)) - # Try to open the dump in Firefox. - about_memory_url = "about:memory?file=%s" % urllib.quote(merged_reports_path) - - opened_in_firefox = False - if args.open_in_firefox: - try: - # Open about_memory_url in Firefox, but don't display stdout or stderr. - # This isn't necessary if Firefox is already running (which it - # probably is), because in that case our |firefox| invocation will - # open a new tab in the existing process and then immediately exit. - # But if Firefox isn't already running, we don't want to pollute - # our terminal with its output. - - # If we wanted to be platform-independent, we might be able to use - # "NUL" on Windows. But the rest of this script already isn't - # platform-independent, so whatever. - fnull = open('/dev/null', 'w') - subprocess.Popen(['firefox', about_memory_url], stdout=fnull, stderr=fnull) - opened_in_firefox = True - + if merged_reports_path: + # Try to open the dump in Firefox. + about_memory_url = "about:memory?file=%s" % urllib.quote(merged_reports_path) + + opened_in_firefox = False + if args.open_in_firefox: + try: + # Open about_memory_url in Firefox, but don't display stdout or stderr. + # This isn't necessary if Firefox is already running (which it + # probably is), because in that case our |firefox| invocation will + # open a new tab in the existing process and then immediately exit. + # But if Firefox isn't already running, we don't want to pollute + # our terminal with its output. + + # If we wanted to be platform-independent, we might be able to use + # "NUL" on Windows. But the rest of this script already isn't + # platform-independent, so whatever. + fnull = open('/dev/null', 'w') + subprocess.Popen(['firefox', about_memory_url], stdout=fnull, stderr=fnull) + opened_in_firefox = True + + print() + print(textwrap.fill(textwrap.dedent('''\ + I just tried to open the memory report in Firefox. If that + didn't work for some reason, or if you want to open this report + at a later time, open the following URL in a Firefox nightly build: + ''')) + '\n\n ' + about_memory_url) + except (subprocess.CalledProcessError, OSError): + pass + + # If we didn't open in Firefox, output the message below. + if not opened_in_firefox: print() print(textwrap.fill(textwrap.dedent('''\ - I just tried to open the memory report in Firefox. If that - didn't work for some reason, or if you want to open this report - at a later time, open the following URL in a Firefox nightly build: + To view this report, open Firefox on this machine and load the + following URL: ''')) + '\n\n ' + about_memory_url) - except (subprocess.CalledProcessError, OSError): - pass - - # If we didn't open in Firefox, output the message below. - if not opened_in_firefox: - print() - print(textwrap.fill(textwrap.dedent('''\ - To view this report, open Firefox on this machine and load the - following URL: - ''')) + '\n\n ' + about_memory_url) + else: + print('') + print("Failed to retrieve memory reports") # Get GC/CC logs if necessary. if args.get_gc_cc_logs: