mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1201597 - Part 2: Add an IPDL subprotocol for opening core dump files to
save heap snapsots into; r=mrbkap
This commit is contained in:
parent
a01fd11bd5
commit
46e4b0e593
@ -33,6 +33,7 @@ var loaderModules = {
|
|||||||
"toolkit/loader": Loader,
|
"toolkit/loader": Loader,
|
||||||
PromiseDebugging,
|
PromiseDebugging,
|
||||||
ThreadSafeChromeUtils,
|
ThreadSafeChromeUtils,
|
||||||
|
HeapSnapshot,
|
||||||
};
|
};
|
||||||
XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => {
|
XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => {
|
||||||
// addDebuggerToGlobal only allows adding the Debugger object to a global. The
|
// addDebuggerToGlobal only allows adding the Debugger object to a global. The
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
#include "mozilla/devtools/AutoMemMap.h"
|
#include "mozilla/devtools/AutoMemMap.h"
|
||||||
#include "mozilla/devtools/CoreDump.pb.h"
|
#include "mozilla/devtools/CoreDump.pb.h"
|
||||||
#include "mozilla/devtools/DeserializedNode.h"
|
#include "mozilla/devtools/DeserializedNode.h"
|
||||||
|
#include "mozilla/devtools/FileDescriptorOutputStream.h"
|
||||||
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
|
||||||
#include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
|
#include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
|
||||||
#include "mozilla/dom/ChromeUtils.h"
|
#include "mozilla/dom/ChromeUtils.h"
|
||||||
|
#include "mozilla/dom/ContentChild.h"
|
||||||
#include "mozilla/dom/HeapSnapshotBinding.h"
|
#include "mozilla/dom/HeapSnapshotBinding.h"
|
||||||
#include "mozilla/RangedPtr.h"
|
#include "mozilla/RangedPtr.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
|
||||||
#include "mozilla/UniquePtr.h"
|
|
||||||
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
@ -810,13 +811,6 @@ WriteHeapGraph(JSContext* cx,
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace devtools
|
|
||||||
|
|
||||||
namespace dom {
|
|
||||||
|
|
||||||
using namespace JS;
|
|
||||||
using namespace devtools;
|
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
msSinceProcessCreation(const TimeStamp& now)
|
msSinceProcessCreation(const TimeStamp& now)
|
||||||
{
|
{
|
||||||
@ -825,10 +819,10 @@ msSinceProcessCreation(const TimeStamp& now)
|
|||||||
return (unsigned long) duration.ToMilliseconds();
|
return (unsigned long) duration.ToMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the `$TEMP_DIR/XXXXXX-XXX.fxsnapshot` core dump file that heap
|
/* static */ already_AddRefed<nsIFile>
|
||||||
// snapshots are serialized into.
|
HeapSnapshot::CreateUniqueCoreDumpFile(ErrorResult& rv,
|
||||||
static already_AddRefed<nsIFile>
|
const TimeStamp& now,
|
||||||
createUniqueCoreDumpFile(ErrorResult& rv, const TimeStamp& now, nsAString& outFilePath)
|
nsAString& outFilePath)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIFile> file;
|
nsCOMPtr<nsIFile> file;
|
||||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
||||||
@ -851,6 +845,92 @@ createUniqueCoreDumpFile(ErrorResult& rv, const TimeStamp& now, nsAString& outFi
|
|||||||
return file.forget();
|
return file.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deletion policy for cleaning up PHeapSnapshotTempFileHelperChild pointers.
|
||||||
|
class DeleteHeapSnapshotTempFileHelperChild
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MOZ_CONSTEXPR DeleteHeapSnapshotTempFileHelperChild() { }
|
||||||
|
|
||||||
|
void operator()(PHeapSnapshotTempFileHelperChild* ptr) const {
|
||||||
|
NS_WARN_IF(!HeapSnapshotTempFileHelperChild::Send__delete__(ptr));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// A UniquePtr alias to automatically manage PHeapSnapshotTempFileHelperChild
|
||||||
|
// pointers.
|
||||||
|
using UniqueHeapSnapshotTempFileHelperChild = UniquePtr<PHeapSnapshotTempFileHelperChild,
|
||||||
|
DeleteHeapSnapshotTempFileHelperChild>;
|
||||||
|
|
||||||
|
// Get an nsIOutputStream that we can write the heap snapshot to. In non-e10s
|
||||||
|
// and in the e10s parent process, open a file directly and create an output
|
||||||
|
// stream for it. In e10s child processes, we are sandboxed without access to
|
||||||
|
// the filesystem. Use IPDL to request a file descriptor from the parent
|
||||||
|
// process.
|
||||||
|
static already_AddRefed<nsIOutputStream>
|
||||||
|
getCoreDumpOutputStream(ErrorResult& rv, TimeStamp& start, nsAString& outFilePath)
|
||||||
|
{
|
||||||
|
if (XRE_IsParentProcess()) {
|
||||||
|
// Create the file and open the output stream directly.
|
||||||
|
|
||||||
|
nsCOMPtr<nsIFile> file = HeapSnapshot::CreateUniqueCoreDumpFile(rv,
|
||||||
|
start,
|
||||||
|
outFilePath);
|
||||||
|
if (NS_WARN_IF(rv.Failed()))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIOutputStream> outputStream;
|
||||||
|
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), file,
|
||||||
|
PR_WRONLY, -1, 0);
|
||||||
|
if (NS_WARN_IF(rv.Failed()))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return outputStream.forget();
|
||||||
|
} else {
|
||||||
|
// Request a file descriptor from the parent process over IPDL.
|
||||||
|
|
||||||
|
auto cc = ContentChild::GetSingleton();
|
||||||
|
if (!cc) {
|
||||||
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
UniqueHeapSnapshotTempFileHelperChild helper(
|
||||||
|
cc->SendPHeapSnapshotTempFileHelperConstructor());
|
||||||
|
if (NS_WARN_IF(!helper)) {
|
||||||
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenHeapSnapshotTempFileResponse response;
|
||||||
|
if (!helper->SendOpenHeapSnapshotTempFile(&response)) {
|
||||||
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (response.type() == OpenHeapSnapshotTempFileResponse::Tnsresult) {
|
||||||
|
rv.Throw(response.get_nsresult());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto opened = response.get_OpenedFile();
|
||||||
|
outFilePath = opened.path();
|
||||||
|
nsCOMPtr<nsIOutputStream> outputStream =
|
||||||
|
FileDescriptorOutputStream::Create(opened.descriptor());
|
||||||
|
if (NS_WARN_IF(!outputStream)) {
|
||||||
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputStream.forget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace devtools
|
||||||
|
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
using namespace JS;
|
||||||
|
using namespace devtools;
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
|
ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
|
||||||
JSContext* cx,
|
JSContext* cx,
|
||||||
@ -865,14 +945,7 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
|
|||||||
uint32_t nodeCount = 0;
|
uint32_t nodeCount = 0;
|
||||||
uint32_t edgeCount = 0;
|
uint32_t edgeCount = 0;
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> file = createUniqueCoreDumpFile(rv, start, outFilePath);
|
nsCOMPtr<nsIOutputStream> outputStream = getCoreDumpOutputStream(rv, start, outFilePath);
|
||||||
if (NS_WARN_IF(rv.Failed()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIOutputStream> outputStream;
|
|
||||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), file,
|
|
||||||
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
|
||||||
-1, 0);
|
|
||||||
if (NS_WARN_IF(rv.Failed()))
|
if (NS_WARN_IF(rv.Failed()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "mozilla/HashFunctions.h"
|
#include "mozilla/HashFunctions.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
|
|
||||||
#include "CoreDump.pb.h"
|
#include "CoreDump.pb.h"
|
||||||
@ -130,6 +131,12 @@ public:
|
|||||||
uint32_t size,
|
uint32_t size,
|
||||||
ErrorResult& rv);
|
ErrorResult& rv);
|
||||||
|
|
||||||
|
// Creates the `$TEMP_DIR/XXXXXX-XXX.fxsnapshot` core dump file that heap
|
||||||
|
// snapshots are serialized into.
|
||||||
|
static already_AddRefed<nsIFile> CreateUniqueCoreDumpFile(ErrorResult& rv,
|
||||||
|
const TimeStamp& now,
|
||||||
|
nsAString& outFilePath);
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(HeapSnapshot)
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(HeapSnapshot)
|
||||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(HeapSnapshot)
|
MOZ_DECLARE_REFCOUNTED_TYPENAME(HeapSnapshot)
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_devtools_HeapSnapshotTempFileHelperChild_h
|
||||||
|
#define mozilla_devtools_HeapSnapshotTempFileHelperChild_h
|
||||||
|
|
||||||
|
#include "mozilla/devtools/PHeapSnapshotTempFileHelperChild.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace devtools {
|
||||||
|
|
||||||
|
class HeapSnapshotTempFileHelperChild : public PHeapSnapshotTempFileHelperChild
|
||||||
|
{
|
||||||
|
explicit HeapSnapshotTempFileHelperChild() { }
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline PHeapSnapshotTempFileHelperChild* Create();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* static */ inline PHeapSnapshotTempFileHelperChild*
|
||||||
|
HeapSnapshotTempFileHelperChild::Create()
|
||||||
|
{
|
||||||
|
return new HeapSnapshotTempFileHelperChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace devtools
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_devtools_HeapSnapshotTempFileHelperChild_h
|
@ -0,0 +1,53 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "mozilla/devtools/HeapSnapshot.h"
|
||||||
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
|
||||||
|
#include "mozilla/ErrorResult.h"
|
||||||
|
#include "private/pprio.h"
|
||||||
|
|
||||||
|
#include "nsIFile.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace devtools {
|
||||||
|
|
||||||
|
using ipc::FileDescriptor;
|
||||||
|
|
||||||
|
static bool
|
||||||
|
openFileFailure(ErrorResult& rv,
|
||||||
|
OpenHeapSnapshotTempFileResponse* outResponse)
|
||||||
|
{
|
||||||
|
*outResponse = rv.StealNSResult();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
HeapSnapshotTempFileHelperParent::RecvOpenHeapSnapshotTempFile(
|
||||||
|
OpenHeapSnapshotTempFileResponse* outResponse)
|
||||||
|
{
|
||||||
|
auto start = TimeStamp::Now();
|
||||||
|
ErrorResult rv;
|
||||||
|
nsAutoString filePath;
|
||||||
|
nsCOMPtr<nsIFile> file = HeapSnapshot::CreateUniqueCoreDumpFile(rv,
|
||||||
|
start,
|
||||||
|
filePath);
|
||||||
|
if (NS_WARN_IF(rv.Failed()))
|
||||||
|
return openFileFailure(rv, outResponse);
|
||||||
|
|
||||||
|
PRFileDesc* prfd;
|
||||||
|
rv = file->OpenNSPRFileDesc(PR_WRONLY, 0, &prfd);
|
||||||
|
if (NS_WARN_IF(rv.Failed()))
|
||||||
|
return openFileFailure(rv, outResponse);
|
||||||
|
|
||||||
|
FileDescriptor::PlatformHandleType handle =
|
||||||
|
FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(prfd));
|
||||||
|
FileDescriptor fd(handle);
|
||||||
|
*outResponse = OpenedFile(filePath, fd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace devtools
|
||||||
|
} // namespace mozilla
|
@ -0,0 +1,35 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_devtools_HeapSnapshotTempFileHelperParent_h
|
||||||
|
#define mozilla_devtools_HeapSnapshotTempFileHelperParent_h
|
||||||
|
|
||||||
|
#include "mozilla/devtools/PHeapSnapshotTempFileHelperParent.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace devtools {
|
||||||
|
|
||||||
|
class HeapSnapshotTempFileHelperParent : public PHeapSnapshotTempFileHelperParent
|
||||||
|
{
|
||||||
|
explicit HeapSnapshotTempFileHelperParent() { }
|
||||||
|
void ActorDestroy(ActorDestroyReason why) override { }
|
||||||
|
bool RecvOpenHeapSnapshotTempFile(OpenHeapSnapshotTempFileResponse* outResponse)
|
||||||
|
override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline PHeapSnapshotTempFileHelperParent* Create();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* static */ inline PHeapSnapshotTempFileHelperParent*
|
||||||
|
HeapSnapshotTempFileHelperParent::Create()
|
||||||
|
{
|
||||||
|
return new HeapSnapshotTempFileHelperParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace devtools
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_devtools_HeapSnapshotTempFileHelperParent_h
|
@ -0,0 +1,35 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
include protocol PContent;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace devtools {
|
||||||
|
|
||||||
|
struct OpenedFile
|
||||||
|
{
|
||||||
|
nsString path;
|
||||||
|
FileDescriptor descriptor;
|
||||||
|
};
|
||||||
|
|
||||||
|
union OpenHeapSnapshotTempFileResponse
|
||||||
|
{
|
||||||
|
nsresult;
|
||||||
|
OpenedFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
sync protocol PHeapSnapshotTempFileHelper
|
||||||
|
{
|
||||||
|
manager PContent;
|
||||||
|
|
||||||
|
parent:
|
||||||
|
sync OpenHeapSnapshotTempFile() returns (OpenHeapSnapshotTempFileResponse response);
|
||||||
|
|
||||||
|
__delete__();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace devtools
|
||||||
|
} // namespace mozilla
|
@ -7,8 +7,9 @@
|
|||||||
if CONFIG['ENABLE_TESTS']:
|
if CONFIG['ENABLE_TESTS']:
|
||||||
DIRS += ['tests/gtest']
|
DIRS += ['tests/gtest']
|
||||||
|
|
||||||
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
XPCSHELL_TESTS_MANIFESTS += [ 'tests/unit/xpcshell.ini' ]
|
||||||
MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
|
MOCHITEST_MANIFESTS += [ 'tests/mochitest/mochitest.ini' ]
|
||||||
|
MOCHITEST_CHROME_MANIFESTS += [ 'tests/mochitest/chrome.ini' ]
|
||||||
|
|
||||||
EXPORTS.mozilla.devtools += [
|
EXPORTS.mozilla.devtools += [
|
||||||
'AutoMemMap.h',
|
'AutoMemMap.h',
|
||||||
@ -16,15 +17,24 @@ EXPORTS.mozilla.devtools += [
|
|||||||
'DeserializedNode.h',
|
'DeserializedNode.h',
|
||||||
'FileDescriptorOutputStream.h',
|
'FileDescriptorOutputStream.h',
|
||||||
'HeapSnapshot.h',
|
'HeapSnapshot.h',
|
||||||
|
'HeapSnapshotTempFileHelperChild.h',
|
||||||
|
'HeapSnapshotTempFileHelperParent.h',
|
||||||
'ZeroCopyNSIOutputStream.h',
|
'ZeroCopyNSIOutputStream.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
IPDL_SOURCES += [
|
||||||
|
'PHeapSnapshotTempFileHelper.ipdl',
|
||||||
|
]
|
||||||
|
|
||||||
|
include('/ipc/chromium/chromium-config.mozbuild')
|
||||||
|
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'AutoMemMap.cpp',
|
'AutoMemMap.cpp',
|
||||||
'CoreDump.pb.cc',
|
'CoreDump.pb.cc',
|
||||||
'DeserializedNode.cpp',
|
'DeserializedNode.cpp',
|
||||||
'FileDescriptorOutputStream.cpp',
|
'FileDescriptorOutputStream.cpp',
|
||||||
'HeapSnapshot.cpp',
|
'HeapSnapshot.cpp',
|
||||||
|
'HeapSnapshotTempFileHelperParent.cpp',
|
||||||
'ZeroCopyNSIOutputStream.cpp',
|
'ZeroCopyNSIOutputStream.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
tags = devtools
|
||||||
|
support-files =
|
||||||
|
|
||||||
|
[test_saveHeapSnapshot_e10s_01.html]
|
||||||
|
|
@ -0,0 +1,82 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<!--
|
||||||
|
Bug 1201597 - Sanity test that we can take a heap snapshot in an e10s child process.
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>saveHeapSnapshot in e10s child processes</title>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="/tests/SimpleTest/SimpleTest.js">
|
||||||
|
</script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="application/javascript">
|
||||||
|
window.onerror = function (msg, url, line, col, err) {
|
||||||
|
ok(false, "@" + url + ":" + line + ":" + col + ": " + msg + "\n" + err.stack);
|
||||||
|
};
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var childFrameURL = "data:text/html,<!DOCTYPE HTML><html><body></body></html>";
|
||||||
|
|
||||||
|
// This function is stringified and loaded in the child process as a frame
|
||||||
|
// script.
|
||||||
|
function childFrameScript() {
|
||||||
|
try {
|
||||||
|
ChromeUtils.saveHeapSnapshot({ runtime: true });
|
||||||
|
} catch (err) {
|
||||||
|
sendAsyncMessage("testSaveHeapSnapshot:error",
|
||||||
|
{ error: err.toString() });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendAsyncMessage("testSaveHeapSnapshot:done", {});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick everything off on load.
|
||||||
|
window.onload = function () {
|
||||||
|
info("window.onload fired");
|
||||||
|
SpecialPowers.addPermission("browser", true, document);
|
||||||
|
SpecialPowers.pushPrefEnv({
|
||||||
|
"set": [
|
||||||
|
["dom.ipc.browser_frames.oop_by_default", true],
|
||||||
|
["dom.mozBrowserFramesEnabled", true],
|
||||||
|
["browser.pagethumbnails.capturing_disabled", true]
|
||||||
|
]
|
||||||
|
}, function () {
|
||||||
|
var iframe = document.createElement("iframe");
|
||||||
|
SpecialPowers.wrap(iframe).mozbrowser = true;
|
||||||
|
iframe.id = "iframe";
|
||||||
|
iframe.src = childFrameURL;
|
||||||
|
|
||||||
|
|
||||||
|
iframe.addEventListener("mozbrowserloadend", function onLoadEnd() {
|
||||||
|
iframe.removeEventListener("mozbrowserloadend", onLoadEnd);
|
||||||
|
info("iframe done loading");
|
||||||
|
|
||||||
|
var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||||
|
|
||||||
|
function onError(e) {
|
||||||
|
ok(false, e.data.error);
|
||||||
|
}
|
||||||
|
mm.addMessageListener("testSaveHeapSnapshot:error", onError);
|
||||||
|
|
||||||
|
mm.addMessageListener("testSaveHeapSnapshot:done", function onMsg() {
|
||||||
|
mm.removeMessageListener("testSaveHeapSnapshot:done", onMsg);
|
||||||
|
mm.removeMessageListener("testSaveHeapSnapshot:error", onError);
|
||||||
|
ok(true, "Saved heap snapshot in child process");
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
info("Loading frame script to save heap snapshot");
|
||||||
|
mm.loadFrameScript("data:,(" + encodeURI(childFrameScript.toString()) + ")();",
|
||||||
|
false);
|
||||||
|
});
|
||||||
|
|
||||||
|
info("Loading iframe");
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</window>
|
@ -24,7 +24,10 @@ const { CensusTreeNode } = require("devtools/shared/heapsnapshot/census-tree-nod
|
|||||||
|
|
||||||
// Always log packets when running tests. runxpcshelltests.py will throw
|
// Always log packets when running tests. runxpcshelltests.py will throw
|
||||||
// the output away anyway, unless you give it the --verbose flag.
|
// the output away anyway, unless you give it the --verbose flag.
|
||||||
Services.prefs.setBoolPref("devtools.debugger.log", true);
|
if (Services.appInfo &&
|
||||||
|
Services.appInfo.processType == Services.appInfo.PROCESS_TYPE_DEFAULT) {
|
||||||
|
Services.prefs.setBoolPref("devtools.debugger.log", true);
|
||||||
|
}
|
||||||
DevToolsUtils.dumpn.wantLogging = true;
|
DevToolsUtils.dumpn.wantLogging = true;
|
||||||
|
|
||||||
const SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"]
|
const SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"]
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
// Test saving a heap snapshot in the sandboxed e10s child process.
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
run_test_in_child("../unit/test_SaveHeapSnapshot.js");
|
||||||
|
}
|
@ -33,3 +33,4 @@ skip-if = os == 'linux' # Bug 1176173
|
|||||||
[test_ReadHeapSnapshot_worker.js]
|
[test_ReadHeapSnapshot_worker.js]
|
||||||
skip-if = os == 'linux' # Bug 1176173
|
skip-if = os == 'linux' # Bug 1176173
|
||||||
[test_SaveHeapSnapshot.js]
|
[test_SaveHeapSnapshot.js]
|
||||||
|
[test_saveHeapSnapshot_e10s_01.js]
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "mozilla/LookAndFeel.h"
|
#include "mozilla/LookAndFeel.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/ProcessHangMonitorIPC.h"
|
#include "mozilla/ProcessHangMonitorIPC.h"
|
||||||
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
|
||||||
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
||||||
#include "mozilla/dom/ContentBridgeChild.h"
|
#include "mozilla/dom/ContentBridgeChild.h"
|
||||||
#include "mozilla/dom/ContentBridgeParent.h"
|
#include "mozilla/dom/ContentBridgeParent.h"
|
||||||
@ -1453,6 +1454,20 @@ ContentChild::DeallocPHalChild(PHalChild* aHal)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devtools::PHeapSnapshotTempFileHelperChild*
|
||||||
|
ContentChild::AllocPHeapSnapshotTempFileHelperChild()
|
||||||
|
{
|
||||||
|
return devtools::HeapSnapshotTempFileHelperChild::Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ContentChild::DeallocPHeapSnapshotTempFileHelperChild(
|
||||||
|
devtools::PHeapSnapshotTempFileHelperChild* aHeapSnapshotHelper)
|
||||||
|
{
|
||||||
|
delete aHeapSnapshotHelper;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PIccChild*
|
PIccChild*
|
||||||
ContentChild::SendPIccConstructor(PIccChild* aActor,
|
ContentChild::SendPIccConstructor(PIccChild* aActor,
|
||||||
const uint32_t& aServiceId)
|
const uint32_t& aServiceId)
|
||||||
|
@ -167,6 +167,9 @@ public:
|
|||||||
virtual PHalChild* AllocPHalChild() override;
|
virtual PHalChild* AllocPHalChild() override;
|
||||||
virtual bool DeallocPHalChild(PHalChild*) override;
|
virtual bool DeallocPHalChild(PHalChild*) override;
|
||||||
|
|
||||||
|
virtual PHeapSnapshotTempFileHelperChild* AllocPHeapSnapshotTempFileHelperChild() override;
|
||||||
|
virtual bool DeallocPHeapSnapshotTempFileHelperChild(PHeapSnapshotTempFileHelperChild*) override;
|
||||||
|
|
||||||
PIccChild*
|
PIccChild*
|
||||||
SendPIccConstructor(PIccChild* aActor, const uint32_t& aServiceId);
|
SendPIccConstructor(PIccChild* aActor, const uint32_t& aServiceId);
|
||||||
virtual PIccChild*
|
virtual PIccChild*
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
#include "mozIApplication.h"
|
#include "mozIApplication.h"
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
#include "mozilla/ClearOnShutdown.h"
|
||||||
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
|
||||||
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
|
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
|
||||||
#include "mozilla/dom/DataStoreService.h"
|
#include "mozilla/dom/DataStoreService.h"
|
||||||
#include "mozilla/dom/DataTransfer.h"
|
#include "mozilla/dom/DataTransfer.h"
|
||||||
@ -3609,6 +3610,20 @@ ContentParent::DeallocPHalParent(hal_sandbox::PHalParent* aHal)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devtools::PHeapSnapshotTempFileHelperParent*
|
||||||
|
ContentParent::AllocPHeapSnapshotTempFileHelperParent()
|
||||||
|
{
|
||||||
|
return devtools::HeapSnapshotTempFileHelperParent::Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ContentParent::DeallocPHeapSnapshotTempFileHelperParent(
|
||||||
|
devtools::PHeapSnapshotTempFileHelperParent* aHeapSnapshotHelper)
|
||||||
|
{
|
||||||
|
delete aHeapSnapshotHelper;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PIccParent*
|
PIccParent*
|
||||||
ContentParent::AllocPIccParent(const uint32_t& aServiceId)
|
ContentParent::AllocPIccParent(const uint32_t& aServiceId)
|
||||||
{
|
{
|
||||||
|
@ -348,6 +348,9 @@ public:
|
|||||||
return PContentParent::RecvPHalConstructor(aActor);
|
return PContentParent::RecvPHalConstructor(aActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual PHeapSnapshotTempFileHelperParent*
|
||||||
|
AllocPHeapSnapshotTempFileHelperParent() override;
|
||||||
|
|
||||||
virtual PStorageParent* AllocPStorageParent() override;
|
virtual PStorageParent* AllocPStorageParent() override;
|
||||||
virtual bool RecvPStorageConstructor(PStorageParent* aActor) override {
|
virtual bool RecvPStorageConstructor(PStorageParent* aActor) override {
|
||||||
return PContentParent::RecvPStorageConstructor(aActor);
|
return PContentParent::RecvPStorageConstructor(aActor);
|
||||||
@ -630,6 +633,8 @@ private:
|
|||||||
|
|
||||||
virtual bool DeallocPHalParent(PHalParent*) override;
|
virtual bool DeallocPHalParent(PHalParent*) override;
|
||||||
|
|
||||||
|
virtual bool DeallocPHeapSnapshotTempFileHelperParent(PHeapSnapshotTempFileHelperParent*) override;
|
||||||
|
|
||||||
virtual PIccParent* AllocPIccParent(const uint32_t& aServiceId) override;
|
virtual PIccParent* AllocPIccParent(const uint32_t& aServiceId) override;
|
||||||
virtual bool DeallocPIccParent(PIccParent* aActor) override;
|
virtual bool DeallocPIccParent(PIccParent* aActor) override;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ include protocol PFileDescriptorSet;
|
|||||||
include protocol PFMRadio;
|
include protocol PFMRadio;
|
||||||
include protocol PFileSystemRequest;
|
include protocol PFileSystemRequest;
|
||||||
include protocol PHal;
|
include protocol PHal;
|
||||||
|
include protocol PHeapSnapshotTempFileHelper;
|
||||||
include protocol PIcc;
|
include protocol PIcc;
|
||||||
include protocol PProcessHangMonitor;
|
include protocol PProcessHangMonitor;
|
||||||
include protocol PImageBridge;
|
include protocol PImageBridge;
|
||||||
@ -432,6 +433,7 @@ prio(normal upto urgent) sync protocol PContent
|
|||||||
manages PFileDescriptorSet;
|
manages PFileDescriptorSet;
|
||||||
manages PFMRadio;
|
manages PFMRadio;
|
||||||
manages PHal;
|
manages PHal;
|
||||||
|
manages PHeapSnapshotTempFileHelper;
|
||||||
manages PIcc;
|
manages PIcc;
|
||||||
manages PMedia;
|
manages PMedia;
|
||||||
manages PMemoryReportRequest;
|
manages PMemoryReportRequest;
|
||||||
@ -758,6 +760,8 @@ parent:
|
|||||||
|
|
||||||
prio(urgent) async PHal();
|
prio(urgent) async PHal();
|
||||||
|
|
||||||
|
async PHeapSnapshotTempFileHelper();
|
||||||
|
|
||||||
PIcc(uint32_t serviceId);
|
PIcc(uint32_t serviceId);
|
||||||
|
|
||||||
PMobileConnection(uint32_t clientId);
|
PMobileConnection(uint32_t clientId);
|
||||||
|
Loading…
Reference in New Issue
Block a user