Skip to content

Commit 55f21a5

Browse files
author
Eugene Ostroukhov
committed
Inspector snapshot
Blink Commit: 60cd6e859b9f557d2312f5bf532f6aec5f284980
1 parent ab732a6 commit 55f21a5

13 files changed

+172
-24
lines changed

third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,11 @@ def read_protocol_file(file_name, json_api):
345345
json_string = input_file.read()
346346
input_file.close()
347347
parsed_json = json.loads(json_string)
348+
version = parsed_json["version"]["major"] + "." + parsed_json["version"]["minor"]
348349
domains = []
349350
for domain in parsed_json["domains"]:
350351
domains.append(domain["domain"])
352+
domain["version"] = version
351353
json_api["domains"] += parsed_json["domains"]
352354
return domains
353355

third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace {{domain.domain}} {
1414

1515
const char Metainfo::domainName[] = "{{domain.domain}}";
1616
const char Metainfo::commandPrefix[] = "{{domain.domain}}.";
17+
const char Metainfo::version[] = "{{domain.version}}";
1718
{% for type in domain.types %}
1819
{% if "enum" in type %}
1920

third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public:
277277
using DispatcherClass = Dispatcher;
278278
static const char domainName[];
279279
static const char commandPrefix[];
280+
static const char version[];
280281
};
281282

282283
} // namespace {{domain.domain}}

third_party/v8_inspector/platform/v8_inspector/PlatformSTL.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,10 @@ inline static int snprintf(char *buffer, size_t n, const char *format, ...)
308308
} // namespace std
309309
#endif // (_WIN32) && defined( _MSC_VER ) && (_MSC_VER < 1900)
310310

311+
#ifdef __sun
312+
namespace std {
313+
using ::snprintf;
314+
} // namespace std
315+
#endif // __sun
316+
311317
#endif // PlatformSTL_h

third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "platform/v8_inspector/V8InspectorImpl.h"
1515
#include "platform/v8_inspector/V8ProfilerAgentImpl.h"
1616
#include "platform/v8_inspector/V8RuntimeAgentImpl.h"
17+
#include "platform/v8_inspector/V8SchemaAgentImpl.h"
1718
#include "platform/v8_inspector/V8StringUtil.h"
1819
#include "platform/v8_inspector/public/V8ContextInfo.h"
1920
#include "platform/v8_inspector/public/V8InspectorClient.h"
@@ -27,7 +28,8 @@ bool V8InspectorSession::canDispatchMethod(const String16& method)
2728
|| method.startsWith(protocol::Debugger::Metainfo::commandPrefix)
2829
|| method.startsWith(protocol::Profiler::Metainfo::commandPrefix)
2930
|| method.startsWith(protocol::HeapProfiler::Metainfo::commandPrefix)
30-
|| method.startsWith(protocol::Console::Metainfo::commandPrefix);
31+
|| method.startsWith(protocol::Console::Metainfo::commandPrefix)
32+
|| method.startsWith(protocol::Schema::Metainfo::commandPrefix);
3133
}
3234

3335
std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const String16* state)
@@ -46,6 +48,7 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
4648
, m_heapProfilerAgent(nullptr)
4749
, m_profilerAgent(nullptr)
4850
, m_consoleAgent(nullptr)
51+
, m_schemaAgent(nullptr)
4952
{
5053
if (savedState) {
5154
std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState);
@@ -72,6 +75,9 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
7275
m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState(protocol::Console::Metainfo::domainName)));
7376
protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get());
7477

78+
m_schemaAgent = wrapUnique(new V8SchemaAgentImpl(this, channel, agentState(protocol::Schema::Metainfo::domainName)));
79+
protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get());
80+
7581
if (savedState) {
7682
m_runtimeAgent->restore();
7783
m_debuggerAgent->restore();
@@ -262,6 +268,26 @@ String16 V8InspectorSessionImpl::stateJSON()
262268
return m_state->toJSONString();
263269
}
264270

