Backed out 2 changesets (bug 1726804) for causing sm bustages in geckoprocesstypes.

CLOSED TREE

Backed out changeset bf7f73fd1921 (bug 1726804)
Backed out changeset c9936f7534cb (bug 1726804)
This commit is contained in:
Alexandru Michis 2021-11-19 11:40:59 +02:00
parent d1b0aec796
commit 2cb5b32d02
32 changed files with 595 additions and 1185 deletions

View file

@ -221,8 +221,5 @@ tools/update-packaging/**/*refs.js
# Ignore backgroundtasks preferences files.
toolkit/components/backgroundtasks/defaults
# Uses preprocessing
toolkit/components/crashes/CrashManager.jsm
# Ignore pre-generated webpack and typescript transpiled files for translations
browser/extensions/translations/extension/

View file

@ -124,5 +124,4 @@ pth:toolkit/components/telemetry/tests/marionette/harness
pth:tools
pth:tools/moztreedocs
pth:xpcom/ds/tools
pth:xpcom/geckoprocesstypes_generator
pth:xpcom/idl-parser

View file

@ -864,20 +864,17 @@ static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) {
PROCTYPE_TO_WEBIDL_CASE(WebCOOPCOEP, WithCoopCoep);
PROCTYPE_TO_WEBIDL_CASE(WebServiceWorker, WebServiceWorker);
PROCTYPE_TO_WEBIDL_CASE(WebLargeAllocation, WebLargeAllocation);
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
PROCTYPE_TO_WEBIDL_CASE(procinfo_typename, webidl_typename);
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#undef SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef GECKO_PROCESS_TYPE
PROCTYPE_TO_WEBIDL_CASE(Browser, Browser);
PROCTYPE_TO_WEBIDL_CASE(IPDLUnitTest, IpdlUnitTest);
PROCTYPE_TO_WEBIDL_CASE(GMPlugin, GmpPlugin);
PROCTYPE_TO_WEBIDL_CASE(GPU, Gpu);
PROCTYPE_TO_WEBIDL_CASE(VR, Vr);
PROCTYPE_TO_WEBIDL_CASE(RDD, Rdd);
PROCTYPE_TO_WEBIDL_CASE(Socket, Socket);
PROCTYPE_TO_WEBIDL_CASE(RemoteSandboxBroker, RemoteSandboxBroker);
#ifdef MOZ_ENABLE_FORKSERVER
PROCTYPE_TO_WEBIDL_CASE(ForkServer, ForkServer);
#endif
PROCTYPE_TO_WEBIDL_CASE(Preallocated, Preallocated);
PROCTYPE_TO_WEBIDL_CASE(Unknown, Unknown);
}
@ -948,28 +945,36 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// These processes are handled separately.
return;
}
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
case GeckoProcessType::GeckoProcessType_##enum_name: { \
type = mozilla::ProcType::procinfo_typename; \
break; \
}
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef SKIP_PROCESS_TYPE_CONTENT
#undef GECKO_PROCESS_TYPE
case GeckoProcessType::GeckoProcessType_Default:
type = mozilla::ProcType::Browser;
break;
case GeckoProcessType::GeckoProcessType_GMPlugin:
type = mozilla::ProcType::GMPlugin;
break;
case GeckoProcessType::GeckoProcessType_GPU:
type = mozilla::ProcType::GPU;
break;
case GeckoProcessType::GeckoProcessType_VR:
type = mozilla::ProcType::VR;
break;
case GeckoProcessType::GeckoProcessType_RDD:
type = mozilla::ProcType::RDD;
break;
case GeckoProcessType::GeckoProcessType_Socket:
type = mozilla::ProcType::Socket;
break;
case GeckoProcessType::GeckoProcessType_RemoteSandboxBroker:
type = mozilla::ProcType::RemoteSandboxBroker;
break;
#ifdef MOZ_ENABLE_FORKSERVER
case GeckoProcessType::GeckoProcessType_ForkServer:
type = mozilla::ProcType::ForkServer;
break;
#endif
default:
// Leave the default Unknown value in |type|.
break;
}
requests.EmplaceBack(
/* aPid = */ childPid,
/* aProcessType = */ type,

View file

@ -14,6 +14,44 @@
#include "nsXULAppAPI.h"
#include "nsIFile.h"
// Consistency checking for nsICrashService constants. We depend on the
// equivalence between nsICrashService values and GeckoProcessType values
// in the code below. Making them equal also ensures that if new process
// types are added, people will know they may need to add crash reporting
// support in various places because compilation errors will be triggered here.
static_assert(nsICrashService::PROCESS_TYPE_MAIN ==
(int)GeckoProcessType_Default,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_CONTENT ==
(int)GeckoProcessType_Content,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_IPDLUNITTEST ==
(int)GeckoProcessType_IPDLUnitTest,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_GMPLUGIN ==
(int)GeckoProcessType_GMPlugin,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_GPU == (int)GeckoProcessType_GPU,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_VR == (int)GeckoProcessType_VR,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_RDD == (int)GeckoProcessType_RDD,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_SOCKET ==
(int)GeckoProcessType_Socket,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_SANDBOX_BROKER ==
(int)GeckoProcessType_RemoteSandboxBroker,
"GeckoProcessType enum is out of sync with nsICrashService!");
static_assert(nsICrashService::PROCESS_TYPE_FORKSERVER ==
(int)GeckoProcessType_ForkServer,
"GeckoProcessType enum is out of sync with nsICrashService!");
// Add new static asserts here if you add more process types.
// Update this static assert as well.
static_assert(nsICrashService::PROCESS_TYPE_FORKSERVER + 1 ==
(int)GeckoProcessType_End,
"GeckoProcessType enum is out of sync with nsICrashService!");
namespace mozilla {
namespace ipc {
@ -102,9 +140,8 @@ void CrashReporterHost::RecordCrashWithTelemetry(GeckoProcessType aProcessType,
nsCString key;
switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType_##enum_name: \
key.AssignLiteral(string_name); \
break;

View file

@ -164,12 +164,6 @@ ARCHIVE_FILES = {
"pattern": "**",
"dest": "tools/mozterm",
},
{
"source": buildconfig.topsrcdir,
"base": "xpcom/geckoprocesstypes_generator",
"pattern": "**",
"dest": "tools/geckoprocesstypes_generator",
},
{
"source": buildconfig.topsrcdir,
"base": "third_party/python/six",

View file

@ -1,5 +1,4 @@
../tools/mozterm
../tools/geckoprocesstypes_generator
../mozbase/manifestparser
../mozbase/mozcrash

View file

@ -1,5 +1,4 @@
--editable ../../python/mozterm
--editable ../../xpcom/geckoprocesstypes_generator
--editable ../mozbase/manifestparser
--editable ../mozbase/mozcrash

View file

@ -7,8 +7,6 @@ from __future__ import absolute_import
import os
import re
from geckoprocesstypes import process_types
def _get_default_logger():
from mozlog import get_default_logger
@ -185,9 +183,16 @@ def process_leak_log(
# This list is based on XRE_GeckoProcessTypeToString. ipdlunittest processes likely
# are not going to produce leak logs we will ever see.
knownProcessTypes = [
p.string_name for p in process_types if p.string_name != "ipdlunittest"
"default",
"forkserver",
"gmplugin",
"gpu",
"plugin",
"rdd",
"socket",
"tab",
"vr",
]
for processType in knownProcessTypes:

View file

@ -38,7 +38,6 @@ SEARCH_PATHS = [
"reftest",
"tools/mach",
"tools/mozterm",
"tools/geckoprocesstypes_generator",
"tools/six",
"tools/wptserve",
"web-platform",

View file

@ -160,7 +160,26 @@ var CrashManager = function(options) {
};
CrashManager.prototype = Object.freeze({
#includesubst @OBJDIR@/GeckoProcessTypes_CrashManager_map.js
// A crash in the main process.
PROCESS_TYPE_MAIN: "main",
// A crash in a content process.
PROCESS_TYPE_CONTENT: "content",
// A crash in a Gecko media plugin process.
PROCESS_TYPE_GMPLUGIN: "gmplugin",
// A crash in the GPU process.
PROCESS_TYPE_GPU: "gpu",
// A crash in the VR process.
PROCESS_TYPE_VR: "vr",
// A crash in the RDD process.
PROCESS_TYPE_RDD: "rdd",
// A crash in the socket process.
PROCESS_TYPE_SOCKET: "socket",
// A real crash.
CRASH_TYPE_CRASH: "crash",
@ -452,8 +471,13 @@ CrashManager.prototype = Object.freeze({
deferred.resolve();
}
// Send a telemetry ping for each non-main process crash
if (
this.isValidProcessType(processType) && this.isPingAllowed(processType)
processType === this.PROCESS_TYPE_CONTENT ||
processType === this.PROCESS_TYPE_GPU ||
processType === this.PROCESS_TYPE_VR ||
processType === this.PROCESS_TYPE_RDD ||
processType === this.PROCESS_TYPE_SOCKET
) {
this._sendCrashPing(id, processType, date, metadata);
}
@ -462,48 +486,6 @@ CrashManager.prototype = Object.freeze({
return promise;
},
/**
* Check that the processType parameter is a valid one:
* - it is a string
* - it is listed in this.processTypes
*
* @param processType (string) Process type to evaluate
*
* @return boolean True or false depending whether it is a legit one
*/
isValidProcessType(processType) {
if (typeof(processType) !== "string") {
return false;
}
for (const pt of Object.values(this.processTypes)) {
if (pt === processType) {
return true;
}
}
return false;
},
/**
* Check that processType is allowed to send a ping
*
* @param processType (string) Process type to check for
*
* @return boolean True or False depending on whether ping is allowed
**/
isPingAllowed(processType) {
#includesubst @OBJDIR@/GeckoProcessTypes_CrashManager_pings.js
// Should not even reach this because of isValidProcessType() but just in
// case we try to be cautious
if (!(processType in processPings)) {
return false;
}
return processPings[processType];
},
/**
* Returns a promise that is resolved only the crash with the specified id
* has been fully recorded.
@ -745,7 +727,7 @@ CrashManager.prototype = Object.freeze({
let crashID = lines[0];
let metadata = JSON.parse(lines[1]);
store.addCrash(
this.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
this.PROCESS_TYPE_MAIN,
this.CRASH_TYPE_CRASH,
crashID,
date,
@ -756,7 +738,7 @@ CrashManager.prototype = Object.freeze({
// If CrashPingUUID is not present then a ping was not generated
// by the crashreporter for this crash so we need to send one from
// here.
this._sendCrashPing(crashID, this.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT], date, metadata);
this._sendCrashPing(crashID, this.PROCESS_TYPE_MAIN, date, metadata);
}
break;
@ -765,7 +747,7 @@ CrashManager.prototype = Object.freeze({
if (lines.length == 3) {
let [crashID, result, remoteID] = lines;
store.addCrash(
this.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
this.PROCESS_TYPE_MAIN,
this.CRASH_TYPE_CRASH,
crashID,
date
@ -1304,7 +1286,7 @@ CrashStore.prototype = Object.freeze({
if (
count > this.HIGH_WATER_DAILY_THRESHOLD &&
processType != CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT]
processType != CrashManager.prototype.PROCESS_TYPE_MAIN
) {
return null;
}
@ -1369,12 +1351,6 @@ CrashStore.prototype = Object.freeze({
return true;
},
/**
* @param processType (string) One of the PROCESS_TYPE constants.
* @param crashType (string) One of the CRASH_TYPE constants.
*
* @return array of crashes
*/
getCrashesOfType(processType, crashType) {
let crashes = [];
for (let crash of this.crashes) {

View file

@ -170,12 +170,35 @@ CrashService.prototype = Object.freeze({
QueryInterface: ChromeUtils.generateQI(["nsICrashService", "nsIObserver"]),
async addCrash(processType, crashType, id) {
if (processType === Ci.nsIXULRuntime.PROCESS_TYPE_IPDLUNITTEST) {
switch (processType) {
case Ci.nsICrashService.PROCESS_TYPE_MAIN:
processType = Services.crashmanager.PROCESS_TYPE_MAIN;
break;
case Ci.nsICrashService.PROCESS_TYPE_CONTENT:
processType = Services.crashmanager.PROCESS_TYPE_CONTENT;
break;
case Ci.nsICrashService.PROCESS_TYPE_GMPLUGIN:
processType = Services.crashmanager.PROCESS_TYPE_GMPLUGIN;
break;
case Ci.nsICrashService.PROCESS_TYPE_GPU:
processType = Services.crashmanager.PROCESS_TYPE_GPU;
break;
case Ci.nsICrashService.PROCESS_TYPE_VR:
processType = Services.crashmanager.PROCESS_TYPE_VR;
break;
case Ci.nsICrashService.PROCESS_TYPE_RDD:
processType = Services.crashmanager.PROCESS_TYPE_RDD;
break;
case Ci.nsICrashService.PROCESS_TYPE_SOCKET:
processType = Services.crashmanager.PROCESS_TYPE_SOCKET;
break;
case Ci.nsICrashService.PROCESS_TYPE_IPDLUNITTEST:
// We'll never send crash reports for this type of process.
return;
default:
throw new Error("Unrecognized PROCESS_TYPE: " + processType);
}
processType = Services.crashmanager[processType];
let allThreads = false;
switch (crashType) {

View file

@ -1,30 +0,0 @@
# 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/.
from geckoprocesstypes import process_types
def main(output):
output.write(
"""
processTypes: {"""
)
for p in process_types:
string_name = p.string_name
if p.string_name == "default":
string_name = "main"
output.write(
"""
// A crash in the %(procname)s process.
%(proctype)d: "%(procname)s","""
% {
"proctype": p.enum_value,
"procname": string_name,
}
)
output.write(
"""
},"""
)

View file

@ -1,27 +0,0 @@
# 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/.
from geckoprocesstypes import process_types
def main(output):
output.write(""" let processPings = {""")
for p in process_types:
string_name = p.string_name
if p.string_name == "default":
string_name = "main"
output.write(
"""
"%(proctype)s": %(crashping)s,"""
% {
"proctype": string_name,
"crashping": "true" if p.crash_ping else "false",
}
)
output.write(
"""
};
"""
)

View file

@ -9,8 +9,6 @@ SPHINX_TREES["crash-manager"] = "docs"
with Files("docs/**"):
SCHEDULES.exclusive = ["docs"]
DEFINES["OBJDIR"] = OBJDIR
XPIDL_MODULE = "toolkit_crashservice"
XPIDL_SOURCES += [
@ -18,22 +16,8 @@ XPIDL_SOURCES += [
]
if CONFIG["MOZ_CRASHREPORTER"]:
GeneratedFile(
"GeckoProcessTypes_CrashManager_map.js",
script="gen_process_map.py",
entry_point="main",
)
GeneratedFile(
"GeckoProcessTypes_CrashManager_pings.js",
script="gen_process_pings.py",
entry_point="main",
)
EXTRA_PP_JS_MODULES += [
"CrashManager.jsm",
]
EXTRA_JS_MODULES += [
"CrashManager.jsm",
"CrashService.jsm",
]

View file

@ -11,7 +11,7 @@ interface nsICrashService : nsISupports
* Records the occurrence of a crash.
*
* @param processType
* One of the PROCESS_TYPE constants defined in nsIXULRuntime.
* One of the PROCESS_TYPE constants defined below.
* @param crashType
* One of the CRASH_TYPE constants defined below.
* @param id
@ -21,6 +21,19 @@ interface nsICrashService : nsISupports
*/
Promise addCrash(in long processType, in long crashType, in AString id);
// This list should be kept in sync with GeckoProcessTypes.h
const long PROCESS_TYPE_MAIN = 0;
const long PROCESS_TYPE_CONTENT = 2;
const long PROCESS_TYPE_IPDLUNITTEST = 3;
const long PROCESS_TYPE_GMPLUGIN = 4;
const long PROCESS_TYPE_GPU = 5;
const long PROCESS_TYPE_VR = 6;
const long PROCESS_TYPE_RDD = 7;
const long PROCESS_TYPE_SOCKET = 8;
const long PROCESS_TYPE_SANDBOX_BROKER = 9;
const long PROCESS_TYPE_FORKSERVER = 10;
// New process types should be added at the end of the above list.
const long CRASH_TYPE_CRASH = 0;
const long CRASH_TYPE_HANG = 1;
};

View file

@ -54,35 +54,6 @@ add_task(async function test_get_manager() {
await m.createDummyDump(false);
});
add_task(async function test_valid_process() {
let m = await getManager();
Assert.ok(m, "CrashManager obtained.");
Assert.ok(!m.isValidProcessType(42));
Assert.ok(!m.isValidProcessType(null));
Assert.ok(!m.isValidProcessType("default"));
Assert.ok(m.isValidProcessType("main"));
});
add_task(async function test_process_ping() {
let m = await getManager();
Assert.ok(m, "CrashManager obtained.");
Assert.ok(!m.isPingAllowed(42));
Assert.ok(!m.isPingAllowed(null));
Assert.ok(!m.isPingAllowed("default"));
Assert.ok(!m.isPingAllowed("main"));
Assert.ok(!m.isPingAllowed("ipdlunittest"));
Assert.ok(!m.isPingAllowed("gmplugin"));
Assert.ok(!m.isPingAllowed("remotesandboxbroker"));
Assert.ok(!m.isPingAllowed("forkserver"));
Assert.ok(m.isPingAllowed("tab"));
Assert.ok(m.isPingAllowed("gpu"));
});
// Unsubmitted dump files on disk are detected properly.
add_task(async function test_pending_dumps() {
let m = await getManager();
@ -215,12 +186,7 @@ add_task(async function test_prune_old() {
let oldDate = new Date(Date.now() - 86400000);
let newDate = new Date(Date.now() - 10000);
await m.createEventsFile("1", "crash.main.3", oldDate, "id1", "{}");
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.CRASH_TYPE_CRASH,
"id2",
newDate
);
await m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH, "id2", newDate);
await m.aggregateEventsFiles();
@ -466,68 +432,68 @@ add_task(async function test_addCrash() {
Assert.equal(crashes.length, 0);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"main-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_HANG,
"main-hang",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.PROCESS_TYPE_CONTENT,
m.CRASH_TYPE_CRASH,
"content-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.PROCESS_TYPE_CONTENT,
m.CRASH_TYPE_HANG,
"content-hang",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GMPLUGIN],
m.PROCESS_TYPE_GMPLUGIN,
m.CRASH_TYPE_CRASH,
"gmplugin-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GPU],
m.PROCESS_TYPE_GPU,
m.CRASH_TYPE_CRASH,
"gpu-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_VR],
m.PROCESS_TYPE_VR,
m.CRASH_TYPE_CRASH,
"vr-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_RDD],
m.PROCESS_TYPE_RDD,
m.CRASH_TYPE_CRASH,
"rdd-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_SOCKET],
m.PROCESS_TYPE_SOCKET,
m.CRASH_TYPE_CRASH,
"socket-crash",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"changing-item",
DUMMY_DATE
);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.PROCESS_TYPE_CONTENT,
m.CRASH_TYPE_HANG,
"changing-item",
DUMMY_DATE_2
@ -541,170 +507,76 @@ add_task(async function test_addCrash() {
let crash = map.get("main-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT] +
"-" +
m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH));
crash = map.get("main-hang");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT] +
"-" +
m.CRASH_TYPE_HANG
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.CRASH_TYPE_HANG
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_HANG);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_HANG));
crash = map.get("content-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT] +
"-" +
m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH));
crash = map.get("content-hang");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT] +
"-" +
m.CRASH_TYPE_HANG
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.CRASH_TYPE_HANG
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_HANG);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG));
crash = map.get("gmplugin-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GMPLUGIN] +
"-" +
m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GMPLUGIN],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_GMPLUGIN + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_GMPLUGIN, m.CRASH_TYPE_CRASH));
crash = map.get("gpu-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GPU] + "-" + m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GPU],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_GPU + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_GPU, m.CRASH_TYPE_CRASH));
crash = map.get("vr-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_VR] + "-" + m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_VR],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_VR + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_VR, m.CRASH_TYPE_CRASH));
crash = map.get("rdd-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_RDD] + "-" + m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_RDD],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_RDD + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_RDD, m.CRASH_TYPE_CRASH));
crash = map.get("socket-crash");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_SOCKET] +
"-" +
m.CRASH_TYPE_CRASH
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_SOCKET],
m.CRASH_TYPE_CRASH
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_SOCKET + "-" + m.CRASH_TYPE_CRASH);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_SOCKET, m.CRASH_TYPE_CRASH));
crash = map.get("changing-item");
Assert.ok(!!crash);
Assert.equal(crash.crashDate, DUMMY_DATE_2);
Assert.equal(
crash.type,
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT] +
"-" +
m.CRASH_TYPE_HANG
);
Assert.ok(
crash.isOfType(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.CRASH_TYPE_HANG
)
);
Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_HANG);
Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG));
});
add_task(async function test_child_process_crash_ping() {
let m = await getManager();
const EXPECTED_PROCESSES = [
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GPU],
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_VR],
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_RDD],
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_SOCKET],
m.PROCESS_TYPE_CONTENT,
m.PROCESS_TYPE_GPU,
m.PROCESS_TYPE_VR,
m.PROCESS_TYPE_RDD,
m.PROCESS_TYPE_SOCKET,
];
const UNEXPECTED_PROCESSES = [
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_GMPLUGIN],
m.PROCESS_TYPE_GMPLUGIN,
null,
12, // non-string process type
];
@ -715,10 +587,7 @@ add_task(async function test_child_process_crash_ping() {
// Add a child-process crash for each allowed process type.
for (let p of EXPECTED_PROCESSES) {
// Generate a ping.
const remoteType =
p === m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT]
? "web"
: undefined;
const remoteType = p === m.PROCESS_TYPE_CONTENT ? "web" : undefined;
let id = await m.createDummyDump();
await m.addCrash(p, m.CRASH_TYPE_CRASH, id, DUMMY_DATE, {
RemoteType: remoteType,
@ -799,7 +668,7 @@ add_task(async function test_addSubmissionAttemptAndResult() {
Assert.equal(crashes.length, 0);
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"main-crash",
DUMMY_DATE
@ -846,7 +715,7 @@ add_task(async function test_addSubmissionAttemptEarlyCall() {
});
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"main-crash",
DUMMY_DATE
@ -870,7 +739,7 @@ add_task(async function test_setCrashClassifications() {
let m = await getManager();
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"main-crash",
DUMMY_DATE
@ -884,7 +753,7 @@ add_task(async function test_setRemoteCrashID() {
let m = await getManager();
await m.addCrash(
m.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
m.PROCESS_TYPE_MAIN,
m.CRASH_TYPE_CRASH,
"main-crash",
DUMMY_DATE

View file

@ -65,7 +65,7 @@ async function teardown() {
async function addCrash(id, type = Ci.nsICrashService.CRASH_TYPE_CRASH) {
let cs = Cc["@mozilla.org/crashservice;1"].getService(Ci.nsICrashService);
return cs.addCrash(Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT, type, id);
return cs.addCrash(Ci.nsICrashService.PROCESS_TYPE_CONTENT, type, id);
}
async function getCrash(crashId) {

View file

@ -19,6 +19,13 @@ const DUMMY_DATE_2 = new Date(Date.now() - 5 * 24 * 60 * 60 * 1000);
DUMMY_DATE_2.setMilliseconds(0);
const {
PROCESS_TYPE_MAIN,
PROCESS_TYPE_CONTENT,
PROCESS_TYPE_GMPLUGIN,
PROCESS_TYPE_GPU,
PROCESS_TYPE_VR,
PROCESS_TYPE_RDD,
PROCESS_TYPE_SOCKET,
CRASH_TYPE_CRASH,
CRASH_TYPE_HANG,
SUBMISSION_RESULT_OK,
@ -51,16 +58,7 @@ add_task(async function test_add_crash() {
Assert.equal(s.crashesCount, 0);
let d = new Date(Date.now() - 5000);
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"id1",
d
)
);
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d));
Assert.equal(s.crashesCount, 1);
@ -71,32 +69,14 @@ add_task(async function test_add_crash() {
Assert.equal(c.id, "id1", "ID set properly.");
Assert.equal(c.crashDate.getTime(), d.getTime(), "Date set.");
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"id2",
new Date()
)
);
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
});
add_task(async function test_reset() {
let s = await getStore();
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"id1",
DUMMY_DATE
)
);
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", DUMMY_DATE));
Assert.equal(s.crashes.length, 1);
s.reset();
Assert.equal(s.crashes.length, 0);
@ -109,26 +89,8 @@ add_task(async function test_save_load() {
let d1 = new Date();
let d2 = new Date(d1.getTime() - 10000);
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"id1",
d1
)
);
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"id2",
d2
)
);
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d1));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", d2));
Assert.ok(s.addSubmissionAttempt("id1", "sub1", d1));
Assert.ok(s.addSubmissionResult("id1", "sub1", d2, SUBMISSION_RESULT_OK));
Assert.ok(s.setRemoteCrashID("id1", "bp-1"));
@ -169,115 +131,259 @@ add_task(async function test_corrupt_json() {
Assert.equal(date.getTime(), s.corruptDate.getTime());
});
async function test_add_process_crash(processType) {
add_task(async function test_add_main_crash() {
let s = await getStore();
const ptName = CrashManager.prototype.processTypes[processType];
Assert.ok(s.addCrash(ptName, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, ptName + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(ptName, CRASH_TYPE_CRASH));
Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH));
Assert.ok(s.addCrash(ptName, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
// Duplicate.
Assert.ok(s.addCrash(ptName, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(ptName, CRASH_TYPE_CRASH, "id3", new Date(), {
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id3", new Date(), {
OOMAllocationSize: 1048576,
})
);
Assert.equal(s.crashesCount, 3);
Assert.deepEqual(s.crashes[2].metadata, { OOMAllocationSize: 1048576 });
let crashes = s.getCrashesOfType(ptName, CRASH_TYPE_CRASH);
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 3);
}
});
async function test_add_process_hang(processType) {
add_task(async function test_add_main_hang() {
let s = await getStore();
const ptName = CrashManager.prototype.processTypes[processType];
Assert.ok(s.addCrash(ptName, CRASH_TYPE_HANG, "id1", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date()));
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, ptName + "-" + CRASH_TYPE_HANG);
Assert.ok(c.isOfType(ptName, CRASH_TYPE_HANG));
Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG);
Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG));
Assert.ok(s.addCrash(ptName, CRASH_TYPE_HANG, "id2", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
Assert.ok(s.addCrash(ptName, CRASH_TYPE_HANG, "id1", new Date()));
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date()));
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(ptName, CRASH_TYPE_HANG);
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 2);
}
});
function iterate_over_processTypes(fn1, fn2) {
for (const pt in CrashManager.prototype.processTypes) {
const ptName = CrashManager.prototype.processTypes[pt];
if (pt !== Ci.nsIXULRuntime.PROCESS_TYPE_IPDLUNITTEST) {
fn1(pt, ptName);
if (
pt === Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT ||
pt === Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
) {
fn2(pt, ptName);
}
}
}
}
add_task(async function test_add_content_crash() {
let s = await getStore();
iterate_over_processTypes(
(pt, _) => {
add_task(test_add_process_crash.bind(null, pt));
},
(pt, _) => {
add_task(test_add_process_hang.bind(null, pt));
}
);
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH));
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id2", new Date())
);
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_content_hang() {
let s = await getStore();
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
);
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG);
Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG));
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id2", new Date())
);
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
);
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_gmplugin_crash() {
let s = await getStore();
Assert.ok(
s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_GMPLUGIN + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH));
Assert.ok(
s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id2", new Date())
);
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_gpu_crash() {
let s = await getStore();
Assert.ok(s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_GPU + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH));
Assert.ok(s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
Assert.ok(s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_vr_crash() {
let s = await getStore();
Assert.ok(s.addCrash(PROCESS_TYPE_VR, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_VR + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_VR, CRASH_TYPE_CRASH));
Assert.ok(s.addCrash(PROCESS_TYPE_VR, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
Assert.ok(s.addCrash(PROCESS_TYPE_VR, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_VR, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_rdd_crash() {
let s = await getStore();
Assert.ok(s.addCrash(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_RDD + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH));
Assert.ok(s.addCrash(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH, "id2", new Date()));
Assert.equal(s.crashesCount, 2);
Assert.ok(s.addCrash(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH, "id1", new Date()));
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_socket_crash() {
let s = await getStore();
Assert.ok(
s.addCrash(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 1);
let c = s.crashes[0];
Assert.ok(c.crashDate);
Assert.equal(c.type, PROCESS_TYPE_SOCKET + "-" + CRASH_TYPE_CRASH);
Assert.ok(c.isOfType(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH));
Assert.ok(
s.addCrash(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH, "id2", new Date())
);
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH, "id1", new Date())
);
Assert.equal(s.crashesCount, 2);
let crashes = s.getCrashesOfType(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
});
add_task(async function test_add_mixed_types() {
let s = await getStore();
let allAdd = true;
iterate_over_processTypes(
(_, ptName) => {
allAdd =
allAdd &&
s.addCrash(ptName, CRASH_TYPE_CRASH, ptName + "crash", new Date());
},
(_, ptName) => {
allAdd =
allAdd &&
Assert.ok(
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mcrash", new Date()) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mhang", new Date()) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_HANG,
"mhang",
PROCESS_TYPE_CONTENT,
CRASH_TYPE_CRASH,
"ccrash",
new Date()
);
}
) &&
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "chang", new Date()) &&
s.addCrash(
PROCESS_TYPE_GMPLUGIN,
CRASH_TYPE_CRASH,
"gmpcrash",
new Date()
) &&
s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "gpucrash", new Date()) &&
s.addCrash(PROCESS_TYPE_VR, CRASH_TYPE_CRASH, "vrcrash", new Date()) &&
s.addCrash(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH, "rddcrash", new Date()) &&
s.addCrash(
PROCESS_TYPE_SOCKET,
CRASH_TYPE_CRASH,
"socketcrash",
new Date()
)
);
const expectedCrashes = Object.keys(CrashManager.prototype.processTypes)
.length;
Assert.ok(allAdd);
Assert.equal(s.crashesCount, expectedCrashes);
Assert.equal(s.crashesCount, 9);
await s.save();
@ -286,18 +392,26 @@ add_task(async function test_add_mixed_types() {
await s.load();
Assert.equal(s.crashesCount, expectedCrashes);
Assert.equal(s.crashesCount, 9);
iterate_over_processTypes(
(_, ptName) => {
const crashes = s.getCrashesOfType(ptName, CRASH_TYPE_CRASH);
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_VR, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_RDD, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
crashes = s.getCrashesOfType(PROCESS_TYPE_SOCKET, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 1);
},
(_, ptName) => {
const hangs = s.getCrashesOfType(ptName, CRASH_TYPE_HANG);
Assert.equal(hangs.length, 1);
}
);
});
// Crashes added beyond the high water mark behave properly.
@ -310,173 +424,41 @@ add_task(async function test_high_water() {
let i = 0;
for (; i < s.HIGH_WATER_DAILY_THRESHOLD; i++) {
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"mc1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"mc2" + i,
d2
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_HANG,
"mh1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_HANG,
"mh2" + i,
d2
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_CRASH,
"cc1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_CRASH,
"cc2" + i,
d2
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_HANG,
"ch1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_HANG,
"ch2" + i,
d2
)
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2) &&
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1) &&
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2) &&
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1) &&
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2)
);
}
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"mc1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"mc2" + i,
d2
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_HANG,
"mh1" + i,
d1
) &&
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_HANG,
"mh2" + i,
d2
)
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2)
);
Assert.ok(
!s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_CRASH,
"cc1" + i,
d1
)
);
Assert.ok(
!s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_CRASH,
"cc2" + i,
d2
)
);
Assert.ok(
!s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_HANG,
"ch1" + i,
d1
)
);
Assert.ok(
!s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
],
CRASH_TYPE_HANG,
"ch2" + i,
d2
)
);
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1));
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2));
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1));
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2));
// We preserve main process crashes and hangs. Content crashes and
// hangs beyond should be discarded.
Assert.equal(s.crashesCount, 8 * s.HIGH_WATER_DAILY_THRESHOLD + 4);
let crashes = s.getCrashesOfType(
CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
CRASH_TYPE_CRASH
);
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
crashes = s.getCrashesOfType(
CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
CRASH_TYPE_HANG
);
crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
crashes = s.getCrashesOfType(
CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
CRASH_TYPE_CRASH
);
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
crashes = s.getCrashesOfType(
CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT],
CRASH_TYPE_HANG
);
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
// But raw counts should be preserved.
@ -486,52 +468,20 @@ add_task(async function test_high_water() {
Assert.ok(s._countsByDay.has(day2));
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
] +
"-" +
CRASH_TYPE_CRASH
),
s._countsByDay.get(day1).get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
] +
"-" +
CRASH_TYPE_HANG
),
s._countsByDay.get(day1).get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
] +
"-" +
CRASH_TYPE_CRASH
),
s._countsByDay.get(day1).get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
] +
"-" +
CRASH_TYPE_HANG
),
s._countsByDay.get(day1).get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
@ -542,52 +492,20 @@ add_task(async function test_high_water() {
Assert.ok(s._countsByDay.has(day2));
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
] +
"-" +
CRASH_TYPE_CRASH
),
s._countsByDay.get(day1).get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
] +
"-" +
CRASH_TYPE_HANG
),
s._countsByDay.get(day1).get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
] +
"-" +
CRASH_TYPE_CRASH
),
s._countsByDay.get(day1).get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
Assert.equal(
s._countsByDay
.get(day1)
.get(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
] +
"-" +
CRASH_TYPE_HANG
),
s._countsByDay.get(day1).get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
s.HIGH_WATER_DAILY_THRESHOLD + 1
);
});
@ -596,14 +514,7 @@ add_task(async function test_addSubmission() {
let s = await getStore();
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"crash1",
DUMMY_DATE
)
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1", DUMMY_DATE)
);
Assert.ok(s.addSubmissionAttempt("crash1", "sub1", DUMMY_DATE));
@ -647,14 +558,7 @@ add_task(async function test_setCrashClassification() {
let s = await getStore();
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"crash1",
new Date()
)
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1", new Date())
);
let classifications = s.crashes[0].classifications;
Assert.ok(!!classifications);
@ -671,14 +575,7 @@ add_task(async function test_setRemoteCrashID() {
let s = await getStore();
Assert.ok(
s.addCrash(
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
],
CRASH_TYPE_CRASH,
"crash1",
new Date()
)
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1", new Date())
);
Assert.equal(s.crashes[0].remoteID, null);
Assert.ok(s.setRemoteCrashID("crash1", "bp-1"));

View file

@ -41,21 +41,18 @@ enum class ProcType {
WebLargeAllocation,
WebCOOPCOEP,
WebServiceWorker,
// the rest matches GeckoProcessTypes.h
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
procinfo_typename,
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#undef SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef GECKO_PROCESS_TYPE
// the rest matches GeckoProcessTypes.h
Browser, // Default is named Browser here
IPDLUnitTest,
GMPlugin,
GPU,
VR,
RDD,
Socket,
RemoteSandboxBroker,
#ifdef MOZ_ENABLE_FORKSERVER
ForkServer,
#endif
Preallocated,
// Unknown type of process
Unknown,

View file

@ -38,12 +38,7 @@ add_task(async function test_main_process_crash() {
let crashes = await cm.getCrashes();
Assert.equal(crashes.length, 1);
let crash = crashes[0];
Assert.ok(
crash.isOfType(
cm.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
cm.CRASH_TYPE_CRASH
)
);
Assert.ok(crash.isOfType(cm.PROCESS_TYPE_MAIN, cm.CRASH_TYPE_CRASH));
Assert.equal(crash.id + ".dmp", basename, "ID recorded properly");
Assert.equal(crash.metadata.ShutdownProgress, "event-test");
Assert.ok("TelemetrySessionId" in crash.metadata);

View file

@ -102,7 +102,6 @@ inline void CommandLineArg<uint64_t>::Put(uint64_t aValue,
}
#if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
@ -126,10 +125,6 @@ static CommandLineArg<bool> sSafeMode{"-safeMode", "safemode"};
static CommandLineArg<bool> sIsForBrowser{"-isForBrowser", "isforbrowser"};
static CommandLineArg<bool> sNotForBrowser{"-notForBrowser", "notforbrowser"};
#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
} // namespace geckoargs
} // namespace mozilla

View file

@ -973,15 +973,22 @@ nsXULAppInfo::GetWidgetToolkit(nsACString& aResult) {
// Ensure that the GeckoProcessType enum, defined in xpcom/build/nsXULAppAPI.h,
// is synchronized with the const unsigned longs defined in
// xpcom/system/nsIXULRuntime.idl.
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
static_assert(nsIXULRuntime::PROCESS_TYPE_##allcaps_name == \
static_cast<int>(GeckoProcessType_##enum_name), \
#define SYNC_ENUMS(a, b) \
static_assert(nsIXULRuntime::PROCESS_TYPE_##a == \
static_cast<int>(GeckoProcessType_##b), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with " \
"nsIXULRuntime.idl");
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
SYNC_ENUMS(DEFAULT, Default)
SYNC_ENUMS(CONTENT, Content)
SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
SYNC_ENUMS(GMPLUGIN, GMPlugin)
SYNC_ENUMS(GPU, GPU)
SYNC_ENUMS(VR, VR)
SYNC_ENUMS(RDD, RDD)
SYNC_ENUMS(SOCKET, Socket)
SYNC_ENUMS(SANDBOX_BROKER, RemoteSandboxBroker)
SYNC_ENUMS(FORKSERVER, ForkServer)
// .. and ensure that that is all of them:
static_assert(GeckoProcessType_ForkServer + 1 == GeckoProcessType_End,
@ -5623,10 +5630,9 @@ bool XRE_IsE10sParentProcess() {
#endif
}
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
bool XRE_Is##proc_typename##Process() { \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
bool XRE_Is##xre_name##Process() { \
return XRE_GetProcessType() == GeckoProcessType_##enum_name; \
}
#include "mozilla/GeckoProcessTypes.h"
@ -5732,11 +5738,10 @@ mozilla::BinPathType XRE_GetChildProcBinPathType(
}
switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType_##enum_name: \
return BinPathType::process_bin_type;
return BinPathType::bin_type;
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
default:

View file

@ -221,9 +221,8 @@ void XRE_TermEmbedding() {
const char* XRE_GeckoProcessTypeToString(GeckoProcessType aProcessType) {
switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType::GeckoProcessType_##enum_name: \
return string_name;
#include "mozilla/GeckoProcessTypes.h"

View file

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 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/. */
// The entries in this file define support functions for each of the process
// types present in Gecko. The format is:
//
// GECKO_PROCESS_TYPE(enum-value, enum-name, string-name, proc-typename,
// process-bin-type)
//
// enum-value: Unsigned int value the enum will use to identify the process
// type. This value must not be shared by different process types and should
// never be changed since it is used e.g. in telemetry reporting. These
// values should be mirrored in nsIXULRuntime.idl.
//
// enum-name: used to name the GeckoChildProcess enum. E.g. `Foo` will
// become `GeckoChildProcess_Foo`. The enum's value will be the enum-value
// above.
//
// string-name: Human-readable name. It is exposed to things like
// telemetry and the crash reporter, so it should not be changed casually.
//
// proc-typename: Used as NAME in the `XRE_Is${NAME}Process` function.
// Ideally, this should match the enum-name. This is included since there
// are legacy exceptions to that rule.
//
// process-bin-type: either Self or PluginContainer. Determines
// whether the child process may be started using the same binary as the parent
// process, or whether to use plugin-container (Note that whether or not this
// value is actually obeyed depends on platform and build configuration. Do not
// use this value directly, but rather use XRE_GetChildProcBinPathType to
// resolve this).
GECKO_PROCESS_TYPE(0, Default, "default", Parent, Self)
GECKO_PROCESS_TYPE(2, Content, "tab", Content, Self)
GECKO_PROCESS_TYPE(3, IPDLUnitTest, "ipdlunittest", IPDLUnitTest,
PluginContainer)
// Gecko Media Plugin process.
GECKO_PROCESS_TYPE(4, GMPlugin, "gmplugin", GMPlugin, PluginContainer)
// GPU and compositor process.
GECKO_PROCESS_TYPE(5, GPU, "gpu", GPU, Self)
// VR process.
GECKO_PROCESS_TYPE(6, VR, "vr", VR, Self)
// Remote Data Decoder process.
GECKO_PROCESS_TYPE(7, RDD, "rdd", RDD, Self)
// Socket process
GECKO_PROCESS_TYPE(8, Socket, "socket", Socket, Self)
GECKO_PROCESS_TYPE(9, RemoteSandboxBroker, "sandboxbroker", RemoteSandboxBroker,
PluginContainer)
GECKO_PROCESS_TYPE(10, ForkServer, "forkserver", ForkServer, Self)
// Please add new process types at the end of this list. You will also need
// to maintain consistency with:
//
// * toolkit/components/processtools/ProcInfo.h (ProcType),
// * xpcom/system/nsIXULRuntime.idl (PROCESS_TYPE constants),
// * toolkit/xre/nsAppRunner.cpp (SYNC_ENUMS),
// * dom/base/ChromeUtils.cpp (ProcTypeToWebIDL and
// ChromeUtils::RequestProcInfo)
// * dom/chrome-webidl/ChromeUtils.webidl (WebIDLProcType)
// * toolkit/components/crashes/nsICrashService.idl and
// CrashService.jsm (PROCESS_TYPE constants)
// * ipc/glue/CrashReporterHost.cpp (assertions)
// * toolkit/locales/en-US/toolkit/global/processTypes.ftl and
// toolkit/modules/ProcessType.jsm
//
// Also, please ensure that any new sandbox environment variables are added
// in build/pgo/profileserver.py to ensure your new process participates in
// PGO profile generation.

View file

@ -1,34 +0,0 @@
# 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/.
from geckoprocesstypes import process_types
def main(output):
output.write(
"""\
/* THIS FILE IS GENERATED BY GeckoProcessTypes - DO NOT EDIT */
"""
)
for p in process_types:
output.write(
"""
#ifndef SKIP_PROCESS_TYPE_%(allcaps_name)s
GECKO_PROCESS_TYPE(%(enum_value)d, %(enum_name)s, "%(string_name)s", """
"""%(proc_typename)s, %(process_bin_type)s, %(procinfo_typename)s, """
"""%(webidl_typename)s, %(allcaps_name)s)
#endif // SKIP_PROCESS_TYPE_%(allcaps_name)s
"""
% {
"enum_value": p.enum_value,
"enum_name": p.enum_name,
"string_name": p.string_name,
"proc_typename": p.proc_typename,
"process_bin_type": p.process_bin_type,
"procinfo_typename": p.procinfo_typename,
"webidl_typename": p.webidl_typename,
"allcaps_name": p.allcaps_name,
}
)

View file

@ -15,9 +15,9 @@ EXPORTS += [
]
EXPORTS.mozilla += [
"!GeckoProcessTypes.h",
"!Services.h",
"FileLocation.h",
"GeckoProcessTypes.h",
"IOInterposer.h",
"LateWriteChecks.h",
"Omnijar.h",
@ -75,11 +75,6 @@ if CONFIG["OS_ARCH"] != "WINNT":
GeneratedFile("Services.cpp", script="Services.py", entry_point="services_cpp")
GeneratedFile("Services.h", script="Services.py", entry_point="services_h")
GeneratedFile("services.rs", script="Services.py", entry_point="services_rs")
GeneratedFile(
"GeckoProcessTypes.h",
script="gen_process_types.py",
entry_point="main",
)
include("/ipc/chromium/chromium-config.mozbuild")

View file

@ -360,9 +360,8 @@ XRE_API(nsresult, XRE_ParseAppData,
// This enum is not dense. See GeckoProcessTypes.h for details.
enum GeckoProcessType {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
GeckoProcessType_##enum_name = enum_value,
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
@ -417,10 +416,9 @@ XRE_API(bool, XRE_IsE10sParentProcess, ())
* the e10s parent process or called in the main process when e10s is
* disabled.
*/
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
XRE_API(bool, XRE_Is##proc_typename##Process, ())
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
XRE_API(bool, XRE_Is##xre_name##Process, ())
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE

View file

@ -1,326 +0,0 @@
# 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/.
from collections import namedtuple
# Besides adding a new process type to this file, a bit of extra work is
# required for places where generated code has not yet been implemented.
# TODO: Bug 1740268: Move this piece into doc and link doc from here.
#
# Basic requirements:
# dom/chrome-webidl/ChromeUtils.webidl
# - Add a new entry to the enum WebIDLProcType
#
# gfx/thebes/gfxPlatform.cpp
# - (if you need GFX related stuff ?)
# - Add a call to your process manager init in gfxPlatform::Init()
# - Add a call to your process manager shutdown in gfxPlatform::Shutdown()
#
# mobile/android/geckoview/src/main/AndroidManifest.xml
# - Add a new <service> entry targetting
# org.mozilla.gecko.process.GeckoChildProcessServices$XXX
#
# mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoChildProcessServices.jinja
# - Add matching class inheritance from GeckoChildProcessServices
#
# mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessType.java
# - Add new entry in public enum GeckoProcessType
#
# toolkit/crashreporter/CrashAnnotations.yaml
# - Add new Xxx*Status entry for your new process type description
#
# toolkit/locales/en-US/toolkit/global/processTypes.ftl
# - Add a user-facing localizable name for your process, if needed
#
# toolkit/modules/ProcessType.jsm
# - Hashmap from process type to user-facing string above in const ProcessType
#
# toolkit/xre/nsAppRunner.cpp
# - Update the static_assert call checking for boundary against
# GeckoProcessType_End
#
# toolkit/xre/nsEmbedFunctions.cpp
# - Add your process to the correct MessageLoop::TYPE_x in the first
# switch(XRE_GetProcessType()) in XRE_InitChildProcess
# - Instantiate your child within the second switch (XRE_GetProcessType())
# in XRE_InitChildProcess
#
# xpcom/system/nsIXULRuntime.idl
# - Add a new entry PROCESS_TYPE_x in nsIXULRuntime interface
#
#
# For static components:
# modules/libpref/components.conf
# toolkit/components/telemetry/core/components.conf
# widget/android/components.conf
# widget/gtk/components.conf
# widget/windows/components.conf
# xpcom/base/components.conf
# xpcom/build/components.conf
# xpcom/components/components.conf
# xpcom/ds/components.conf
# xpcom/threads/components.conf
# widget/cocoa/nsWidgetFactory.mm
# xpcom/build/XPCOMInit.cpp
# - Update allowance in those config file to match new process selector
# including your new process
#
# xpcom/components/gen_static_components.py
# - Add new definition in ProcessSelector for your new process
# ALLOW_IN_x_PROCESS = 0x..
# - Add new process selector masks including your new process definition
# - Also add those into the PROCESSES structure
#
# xpcom/components/Module.h
# - Add new definition in enum ProcessSelector
# - Add new process selector mask including the new definition
# - Update kMaxProcessSelector
#
# xpcom/components/nsComponentManager.cpp
# - Add new selector match in ProcessSelectorMatches for your new process
# (needed?)
# - Add new process selector for gProcessMatchTable
# in nsComponentManagerImpl::Init()
# xpcom/build/XPCOMInit.cpp
#
#
# For sandbox:
# Sandbox Linux:
# security/sandbox/linux/Sandbox.cpp
# - Add new SetXXXSandbox() function
# security/sandbox/linux/SandboxFilter.cpp
# - Add new helper GetXXXSandboxPolicy() called by SetXXXSandbox()
# - Derive new class inheriting SandboxPolicyCommon or SandboxPolicyBase and
# defining the sandboxing policy
# security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
# - Add new SandboxBrokerPolicyFactory::GetXXXProcessPolicy()
# security/sandbox/linux/launch/SandboxLaunch.cpp
# - Add new case handling in GetEffectiveSandboxLevel()
# security/sandbox/linux/reporter/SandboxReporter.cpp
# - Add new case handling in SubmitToTelemetry()
# security/sandbox/linux/reporter/SandboxReporterCommon.h
# - Add new entry in enum class ProcType
# security/sandbox/linux/reporter/SandboxReporterWrappers.cpp
# - Add new case handling in SandboxReportWrapper::GetProcType()
#
# Sandbox Mac:
# ipc/glue/GeckoChildProcessHost.cpp
# - Add new case handling in GeckoChildProcessHost::StartMacSandbox()
# security/sandbox/mac/Sandbox.h
# - Add new entry in enum MacSandboxType
# security/sandbox/mac/Sandbox.mm
# - Handle the new MacSandboxType in MacSandboxInfo::AppendAsParams()
# - Handle the new MacSandboxType in StartMacSandbox()
# - Handle the new MacSandboxType in StartMacSandboxIfEnabled()
# security/sandbox/mac/SandboxPolicy<XXX>.h
# - Create this new file for your new process <XXX>, it defines the new
# sandbox
# security/sandbox/mac/moz.build
# - Add the previous new file
#
# Sandbox Win:
# ipc/glue/GeckoChildProcessHost.cpp
# - Add new case handling in WindowsProcessLauncher::DoSetup() calling
# SandboxBroker::SetSecurityLevelForXXXProcess()
# security/sandbox/win/src/remotesandboxbroker/remoteSandboxBroker.cpp
# - Introduce a new SandboxBroker::SetSecurityLevelForXXXProcess()
# security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
# - Introduce a new SandboxBroker::SetSecurityLevelForXXXProcess() that
# defines the new sandbox
#
# Sandbox tests:
# - Your new process needs to implement PSandboxTesting.ipdl
# security/sandbox/test/browser_sandbox_test.js
# - Add your new process string_name in the processTypes list
# security/sandbox/common/test/SandboxTest.cpp
# - Add a new case in SandboxTest::StartTests() to handle your new process
# security/sandbox/common/test/SandboxTestingChild.cpp
# - Add a new if branch for your new process in SandboxTestingChild::Bind()
# security/sandbox/common/test/SandboxTestingChildTests.h
# - Add a new RunTestsXXX function for your new process (called by Bind() above)
#
# ~~~~~
#
# The entries in this file define support functions for each of the process
# types present in Gecko.
#
# GECKO_PROCESS_TYPE(
# enum-value,
# enum-name,
# string-name,
# proc-typename,
# process-bin-type,
# procinfo-typename,
# webidl-typename,
# allcaps-name,
# crash-ping,
# )
#
# enum-value:
# Unsigned int value the enum will use to identify the process type. This
# value must not be shared by different process types and should never be
# changed since it is used e.g. in telemetry reporting.
#
# ***These values should be mirrored in nsIXULRuntime.idl.***
#
# enum-name:
# Used to name the GeckoChildProcess enum. E.g. `Foo` will become
# `GeckoChildProcess_Foo`. The enum's value will be the enum-value above.
#
# string-name:
# Human-readable name. It is exposed to things like telemetry and the crash
# reporter, so it should not be changed casually.
#
# proc-typename:
# Used as NAME in the `XRE_Is${NAME}Process` function. Ideally, this should
# match the enum-name. This is included since there are legacy exceptions to
# that rule.
#
# process-bin-type:
# Either Self or PluginContainer. Determines whether the child process may
# be started using the same binary as the parent process, or whether to use
# plugin-container (Note that whether or not this value is actually obeyed
# depends on platform and build configuration. Do not use this value
# directly, but rather use XRE_GetChildProcBinPathType to resolve this).
#
# procinfo-typename:
# Used as NAME in the ProcType enum defined by ProcInfo.h.
#
# webidl-typename:
# Used as NAME in the ChromeUtils.cpp code
#
# allcaps-name:
# Used as NAME for checking SYNC_ENUM in nsXULAppAPI.h
#
# crash-ping:
# Boolean reflecting if the process is allowed to send crash ping.
GeckoProcessType = namedtuple(
"GeckoProcessType",
[
"enum_value",
"enum_name",
"string_name",
"proc_typename",
"process_bin_type",
"procinfo_typename",
"webidl_typename",
"allcaps_name",
"crash_ping",
],
)
process_types = [
GeckoProcessType(
0,
"Default",
"default",
"Parent",
"Self",
"Browser",
"Browser",
"DEFAULT",
False,
),
GeckoProcessType(
2,
"Content",
"tab",
"Content",
"Self",
"Content",
"Content",
"CONTENT",
True,
),
GeckoProcessType(
3,
"IPDLUnitTest",
"ipdlunittest",
"IPDLUnitTest",
"PluginContainer",
"IPDLUnitTest",
"IpdlUnitTest",
"IPDLUNITTEST",
False,
),
GeckoProcessType(
4,
"GMPlugin",
"gmplugin",
"GMPlugin",
"PluginContainer",
"GMPlugin",
"GmpPlugin",
"GMPLUGIN",
False,
),
GeckoProcessType(
5,
"GPU",
"gpu",
"GPU",
"Self",
"GPU",
"Gpu",
"GPU",
True,
),
GeckoProcessType(
6,
"VR",
"vr",
"VR",
"Self",
"VR",
"Vr",
"VR",
True,
),
GeckoProcessType(
7,
"RDD",
"rdd",
"RDD",
"Self",
"RDD",
"Rdd",
"RDD",
True,
),
GeckoProcessType(
8,
"Socket",
"socket",
"Socket",
"Self",
"Socket",
"Socket",
"SOCKET",
True,
),
GeckoProcessType(
9,
"RemoteSandboxBroker",
"sandboxbroker",
"RemoteSandboxBroker",
"PluginContainer",
"RemoteSandboxBroker",
"RemoteSandboxBroker",
"REMOTESANDBOXBROKER",
False,
),
GeckoProcessType(
10,
"ForkServer",
"forkserver",
"ForkServer",
"Self",
"ForkServer",
"ForkServer",
"FORKSERVER",
False,
),
]

View file

@ -1,5 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

View file

@ -1,18 +0,0 @@
# 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/.
from setuptools import setup, find_packages
setup(
name="geckoprocesstypes",
version="1.0",
description="Generator for GeckoProcessTypes related resources.",
author="Mozilla Foundation",
license="MPL 2.0",
packages=find_packages(),
install_requires=[],
entry_points={"console_scripts": ["GeckoProcessTypes.py = geckoprocesstypes:main"]},
keywords=["geckoprocesstypes"],
)

View file

@ -9,7 +9,6 @@ with Files("**"):
DIRS += [
"idl-parser/xpidl",
"geckoprocesstypes_generator/geckoprocesstypes",
]
DIRS += [

View file

@ -188,7 +188,7 @@ interface nsIXULRuntime : nsISupports
const unsigned long PROCESS_TYPE_VR = 6;
const unsigned long PROCESS_TYPE_RDD = 7;
const unsigned long PROCESS_TYPE_SOCKET = 8;
const unsigned long PROCESS_TYPE_REMOTESANDBOXBROKER = 9;
const unsigned long PROCESS_TYPE_SANDBOX_BROKER = 9;
const unsigned long PROCESS_TYPE_FORKSERVER = 10;
/**