Commit a61585e9 authored by jgruber's avatar jgruber Committed by Commit bot

[debug-wrapper] AsyncTaskEvent event type

AsyncTaskEvents are not exposed through the inspector interface.

BUG=v8:5530

Review-Url: https://codereview.chromium.org/2532693002
Cr-Commit-Position: refs/heads/master@{#41299}
parent 65fd9c43
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Debug = debug.Debug;
var base_id = -1;
var exception = null;
var expected = [
"enqueue #1",
"willHandle #1",
"then #1",
"enqueue #2",
"didHandle #1",
"willHandle #2",
"then #2",
"didHandle #2",
"enqueue #3",
"willHandle #3",
"didHandle #3"
];
function assertLog(msg) {
print(msg);
assertTrue(expected.length > 0);
assertEquals(expected.shift(), msg);
if (!expected.length) {
Debug.setListener(null);
}
}
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.AsyncTaskEvent) return;
try {
if (base_id < 0)
base_id = event_data.id();
var id = event_data.id() - base_id + 1;
assertEquals("Promise.resolve", event_data.name());
assertLog(event_data.type() + " #" + id);
} catch (e) {
print(e + e.stack)
exception = e;
}
}
Debug.setListener(listener);
var resolver;
var p = new Promise(function(resolve, reject) {
resolver = resolve;
});
p.then(function() {
assertLog("then #1");
}).then(function() {
assertLog("then #2");
});
resolver();
%RunMicrotasks();
assertNull(exception);
...@@ -24,7 +24,6 @@ var q = p.then( ...@@ -24,7 +24,6 @@ var q = p.then(
}); });
function listener(event, exec_state, event_data, data) { function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.AsyncTaskEvent) return;
try { try {
if (event == Debug.DebugEvent.Exception) { if (event == Debug.DebugEvent.Exception) {
expected_events--; expected_events--;
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-async-await
// The test observes the callbacks that async/await makes to the inspector
// to make accurate stack traces. The pattern is based on saving a stack once
// with enqueueRecurring and restoring it multiple times.
// Additionally, the limited number of events is an indirect indication that
// we are not doing extra Promise processing that could be associated with memory
// leaks (v8:5380). In particular, no stacks are saved and restored for extra
// Promise handling on throwaway Promises.
// TODO(littledan): Write a test that demonstrates that the memory leak in
// the exception case is fixed.
Debug = debug.Debug;
var base_id = -1;
var exception = null;
var expected = [
'enqueueRecurring #1',
'willHandle #1',
'then #1',
'didHandle #1',
'willHandle #1',
'then #2',
'cancel #1',
'didHandle #1',
];
function assertLog(msg) {
print(msg);
assertTrue(expected.length > 0);
assertEquals(expected.shift(), msg);
if (!expected.length) {
Debug.setListener(null);
}
}
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.AsyncTaskEvent) return;
try {
if ("Promise.resolve" == event_data.name()) return;
if (base_id < 0)
base_id = event_data.id();
var id = event_data.id() - base_id + 1;
assertTrue("async function" == event_data.name());
assertLog(event_data.type() + " #" + id);
} catch (e) {
print(e + e.stack)
exception = e;
}
}
Debug.setListener(listener);
var resolver;
var p = new Promise(function(resolve, reject) {
resolver = resolve;
});
async function main() {
await p;
assertLog("then #1");
await undefined;
assertLog("then #2");
}
main();
resolver();
%RunMicrotasks();
assertNull(exception);
Debug.clearBreakOnUncaughtException();
Debug.setListener(null);
var resolve;
var turnOnListenerPromise = new Promise(r => resolve = r);
async function confused() {
await turnOnListenerPromise;
throw foo
}
confused();
Promise.resolve().then(() => {
Debug.setListener(listener);
Debug.setBreakOnUncaughtException();
resolve();
});
%RunMicrotasks();
assertNull(exception);
...@@ -27,13 +27,11 @@ class DebugWrapper { ...@@ -27,13 +27,11 @@ class DebugWrapper {
// The listener method called on certain events. // The listener method called on certain events.
this.listener = undefined; this.listener = undefined;
// TODO(jgruber): Determine which of these are still required and possible.
// Debug events which can occur in the V8 JavaScript engine. // Debug events which can occur in the V8 JavaScript engine.
this.DebugEvent = { Break: 1, this.DebugEvent = { Break: 1,
Exception: 2, Exception: 2,
AfterCompile: 3, AfterCompile: 3,
CompileError: 4, CompileError: 4,
AsyncTaskEvent: 5
}; };
// The different types of steps. // The different types of steps.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment