Skip to content

Commit

Permalink
Bug 1149085 - Handle if no memory reports are retrieved. r=mccr8
Browse files Browse the repository at this point in the history
Adds handling of the case when all child processes die/restart before memory
reports are retrieved.
  • Loading branch information
EricRahm committed Apr 2, 2015
1 parent 9260e00 commit 801196c
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions tools/get_about_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,21 @@ 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:
for f in memory_report_files:
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)
Expand All @@ -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:
Expand Down

0 comments on commit 801196c

Please sign in to comment.