Skip to content

Commit b1cd96e

Browse files
alexkozyCommit Bot
authored and
Commit Bot
committed
[inspector] added V8InspectorClient::maxAsyncCallStackDepthChanged
[email protected] Bug: none Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I0fa10978266feb3c3907ce1f3386ae7a34a33582 Reviewed-on: https://chromium-review.googlesource.com/726490 Reviewed-by: Dmitry Gozman <[email protected]> Commit-Queue: Aleksey Kozyatinskiy <[email protected]> Cr-Commit-Position: refs/heads/master@{#48705}
1 parent 3e48c30 commit b1cd96e

7 files changed

+52
-0
lines changed

include/v8-inspector.h

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ class V8_EXPORT V8InspectorClient {
211211
// TODO(dgozman): this was added to support service worker shadow page. We
212212
// should not connect at all.
213213
virtual bool canExecuteScripts(int contextGroupId) { return true; }
214+
215+
virtual void maxAsyncCallStackDepthChanged(int depth) {}
214216
};
215217

216218
class V8_EXPORT V8Inspector {

src/inspector/v8-debugger.cc

+2
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) {
720720
if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return;
721721
// TODO(dgozman): ideally, this should be per context group.
722722
m_maxAsyncCallStackDepth = maxAsyncCallStackDepth;
723+
m_inspector->client()->maxAsyncCallStackDepthChanged(
724+
m_maxAsyncCallStackDepth);
723725
if (!maxAsyncCallStackDepth) allAsyncTasksCanceled();
724726
}
725727

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Tests for max async call stack depth changed.
2+
maxAsyncCallStackDepthChanged: 8
3+
maxAsyncCallStackDepthChanged: 0
4+
maxAsyncCallStackDepthChanged: 8
5+
maxAsyncCallStackDepthChanged: 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 the V8 project 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+
let {session, contextGroup, Protocol} =
6+
InspectorTest.start('Tests for max async call stack depth changed.');
7+
8+
(async function test(){
9+
utils.setLogMaxAsyncCallStackDepthChanged(true);
10+
await Protocol.Debugger.enable();
11+
await Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 8});
12+
await Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 0});
13+
await Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 8});
14+
await Protocol.Debugger.disable();
15+
InspectorTest.completeTest();
16+
})();

test/inspector/inspector-test.cc

+15
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
299299
utils->Set(ToV8String(isolate, "setLogConsoleApiMessageCalls"),
300300
v8::FunctionTemplate::New(
301301
isolate, &UtilsExtension::SetLogConsoleApiMessageCalls));
302+
utils->Set(
303+
ToV8String(isolate, "setLogMaxAsyncCallStackDepthChanged"),
304+
v8::FunctionTemplate::New(
305+
isolate, &UtilsExtension::SetLogMaxAsyncCallStackDepthChanged));
302306
utils->Set(ToV8String(isolate, "createContextGroup"),
303307
v8::FunctionTemplate::New(isolate,
304308
&UtilsExtension::CreateContextGroup));
@@ -486,6 +490,17 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
486490
args[0].As<v8::Boolean>()->Value());
487491
}
488492

493+
static void SetLogMaxAsyncCallStackDepthChanged(
494+
const v8::FunctionCallbackInfo<v8::Value>& args) {
495+
if (args.Length() != 1 || !args[0]->IsBoolean()) {
496+
fprintf(stderr,
497+
"Internal error: setLogMaxAsyncCallStackDepthChanged(bool).");
498+
Exit();
499+
}
500+
backend_runner_->data()->SetLogMaxAsyncCallStackDepthChanged(
501+
args[0].As<v8::Boolean>()->Value());
502+
}
503+
489504
static void CreateContextGroup(
490505
const v8::FunctionCallbackInfo<v8::Value>& args) {
491506
if (args.Length() != 0) {

test/inspector/isolate-data.cc

+9
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ void IsolateData::SetLogConsoleApiMessageCalls(bool log) {
370370
log_console_api_message_calls_ = log;
371371
}
372372

373+
void IsolateData::SetLogMaxAsyncCallStackDepthChanged(bool log) {
374+
log_max_async_call_stack_depth_changed_ = log;
375+
}
376+
373377
v8::MaybeLocal<v8::Value> IsolateData::memoryInfo(v8::Isolate* isolate,
374378
v8::Local<v8::Context>) {
375379
if (memory_info_.IsEmpty()) return v8::MaybeLocal<v8::Value>();
@@ -396,3 +400,8 @@ void IsolateData::consoleAPIMessage(int contextGroupId,
396400
Print(isolate_, stack->toString()->string());
397401
fprintf(stdout, "\n");
398402
}
403+
404+
void IsolateData::maxAsyncCallStackDepthChanged(int depth) {
405+
if (!log_max_async_call_stack_depth_changed_) return;
406+
fprintf(stdout, "maxAsyncCallStackDepthChanged: %d\n", depth);
407+
}

test/inspector/isolate-data.h

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
6464
void SetCurrentTimeMS(double time);
6565
void SetMemoryInfo(v8::Local<v8::Value> memory_info);
6666
void SetLogConsoleApiMessageCalls(bool log);
67+
void SetLogMaxAsyncCallStackDepthChanged(bool log);
6768
void SetMaxAsyncTaskStacksForTest(int limit);
6869
void DumpAsyncTaskStacksStateForTest();
6970
void FireContextCreated(v8::Local<v8::Context> context, int context_group_id);
@@ -106,6 +107,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
106107
unsigned lineNumber, unsigned columnNumber,
107108
v8_inspector::V8StackTrace*) override;
108109
bool isInspectableHeapObject(v8::Local<v8::Object>) override;
110+
void maxAsyncCallStackDepthChanged(int depth) override;
109111

110112
TaskRunner* task_runner_;
111113
SetupGlobalTasks setup_global_tasks_;
@@ -123,6 +125,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
123125
bool current_time_set_ = false;
124126
double current_time_ = 0.0;
125127
bool log_console_api_message_calls_ = false;
128+
bool log_max_async_call_stack_depth_changed_ = false;
126129
v8::Global<v8::Private> not_inspectable_private_;
127130

128131
DISALLOW_COPY_AND_ASSIGN(IsolateData);

0 commit comments

Comments
 (0)