36ab7afb9e
Adds ability to pause JavaScript debugger from d8 by defining a global function `handleInspectorMessage` which should block waiting for a new inspector message, and `send` it afterwards. Additionally, adds a simple helper script that, when invoked via `websocketd` as per instructions, can be used for debugging `d8` using Chrome DevTools (inspecting script sources, pausing, stepping over, etc.). Change-Id: Iee75fb4e3f2ccc8c8552c804fefaefb233d6b089 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1829221 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Ingvar Stepanyan <rreverser@google.com> Cr-Commit-Position: refs/heads/master@{#64040}
31 lines
845 B
JavaScript
31 lines
845 B
JavaScript
// Copyright 2019 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.
|
|
|
|
// This helper allows to debug d8 using Chrome DevTools.
|
|
//
|
|
// It runs a simple REPL for inspector messages and relies on
|
|
// websocketd (https://github.com/joewalnes/websocketd) for the WebSocket
|
|
// communication.
|
|
//
|
|
// You can start a session with a debug build of d8 like:
|
|
//
|
|
// $ websocketd out/x64.debug/d8 YOUR_SCRIPT.js tools/inspect-d8.js
|
|
//
|
|
// After that, copy the URL from console and pass it as `ws=` parameter to
|
|
// the Chrome DevTools frontend like:
|
|
//
|
|
// chrome-devtools://devtools/bundled/js_app.html?ws=localhost:80
|
|
|
|
function receive(msg) {
|
|
print(msg);
|
|
}
|
|
|
|
function handleInspectorMessage() {
|
|
send(readline());
|
|
}
|
|
|
|
while (true) {
|
|
handleInspectorMessage();
|
|
}
|