Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
Cu.import("resource://gre/modules/Log.jsm", this);
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
Cu.import("resource://gre/modules/osfile.jsm", this)
|
2014-01-27 15:49:11 -08:00
|
|
|
Cu.import("resource://gre/modules/Promise.jsm", this);
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm", this);
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
Cu.import("resource://gre/modules/Task.jsm", this);
|
2014-01-27 15:49:11 -08:00
|
|
|
Cu.import("resource://gre/modules/Timer.jsm", this);
|
2014-01-23 15:49:24 -08:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
2014-01-27 15:49:11 -08:00
|
|
|
Cu.import("resource://services-common/utils.js", this);
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
|
|
|
|
this.EXPORTED_SYMBOLS = [
|
|
|
|
"CrashManager",
|
|
|
|
];
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
/**
|
|
|
|
* How long to wait after application startup before crash event files are
|
|
|
|
* automatically aggregated.
|
|
|
|
*
|
|
|
|
* We defer aggregation for performance reasons, as we don't want too many
|
|
|
|
* services competing for I/O immediately after startup.
|
|
|
|
*/
|
|
|
|
const AGGREGATE_STARTUP_DELAY_MS = 57000;
|
|
|
|
|
|
|
|
const MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000;
|
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
// Converts Date to days since UNIX epoch.
|
|
|
|
// This was copied from /services/metrics.storage.jsm. The implementation
|
|
|
|
// does not account for leap seconds.
|
|
|
|
function dateToDays(date) {
|
|
|
|
return Math.floor(date.getTime() / MILLISECONDS_IN_DAY);
|
|
|
|
}
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
/**
|
|
|
|
* A gateway to crash-related data.
|
|
|
|
*
|
|
|
|
* This type is generic and can be instantiated any number of times.
|
|
|
|
* However, most applications will typically only have one instance
|
|
|
|
* instantiated and that instance will point to profile and user appdata
|
|
|
|
* directories.
|
|
|
|
*
|
|
|
|
* Instances are created by passing an object with properties.
|
|
|
|
* Recognized properties are:
|
|
|
|
*
|
|
|
|
* pendingDumpsDir (string) (required)
|
|
|
|
* Where dump files that haven't been uploaded are located.
|
|
|
|
*
|
|
|
|
* submittedDumpsDir (string) (required)
|
|
|
|
* Where records of uploaded dumps are located.
|
2014-01-27 15:49:11 -08:00
|
|
|
*
|
|
|
|
* eventsDirs (array)
|
|
|
|
* Directories (defined as strings) where events files are written. This
|
|
|
|
* instance will collects events from files in the directories specified.
|
|
|
|
*
|
|
|
|
* storeDir (string)
|
|
|
|
* Directory we will use for our data store. This instance will write
|
|
|
|
* data files into the directory specified.
|
|
|
|
*
|
|
|
|
* telemetryStoreSizeKey (string)
|
|
|
|
* Telemetry histogram to report store size under.
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
*/
|
|
|
|
this.CrashManager = function (options) {
|
2014-01-27 15:49:11 -08:00
|
|
|
for (let k of ["pendingDumpsDir", "submittedDumpsDir", "eventsDirs",
|
|
|
|
"storeDir"]) {
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
if (!(k in options)) {
|
|
|
|
throw new Error("Required key not present in options: " + k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
this._log = Log.repository.getLogger("Crashes.CrashManager");
|
|
|
|
|
|
|
|
for (let k in options) {
|
|
|
|
let v = options[k];
|
|
|
|
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
switch (k) {
|
|
|
|
case "pendingDumpsDir":
|
|
|
|
this._pendingDumpsDir = v;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "submittedDumpsDir":
|
|
|
|
this._submittedDumpsDir = v;
|
|
|
|
break;
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
case "eventsDirs":
|
|
|
|
this._eventsDirs = v;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "storeDir":
|
|
|
|
this._storeDir = v;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "telemetryStoreSizeKey":
|
|
|
|
this._telemetryStoreSizeKey = v;
|
|
|
|
break;
|
|
|
|
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
default:
|
|
|
|
throw new Error("Unknown property in options: " + k);
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 15:49:11 -08:00
|
|
|
|
|
|
|
// Promise for in-progress aggregation operation. We store it on the
|
|
|
|
// object so it can be returned for in-progress operations.
|
|
|
|
this._aggregatePromise = null;
|
|
|
|
|
|
|
|
// The CrashStore currently attached to this object.
|
|
|
|
this._store = null;
|
|
|
|
|
|
|
|
// The timer controlling the expiration of the CrashStore instance.
|
|
|
|
this._storeTimer = null;
|
|
|
|
|
|
|
|
// This is a semaphore that prevents the store from being freed by our
|
|
|
|
// timer-based resource freeing mechanism.
|
|
|
|
this._storeProtectedCount = 0;
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
this.CrashManager.prototype = Object.freeze({
|
2014-05-12 11:58:18 -07:00
|
|
|
// A crash in the main process.
|
|
|
|
PROCESS_TYPE_MAIN: "main",
|
|
|
|
|
|
|
|
// A crash in a content process.
|
|
|
|
PROCESS_TYPE_CONTENT: "content",
|
|
|
|
|
|
|
|
// A crash in a plugin process.
|
|
|
|
PROCESS_TYPE_PLUGIN: "plugin",
|
|
|
|
|
2014-08-08 15:41:07 -07:00
|
|
|
// A crash in a Gecko media plugin process.
|
|
|
|
PROCESS_TYPE_GMPLUGIN: "gmplugin",
|
|
|
|
|
2014-07-03 11:04:28 -07:00
|
|
|
// A submission of a crash.
|
|
|
|
PROCESS_TYPE_SUBMISSION: "submission",
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
// A real crash.
|
|
|
|
CRASH_TYPE_CRASH: "crash",
|
|
|
|
|
|
|
|
// A hang.
|
|
|
|
CRASH_TYPE_HANG: "hang",
|
|
|
|
|
2014-07-03 11:04:28 -07:00
|
|
|
// A successful submission.
|
|
|
|
SUBMISSION_TYPE_SUCCEEDED: "succeeded",
|
|
|
|
|
|
|
|
// A failed submission.
|
|
|
|
SUBMISSION_TYPE_FAILED: "failed",
|
|
|
|
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
DUMP_REGEX: /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.dmp$/i,
|
|
|
|
SUBMITTED_REGEX: /^bp-(?:hr-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.txt$/i,
|
2014-01-27 15:49:11 -08:00
|
|
|
ALL_REGEX: /^(.*)$/,
|
|
|
|
|
|
|
|
// How long the store object should persist in memory before being
|
|
|
|
// automatically garbage collected.
|
|
|
|
STORE_EXPIRATION_MS: 60 * 1000,
|
|
|
|
|
|
|
|
// Number of days after which a crash with no activity will get purged.
|
|
|
|
PURGE_OLDER_THAN_DAYS: 180,
|
|
|
|
|
|
|
|
// The following are return codes for individual event file processing.
|
|
|
|
// File processed OK.
|
|
|
|
EVENT_FILE_SUCCESS: "ok",
|
|
|
|
// The event appears to be malformed.
|
|
|
|
EVENT_FILE_ERROR_MALFORMED: "malformed",
|
|
|
|
// The type of event is unknown.
|
|
|
|
EVENT_FILE_ERROR_UNKNOWN_EVENT: "unknown-event",
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a list of all dumps pending upload.
|
|
|
|
*
|
|
|
|
* The returned value is a promise that resolves to an array of objects
|
|
|
|
* on success. Each element in the array has the following properties:
|
|
|
|
*
|
|
|
|
* id (string)
|
|
|
|
* The ID of the crash (a UUID).
|
|
|
|
*
|
|
|
|
* path (string)
|
|
|
|
* The filename of the crash (<UUID.dmp>)
|
|
|
|
*
|
|
|
|
* date (Date)
|
|
|
|
* When this dump was created
|
|
|
|
*
|
|
|
|
* The returned arry is sorted by the modified time of the file backing
|
|
|
|
* the entry, oldest to newest.
|
|
|
|
*
|
|
|
|
* @return Promise<Array>
|
|
|
|
*/
|
|
|
|
pendingDumps: function () {
|
|
|
|
return this._getDirectoryEntries(this._pendingDumpsDir, this.DUMP_REGEX);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a list of all dump files corresponding to submitted crashes.
|
|
|
|
*
|
|
|
|
* The returned value is a promise that resolves to an Array of
|
|
|
|
* objects. Each object has the following properties:
|
|
|
|
*
|
|
|
|
* path (string)
|
|
|
|
* The path of the file this entry comes from.
|
|
|
|
*
|
|
|
|
* id (string)
|
|
|
|
* The crash UUID.
|
|
|
|
*
|
|
|
|
* date (Date)
|
|
|
|
* The (estimated) date this crash was submitted.
|
|
|
|
*
|
|
|
|
* The returned array is sorted by the modified time of the file backing
|
|
|
|
* the entry, oldest to newest.
|
|
|
|
*
|
|
|
|
* @return Promise<Array>
|
|
|
|
*/
|
|
|
|
submittedDumps: function () {
|
|
|
|
return this._getDirectoryEntries(this._submittedDumpsDir,
|
|
|
|
this.SUBMITTED_REGEX);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-01-27 15:49:11 -08:00
|
|
|
* Aggregates "loose" events files into the unified "database."
|
|
|
|
*
|
|
|
|
* This function should be called periodically to collect metadata from
|
|
|
|
* all events files into the central data store maintained by this manager.
|
|
|
|
*
|
|
|
|
* Once events have been stored in the backing store the corresponding
|
|
|
|
* source files are deleted.
|
|
|
|
*
|
|
|
|
* Only one aggregation operation is allowed to occur at a time. If this
|
|
|
|
* is called when an existing aggregation is in progress, the promise for
|
|
|
|
* the original call will be returned.
|
|
|
|
*
|
|
|
|
* @return promise<int> The number of event files that were examined.
|
|
|
|
*/
|
|
|
|
aggregateEventsFiles: function () {
|
|
|
|
if (this._aggregatePromise) {
|
|
|
|
return this._aggregatePromise;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._aggregatePromise = Task.spawn(function* () {
|
|
|
|
if (this._aggregatePromise) {
|
|
|
|
return this._aggregatePromise;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
let unprocessedFiles = yield this._getUnprocessedEventsFiles();
|
|
|
|
|
|
|
|
let deletePaths = [];
|
|
|
|
let needsSave = false;
|
|
|
|
|
|
|
|
this._storeProtectedCount++;
|
|
|
|
for (let entry of unprocessedFiles) {
|
|
|
|
try {
|
|
|
|
let result = yield this._processEventFile(entry);
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case this.EVENT_FILE_SUCCESS:
|
|
|
|
needsSave = true;
|
|
|
|
// Fall through.
|
|
|
|
|
|
|
|
case this.EVENT_FILE_ERROR_MALFORMED:
|
|
|
|
deletePaths.push(entry.path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case this.EVENT_FILE_ERROR_UNKNOWN_EVENT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Cu.reportError("Unhandled crash event file return code. Please " +
|
|
|
|
"file a bug: " + result);
|
|
|
|
}
|
|
|
|
} catch (ex if ex instanceof OS.File.Error) {
|
|
|
|
this._log.warn("I/O error reading " + entry.path + ": " +
|
|
|
|
CommonUtils.exceptionStr(ex));
|
|
|
|
} catch (ex) {
|
|
|
|
// We should never encounter an exception. This likely represents
|
|
|
|
// a coding error because all errors should be detected and
|
|
|
|
// converted to return codes.
|
|
|
|
//
|
|
|
|
// If we get here, report the error and delete the source file
|
|
|
|
// so we don't see it again.
|
|
|
|
Cu.reportError("Exception when processing crash event file: " +
|
|
|
|
CommonUtils.exceptionStr(ex));
|
|
|
|
deletePaths.push(entry.path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needsSave) {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
yield store.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let path of deletePaths) {
|
|
|
|
try {
|
|
|
|
yield OS.File.remove(path);
|
|
|
|
} catch (ex) {
|
|
|
|
this._log.warn("Error removing event file (" + path + "): " +
|
|
|
|
CommonUtils.exceptionStr(ex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return unprocessedFiles.length;
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
this._aggregatePromise = false;
|
|
|
|
this._storeProtectedCount--;
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prune old crash data.
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
*
|
2014-01-27 15:49:11 -08:00
|
|
|
* @param date
|
|
|
|
* (Date) The cutoff point for pruning. Crashes without data newer
|
|
|
|
* than this will be pruned.
|
|
|
|
*/
|
|
|
|
pruneOldCrashes: function (date) {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
store.pruneOldCrashes(date);
|
|
|
|
yield store.save();
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run tasks that should be periodically performed.
|
|
|
|
*/
|
|
|
|
runMaintenanceTasks: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
yield this.aggregateEventsFiles();
|
|
|
|
|
|
|
|
let offset = this.PURGE_OLDER_THAN_DAYS * MILLISECONDS_IN_DAY;
|
|
|
|
yield this.pruneOldCrashes(new Date(Date.now() - offset));
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule maintenance tasks for some point in the future.
|
|
|
|
*
|
|
|
|
* @param delay
|
|
|
|
* (integer) Delay in milliseconds when maintenance should occur.
|
|
|
|
*/
|
|
|
|
scheduleMaintenance: function (delay) {
|
|
|
|
let deferred = Promise.defer();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.runMaintenanceTasks().then(deferred.resolve, deferred.reject);
|
|
|
|
}, delay);
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
},
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
/**
|
|
|
|
* Record the occurrence of a crash.
|
|
|
|
*
|
|
|
|
* This method skips event files altogether and writes directly and
|
|
|
|
* immediately to the manager's data store.
|
|
|
|
*
|
|
|
|
* @param processType (string) One of the PROCESS_TYPE constants.
|
|
|
|
* @param crashType (string) One of the CRASH_TYPE constants.
|
|
|
|
* @param id (string) Crash ID. Likely a UUID.
|
|
|
|
* @param date (Date) When the crash occurred.
|
|
|
|
*
|
|
|
|
* @return promise<null> Resolved when the store has been saved.
|
|
|
|
*/
|
|
|
|
addCrash: function (processType, crashType, id, date) {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
if (store.addCrash(processType, crashType, id, date)) {
|
|
|
|
yield store.save();
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
2014-07-03 11:04:28 -07:00
|
|
|
/**
|
|
|
|
* Record the occurrence of a crash submission.
|
|
|
|
*
|
|
|
|
* @param processType (string) One of the PROCESS_TYPE constants.
|
|
|
|
* @param crashType (string) One of the CRASH_TYPE constants.
|
|
|
|
* @param succeeded (boolean) Whether the submission succeeded.
|
|
|
|
* @param id (string) Crash ID. Likely a UUID.
|
|
|
|
* @param date (Date) When the crash occurred.
|
|
|
|
*
|
|
|
|
* @return boolean True if the crash submission was recorded and false if not.
|
|
|
|
*/
|
|
|
|
addSubmission: function (processType, crashType, succeeded, id, date) {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
if (this._addSubmissionAsCrash(store, processType, crashType, succeeded,
|
|
|
|
id, date)) {
|
|
|
|
yield store.save();
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
_addSubmissionAsCrash: function (store, processType, crashType, succeeded,
|
|
|
|
id, date) {
|
2014-08-19 17:27:58 -07:00
|
|
|
id += "-" + this.PROCESS_TYPE_SUBMISSION;
|
2014-07-03 11:04:28 -07:00
|
|
|
let process = processType + "-" + crashType + "-" +
|
|
|
|
this.PROCESS_TYPE_SUBMISSION;
|
|
|
|
let submission_type = (
|
|
|
|
succeeded ? this.SUBMISSION_TYPE_SUCCEEDED : this.SUBMISSION_TYPE_FAILED);
|
|
|
|
|
|
|
|
return store.addCrash(process, submission_type, id, date);
|
|
|
|
},
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
/**
|
|
|
|
* Obtain the paths of all unprocessed events files.
|
|
|
|
*
|
|
|
|
* The promise-resolved array is sorted by file mtime, oldest to newest.
|
|
|
|
*/
|
|
|
|
_getUnprocessedEventsFiles: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let entries = [];
|
|
|
|
|
|
|
|
for (let dir of this._eventsDirs) {
|
|
|
|
for (let e of yield this._getDirectoryEntries(dir, this.ALL_REGEX)) {
|
|
|
|
entries.push(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
entries.sort((a, b) => { return a.date - b.date; });
|
|
|
|
|
|
|
|
return entries;
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
// See docs/crash-events.rst for the file format specification.
|
|
|
|
_processEventFile: function (entry) {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let data = yield OS.File.read(entry.path);
|
|
|
|
let store = yield this._getStore();
|
|
|
|
|
|
|
|
let decoder = new TextDecoder();
|
|
|
|
data = decoder.decode(data);
|
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
let type, time, payload;
|
|
|
|
let start = 0;
|
|
|
|
for (let i = 0; i < 2; i++) {
|
|
|
|
let index = data.indexOf("\n", start);
|
|
|
|
if (index == -1) {
|
|
|
|
return this.EVENT_FILE_ERROR_MALFORMED;
|
|
|
|
}
|
2014-01-27 15:49:11 -08:00
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
let sub = data.substring(start, index);
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
type = sub;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
time = sub;
|
|
|
|
try {
|
|
|
|
time = parseInt(time, 10);
|
|
|
|
} catch (ex) {
|
|
|
|
return this.EVENT_FILE_ERROR_MALFORMED;
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 15:49:11 -08:00
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
start = index + 1;
|
|
|
|
}
|
|
|
|
let date = new Date(time * 1000);
|
|
|
|
let payload = data.substring(start);
|
|
|
|
|
|
|
|
return this._handleEventFilePayload(store, entry, type, date, payload);
|
2014-01-27 15:49:11 -08:00
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
_handleEventFilePayload: function (store, entry, type, date, payload) {
|
|
|
|
// The payload types and formats are documented in docs/crash-events.rst.
|
|
|
|
// Do not change the format of an existing type. Instead, invent a new
|
|
|
|
// type.
|
2014-07-03 11:04:28 -07:00
|
|
|
// DO NOT ADD NEW TYPES WITHOUT DOCUMENTING!
|
|
|
|
let lines = payload.split("\n");
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case "crash.main.1":
|
|
|
|
if (lines.length > 1) {
|
|
|
|
this._log.warn("Multiple lines unexpected in payload for " +
|
|
|
|
entry.path);
|
|
|
|
return this.EVENT_FILE_ERROR_MALFORMED;
|
|
|
|
}
|
|
|
|
store.addCrash(this.PROCESS_TYPE_MAIN, this.CRASH_TYPE_CRASH,
|
|
|
|
payload, date);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "crash.submission.1":
|
|
|
|
if (lines.length == 3) {
|
|
|
|
this._addSubmissionAsCrash(store, this.PROCESS_TYPE_MAIN,
|
|
|
|
this.CRASH_TYPE_CRASH,
|
|
|
|
lines[1] === "true", lines[0], date);
|
|
|
|
} else {
|
|
|
|
return this.EVENT_FILE_ERROR_MALFORMED;
|
|
|
|
}
|
|
|
|
break;
|
2014-01-28 15:46:03 -08:00
|
|
|
|
2014-07-03 11:04:28 -07:00
|
|
|
default:
|
|
|
|
return this.EVENT_FILE_ERROR_UNKNOWN_EVENT;
|
2014-01-28 15:46:03 -08:00
|
|
|
}
|
|
|
|
|
2014-07-03 11:04:28 -07:00
|
|
|
return this.EVENT_FILE_SUCCESS;
|
2014-01-27 15:49:11 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
* The resolved promise is an array of objects with the properties:
|
|
|
|
*
|
|
|
|
* path -- String filename
|
|
|
|
* id -- regexp.match()[1] (likely the crash ID)
|
|
|
|
* date -- Date mtime of the file
|
|
|
|
*/
|
|
|
|
_getDirectoryEntries: function (path, re) {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
try {
|
|
|
|
yield OS.File.stat(path);
|
|
|
|
} catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
let it = new OS.File.DirectoryIterator(path);
|
|
|
|
let entries = [];
|
|
|
|
|
|
|
|
try {
|
|
|
|
yield it.forEach((entry, index, it) => {
|
|
|
|
if (entry.isDir) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let match = re.exec(entry.name);
|
|
|
|
if (!match) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OS.File.stat(entry.path).then((info) => {
|
|
|
|
entries.push({
|
|
|
|
path: entry.path,
|
|
|
|
id: match[1],
|
|
|
|
date: info.lastModificationDate,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} finally {
|
|
|
|
it.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
entries.sort((a, b) => { return a.date - b.date; });
|
|
|
|
|
|
|
|
return entries;
|
|
|
|
}.bind(this));
|
|
|
|
},
|
2014-01-27 15:49:11 -08:00
|
|
|
|
|
|
|
_getStore: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
if (!this._store) {
|
2014-03-04 16:21:11 -08:00
|
|
|
yield OS.File.makeDir(this._storeDir, {
|
|
|
|
ignoreExisting: true,
|
|
|
|
unixMode: OS.Constants.libc.S_IRWXU,
|
|
|
|
});
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
let store = new CrashStore(this._storeDir, this._telemetryStoreSizeKey);
|
|
|
|
yield store.load();
|
|
|
|
|
|
|
|
this._store = store;
|
|
|
|
this._storeTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The application can go long periods without interacting with the
|
|
|
|
// store. Since the store takes up resources, we automatically "free"
|
|
|
|
// the store after inactivity so resources can be returned to the system.
|
|
|
|
// We do this via a timer and a mechanism that tracks when the store
|
|
|
|
// is being accessed.
|
|
|
|
this._storeTimer.cancel();
|
|
|
|
|
|
|
|
// This callback frees resources from the store unless the store
|
|
|
|
// is protected from freeing by some other process.
|
|
|
|
let timerCB = function () {
|
|
|
|
if (this._storeProtectedCount) {
|
|
|
|
this._storeTimer.initWithCallback(timerCB, this.STORE_EXPIRATION_MS,
|
|
|
|
this._storeTimer.TYPE_ONE_SHOT);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We kill the reference that we hold. GC will kill it later. If
|
|
|
|
// someone else holds a reference, that will prevent GC until that
|
|
|
|
// reference is gone.
|
|
|
|
this._store = null;
|
|
|
|
this._storeTimer = null;
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
this._storeTimer.initWithCallback(timerCB, this.STORE_EXPIRATION_MS,
|
|
|
|
this._storeTimer.TYPE_ONE_SHOT);
|
|
|
|
|
|
|
|
return this._store;
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain information about all known crashes.
|
|
|
|
*
|
|
|
|
* Returns an array of CrashRecord instances. Instances are read-only.
|
|
|
|
*/
|
|
|
|
getCrashes: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
|
|
|
|
return store.crashes;
|
|
|
|
}.bind(this));
|
|
|
|
},
|
2014-01-30 16:48:52 -08:00
|
|
|
|
|
|
|
getCrashCountsByDay: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
let store = yield this._getStore();
|
|
|
|
|
|
|
|
return store._countsByDay;
|
|
|
|
}.bind(this));
|
|
|
|
},
|
Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric
The tree doesn't have a robust and reusable API for interfacing with
crash data. This patch is the start of a new API.
In this patch, the CrashManager type is introduced. It has APIs for
retrieving the lists of files related to crash dumps. In subsequent
patches, I will convert existing code in the tree that does similar
things to the new API. I will also build the events/timeline API onto
this type.
I made CrashManager generic because I hate, hate, hate singletons and
global variables. Allowing it to be instantiated multiple times with
different options (instead of say binding a global instance to ProfD)
makes the testing story much, much nicer. That is reason enough, IMO. In
a subsequent patch, I'll add an XPCOM service that instantiates the
"global" instance of CrashManager with the appropriate options.
It was tempting to add this code into the existing CrashReports.jsm.
However, this file does not import cleanly in xpcshell tests and I
didn't want to bloat scope to include fixing that file... yet.
CrashReports.jsm is using synchronous I/O. So, depending on how
adventerous I feel, I may replace consumers of CrashReports.jsm with the
new CrashManager.jsm, remove CrashReports.jsm, and eliminate another
source of synchronous I/O in the tree.
--HG--
extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c
2013-11-19 14:08:25 -08:00
|
|
|
});
|
2014-01-23 15:49:24 -08:00
|
|
|
|
|
|
|
let gCrashManager;
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
/**
|
|
|
|
* Interface to storage of crash data.
|
|
|
|
*
|
|
|
|
* This type handles storage of crash metadata. It exists as a separate type
|
|
|
|
* from the crash manager for performance reasons: since all crash metadata
|
|
|
|
* needs to be loaded into memory for access, we wish to easily dispose of all
|
|
|
|
* associated memory when this data is no longer needed. Having an isolated
|
|
|
|
* object whose references can easily be lost faciliates that simple disposal.
|
|
|
|
*
|
|
|
|
* When metadata is updated, the caller must explicitly persist the changes
|
|
|
|
* to disk. This prevents excessive I/O during updates.
|
|
|
|
*
|
2014-01-28 17:33:38 -08:00
|
|
|
* The store has a mechanism for ensuring it doesn't grow too large. A ceiling
|
|
|
|
* is placed on the number of daily events that can occur for events that can
|
|
|
|
* occur with relatively high frequency, notably plugin crashes and hangs
|
|
|
|
* (plugins can enter cycles where they repeatedly crash). If we've reached
|
|
|
|
* the high water mark and new data arrives, it's silently dropped.
|
|
|
|
* However, the count of actual events is always preserved. This allows
|
|
|
|
* us to report on the severity of problems beyond the storage threshold.
|
|
|
|
*
|
|
|
|
* Main process crashes are excluded from limits because they are both
|
|
|
|
* important and should be rare.
|
|
|
|
*
|
2014-01-27 15:49:11 -08:00
|
|
|
* @param storeDir (string)
|
|
|
|
* Directory the store should be located in.
|
|
|
|
* @param telemetrySizeKey (string)
|
|
|
|
* The telemetry histogram that should be used to store the size
|
|
|
|
* of the data file.
|
|
|
|
*/
|
|
|
|
function CrashStore(storeDir, telemetrySizeKey) {
|
|
|
|
this._storeDir = storeDir;
|
|
|
|
this._telemetrySizeKey = telemetrySizeKey;
|
|
|
|
|
|
|
|
this._storePath = OS.Path.join(storeDir, "store.json.mozlz4");
|
|
|
|
|
|
|
|
// Holds the read data from disk.
|
|
|
|
this._data = null;
|
2014-01-28 17:33:38 -08:00
|
|
|
|
|
|
|
// Maps days since UNIX epoch to a Map of event types to counts.
|
|
|
|
// This data structure is populated when the JSON file is loaded
|
|
|
|
// and is also updated when new events are added.
|
|
|
|
this._countsByDay = new Map();
|
2014-01-27 15:49:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
CrashStore.prototype = Object.freeze({
|
2014-01-28 17:33:38 -08:00
|
|
|
// Maximum number of events to store per day. This establishes a
|
|
|
|
// ceiling on the per-type/per-day records that will be stored.
|
|
|
|
HIGH_WATER_DAILY_THRESHOLD: 100,
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
/**
|
|
|
|
* Load data from disk.
|
|
|
|
*
|
2014-01-28 17:33:38 -08:00
|
|
|
* @return Promise
|
2014-01-27 15:49:11 -08:00
|
|
|
*/
|
|
|
|
load: function () {
|
|
|
|
return Task.spawn(function* () {
|
2014-01-28 17:33:38 -08:00
|
|
|
// Loading replaces data. So reset data structures.
|
2014-01-27 15:49:11 -08:00
|
|
|
this._data = {
|
|
|
|
v: 1,
|
|
|
|
crashes: new Map(),
|
|
|
|
corruptDate: null,
|
|
|
|
};
|
2014-01-28 17:33:38 -08:00
|
|
|
this._countsByDay = new Map();
|
2014-01-27 15:49:11 -08:00
|
|
|
|
|
|
|
try {
|
|
|
|
let decoder = new TextDecoder();
|
2014-03-13 06:50:24 -07:00
|
|
|
let data = yield OS.File.read(this._storePath, {compression: "lz4"});
|
2014-01-27 15:49:11 -08:00
|
|
|
data = JSON.parse(decoder.decode(data));
|
|
|
|
|
|
|
|
if (data.corruptDate) {
|
|
|
|
this._data.corruptDate = new Date(data.corruptDate);
|
|
|
|
}
|
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
// actualCounts is used to validate that the derived counts by
|
|
|
|
// days stored in the payload matches up to actual data.
|
|
|
|
let actualCounts = new Map();
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
for (let id in data.crashes) {
|
|
|
|
let crash = data.crashes[id];
|
|
|
|
let denormalized = this._denormalize(crash);
|
2014-01-28 17:33:38 -08:00
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
this._data.crashes.set(id, denormalized);
|
2014-01-28 17:33:38 -08:00
|
|
|
|
|
|
|
let key = dateToDays(denormalized.crashDate) + "-" + denormalized.type;
|
|
|
|
actualCounts.set(key, (actualCounts.get(key) || 0) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The validation in this loop is arguably not necessary. We perform
|
|
|
|
// it as a defense against unknown bugs.
|
|
|
|
for (let dayKey in data.countsByDay) {
|
|
|
|
let day = parseInt(dayKey, 10);
|
|
|
|
for (let type in data.countsByDay[day]) {
|
|
|
|
this._ensureCountsForDay(day);
|
|
|
|
|
|
|
|
let count = data.countsByDay[day][type];
|
|
|
|
let key = day + "-" + type;
|
|
|
|
|
|
|
|
// If the payload says we have data for a given day but we
|
|
|
|
// don't, the payload is wrong. Ignore it.
|
|
|
|
if (!actualCounts.has(key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we encountered more data in the payload than what the
|
|
|
|
// data structure says, use the proper value.
|
|
|
|
count = Math.max(count, actualCounts.get(key));
|
|
|
|
|
|
|
|
this._countsByDay.get(day).set(type, count);
|
|
|
|
}
|
2014-01-27 15:49:11 -08:00
|
|
|
}
|
|
|
|
} catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
|
|
|
|
// Missing files (first use) are allowed.
|
|
|
|
} catch (ex) {
|
|
|
|
// If we can't load for any reason, mark a corrupt date in the instance
|
|
|
|
// and swallow the error.
|
|
|
|
//
|
|
|
|
// The marking of a corrupted file is intentionally not persisted to
|
|
|
|
// disk yet. Instead, we wait until the next save(). This is to give
|
|
|
|
// non-permanent failures the opportunity to recover on their own.
|
|
|
|
this._data.corruptDate = new Date();
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save data to disk.
|
|
|
|
*
|
|
|
|
* @return Promise<null>
|
|
|
|
*/
|
|
|
|
save: function () {
|
|
|
|
return Task.spawn(function* () {
|
|
|
|
if (!this._data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let normalized = {
|
2014-01-28 17:33:38 -08:00
|
|
|
// The version should be incremented whenever the format
|
|
|
|
// changes.
|
2014-01-27 15:49:11 -08:00
|
|
|
v: 1,
|
2014-01-28 17:33:38 -08:00
|
|
|
// Maps crash IDs to objects defining the crash.
|
2014-01-27 15:49:11 -08:00
|
|
|
crashes: {},
|
2014-01-28 17:33:38 -08:00
|
|
|
// Maps days since UNIX epoch to objects mapping event types to
|
|
|
|
// counts. This is a mirror of this._countsByDay. e.g.
|
|
|
|
// {
|
|
|
|
// 15000: {
|
|
|
|
// "main-crash": 2,
|
|
|
|
// "plugin-crash": 1
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
countsByDay: {},
|
|
|
|
|
|
|
|
// When the store was last corrupted.
|
2014-01-27 15:49:11 -08:00
|
|
|
corruptDate: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this._data.corruptDate) {
|
|
|
|
normalized.corruptDate = this._data.corruptDate.getTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let [id, crash] of this._data.crashes) {
|
|
|
|
let c = this._normalize(crash);
|
|
|
|
normalized.crashes[id] = c;
|
|
|
|
}
|
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
for (let [day, m] of this._countsByDay) {
|
|
|
|
normalized.countsByDay[day] = {};
|
|
|
|
for (let [type, count] of m) {
|
|
|
|
normalized.countsByDay[day][type] = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
let encoder = new TextEncoder();
|
|
|
|
let data = encoder.encode(JSON.stringify(normalized));
|
|
|
|
let size = yield OS.File.writeAtomic(this._storePath, data, {
|
|
|
|
tmpPath: this._storePath + ".tmp",
|
|
|
|
compression: "lz4"});
|
|
|
|
if (this._telemetrySizeKey) {
|
|
|
|
Services.telemetry.getHistogramById(this._telemetrySizeKey).add(size);
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Normalize an object into one fit for serialization.
|
|
|
|
*
|
|
|
|
* This function along with _denormalize() serve to hack around the
|
|
|
|
* default handling of Date JSON serialization because Date serialization
|
|
|
|
* is undefined by JSON.
|
|
|
|
*
|
|
|
|
* Fields ending with "Date" are assumed to contain Date instances.
|
|
|
|
* We convert these to milliseconds since epoch on output and back to
|
|
|
|
* Date on input.
|
|
|
|
*/
|
|
|
|
_normalize: function (o) {
|
|
|
|
let normalized = {};
|
|
|
|
|
|
|
|
for (let k in o) {
|
|
|
|
let v = o[k];
|
|
|
|
if (v && k.endsWith("Date")) {
|
|
|
|
normalized[k] = v.getTime();
|
|
|
|
} else {
|
|
|
|
normalized[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return normalized;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a serialized object back to its native form.
|
|
|
|
*/
|
|
|
|
_denormalize: function (o) {
|
|
|
|
let n = {};
|
|
|
|
|
|
|
|
for (let k in o) {
|
|
|
|
let v = o[k];
|
|
|
|
if (v && k.endsWith("Date")) {
|
|
|
|
n[k] = new Date(parseInt(v, 10));
|
|
|
|
} else {
|
|
|
|
n[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prune old crash data.
|
|
|
|
*
|
|
|
|
* Crashes without recent activity are pruned from the store so the
|
|
|
|
* size of the store is not unbounded. If there is activity on a crash,
|
|
|
|
* that activity will keep the crash and all its data around for longer.
|
|
|
|
*
|
|
|
|
* @param date
|
|
|
|
* (Date) The cutoff at which data will be pruned. If an entry
|
|
|
|
* doesn't have data newer than this, it will be pruned.
|
|
|
|
*/
|
|
|
|
pruneOldCrashes: function (date) {
|
|
|
|
for (let crash of this.crashes) {
|
|
|
|
let newest = crash.newestDate;
|
|
|
|
if (!newest || newest.getTime() < date.getTime()) {
|
|
|
|
this._data.crashes.delete(crash.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Date the store was last corrupted and required a reset.
|
|
|
|
*
|
|
|
|
* May be null (no corruption has ever occurred) or a Date instance.
|
|
|
|
*/
|
|
|
|
get corruptDate() {
|
|
|
|
return this._data.corruptDate;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of distinct crashes tracked.
|
|
|
|
*/
|
|
|
|
get crashesCount() {
|
|
|
|
return this._data.crashes.size;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All crashes tracked.
|
|
|
|
*
|
|
|
|
* This is an array of CrashRecord.
|
|
|
|
*/
|
|
|
|
get crashes() {
|
|
|
|
let crashes = [];
|
|
|
|
for (let [id, crash] of this._data.crashes) {
|
|
|
|
crashes.push(new CrashRecord(crash));
|
|
|
|
}
|
|
|
|
|
|
|
|
return crashes;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a particular crash from its ID.
|
|
|
|
*
|
|
|
|
* A CrashRecord will be returned if the crash exists. null will be returned
|
|
|
|
* if the crash is unknown.
|
|
|
|
*/
|
|
|
|
getCrash: function (id) {
|
|
|
|
for (let crash of this.crashes) {
|
|
|
|
if (crash.id == id) {
|
|
|
|
return crash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
2014-01-28 15:46:03 -08:00
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
_ensureCountsForDay: function (day) {
|
|
|
|
if (!this._countsByDay.has(day)) {
|
|
|
|
this._countsByDay.set(day, new Map());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure the crash record is present in storage.
|
|
|
|
*
|
|
|
|
* Returns the crash record if we're allowed to store it or null
|
|
|
|
* if we've hit the high water mark.
|
|
|
|
*
|
2014-05-12 11:58:18 -07:00
|
|
|
* @param processType
|
|
|
|
* (string) One of the PROCESS_TYPE constants.
|
|
|
|
* @param crashType
|
|
|
|
* (string) One of the CRASH_TYPE constants.
|
2014-01-28 17:33:38 -08:00
|
|
|
* @param id
|
|
|
|
* (string) The crash ID.
|
|
|
|
* @param date
|
|
|
|
* (Date) When this crash occurred.
|
|
|
|
*
|
|
|
|
* @return null | object crash record
|
|
|
|
*/
|
2014-05-12 11:58:18 -07:00
|
|
|
_ensureCrashRecord: function (processType, crashType, id, date) {
|
|
|
|
if (!id) {
|
|
|
|
// Crashes are keyed on ID, so it's not really helpful to store crashes
|
|
|
|
// without IDs.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
let day = dateToDays(date);
|
|
|
|
this._ensureCountsForDay(day);
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
let type = processType + "-" + crashType;
|
2014-01-28 17:33:38 -08:00
|
|
|
let count = (this._countsByDay.get(day).get(type) || 0) + 1;
|
|
|
|
this._countsByDay.get(day).set(type, count);
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
if (count > this.HIGH_WATER_DAILY_THRESHOLD &&
|
|
|
|
processType != CrashManager.prototype.PROCESS_TYPE_MAIN) {
|
2014-01-28 17:33:38 -08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
if (!this._data.crashes.has(id)) {
|
|
|
|
this._data.crashes.set(id, {
|
|
|
|
id: id,
|
2014-01-28 17:33:38 -08:00
|
|
|
type: type,
|
|
|
|
crashDate: date,
|
2014-01-28 15:46:03 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
let crash = this._data.crashes.get(id);
|
|
|
|
crash.type = type;
|
2014-08-07 21:52:05 -07:00
|
|
|
crash.crashDate = date;
|
2014-01-28 17:33:38 -08:00
|
|
|
|
|
|
|
return crash;
|
2014-01-28 15:46:03 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-05-12 11:58:18 -07:00
|
|
|
* Record the occurrence of a crash.
|
2014-01-28 15:46:03 -08:00
|
|
|
*
|
2014-05-12 11:58:18 -07:00
|
|
|
* @param processType (string) One of the PROCESS_TYPE constants.
|
|
|
|
* @param crashType (string) One of the CRASH_TYPE constants.
|
2014-01-28 15:46:03 -08:00
|
|
|
* @param id (string) Crash ID. Likely a UUID.
|
|
|
|
* @param date (Date) When the crash occurred.
|
|
|
|
*
|
2014-05-12 11:58:18 -07:00
|
|
|
* @return boolean True if the crash was recorded and false if not.
|
2014-01-28 15:46:03 -08:00
|
|
|
*/
|
2014-05-12 11:58:18 -07:00
|
|
|
addCrash: function (processType, crashType, id, date) {
|
|
|
|
return !!this._ensureCrashRecord(processType, crashType, id, date);
|
2014-01-28 15:46:03 -08:00
|
|
|
},
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
getCrashesOfType: function (processType, crashType) {
|
2014-01-28 15:46:03 -08:00
|
|
|
let crashes = [];
|
|
|
|
for (let crash of this.crashes) {
|
2014-05-12 11:58:18 -07:00
|
|
|
if (crash.isOfType(processType, crashType)) {
|
2014-01-28 15:46:03 -08:00
|
|
|
crashes.push(crash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return crashes;
|
|
|
|
},
|
2014-01-27 15:49:11 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an individual crash with metadata.
|
|
|
|
*
|
|
|
|
* This is a wrapper around the low-level anonymous JS objects that define
|
|
|
|
* crashes. It exposes a consistent and helpful API.
|
|
|
|
*
|
|
|
|
* Instances of this type should only be constructured inside this module,
|
|
|
|
* not externally. The constructor is not considered a public API.
|
|
|
|
*
|
|
|
|
* @param o (object)
|
|
|
|
* The crash's entry from the CrashStore.
|
|
|
|
*/
|
|
|
|
function CrashRecord(o) {
|
|
|
|
this._o = o;
|
|
|
|
}
|
|
|
|
|
|
|
|
CrashRecord.prototype = Object.freeze({
|
|
|
|
get id() {
|
|
|
|
return this._o.id;
|
|
|
|
},
|
|
|
|
|
|
|
|
get crashDate() {
|
|
|
|
return this._o.crashDate;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the newest date in this record.
|
|
|
|
*
|
|
|
|
* This is a convenience getter. The returned value is used to determine when
|
|
|
|
* to expire a record.
|
|
|
|
*/
|
|
|
|
get newestDate() {
|
|
|
|
// We currently only have 1 date, so this is easy.
|
|
|
|
return this._o.crashDate;
|
|
|
|
},
|
2014-01-28 15:46:03 -08:00
|
|
|
|
2014-01-28 17:33:38 -08:00
|
|
|
get oldestDate() {
|
|
|
|
return this._o.crashDate;
|
|
|
|
},
|
|
|
|
|
2014-01-28 15:46:03 -08:00
|
|
|
get type() {
|
|
|
|
return this._o.type;
|
|
|
|
},
|
|
|
|
|
2014-05-12 11:58:18 -07:00
|
|
|
isOfType: function (processType, crashType) {
|
|
|
|
return processType + "-" + crashType == this.type;
|
2014-01-28 15:46:03 -08:00
|
|
|
},
|
2014-01-27 15:49:11 -08:00
|
|
|
});
|
|
|
|
|
2014-01-23 15:49:24 -08:00
|
|
|
/**
|
|
|
|
* Obtain the global CrashManager instance used by the running application.
|
|
|
|
*
|
|
|
|
* CrashManager is likely only ever instantiated once per application lifetime.
|
|
|
|
* The main reason it's implemented as a reusable type is to facilitate testing.
|
|
|
|
*/
|
|
|
|
XPCOMUtils.defineLazyGetter(this.CrashManager, "Singleton", function () {
|
|
|
|
if (gCrashManager) {
|
|
|
|
return gCrashManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
let crPath = OS.Path.join(OS.Constants.Path.userApplicationDataDir,
|
|
|
|
"Crash Reports");
|
2014-01-27 15:49:11 -08:00
|
|
|
let storePath = OS.Path.join(OS.Constants.Path.profileDir, "crashes");
|
|
|
|
|
2014-01-23 15:49:24 -08:00
|
|
|
gCrashManager = new CrashManager({
|
|
|
|
pendingDumpsDir: OS.Path.join(crPath, "pending"),
|
|
|
|
submittedDumpsDir: OS.Path.join(crPath, "submitted"),
|
2014-01-27 15:49:11 -08:00
|
|
|
eventsDirs: [OS.Path.join(crPath, "events"), OS.Path.join(storePath, "events")],
|
|
|
|
storeDir: storePath,
|
|
|
|
telemetryStoreSizeKey: "CRASH_STORE_COMPRESSED_BYTES",
|
2014-01-23 15:49:24 -08:00
|
|
|
});
|
|
|
|
|
2014-01-27 15:49:11 -08:00
|
|
|
// Automatically aggregate event files shortly after startup. This
|
|
|
|
// ensures it happens with some frequency.
|
|
|
|
//
|
|
|
|
// There are performance considerations here. While this is doing
|
|
|
|
// work and could negatively impact performance, the amount of work
|
|
|
|
// is kept small per run by periodically aggregating event files.
|
|
|
|
// Furthermore, well-behaving installs should not have much work
|
|
|
|
// here to do. If there is a lot of work, that install has bigger
|
|
|
|
// issues beyond reduced performance near startup.
|
|
|
|
gCrashManager.scheduleMaintenance(AGGREGATE_STARTUP_DELAY_MS);
|
|
|
|
|
2014-01-23 15:49:24 -08:00
|
|
|
return gCrashManager;
|
|
|
|
});
|