Bug 956961 - Open content processes' DMD log files in the parent process. r=njn

This commit is contained in:
Jed Davis
2014-07-02 11:27:48 -07:00
parent 17c5065ec9
commit 3e4ac648bb
11 changed files with 111 additions and 38 deletions

View File

@@ -1104,8 +1104,17 @@ nsMemoryReporterManager::StartGettingReports()
GetReportsState* s = mGetReportsState;
// Get reports for this process.
FILE *parentDMDFile = nullptr;
#ifdef MOZ_DMD
nsresult rv = nsMemoryInfoDumper::OpenDMDFile(s->mDMDDumpIdent, getpid(),
&parentDMDFile);
if (NS_WARN_IF(NS_FAILED(rv))) {
// Proceed with the memory report as if DMD were disabled.
parentDMDFile = nullptr;
}
#endif
GetReportsForThisProcessExtended(s->mHandleReport, s->mHandleReportData,
s->mAnonymize, s->mDMDDumpIdent);
s->mAnonymize, parentDMDFile);
s->mParentDone = true;
// If there are no remaining child processes, we can finish up immediately.
@@ -1138,13 +1147,13 @@ nsMemoryReporterManager::GetReportsForThisProcess(
nsISupports* aHandleReportData, bool aAnonymize)
{
return GetReportsForThisProcessExtended(aHandleReport, aHandleReportData,
aAnonymize, nsString());
aAnonymize, nullptr);
}
NS_IMETHODIMP
nsMemoryReporterManager::GetReportsForThisProcessExtended(
nsIHandleReportCallback* aHandleReport, nsISupports* aHandleReportData,
bool aAnonymize, const nsAString& aDMDDumpIdent)
bool aAnonymize, FILE* aDMDFile)
{
// Memory reporters are not necessarily threadsafe, so this function must
// be called from the main thread.
@@ -1153,11 +1162,13 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
}
#ifdef MOZ_DMD
if (!aDMDDumpIdent.IsEmpty()) {
if (aDMDFile) {
// Clear DMD's reportedness state before running the memory
// reporters, to avoid spurious twice-reported warnings.
dmd::ClearReports();
}
#else
MOZ_ASSERT(!aDMDFile);
#endif
MemoryReporterArray allReporters;
@@ -1172,8 +1183,8 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
}
#ifdef MOZ_DMD
if (!aDMDDumpIdent.IsEmpty()) {
return nsMemoryInfoDumper::DumpDMD(aDMDDumpIdent);
if (aDMDFile) {
return nsMemoryInfoDumper::DumpDMDToFile(aDMDFile);
}
#endif