271+
std::unique_ptr<protocol::Array<protocol::Schema::API::Domain>> V8InspectorSessionImpl::supportedDomains()
272+
{
273+
std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = supportedDomainsImpl();
274+
std::unique_ptr<protocol::Array<protocol::Schema::API::Domain>> result = protocol::Array<protocol::Schema::API::Domain>::create();
275+
for (size_t i = 0; i < domains.size(); ++i)
276+
result->addItem(std::move(domains[i]));
277+
return result;
278+
}
279+
280+
std::vector<std::unique_ptr<protocol::Schema::Domain>> V8InspectorSessionImpl::supportedDomainsImpl()
281+
{
282+
std::vector<std::unique_ptr<protocol::Schema::Domain>> result;
283+
result.push_back(protocol::Schema::Domain::create().setName(protocol::Runtime::Metainfo::domainName).setVersion(protocol::Runtime::Metainfo::version).build());
284+
result.push_back(protocol::Schema::Domain::create().setName(protocol::Debugger::Metainfo::domainName).setVersion(protocol::Debugger::Metainfo::version).build());
285+
result.push_back(protocol::Schema::Domain::create().setName(protocol::Profiler::Metainfo::domainName).setVersion(protocol::Profiler::Metainfo::version).build());
286+
result.push_back(protocol::Schema::Domain::create().setName(protocol::HeapProfiler::Metainfo::domainName).setVersion(protocol::HeapProfiler::Metainfo::version).build());
287+
result.push_back(protocol::Schema::Domain::create().setName(protocol::Schema::Metainfo::domainName).setVersion(protocol::Schema::Metainfo::version).build());
288+
return result;
289+
}
290+
265291
void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable> inspectable)
266292
{
267293
m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable));

third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "platform/inspector_protocol/InspectorProtocol.h"
99
#include "platform/v8_inspector/protocol/Runtime.h"
10+
#include "platform/v8_inspector/protocol/Schema.h"
1011
#include "platform/v8_inspector/public/V8InspectorSession.h"
1112

1213
#include <v8.h>
@@ -23,6 +24,7 @@ class V8InspectorImpl;
2324
class V8HeapProfilerAgentImpl;
2425
class V8ProfilerAgentImpl;
2526
class V8RuntimeAgentImpl;
27+
class V8SchemaAgentImpl;
2628

2729
namespace protocol = blink::protocol;
2830

@@ -35,6 +37,7 @@ class V8InspectorSessionImpl : public V8InspectorSession {
3537
V8InspectorImpl* inspector() const { return m_inspector; }
3638
V8ConsoleAgentImpl* consoleAgent() { return m_consoleAgent.get(); }
3739
V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); }
40+
V8SchemaAgentImpl* schemaAgent() { return m_schemaAgent.get(); }
3841
V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); }
3942
V8RuntimeAgentImpl* runtimeAgent() { return m_runtimeAgent.get(); }
4043
int contextGroupId() const { return m_contextGroupId; }
@@ -47,10 +50,12 @@ class V8InspectorSessionImpl : public V8InspectorSession {
4750
void setCustomObjectFormatterEnabled(bool);
4851
std::unique_ptr<protocol::Runtime::RemoteObject> wrapObject(v8::Local<v8::Context>, v8::Local<v8::Value>, const String16& groupName, bool generatePreview);
4952
std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable(v8::Local<v8::Context>, v8::Local<v8::Value> table, v8::Local<v8::Value> columns);
53+
std::vector<std::unique_ptr<protocol::Schema::Domain>> supportedDomainsImpl();
5054

5155
// V8InspectorSession implementation.
5256
void dispatchProtocolMessage(const String16& message) override;
5357
String16 stateJSON() override;
58+
std::unique_ptr<protocol::Array<protocol::Schema::API::Domain>> supportedDomains() override;
5459
void addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable>) override;
5560
void schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails) override;
5661
void cancelPauseOnNextStatement() override;
@@ -82,6 +87,7 @@ class V8InspectorSessionImpl : public V8InspectorSession {
8287
std::unique_ptr<V8HeapProfilerAgentImpl> m_heapProfilerAgent;
8388
std::unique_ptr<V8ProfilerAgentImpl> m_profilerAgent;
8489
std::unique_ptr<V8ConsoleAgentImpl> m_consoleAgent;
90+
std::unique_ptr<V8SchemaAgentImpl> m_schemaAgent;
8591
std::vector<std::unique_ptr<V8InspectorSession::Inspectable>> m_inspectedObjects;
8692
};
8793

