Backed out 3 changesets (bug 956961) for non-unified build bustage

Backed out changeset f1be89cb58b9 (bug 956961)
Backed out changeset 272b01e4f856 (bug 956961)
Backed out changeset 56907af18c66 (bug 956961)
This commit is contained in:
Wes Kocher 2014-07-02 15:03:29 -07:00
Родитель f87d695780
Коммит 03cdc19fec
13 изменённых файлов: 48 добавлений и 114 удалений

Просмотреть файл

@ -59,7 +59,6 @@
#include "nsIMutable.h"
#include "nsIObserverService.h"
#include "nsIScriptSecurityManager.h"
#include "nsMemoryInfoDumper.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
#include "nsXULAppAPI.h"
@ -193,22 +192,22 @@ public:
NS_DECL_ISUPPORTS
MemoryReportRequestChild(uint32_t aGeneration, bool aAnonymize,
const FileDescriptor& aDMDFile);
const nsAString& aDMDDumpIdent);
NS_IMETHOD Run();
private:
virtual ~MemoryReportRequestChild();
uint32_t mGeneration;
bool mAnonymize;
FileDescriptor mDMDFile;
nsString mDMDDumpIdent;
};
NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
MemoryReportRequestChild::MemoryReportRequestChild(
uint32_t aGeneration, bool aAnonymize, const FileDescriptor& aDMDFile)
uint32_t aGeneration, bool aAnonymize, const nsAString& aDMDDumpIdent)
: mGeneration(aGeneration), mAnonymize(aAnonymize),
mDMDFile(aDMDFile)
mDMDDumpIdent(aDMDDumpIdent)
{
MOZ_COUNT_CTOR(MemoryReportRequestChild);
}
@ -693,10 +692,10 @@ PMemoryReportRequestChild*
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile)
const nsString& aDMDDumpIdent)
{
MemoryReportRequestChild *actor =
new MemoryReportRequestChild(aGeneration, aAnonymize, aDMDFile);
new MemoryReportRequestChild(aGeneration, aAnonymize, aDMDDumpIdent);
actor->AddRef();
return actor;
}
@ -751,7 +750,7 @@ ContentChild::RecvPMemoryReportRequestConstructor(
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile)
const nsString& aDMDDumpIdent)
{
MemoryReportRequestChild *actor =
static_cast<MemoryReportRequestChild*>(aChild);
@ -785,7 +784,7 @@ NS_IMETHODIMP MemoryReportRequestChild::Run()
new MemoryReportsWrapper(&reports);
nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process);
mgr->GetReportsForThisProcessExtended(cb, wrappedReports, mAnonymize,
FileDescriptorToFILE(mDMDFile, "wb"));
mDMDDumpIdent);
bool sent = Send__delete__(this, mGeneration, reports);
return sent ? NS_OK : NS_ERROR_FAILURE;

Просмотреть файл

@ -155,7 +155,7 @@ public:
AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile) MOZ_OVERRIDE;
const nsString& aDMDDumpIdent) MOZ_OVERRIDE;
virtual bool
DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) MOZ_OVERRIDE;
@ -164,7 +164,7 @@ public:
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile) MOZ_OVERRIDE;
const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
virtual PCycleCollectWithLogsChild*
AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,

Просмотреть файл

@ -103,7 +103,6 @@
#include "nsIURIFixup.h"
#include "nsIWindowWatcher.h"
#include "nsIXULRuntime.h"
#include "nsMemoryInfoDumper.h"
#include "nsMemoryReporterManager.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
@ -2458,22 +2457,9 @@ ContentParent::Observe(nsISupports* aSubject,
// The pre-%n part of the string should be all ASCII, so the byte
// offset in identOffset should be correct as a char offset.
MOZ_ASSERT(cmsg[identOffset - 1] == '=');
FileDescriptor dmdFileDesc;
#ifdef MOZ_DMD
FILE *dmdFile;
nsAutoString dmdIdent(Substring(msg, identOffset));
nsresult rv = nsMemoryInfoDumper::OpenDMDFile(dmdIdent, Pid(), &dmdFile);
if (NS_WARN_IF(NS_FAILED(rv))) {
// Proceed with the memory report as if DMD were disabled.
dmdFile = nullptr;
}
if (dmdFile) {
dmdFileDesc = FILEToFileDescriptor(dmdFile);
fclose(dmdFile);
}
#endif
unused << SendPMemoryReportRequestConstructor(
generation, anonymize, minimize, dmdFileDesc);
generation, anonymize, minimize,
nsString(Substring(msg, identOffset)));
}
}
else if (!strcmp(aTopic, "child-gc-request")){
@ -2818,7 +2804,7 @@ PMemoryReportRequestParent*
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile)
const nsString &aDMDDumpIdent)
{
MemoryReportRequestParent* parent = new MemoryReportRequestParent();
return parent;

Просмотреть файл

@ -422,7 +422,7 @@ private:
AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile) MOZ_OVERRIDE;
const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
virtual bool DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor) MOZ_OVERRIDE;
virtual PCycleCollectWithLogsParent*

