#include "src/inspector/v8-profiler-agent-impl.h"
#include <vector>
#include "include/v8-profiler.h"
#include "src/base/atomicops.h"
#include "src/base/platform/time.h"
#include "src/debug/debug-interface.h"
#include "src/inspector/protocol/Protocol.h"
#include "src/inspector/string-util.h"
#include "src/inspector/v8-debugger.h"
#include "src/inspector/v8-inspector-impl.h"
#include "src/inspector/v8-inspector-session-impl.h"
#include "src/inspector/v8-stack-trace-impl.h"
namespace v8_inspector {
namespace ProfilerAgentState {
static const char samplingInterval[] = …;
static const char userInitiatedProfiling[] = …;
static const char profilerEnabled[] = …;
static const char preciseCoverageStarted[] = …;
static const char preciseCoverageCallCount[] = …;
static const char preciseCoverageDetailed[] = …;
static const char preciseCoverageAllowTriggeredUpdates[] = …;
}
namespace {
String16 resourceNameToUrl(V8InspectorImpl* inspector,
v8::Local<v8::String> v8Name) { … }
std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>>
buildInspectorObjectForPositionTicks(const v8::CpuProfileNode* node) { … }
std::unique_ptr<protocol::Profiler::ProfileNode> buildInspectorObjectFor(
V8InspectorImpl* inspector, const v8::CpuProfileNode* node) { … }
std::unique_ptr<protocol::Array<int>> buildInspectorObjectForSamples(
v8::CpuProfile* v8profile) { … }
std::unique_ptr<protocol::Array<int>> buildInspectorObjectForTimestamps(
v8::CpuProfile* v8profile) { … }
void flattenNodesTree(V8InspectorImpl* inspector,
const v8::CpuProfileNode* node,
protocol::Array<protocol::Profiler::ProfileNode>* list) { … }
std::unique_ptr<protocol::Profiler::Profile> createCPUProfile(
V8InspectorImpl* inspector, v8::CpuProfile* v8profile) { … }
std::unique_ptr<protocol::Debugger::Location> currentDebugLocation(
V8InspectorImpl* inspector) { … }
volatile int s_lastProfileId = …;
}
class V8ProfilerAgentImpl::ProfileDescriptor { … };
V8ProfilerAgentImpl::V8ProfilerAgentImpl(
V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel,
protocol::DictionaryValue* state)
: … { … }
V8ProfilerAgentImpl::~V8ProfilerAgentImpl() { … }
void V8ProfilerAgentImpl::consoleProfile(const String16& title) { … }
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) { … }
Response V8ProfilerAgentImpl::enable() { … }
Response V8ProfilerAgentImpl::disable() { … }
Response V8ProfilerAgentImpl::setSamplingInterval(int interval) { … }
void V8ProfilerAgentImpl::restore() { … }
Response V8ProfilerAgentImpl::start() { … }
Response V8ProfilerAgentImpl::stop(
std::unique_ptr<protocol::Profiler::Profile>* profile) { … }
Response V8ProfilerAgentImpl::startPreciseCoverage(
Maybe<bool> callCount, Maybe<bool> detailed,
Maybe<bool> allowTriggeredUpdates, double* out_timestamp) { … }
Response V8ProfilerAgentImpl::stopPreciseCoverage() { … }
namespace {
std::unique_ptr<protocol::Profiler::CoverageRange> createCoverageRange(
int start, int end, int count) { … }
Response coverageToProtocol(
V8InspectorImpl* inspector, const v8::debug::Coverage& coverage,
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) { … }
}
Response V8ProfilerAgentImpl::takePreciseCoverage(
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result,
double* out_timestamp) { … }
void V8ProfilerAgentImpl::triggerPreciseCoverageDeltaUpdate(
const String16& occasion) { … }
Response V8ProfilerAgentImpl::getBestEffortCoverage(
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) { … }
String16 V8ProfilerAgentImpl::nextProfileId() { … }
void V8ProfilerAgentImpl::startProfiling(const String16& title) { … }
std::unique_ptr<protocol::Profiler::Profile> V8ProfilerAgentImpl::stopProfiling(
const String16& title, bool serialize) { … }
}