third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ namespace {
2828

2929
std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> buildInspectorObjectForPositionTicks(const v8::CpuProfileNode* node)
3030
{
31-
std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> array = protocol::Array<protocol::Profiler::PositionTickInfo>::create();
3231
unsigned lineCount = node->GetHitLineCount();
3332
if (!lineCount)
34-
return array;
35-
33+
return nullptr;
34+
auto array = protocol::Array<protocol::Profiler::PositionTickInfo>::create();
3635
std::vector<v8::CpuProfileNode::LineTick> entries(lineCount);
3736
if (node->GetLineTicks(&entries[0], lineCount)) {
3837
for (unsigned i = 0; i < lineCount; i++) {
@@ -42,42 +41,46 @@ std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> buildInsp
4241
array->addItem(std::move(line));
4342
}
4443
}
45-
4644
return array;
4745
}
4846

4947
std::unique_ptr<protocol::Profiler::CPUProfileNode> buildInspectorObjectFor(v8::Isolate* isolate, const v8::CpuProfileNode* node)
5048
{
5149
v8::HandleScope handleScope(isolate);
52-
53-
std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> positionTicks = buildInspectorObjectForPositionTicks(node);
54-
std::unique_ptr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime::CallFrame::create()
50+
auto callFrame = protocol::Runtime::CallFrame::create()
5551
.setFunctionName(toProtocolString(node->GetFunctionName()))
5652
.setScriptId(String16::fromInteger(node->GetScriptId()))
5753
.setUrl(toProtocolString(node->GetScriptResourceName()))
5854
.setLineNumber(node->GetLineNumber() - 1)
5955
.setColumnNumber(node->GetColumnNumber() - 1)
6056
.build();
61-
std::unique_ptr<protocol::Profiler::CPUProfileNode> result = protocol::Profiler::CPUProfileNode::create()
57+
auto result = protocol::Profiler::CPUProfileNode::create()
6258
.setCallFrame(std::move(callFrame))
6359
.setHitCount(node->GetHitCount())
64-
.setPositionTicks(std::move(positionTicks))
65-
.setDeoptReason(node->GetBailoutReason())
6660
.setId(node->GetNodeId()).build();
6761

6862
const int childrenCount = node->GetChildrenCount();
6963
if (childrenCount) {
70-
std::unique_ptr<protocol::Array<int>> children = protocol::Array<int>::create();
64+
auto children = protocol::Array<int>::create();
7165
for (int i = 0; i < childrenCount; i++)
7266
children->addItem(node->GetChild(i)->GetNodeId());
7367
result->setChildren(std::move(children));
7468
}
69+
70+
const char* deoptReason = node->GetBailoutReason();
71+
if (deoptReason && deoptReason[0] && strcmp(deoptReason, "no reason"))
72+
result->setDeoptReason(deoptReason);
73+
74+
auto positionTicks = buildInspectorObjectForPositionTicks(node);
75+
if (positionTicks)
76+
result->setPositionTicks(std::move(positionTicks));
77+
7578
return result;
7679
}
7780

7881
std::unique_ptr<protocol::Array<int>> buildInspectorObjectForSamples(v8::CpuProfile* v8profile)
7982
{
80-
std::unique_ptr<protocol::Array<int>> array = protocol::Array<int>::create();
83+
auto array = protocol::Array<int>::create();
8184
int count = v8profile->GetSamplesCount();
8285
for (int i = 0; i < count; i++)
8386
array->addItem(v8profile->GetSample(i)->GetNodeId());
@@ -86,7 +89,7 @@ std::unique_ptr<protocol::Array<int>> buildInspectorObjectForSamples(v8::CpuProf
8689

8790
std::unique_ptr<protocol::Array<int>> buildInspectorObjectForTimestamps(v8::CpuProfile* v8profile)
8891
{
89-
std::unique_ptr<protocol::Array<int>> array = protocol::Array<int>::create();
92+
auto array = protocol::Array<int>::create();
9093
int count = v8profile->GetSamplesCount();
9194
uint64_t lastTime = v8profile->GetStartTime();
9295
for (int i = 0; i < count; i++) {
@@ -107,10 +110,10 @@ void flattenNodesTree(v8::Isolate* isolate, const v8::CpuProfileNode* node, prot
107110

108111
std::unique_ptr<protocol::Profiler::CPUProfile> createCPUProfile(v8::Isolate* isolate, v8::CpuProfile* v8profile)
109112
{
110-
std::unique_ptr<protocol::Array<protocol::Profiler::CPUProfileNode>> nodes = protocol::Array<protocol::Profiler::CPUProfileNode>::create();
113+
auto nodes = protocol::Array<protocol::Profiler::CPUProfileNode>::create();
111114
flattenNodesTree(isolate, v8profile->GetTopDownRoot(), nodes.get());
112115

113-
std::unique_ptr<protocol::Profiler::CPUProfile> profile = protocol::Profiler::CPUProfile::create()
116+
auto profile = protocol::Profiler::CPUProfile::create()
114117
.setNodes(std::move(nodes))
115118
.setStartTime(static_cast<double>(v8profile->GetStartTime()))
116119
.setEndTime(static_cast<double>(v8profile->GetEndTime())).build();
@@ -122,7 +125,7 @@ std::unique_ptr<protocol::Profiler::CPUProfile> createCPUProfile(v8::Isolate* is
122125
std::unique_ptr<protocol::Debugger::Location> currentDebugLocation(V8InspectorImpl* inspector)
123126
{
124127
std::unique_ptr<V8StackTrace> callStack = inspector->captureStackTrace(1);
125-
std::unique_ptr<protocol::Debugger::Location> location = protocol::Debugger::Location::create()
128+
auto location = protocol::Debugger::Location::create()
126129
.setScriptId(callStack->topScriptId())
127130
.setLineNumber(callStack->topLineNumber()).build();
128131
location->setColumnNumber(callStack->topColumnNumber());
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "platform/v8_inspector/V8SchemaAgentImpl.h"
6+
7+
#include "platform/v8_inspector/V8InspectorSessionImpl.h"
8+
9+
namespace v8_inspector {
10+
11+
V8SchemaAgentImpl::V8SchemaAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
12+
: m_session(session)
13+
, m_frontend(frontendChannel)
14+
{
15+
}
16+
17+
V8SchemaAgentImpl::~V8SchemaAgentImpl()
18+
{
19+
}
20+
21+
void V8SchemaAgentImpl::getDomains(ErrorString*, std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* result)
22+
{
23+
std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = m_session->supportedDomainsImpl();
24+
*result = protocol::Array<protocol::Schema::Domain>::create();
25+
for (size_t i = 0; i < domains.size(); ++i)
26+
(*result)->addItem(std::move(domains[i]));
27+
}
28+
29+
} // namespace v8_inspector
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef V8SchemaAgentImpl_h
6+
#define V8SchemaAgentImpl_h
7+
8+
#include "platform/inspector_protocol/InspectorProtocol.h"
9+
#include "platform/v8_inspector/protocol/Schema.h"
10+
11+
namespace v8_inspector {
12+
13+
class V8InspectorSessionImpl;
14+
15+
namespace protocol = blink::protocol;
16+
17+
class V8SchemaAgentImpl : public protocol::Schema::Backend {
18+
PROTOCOL_DISALLOW_COPY(V8SchemaAgentImpl);
19+
public:
20+
V8SchemaAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state);
21+
~V8SchemaAgentImpl() override;
22+
23+
void getDomains(ErrorString*, std::unique_ptr<protocol::Array<protocol::Schema::Domain>>*) override;
24+
25+
private:
26+
V8InspectorSessionImpl* m_session;
27+
protocol::Schema::Frontend m_frontend;
28+
};
29+
30+
} // namespace v8_inspector
31+
32+
33+
#endif // !defined(V8SchemaAgentImpl_h)

third_party/v8_inspector/platform/v8_inspector/js_protocol.json

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
{
22
"version": { "major": "1", "minor": "1" },
3-
"domains": [{
3+
"domains": [
4+
{
5+
"domain": "Schema",
6+
"description": "Provides information about the protocol schema.",
7+
"experimental": true,
8+
"types": [
9+
{
10+
"id": "Domain",
11+
"type": "object",
12+
"description": "Description of the protocol domain.",
13+
"exported": true,
14+
"properties": [
15+
{ "name": "name", "type": "string", "description": "Domain name." },
16+
{ "name": "version", "type": "string", "description": "Domain version." }
17+
]
18+
}
19+
],
20+
"commands": [
21+
{
22+
"name": "getDomains",
23+
"description": "Returns supported domains.",
24+
"handlers": ["browser", "renderer"],
25+
"returns": [
26+
{ "name": "domains", "type": "array", "items": { "$ref": "Domain" }, "description": "List of supported domains." }
27+
]
28+
}
29+
]
30+
},
31+
{
432
"domain": "Runtime",
533
"description": "Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.",
634
"types": [
@@ -781,8 +809,8 @@
781809
{ "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." },
782810
{ "name": "hitCount", "type": "integer", "description": "Number of samples where this node was on top of the call stack." },
783811
{ "name": "children", "type": "array", "items": { "type": "integer" }, "optional": true, "description": "Child node ids." },
784-
{ "name": "deoptReason", "type": "string", "experimental": true, "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."},
785-
{ "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "experimental": true, "description": "An array of source position ticks." }
812+
{ "name": "deoptReason", "type": "string", "optional": true, "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."},
813+
{ "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "optional": true, "experimental": true, "description": "An array of source position ticks." }
786814
]
787815
},
788816
{

third_party/v8_inspector/platform/v8_inspector/public/InspectorVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// found in the LICENSE file.
44

55
// This file is automatically generated. Do not modify.
6-
#define V8_INSPECTOR_REVISION "3c58e3c966928309ada55f792a5cc43bcbdec8d2"
6+
#define V8_INSPECTOR_REVISION "60cd6e859b9f557d2312f5bf532f6aec5f284980"

third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "platform/inspector_protocol/InspectorProtocol.h"
99
#include "platform/v8_inspector/public/protocol/Debugger.h"
1010
#include "platform/v8_inspector/public/protocol/Runtime.h"
11+
#include "platform/v8_inspector/public/protocol/Schema.h"
1112

1213
#include <v8.h>
1314

@@ -29,6 +30,7 @@ class PLATFORM_EXPORT V8InspectorSession {
2930
static bool canDispatchMethod(const String16& method);
3031
virtual void dispatchProtocolMessage(const String16& message) = 0;
3132
virtual String16 stateJSON() = 0;
33+
virtual std::unique_ptr<blink::protocol::Array<blink::protocol::Schema::API::Domain>> supportedDomains() = 0;
3234

3335
// Debugger actions.
3436
virtual void schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails) = 0;

0 commit comments

Comments
 (0)