Просмотреть файл

@ -352,7 +352,7 @@ child:
async SetProcessSandbox();
PMemoryReportRequest(uint32_t generation, bool anonymize,
bool minimizeMemoryUsage, FileDescriptor DMDFile);
bool minimizeMemoryUsage, nsString DMDDumpIdent);
/**
* Notify the AudioChannelService in the child processes.

Просмотреть файл

@ -91,13 +91,11 @@ FILE*
FileDescriptorToFILE(const FileDescriptor& aDesc,
const char* aOpenMode)
{
// Debug builds check whether the handle was "used", even if it's
// invalid, so that needs to happen first.
FileDescriptor::PlatformHandleType handle = aDesc.PlatformHandle();
if (!aDesc.IsValid()) {
errno = EBADF;
return nullptr;
}
FileDescriptor::PlatformHandleType handle = aDesc.PlatformHandle();
#ifdef XP_WIN
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(handle), 0);
if (fd == -1) {

Просмотреть файл

@ -211,6 +211,15 @@ InstallSyscallReporter(void)
static int
InstallSyscallFilter(const sock_fprog *prog)
{
#ifdef MOZ_DMD
char* e = PR_GetEnv("DMD");
if (e && strcmp(e, "") != 0 && strcmp(e, "0") != 0) {
LOG_ERROR("SANDBOX DISABLED FOR DMD! See bug 956961.");
// Must treat this as "failure" in order to prevent infinite loop;
// cf. the PR_GET_SECCOMP check below.
return 1;
}
#endif
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
return 1;
}

Просмотреть файл

@ -47,14 +47,9 @@ nsGZFileWriter::Init(nsIFile* aFile)
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return InitANSIFileDesc(file);
}
NS_IMETHODIMP
nsGZFileWriter::InitANSIFileDesc(FILE* aFile)
{
mGZFile = gzdopen(dup(fileno(aFile)), "wb");
fclose(aFile);
mGZFile = gzdopen(dup(fileno(file)), "wb");
fclose(file);
// gzdopen returns nullptr on error.
if (NS_WARN_IF(!mGZFile)) {

Просмотреть файл

@ -8,11 +8,9 @@
%{C++
#include "nsDependentString.h"
#include <stdio.h>
%}
interface nsIFile;
[ptr] native FILE(FILE);
/**
* A simple interface for writing to a .gz file.
@ -24,7 +22,7 @@ interface nsIFile;
* The standard gunzip tool cannot decompress a raw gzip stream, but can handle
* the files produced by this interface.
*/
[scriptable, uuid(6bd5642c-1b90-4499-ba4b-199f27efaba5)]
[scriptable, uuid(a256f26a-c603-459e-b5a4-53b4877f2cd8)]
interface nsIGZFileWriter : nsISupports
{
/**
@ -36,12 +34,6 @@ interface nsIGZFileWriter : nsISupports
*/
void init(in nsIFile file);
/**
* Alternate version of init() for use when the file is already opened;
* e.g., with a FileDescriptor passed over IPC.
*/
[noscript] void initANSIFileDesc(in FILE file);
/**
* Write the given string to the file.
*/

Просмотреть файл

@ -5,14 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
%{C++
#include <stdio.h>
%}
interface nsIDOMWindow;
interface nsIRunnable;
interface nsISimpleEnumerator;
[ptr] native FILE(FILE);
/*
* Memory reporters measure Firefox's memory usage. They are primarily used to
@ -205,7 +201,7 @@ interface nsIFinishReportingCallback : nsISupports
void callback(in nsISupports data);
};
[scriptable, builtinclass, uuid(51e17609-e98a-47cc-9f95-095ef3c3823e)]
[scriptable, builtinclass, uuid(c27f8662-a0b7-45b3-8207-14d66b02b9c5)]
interface nsIMemoryReporterManager : nsISupports
{
/*
@ -298,14 +294,15 @@ interface nsIMemoryReporterManager : nsISupports
in boolean anonymize);
/*
* As above, but if DMD is enabled and |DMDFile| is non-null then
* write a DMD report to that file and close it.
* As above, but if DMD is enabled and |DMDDumpIdent| is non-empty
* then write a DMD report to a file in the usual temporary directory (see
* |dumpMemoryInfoToTempDir| in |nsIMemoryInfoDumper|.)
*/
[noscript] void
getReportsForThisProcessExtended(in nsIMemoryReporterCallback handleReport,
in nsISupports handleReportData,
in boolean anonymize,
in FILE DMDFile);
in AString DMDDumpIdent);
/*
* The memory reporter manager, for the most part, treats reporters

Просмотреть файл

@ -508,12 +508,12 @@ NS_IMPL_ISUPPORTS(DumpReportCallback, nsIHandleReportCallback)
static void
MakeFilename(const char* aPrefix, const nsAString& aIdentifier,
int aPid, const char* aSuffix, nsACString& aResult)
const char* aSuffix, nsACString& aResult)
{
aResult = nsPrintfCString("%s-%s-%d.%s",
aPrefix,
NS_ConvertUTF16toUTF8(aIdentifier).get(),
aPid, aSuffix);
getpid(), aSuffix);
}
#ifdef MOZ_DMD
@ -633,8 +633,7 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
// each process as was the case before bug 946407. This is so that
// the get_about_memory.py script in the B2G repository can
// determine when it's done waiting for files to appear.
MakeFilename("unified-memory-report", identifier, getpid(), "json.gz",
mrFilename);
MakeFilename("unified-memory-report", identifier, "json.gz", mrFilename);
nsCOMPtr<nsIFile> mrTmpFile;
nsresult rv;
@ -677,25 +676,24 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
#ifdef MOZ_DMD
nsresult
nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid,
FILE** aOutFile)
nsMemoryInfoDumper::DumpDMD(const nsAString& aIdentifier)
{
if (!dmd::IsRunning()) {
*aOutFile = nullptr;
return NS_OK;
}
nsresult rv;
// Create a filename like dmd-<identifier>-<pid>.txt.gz, which will be used
// if DMD is enabled.
nsCString dmdFilename;
MakeFilename("dmd", aIdentifier, aPid, "txt.gz", dmdFilename);
MakeFilename("dmd", aIdentifier, "txt.gz", dmdFilename);
// Open a new DMD file named |dmdFilename| in NS_OS_TEMP_DIR for writing,
// and dump DMD output to it. This must occur after the memory reporters
// have been run (above), but before the memory-reports file has been
// renamed (so scripts can detect the DMD file, if present).
nsresult rv;
nsCOMPtr<nsIFile> dmdFile;
rv = nsDumpUtils::OpenTempFile(dmdFilename,
getter_AddRefs(dmdFile),
@ -703,21 +701,15 @@ nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid,
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = dmdFile->OpenANSIFileDesc("wb", aOutFile);
NS_WARN_IF(NS_FAILED(rv));
return rv;
}
nsresult
nsMemoryInfoDumper::DumpDMDToFile(FILE* aFile)
{
nsRefPtr<nsGZFileWriter> dmdWriter = new nsGZFileWriter();
nsresult rv = dmdWriter->InitANSIFileDesc(aFile);
rv = dmdWriter->Init(dmdFile);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Dump DMD output to the file.
DMDWriteState state(dmdWriter);
dmd::Writer w(DMDWrite, &state);
dmd::Dump(w);
@ -726,21 +718,6 @@ nsMemoryInfoDumper::DumpDMDToFile(FILE* aFile)
NS_WARN_IF(NS_FAILED(rv));
return rv;
}
nsresult
nsMemoryInfoDumper::DumpDMD(const nsAString& aIdentifier)
{
nsresult rv;
FILE* dmdFile;
rv = OpenDMDFile(aIdentifier, getpid(), &dmdFile);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (!dmdFile) {
return NS_OK;
}
return DumpDMDToFile(dmdFile);
}
#endif // MOZ_DMD
NS_IMETHODIMP

Просмотреть файл

@ -8,7 +8,6 @@
#define mozilla_nsMemoryInfoDumper_h
#include "nsIMemoryInfoDumper.h"
#include <stdio.h>
class nsACString;
@ -32,14 +31,7 @@ public:
static void Initialize();
#ifdef MOZ_DMD
// Write a DMD report.
static nsresult DumpDMD(const nsAString& aIdentifier);
// Open an appropriately named file for a DMD report. If DMD is
// disabled, return a null FILE* instead.
static nsresult OpenDMDFile(const nsAString& aIdentifier, int aPid,
FILE** aOutFile);
// Write a DMD report to the given file and close it.
static nsresult DumpDMDToFile(FILE* aFile);
#endif
};

Просмотреть файл

@ -1104,17 +1104,8 @@ 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, parentDMDFile);
s->mAnonymize, s->mDMDDumpIdent);
s->mParentDone = true;
// If there are no remaining child processes, we can finish up immediately.
@ -1147,13 +1138,13 @@ nsMemoryReporterManager::GetReportsForThisProcess(
nsISupports* aHandleReportData, bool aAnonymize)
{
return GetReportsForThisProcessExtended(aHandleReport, aHandleReportData,
aAnonymize, nullptr);
aAnonymize, nsString());
}
NS_IMETHODIMP
nsMemoryReporterManager::GetReportsForThisProcessExtended(
nsIHandleReportCallback* aHandleReport, nsISupports* aHandleReportData,
bool aAnonymize, FILE* aDMDFile)
bool aAnonymize, const nsAString& aDMDDumpIdent)
{
// Memory reporters are not necessarily threadsafe, so this function must
// be called from the main thread.
@ -1162,13 +1153,11 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
}
#ifdef MOZ_DMD
if (aDMDFile) {
if (!aDMDDumpIdent.IsEmpty()) {
// 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;
@ -1183,8 +1172,8 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
}
#ifdef MOZ_DMD
if (aDMDFile) {
return nsMemoryInfoDumper::DumpDMDToFile(aDMDFile);
if (!aDMDDumpIdent.IsEmpty()) {
return nsMemoryInfoDumper::DumpDMD(aDMDDumpIdent);
}
#endif