зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1380659 - Introduce code coverage component to dump/reset coverage counters. r=erahm
--HG-- rename : ipc/glue/CodeCoverageHandler.cpp => tools/code-coverage/CodeCoverageHandler.cpp rename : ipc/glue/CodeCoverageHandler.h => tools/code-coverage/CodeCoverageHandler.h extra : rebase_source : 77b2f698d9120d3fadcae65b3d22831a9e5429f9
This commit is contained in:
Родитель
61cece8105
Коммит
9ca39b7d11
|
@ -185,6 +185,9 @@
|
|||
@RESPATH@/browser/components/browser-feeds.xpt
|
||||
@RESPATH@/components/caps.xpt
|
||||
@RESPATH@/components/chrome.xpt
|
||||
#ifdef MOZ_CODE_COVERAGE
|
||||
@RESPATH@/components/code-coverage.xpt
|
||||
#endif
|
||||
@RESPATH@/components/commandhandler.xpt
|
||||
@RESPATH@/components/commandlines.xpt
|
||||
@RESPATH@/components/composer.xpt
|
||||
|
|
|
@ -214,15 +214,6 @@ LOCAL_INCLUDES += [
|
|||
'/xpcom/threads',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_CODE_COVERAGE']:
|
||||
SOURCES += [
|
||||
'CodeCoverageHandler.cpp',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'CodeCoverageHandler.h',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
|
|
@ -111,6 +111,7 @@ if CONFIG['MOZ_JPROF']:
|
|||
DIRS += ['/tools/jprof']
|
||||
|
||||
DIRS += [
|
||||
'/tools/code-coverage',
|
||||
'/tools/power',
|
||||
'/tools/profiler',
|
||||
'/tools/memory-profiler',
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# -*- 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/.
|
||||
|
||||
if CONFIG['MOZ_CODE_COVERAGE']:
|
||||
XPIDL_MODULE = 'code-coverage'
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsICodeCoverage.idl',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'CodeCoverageHandler.cpp',
|
||||
'nsCodeCoverage.cpp',
|
||||
'nsCodeCoverageFactory.cpp',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'CodeCoverageHandler.h',
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/ipc/chromium/src',
|
||||
'/xpcom/base',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsCodeCoverage.h"
|
||||
#include "mozilla/CodeCoverageHandler.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsCodeCoverage,
|
||||
nsICodeCoverage)
|
||||
|
||||
nsCodeCoverage::nsCodeCoverage()
|
||||
{
|
||||
}
|
||||
|
||||
nsCodeCoverage::~nsCodeCoverage()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCodeCoverage::DumpCounters()
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CodeCoverageHandler::DumpCounters(0);
|
||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||
Unused << cp->SendDumpCodeCoverageCounters();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCodeCoverage::ResetCounters()
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CodeCoverageHandler::ResetCounters(0);
|
||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||
Unused << cp->SendResetCodeCoverageCounters();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef tools_codecoverage_nscodecoverage_h
|
||||
#define tools_codecoverage_nscodecoverage_h
|
||||
|
||||
#include "nsICodeCoverage.h"
|
||||
|
||||
#define NS_CODECOVERAGE_CID \
|
||||
{ 0x93576af0, 0xa62f, 0x4c88, \
|
||||
{ 0xbc, 0x12, 0xf1, 0x85, 0x5d, 0x4e, 0x01, 0x73 } }
|
||||
|
||||
class nsCodeCoverage final : nsICodeCoverage {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICODECOVERAGE
|
||||
|
||||
nsCodeCoverage();
|
||||
|
||||
private:
|
||||
~nsCodeCoverage();
|
||||
};
|
||||
|
||||
#endif // tools_codecoverage_nscodecoverage_h
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCodeCoverage.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCodeCoverage)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_CODECOVERAGE_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kCodeCoverageCIDs[] = {
|
||||
{ &kNS_CODECOVERAGE_CID, false, nullptr, nsCodeCoverageConstructor },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kCodeCoverageContracts[] = {
|
||||
{ "@mozilla.org/tools/code-coverage;1", &kNS_CODECOVERAGE_CID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module kCodeCoverageModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kCodeCoverageCIDs,
|
||||
kCodeCoverageContracts
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(nsCodeCoverageModule) = &kCodeCoverageModule;
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The nsICodeCoverage component allows controlling the code coverage counters
|
||||
* collected by Firefox during execution.
|
||||
* By resetting and dumping the counters, one can analyze the coverage information
|
||||
* for a subset of the program execution (e.g. startup code coverage).
|
||||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(57d92056-37b4-4d0a-a52f-deb8f6dac8bc)]
|
||||
interface nsICodeCoverage : nsISupports
|
||||
{
|
||||
/**
|
||||
* Write the coverage counters to disk.
|
||||
*/
|
||||
void dumpCounters();
|
||||
|
||||
/**
|
||||
* Reset the coverage counters to 0 (as if nothing was executed).
|
||||
*/
|
||||
void resetCounters();
|
||||
};
|
Загрузка…
Ссылка в новой задаче