зеркало из https://github.com/mozilla/gecko-dev.git
Bug 763138: Telemetry should indicate whether a debugger is attached. r=bsmedberg,smichaud
This commit is contained in:
Родитель
d81b3c6fa4
Коммит
2e4f27310a
|
@ -65,6 +65,8 @@ const IDLE_TIMEOUT_SECONDS = 5 * 60;
|
|||
|
||||
var gLastMemoryPoll = null;
|
||||
|
||||
let gWasDebuggerAttached = false;
|
||||
|
||||
function getLocale() {
|
||||
return Cc["@mozilla.org/chrome/chrome-registry;1"].
|
||||
getService(Ci.nsIXULChromeRegistry).
|
||||
|
@ -121,6 +123,12 @@ function getSimpleMeasurements() {
|
|||
|
||||
ret.startupInterrupted = new Number(Services.startup.interrupted);
|
||||
|
||||
// Update debuggerAttached flag
|
||||
let debugService = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
|
||||
let isDebuggerAttached = debugService.isDebuggerAttached;
|
||||
gWasDebuggerAttached = gWasDebuggerAttached || isDebuggerAttached;
|
||||
ret.debuggerAttached = new Number(gWasDebuggerAttached);
|
||||
|
||||
ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
|
||||
.getService(Ci.nsIJSEngineTelemetryStats)
|
||||
.telemetryValue;
|
||||
|
@ -776,6 +784,9 @@ TelemetryPing.prototype = {
|
|||
case "sessionstore-windows-restored":
|
||||
Services.obs.removeObserver(this, "sessionstore-windows-restored");
|
||||
this._hasWindowRestoredObserver = false;
|
||||
// Check whether debugger was attached during startup
|
||||
let debugService = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
|
||||
gWasDebuggerAttached = debugService.isDebuggerAttached;
|
||||
// fall through
|
||||
case "test-gather-startup":
|
||||
this.gatherStartupInformation();
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
#include "nsString.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "mozilla/mozalloc_abort.h"
|
||||
|
||||
static void
|
||||
|
@ -136,6 +143,40 @@ nsDebugImpl::GetAssertionCount(PRInt32* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDebugImpl::GetIsDebuggerAttached(bool* aResult)
|
||||
{
|
||||
*aResult = false;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
*aResult = ::IsDebuggerPresent();
|
||||
#elif defined(XP_MACOSX)
|
||||
// Specify the info we're looking for
|
||||
int mib[4];
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_PROC;
|
||||
mib[2] = KERN_PROC_PID;
|
||||
mib[3] = getpid();
|
||||
size_t mibSize = sizeof(mib) / sizeof(int);
|
||||
|
||||
struct kinfo_proc info;
|
||||
size_t infoSize = sizeof(info);
|
||||
memset(&info, 0, infoSize);
|
||||
|
||||
if (sysctl(mib, mibSize, &info, &infoSize, NULL, 0)) {
|
||||
// if the call fails, default to false
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (info.kp_proc.p_flag & P_TRACED) {
|
||||
*aResult = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsDebugImpl::SetMultiprocessMode(const char *aDesc)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "nsIDebug.idl"
|
||||
|
||||
[scriptable, uuid(9c9307ed-480a-4f2a-8f29-21378c03bcbc)]
|
||||
[scriptable, uuid(6cb17fec-cdf7-4f7c-b267-37a0acaa9cf1)]
|
||||
interface nsIDebug2 : nsIDebug
|
||||
{
|
||||
/**
|
||||
|
@ -21,4 +21,10 @@ interface nsIDebug2 : nsIDebug
|
|||
* The number of assertions since process start.
|
||||
*/
|
||||
readonly attribute long assertionCount;
|
||||
|
||||
/**
|
||||
* Whether a debugger is currently attached.
|
||||
* Supports Windows + Mac
|
||||
*/
|
||||
readonly attribute bool isDebuggerAttached;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче