From 81b7e77ff02189bf7d4d4b86e1ebd666960cbe51 Mon Sep 17 00:00:00 2001 From: dgozman Date: Tue, 6 Sep 2016 16:26:08 -0700 Subject: [PATCH] [inspector] Build inspector under v8_enable_inspector build flag. - inspector becomes a dependency of v8_base; - generated public protocol files are placed to gen/v8/include/inspector/; - added v8_enable_inspector_override to be used in embedders (gn only); - combined public headers into v8-inspector.h and v8-inspector-protocol.h. BUG=chromium:635948 Review-Url: https://codereview.chromium.org/2292053003 Cr-Commit-Position: refs/heads/master@{#39226} --- BUILD.gn | 7 + build_overrides/v8.gni | 16 +- gypfiles/standalone.gypi | 1 + include/DEPS | 4 + include/OWNERS | 5 + include/v8-inspector-protocol.h | 13 + include/v8-inspector.h | 267 +++++++++++++++++++ src/inspector/BUILD.gn | 233 +++++++++++----- src/inspector/InjectedScript.cpp | 4 +- src/inspector/InjectedScript.h | 4 +- src/inspector/InjectedScriptNative.h | 3 +- src/inspector/InspectedContext.cpp | 4 +- src/inspector/InspectedContext.h | 2 +- src/inspector/JavaScriptCallFrame.cpp | 3 +- src/inspector/JavaScriptCallFrame.h | 3 +- src/inspector/OWNERS | 15 ++ src/inspector/ProtocolPlatform.h | 16 +- src/inspector/StringUtil.cpp | 4 +- src/inspector/StringUtil.h | 4 +- src/inspector/V8Compat.h | 33 --- src/inspector/V8Console.cpp | 27 +- src/inspector/V8Console.h | 2 +- src/inspector/V8ConsoleMessage.cpp | 5 +- src/inspector/V8ConsoleMessage.h | 2 +- src/inspector/V8Debugger.cpp | 23 +- src/inspector/V8Debugger.h | 7 +- src/inspector/V8DebuggerAgentImpl.cpp | 5 +- src/inspector/V8DebuggerScript.h | 2 +- src/inspector/V8FunctionCall.cpp | 4 +- src/inspector/V8FunctionCall.h | 2 +- src/inspector/V8HeapProfilerAgentImpl.cpp | 6 +- src/inspector/V8HeapProfilerAgentImpl.h | 2 +- src/inspector/V8InjectedScriptHost.cpp | 11 +- src/inspector/V8InjectedScriptHost.h | 2 +- src/inspector/V8InspectorImpl.cpp | 5 +- src/inspector/V8InspectorImpl.h | 6 +- src/inspector/V8InspectorSessionImpl.cpp | 2 - src/inspector/V8InspectorSessionImpl.h | 5 +- src/inspector/V8InternalValueType.cpp | 2 +- src/inspector/V8InternalValueType.h | 2 +- src/inspector/V8ProfilerAgentImpl.cpp | 3 +- src/inspector/V8Regex.cpp | 4 +- src/inspector/V8Regex.h | 2 +- src/inspector/V8RuntimeAgentImpl.cpp | 10 +- src/inspector/V8RuntimeAgentImpl.h | 2 +- src/inspector/V8StackTraceImpl.cpp | 6 +- src/inspector/V8StackTraceImpl.h | 3 +- src/inspector/V8ValueCopier.h | 2 +- src/inspector/inspector.gyp | 176 ++++++------ src/inspector/inspector.gypi | 97 +++++++ src/inspector/inspector_protocol_config.json | 18 +- src/inspector/public/StringBuffer.h | 24 -- src/inspector/public/StringView.h | 42 --- src/inspector/public/V8ContextInfo.h | 46 ---- src/inspector/public/V8Inspector.h | 72 ----- src/inspector/public/V8InspectorClient.h | 74 ----- src/inspector/public/V8InspectorSession.h | 63 ----- src/inspector/public/V8StackTrace.h | 34 --- src/v8.gyp | 27 +- 59 files changed, 810 insertions(+), 658 deletions(-) create mode 100644 include/DEPS create mode 100644 include/v8-inspector-protocol.h create mode 100644 include/v8-inspector.h create mode 100644 src/inspector/OWNERS delete mode 100644 src/inspector/V8Compat.h create mode 100644 src/inspector/inspector.gypi delete mode 100644 src/inspector/public/StringBuffer.h delete mode 100644 src/inspector/public/StringView.h delete mode 100644 src/inspector/public/V8ContextInfo.h delete mode 100644 src/inspector/public/V8Inspector.h delete mode 100644 src/inspector/public/V8InspectorClient.h delete mode 100644 src/inspector/public/V8InspectorSession.h delete mode 100644 src/inspector/public/V8StackTrace.h diff --git a/BUILD.gn b/BUILD.gn index 7e31ab95e5..4e2c2b9aac 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -140,6 +140,9 @@ config("external_config") { ] } include_dirs = [ "include" ] + if (v8_enable_inspector_override) { + include_dirs += [ "$target_gen_dir/include" ] + } libs = [] if (is_android && current_toolchain != host_toolchain) { libs += [ "log" ] @@ -2023,6 +2026,10 @@ v8_source_set("v8_base") { sources += [ "$target_gen_dir/debug-support.cc" ] deps += [ ":postmortem-metadata" ] } + + if (v8_enable_inspector_override) { + deps += [ "src/inspector:inspector" ] + } } v8_source_set("v8_libbase") { diff --git a/build_overrides/v8.gni b/build_overrides/v8.gni index fc4a70e579..09ea4570b0 100644 --- a/build_overrides/v8.gni +++ b/build_overrides/v8.gni @@ -11,10 +11,8 @@ if (is_android) { import("//build/config/android/config.gni") } -if (((v8_current_cpu == "x86" || - v8_current_cpu == "x64" || - v8_current_cpu=="x87") && - (is_linux || is_mac)) || +if (((v8_current_cpu == "x86" || v8_current_cpu == "x64" || + v8_current_cpu == "x87") && (is_linux || is_mac)) || (v8_current_cpu == "ppc64" && is_linux)) { v8_enable_gdbjit_default = true } @@ -23,4 +21,12 @@ v8_imminent_deprecation_warnings_default = true # Add simple extras solely for the purpose of the cctests. v8_extra_library_files = [ "//test/cctest/test-extra.js" ] -v8_experimental_extra_library_files = [ "//test/cctest/test-experimental-extra.js" ] +v8_experimental_extra_library_files = + [ "//test/cctest/test-experimental-extra.js" ] + +declare_args() { + # Enable inspector. See include/v8-inspector.h. + v8_enable_inspector = false +} + +v8_enable_inspector_override = v8_enable_inspector diff --git a/gypfiles/standalone.gypi b/gypfiles/standalone.gypi index 7116f622dc..9a030041d9 100644 --- a/gypfiles/standalone.gypi +++ b/gypfiles/standalone.gypi @@ -46,6 +46,7 @@ 'msvs_multi_core_compile%': '1', 'mac_deployment_target%': '10.7', 'release_extra_cflags%': '', + 'v8_enable_inspector%': 0, 'variables': { 'variables': { 'variables': { diff --git a/include/DEPS b/include/DEPS new file mode 100644 index 0000000000..ca60f841f5 --- /dev/null +++ b/include/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + # v8-inspector-protocol.h depends on generated files under include/inspector. + "+inspector", +] diff --git a/include/OWNERS b/include/OWNERS index efa3b936d5..07f8a610c5 100644 --- a/include/OWNERS +++ b/include/OWNERS @@ -1,2 +1,7 @@ danno@chromium.org jochen@chromium.org + +per-file v8-inspector.h=dgozman@chromium.org +per-file v8-inspector.h=pfeldman@chromium.org +per-file v8-inspector-protocol.h=dgozman@chromium.org +per-file v8-inspector-protocol.h=pfeldman@chromium.org diff --git a/include/v8-inspector-protocol.h b/include/v8-inspector-protocol.h new file mode 100644 index 0000000000..612a2ebc39 --- /dev/null +++ b/include/v8-inspector-protocol.h @@ -0,0 +1,13 @@ +// 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. + +#ifndef V8_V8_INSPECTOR_PROTOCOL_H_ +#define V8_V8_INSPECTOR_PROTOCOL_H_ + +#include "inspector/Debugger.h" // NOLINT(build/include) +#include "inspector/Runtime.h" // NOLINT(build/include) +#include "inspector/Schema.h" // NOLINT(build/include) +#include "v8-inspector.h" // NOLINT(build/include) + +#endif // V8_V8_INSPECTOR_PROTOCOL_H_ diff --git a/include/v8-inspector.h b/include/v8-inspector.h new file mode 100644 index 0000000000..aa90de5abb --- /dev/null +++ b/include/v8-inspector.h @@ -0,0 +1,267 @@ +// 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. + +#ifndef V8_V8_INSPECTOR_H_ +#define V8_V8_INSPECTOR_H_ + +#include +#include + +#include + +#include "v8.h" // NOLINT(build/include) + +namespace v8_inspector { + +namespace protocol { +namespace Debugger { +namespace API { +class SearchMatch; +} +} +namespace Runtime { +namespace API { +class RemoteObject; +class StackTrace; +} +} +namespace Schema { +namespace API { +class Domain; +} +} +} // namespace protocol + +class V8_EXPORT StringView { + public: + StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} + + StringView(const uint8_t* characters, unsigned length) + : m_is8Bit(true), m_length(length), m_characters8(characters) {} + + StringView(const uint16_t* characters, unsigned length) + : m_is8Bit(false), m_length(length), m_characters16(characters) {} + + bool is8Bit() const { return m_is8Bit; } + unsigned length() const { return m_length; } + + // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used + // here. + const uint8_t* characters8() const { return m_characters8; } + const uint16_t* characters16() const { return m_characters16; } + + private: + bool m_is8Bit; + unsigned m_length; + union { + const uint8_t* m_characters8; + const uint16_t* m_characters16; + }; +}; + +class V8_EXPORT StringBuffer { + public: + virtual ~StringBuffer() {} + virtual const StringView& string() = 0; + // This method copies contents. + static std::unique_ptr create(const StringView&); +}; + +class V8_EXPORT V8ContextInfo { + public: + V8ContextInfo(v8::Local context, int contextGroupId, + const StringView& humanReadableName) + : context(context), + contextGroupId(contextGroupId), + humanReadableName(humanReadableName), + hasMemoryOnConsole(false) {} + + v8::Local context; + // Each v8::Context is a part of a group. The group id must be non-zero. + int contextGroupId; + StringView humanReadableName; + StringView origin; + StringView auxData; + bool hasMemoryOnConsole; + + private: + // Disallow copying and allocating this one. + enum NotNullTagEnum { NotNullLiteral }; + void* operator new(size_t) = delete; + void* operator new(size_t, NotNullTagEnum, void*) = delete; + void* operator new(size_t, void*) = delete; + V8ContextInfo(const V8ContextInfo&) = delete; + V8ContextInfo& operator=(const V8ContextInfo&) = delete; +}; + +class V8_EXPORT V8StackTrace { + public: + virtual bool isEmpty() const = 0; + virtual StringView topSourceURL() const = 0; + virtual int topLineNumber() const = 0; + virtual int topColumnNumber() const = 0; + virtual StringView topScriptId() const = 0; + virtual StringView topFunctionName() const = 0; + + virtual ~V8StackTrace() {} + virtual std::unique_ptr + buildInspectorObject() const = 0; + virtual std::unique_ptr toString() const = 0; + + // Safe to pass between threads, drops async chain. + virtual std::unique_ptr clone() = 0; +}; + +class V8_EXPORT V8InspectorSession { + public: + virtual ~V8InspectorSession() {} + + // Cross-context inspectable values (DOM nodes in different worlds, etc.). + class V8_EXPORT Inspectable { + public: + virtual v8::Local get(v8::Local) = 0; + virtual ~Inspectable() {} + }; + virtual void addInspectedObject(std::unique_ptr) = 0; + + // Dispatching protocol messages. + static bool canDispatchMethod(const StringView& method); + virtual void dispatchProtocolMessage(const StringView& message) = 0; + virtual std::unique_ptr stateJSON() = 0; + virtual std::vector> + supportedDomains() = 0; + + // Debugger actions. + virtual void schedulePauseOnNextStatement(const StringView& breakReason, + const StringView& breakDetails) = 0; + virtual void cancelPauseOnNextStatement() = 0; + virtual void breakProgram(const StringView& breakReason, + const StringView& breakDetails) = 0; + virtual void setSkipAllPauses(bool) = 0; + virtual void resume() = 0; + virtual void stepOver() = 0; + virtual std::vector> + searchInTextByLines(const StringView& text, const StringView& query, + bool caseSensitive, bool isRegex) = 0; + + // Remote objects. + virtual std::unique_ptr wrapObject( + v8::Local, v8::Local, + const StringView& groupName) = 0; + virtual bool unwrapObject(std::unique_ptr* error, + const StringView& objectId, v8::Local*, + v8::Local*, + std::unique_ptr* objectGroup) = 0; + virtual void releaseObjectGroup(const StringView&) = 0; +}; + +enum class V8ConsoleAPIType { kClear, kDebug, kLog, kInfo, kWarning, kError }; + +class V8_EXPORT V8InspectorClient { + public: + virtual ~V8InspectorClient() {} + + virtual void runMessageLoopOnPause(int contextGroupId) {} + virtual void quitMessageLoopOnPause() {} + virtual void runIfWaitingForDebugger(int contextGroupId) {} + + virtual void muteMetrics(int contextGroupId) {} + virtual void unmuteMetrics(int contextGroupId) {} + + virtual void beginUserGesture() {} + virtual void endUserGesture() {} + + virtual std::unique_ptr valueSubtype(v8::Local) { + return nullptr; + } + virtual bool formatAccessorsAsProperties(v8::Local) { + return false; + } + virtual bool isInspectableHeapObject(v8::Local) { return true; } + + virtual v8::Local ensureDefaultContextInGroup( + int contextGroupId) { + return v8::Local(); + } + virtual void beginEnsureAllContextsInGroup(int contextGroupId) {} + virtual void endEnsureAllContextsInGroup(int contextGroupId) {} + + virtual void installAdditionalCommandLineAPI(v8::Local, + v8::Local) {} + virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType, + const StringView& message, + const StringView& url, unsigned lineNumber, + unsigned columnNumber, V8StackTrace*) {} + virtual v8::MaybeLocal memoryInfo(v8::Isolate*, + v8::Local) { + return v8::MaybeLocal(); + } + + virtual void consoleTime(const StringView& title) {} + virtual void consoleTimeEnd(const StringView& title) {} + virtual void consoleTimeStamp(const StringView& title) {} + virtual double currentTimeMS() { return 0; } + typedef void (*TimerCallback)(void*); + virtual void startRepeatingTimer(double, TimerCallback, void* data) {} + virtual void cancelTimer(void* data) {} + + // TODO(dgozman): this was added to support service worker shadow page. We + // should not connect at all. + virtual bool canExecuteScripts(int contextGroupId) { return true; } +}; + +class V8_EXPORT V8Inspector { + public: + static std::unique_ptr create(v8::Isolate*, V8InspectorClient*); + virtual ~V8Inspector() {} + + // Contexts instrumentation. + virtual void contextCreated(const V8ContextInfo&) = 0; + virtual void contextDestroyed(v8::Local) = 0; + virtual void resetContextGroup(int contextGroupId) = 0; + + // Various instrumentation. + virtual void willExecuteScript(v8::Local, int scriptId) = 0; + virtual void didExecuteScript(v8::Local) = 0; + virtual void idleStarted() = 0; + virtual void idleFinished() = 0; + + // Async stack traces instrumentation. + virtual void asyncTaskScheduled(const StringView& taskName, void* task, + bool recurring) = 0; + virtual void asyncTaskCanceled(void* task) = 0; + virtual void asyncTaskStarted(void* task) = 0; + virtual void asyncTaskFinished(void* task) = 0; + virtual void allAsyncTasksCanceled() = 0; + + // Exceptions instrumentation. + virtual unsigned exceptionThrown( + v8::Local, const StringView& message, + v8::Local exception, const StringView& detailedMessage, + const StringView& url, unsigned lineNumber, unsigned columnNumber, + std::unique_ptr, int scriptId) = 0; + virtual void exceptionRevoked(v8::Local, unsigned exceptionId, + const StringView& message) = 0; + + // Connection. + class V8_EXPORT Channel { + public: + virtual ~Channel() {} + virtual void sendProtocolResponse(int callId, + const StringView& message) = 0; + virtual void sendProtocolNotification(const StringView& message) = 0; + virtual void flushProtocolNotifications() = 0; + }; + virtual std::unique_ptr connect( + int contextGroupId, Channel*, const StringView& state) = 0; + + // API methods. + virtual std::unique_ptr createStackTrace( + v8::Local) = 0; + virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; +}; + +} // namespace v8_inspector + +#endif // V8_V8_INSPECTOR_H_ diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn index 56b96e1cd6..6d8d49657f 100644 --- a/src/inspector/BUILD.gn +++ b/src/inspector/BUILD.gn @@ -2,57 +2,98 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -protocol_path = "//third_party/WebKit/Source/platform/inspector_protocol" -protocol_sources = [ - "$target_gen_dir/Console.cpp", - "$target_gen_dir/Console.h", - "$target_gen_dir/Debugger.cpp", - "$target_gen_dir/Debugger.h", - "$target_gen_dir/HeapProfiler.cpp", - "$target_gen_dir/HeapProfiler.h", - "$target_gen_dir/Profiler.cpp", - "$target_gen_dir/Profiler.h", - "$target_gen_dir/public/Debugger.h", - "$target_gen_dir/public/Runtime.h", - "$target_gen_dir/Runtime.cpp", - "$target_gen_dir/Runtime.h", +import("../../gni/v8.gni") + +_inspector_protocol = "//third_party/WebKit/Source/platform/inspector_protocol" +import("$_inspector_protocol/inspector_protocol.gni") + +_protocol_generated = [ + "protocol/Forward.h", + "protocol/Protocol.cpp", + "protocol/Protocol.h", + "protocol/Console.cpp", + "protocol/Console.h", + "protocol/Debugger.cpp", + "protocol/Debugger.h", + "protocol/HeapProfiler.cpp", + "protocol/HeapProfiler.h", + "protocol/Profiler.cpp", + "protocol/Profiler.h", + "protocol/Runtime.cpp", + "protocol/Runtime.h", + "protocol/Schema.cpp", + "protocol/Schema.h", + "../../include/inspector/Debugger.h", + "../../include/inspector/Runtime.h", + "../../include/inspector/Schema.h", ] -action("inspector_protocol_sources") { +action("protocol_compatibility") { visibility = [ ":*" ] # Only targets in this file can depend on this. - script = "$protocol_path/CodeGenerator.py" - sources = [ - "$protocol_path/CodeGenerator.py", - "$protocol_path/Exported_h.template", - "$protocol_path/Imported_h.template", - "$protocol_path/TypeBuilder_cpp.template", - "$protocol_path/TypeBuilder_h.template", - ] + script = "$_inspector_protocol/CheckProtocolCompatibility.py" inputs = [ "js_protocol.json", ] - outputs = protocol_sources + _stamp = "$target_gen_dir/js_protocol.stamp" + outputs = [ + _stamp, + ] args = [ - "--protocol", + "--stamp", + rebase_path(_stamp, root_build_dir), rebase_path("js_protocol.json", root_build_dir), - "--string_type", - "String16", - "--export_macro", - "PLATFORM_EXPORT", - "--output_dir", - rebase_path(target_gen_dir, root_build_dir), - "--output_package", - "inspector", - "--exported_dir", - rebase_path("$target_gen_dir/public", root_build_dir), - "--exported_package", - "inspector/public", ] } -config("inspector_protocol_config") { - include_dirs = [ "$protocol_path/../.." ] - defines = [ "V8_INSPECTOR_USE_STL" ] +inspector_protocol_generate("protocol_generated_sources") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + deps = [ + ":protocol_compatibility", + ] + + out_dir = target_gen_dir + config_file = "inspector_protocol_config.json" + inputs = [ + "js_protocol.json", + "inspector_protocol_config.json", + ] + outputs = _protocol_generated +} + +action("inspector_injected_script") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + script = "build/xxd.py" + inputs = [ + "InjectedScriptSource.js", + ] + outputs = [ + "$target_gen_dir/InjectedScriptSource.h", + ] + args = [ + "InjectedScriptSource_js", + rebase_path("InjectedScriptSource.js", root_build_dir), + rebase_path("$target_gen_dir/InjectedScriptSource.h", root_build_dir), + ] +} + +action("inspector_debugger_script") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + script = "build/xxd.py" + inputs = [ + "DebuggerScript.js", + ] + outputs = [ + "$target_gen_dir/DebuggerScript.h", + ] + args = [ + "DebuggerScript_js", + rebase_path("DebuggerScript.js", root_build_dir), + rebase_path("$target_gen_dir/DebuggerScript.h", root_build_dir), + ] +} + +config("inspector_config") { + visibility = [ ":*" ] # Only targets in this file can depend on this. cflags = [] if (is_win) { cflags += [ @@ -64,38 +105,90 @@ config("inspector_protocol_config") { "/wd4996", # Deprecated function call. ] } + if (is_component_build) { + defines = [ + "V8_SHARED", + "BUILDING_V8_SHARED", + ] + } } -source_set("inspector_protocol") { +v8_source_set("inspector") { deps = [ - ":inspector_protocol_sources", + ":inspector_debugger_script", + ":inspector_injected_script", + ":protocol_generated_sources", + ] + configs = [ ":inspector_config" ] + include_dirs = [ + "../..", + "../../include", + "$target_gen_dir/../..", + "$target_gen_dir/../../include", + ] + sources = rebase_path(_protocol_generated, ".", target_gen_dir) + sources += [ + "../../include/v8-inspector-protocol.h", + "../../include/v8-inspector.h", + ] + sources += get_target_outputs(":inspector_injected_script") + sources += get_target_outputs(":inspector_debugger_script") + sources += [ + "Allocator.h", + "Atomics.h", + "InjectedScript.cpp", + "InjectedScript.h", + "InjectedScriptNative.cpp", + "InjectedScriptNative.h", + "InspectedContext.cpp", + "InspectedContext.h", + "JavaScriptCallFrame.cpp", + "JavaScriptCallFrame.h", + "ProtocolPlatform.h", + "RemoteObjectId.cpp", + "RemoteObjectId.h", + "ScriptBreakpoint.h", + "SearchUtil.cpp", + "SearchUtil.h", + "String16.cpp", + "String16.h", + "StringUtil.cpp", + "StringUtil.h", + "V8Console.cpp", + "V8Console.h", + "V8ConsoleAgentImpl.cpp", + "V8ConsoleAgentImpl.h", + "V8ConsoleMessage.cpp", + "V8ConsoleMessage.h", + "V8Debugger.cpp", + "V8Debugger.h", + "V8DebuggerAgentImpl.cpp", + "V8DebuggerAgentImpl.h", + "V8DebuggerScript.cpp", + "V8DebuggerScript.h", + "V8FunctionCall.cpp", + "V8FunctionCall.h", + "V8HeapProfilerAgentImpl.cpp", + "V8HeapProfilerAgentImpl.h", + "V8InjectedScriptHost.cpp", + "V8InjectedScriptHost.h", + "V8InspectorImpl.cpp", + "V8InspectorImpl.h", + "V8InspectorSessionImpl.cpp", + "V8InspectorSessionImpl.h", + "V8InternalValueType.cpp", + "V8InternalValueType.h", + "V8ProfilerAgentImpl.cpp", + "V8ProfilerAgentImpl.h", + "V8Regex.cpp", + "V8Regex.h", + "V8RuntimeAgentImpl.cpp", + "V8RuntimeAgentImpl.h", + "V8SchemaAgentImpl.cpp", + "V8SchemaAgentImpl.h", + "V8StackTraceImpl.cpp", + "V8StackTraceImpl.h", + "V8ValueCopier.cpp", + "V8ValueCopier.h", ] - configs += [ ":inspector_protocol_config" ] - include_dirs = [ "$target_gen_dir/.." ] - sources = protocol_sources + [ - "$protocol_path/Allocator.h", - "$protocol_path/Array.h", - "$protocol_path/BackendCallback.h", - "$protocol_path/CodeGenerator.py", - "$protocol_path/Collections.h", - "$protocol_path/DispatcherBase.cpp", - "$protocol_path/DispatcherBase.h", - "$protocol_path/ErrorSupport.cpp", - "$protocol_path/ErrorSupport.h", - "$protocol_path/FrontendChannel.h", - "$protocol_path/Maybe.h", - "$protocol_path/Object.cpp", - "$protocol_path/Object.h", - "$protocol_path/Parser.cpp", - "$protocol_path/Parser.h", - "$protocol_path/Platform.h", - "$protocol_path/PlatformSTL.h", - "$protocol_path/String16.cpp", - "$protocol_path/String16.h", - "$protocol_path/String16STL.cpp", - "$protocol_path/String16STL.h", - "$protocol_path/ValueConversions.h", - "$protocol_path/Values.cpp", - "$protocol_path/Values.h", - ] } diff --git a/src/inspector/InjectedScript.cpp b/src/inspector/InjectedScript.cpp index e401dd6c12..0dbe3dd827 100644 --- a/src/inspector/InjectedScript.cpp +++ b/src/inspector/InjectedScript.cpp @@ -35,7 +35,6 @@ #include "src/inspector/InspectedContext.h" #include "src/inspector/RemoteObjectId.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8Console.h" #include "src/inspector/V8FunctionCall.h" #include "src/inspector/V8InjectedScriptHost.h" @@ -44,7 +43,8 @@ #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/V8ValueCopier.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { diff --git a/src/inspector/InjectedScript.h b/src/inspector/InjectedScript.h index bfda761b31..2c5c8835f6 100644 --- a/src/inspector/InjectedScript.h +++ b/src/inspector/InjectedScript.h @@ -39,7 +39,7 @@ #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" -#include +#include "include/v8.h" namespace v8_inspector { @@ -118,7 +118,7 @@ class InjectedScript final { protected: Scope(ErrorString*, V8InspectorImpl*, int contextGroupId); - ~Scope(); + virtual ~Scope(); virtual void findInjectedScript(V8InspectorSessionImpl*) = 0; ErrorString* m_errorString; diff --git a/src/inspector/InjectedScriptNative.h b/src/inspector/InjectedScriptNative.h index bdbcded71a..90edc422dc 100644 --- a/src/inspector/InjectedScriptNative.h +++ b/src/inspector/InjectedScriptNative.h @@ -7,7 +7,8 @@ #include "src/inspector/protocol/Protocol.h" -#include +#include "include/v8.h" + #include namespace v8_inspector { diff --git a/src/inspector/InspectedContext.cpp b/src/inspector/InspectedContext.cpp index 521bba4508..83da6a9ed2 100644 --- a/src/inspector/InspectedContext.cpp +++ b/src/inspector/InspectedContext.cpp @@ -9,8 +9,8 @@ #include "src/inspector/V8Console.h" #include "src/inspector/V8InspectorImpl.h" #include "src/inspector/V8ValueCopier.h" -#include "src/inspector/public/V8ContextInfo.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { diff --git a/src/inspector/InspectedContext.h b/src/inspector/InspectedContext.h index 2b743a559a..ba5d9058bc 100644 --- a/src/inspector/InspectedContext.h +++ b/src/inspector/InspectedContext.h @@ -8,7 +8,7 @@ #include "src/inspector/Allocator.h" #include "src/inspector/String16.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/JavaScriptCallFrame.cpp b/src/inspector/JavaScriptCallFrame.cpp index c4f5d47c35..5d7d390107 100644 --- a/src/inspector/JavaScriptCallFrame.cpp +++ b/src/inspector/JavaScriptCallFrame.cpp @@ -31,9 +31,8 @@ #include "src/inspector/JavaScriptCallFrame.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" -#include +#include "include/v8-debug.h" namespace v8_inspector { diff --git a/src/inspector/JavaScriptCallFrame.h b/src/inspector/JavaScriptCallFrame.h index 92bfe39026..15bd6fbc1f 100644 --- a/src/inspector/JavaScriptCallFrame.h +++ b/src/inspector/JavaScriptCallFrame.h @@ -34,7 +34,8 @@ #include "src/inspector/Allocator.h" #include "src/inspector/ProtocolPlatform.h" -#include +#include "include/v8.h" + #include namespace v8_inspector { diff --git a/src/inspector/OWNERS b/src/inspector/OWNERS new file mode 100644 index 0000000000..2c4bd8d24b --- /dev/null +++ b/src/inspector/OWNERS @@ -0,0 +1,15 @@ +set noparent + +alph@chromium.org +caseq@chromium.org +dgozman@chromium.org +jochen@chromium.org +kozyatinskiy@chromium.org +pfeldman@chromium.org +yangguo@chromium.org + +# Changes to remote debugging protocol require devtools review to +# ensure backwards compatibility and committment to maintain. +per-file js_protocol.json=set noparent +per-file js_protocol.json=dgozman@chromium.org +per-file js_protocol.json=pfeldman@chromium.org diff --git a/src/inspector/ProtocolPlatform.h b/src/inspector/ProtocolPlatform.h index cb6d4f2dbe..c7723932b4 100644 --- a/src/inspector/ProtocolPlatform.h +++ b/src/inspector/ProtocolPlatform.h @@ -5,11 +5,17 @@ #ifndef V8_INSPECTOR_PROTOCOLPLATFORM_H_ #define V8_INSPECTOR_PROTOCOLPLATFORM_H_ -// TODO(dgozman): this file should be removed from v8_inspector. - -//#include "wtf/Assertions.h" -//#include "wtf/PtrUtil.h" - #include +#include "src/base/logging.h" + +namespace v8_inspector { + +template +std::unique_ptr wrapUnique(T* ptr) { + return std::unique_ptr(ptr); +} + +} // namespace v8_inspector + #endif // V8_INSPECTOR_PROTOCOLPLATFORM_H_ diff --git a/src/inspector/StringUtil.cpp b/src/inspector/StringUtil.cpp index 46feb6fafc..04b9e85c8f 100644 --- a/src/inspector/StringUtil.cpp +++ b/src/inspector/StringUtil.cpp @@ -107,7 +107,7 @@ std::unique_ptr toProtocolValue(v8::Local context, v8::Local value, int maxDepth) { if (value.IsEmpty()) { - NOTREACHED(); + UNREACHABLE(); return nullptr; } @@ -172,7 +172,7 @@ std::unique_ptr toProtocolValue(v8::Local context, } return std::move(jsonObject); } - NOTREACHED(); + UNREACHABLE(); return nullptr; } diff --git a/src/inspector/StringUtil.h b/src/inspector/StringUtil.h index 8eb0679d38..3a69454d95 100644 --- a/src/inspector/StringUtil.h +++ b/src/inspector/StringUtil.h @@ -7,10 +7,8 @@ #include "src/inspector/Allocator.h" #include "src/inspector/String16.h" -#include "src/inspector/public/StringBuffer.h" -#include "src/inspector/public/StringView.h" -#include +#include "include/v8-inspector.h" namespace v8_inspector { diff --git a/src/inspector/V8Compat.h b/src/inspector/V8Compat.h deleted file mode 100644 index 9ad919cc7d..0000000000 --- a/src/inspector/V8Compat.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_V8COMPAT_H_ -#define V8_INSPECTOR_V8COMPAT_H_ - -#include - -#if V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1) -namespace v8 { - -// In standalone V8 inspector this is expected to be noop anyways... -class V8_EXPORT MicrotasksScope { - public: - enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; - - MicrotasksScope(Isolate* isolate, Type type) { - // No-op - } -}; - -} // namespace v8 -#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \ - v8::Function::New((context), (callback), (data), (length)) -#else -#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \ - v8::Function::New((context), (callback), (data), (length), \ - v8::ConstructorBehavior::kThrow) -#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < - // 1) - -#endif // V8_INSPECTOR_V8COMPAT_H_ diff --git a/src/inspector/V8Console.cpp b/src/inspector/V8Console.cpp index 2940e46c73..33ba0a5102 100644 --- a/src/inspector/V8Console.cpp +++ b/src/inspector/V8Console.cpp @@ -4,10 +4,10 @@ #include "src/inspector/V8Console.h" +#include "src/base/macros.h" #include "src/inspector/InjectedScript.h" #include "src/inspector/InspectedContext.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8ConsoleMessage.h" #include "src/inspector/V8DebuggerAgentImpl.h" #include "src/inspector/V8InspectorImpl.h" @@ -16,7 +16,8 @@ #include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/V8ValueCopier.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { @@ -254,7 +255,8 @@ void createBoundFunctionProperty(v8::Local context, v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, console, 0) + if (!v8::Function::New(context, callback, console, 0, + v8::ConstructorBehavior::kThrow) .ToLocal(&func)) return; func->SetName(funcName); @@ -262,8 +264,8 @@ void createBoundFunctionProperty(v8::Local context, v8::Local returnValue = toV8String(context->GetIsolate(), description); v8::Local toStringFunction; - if (V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, returnDataCallback, - returnValue, 0) + if (v8::Function::New(context, returnDataCallback, returnValue, 0, + v8::ConstructorBehavior::kThrow) .ToLocal(&toStringFunction)) createDataProperty(context, func, toV8StringInternalized( context->GetIsolate(), "toString"), @@ -661,6 +663,7 @@ v8::Local V8Console::createConsole( bool success = console->SetPrototype(context, v8::Object::New(isolate)).FromMaybe(false); DCHECK(success); + USE(success); createBoundFunctionProperty(context, console, "debug", V8Console::debugCallback); @@ -710,11 +713,12 @@ v8::Local V8Console::createConsole( if (hasMemoryAttribute) console->SetAccessorProperty( toV8StringInternalized(isolate, "memory"), - V8_FUNCTION_NEW_REMOVE_PROTOTYPE( - context, V8Console::memoryGetterCallback, console, 0) + v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, + v8::ConstructorBehavior::kThrow) .ToLocalChecked(), - V8_FUNCTION_NEW_REMOVE_PROTOTYPE( - context, V8Console::memorySetterCallback, v8::Local(), 0) + v8::Function::New(context, V8Console::memorySetterCallback, + v8::Local(), 0, + v8::ConstructorBehavior::kThrow) .ToLocalChecked(), static_cast(v8::None), v8::DEFAULT); @@ -741,6 +745,7 @@ v8::Local V8Console::createCommandLineAPI( bool success = commandLineAPI->SetPrototype(context, v8::Null(isolate)).FromMaybe(false); DCHECK(success); + USE(success); createBoundFunctionProperty(context, commandLineAPI, "dir", V8Console::dirCallback, @@ -824,6 +829,7 @@ void V8Console::CommandLineAPIScope::accessorGetterCallback( if (scope->m_cleanup) { bool removed = info.Holder()->Delete(context, name).FromMaybe(false); DCHECK(removed); + USE(removed); return; } v8::Local commandLineAPI = scope->m_commandLineAPI; @@ -855,6 +861,7 @@ void V8Console::CommandLineAPIScope::accessorSetterCallback( bool removed = scope->m_installedMethods->Delete(context, name).FromMaybe(false); DCHECK(removed); + USE(removed); } V8Console::CommandLineAPIScope::CommandLineAPIScope( @@ -883,6 +890,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( .FromMaybe(false)) { bool removed = m_installedMethods->Delete(context, name).FromMaybe(false); DCHECK(removed); + USE(removed); continue; } } @@ -901,6 +909,7 @@ V8Console::CommandLineAPIScope::~CommandLineAPIScope() { m_context, v8::Local::Cast(name)) .ToLocal(&descriptor); DCHECK(success); + USE(success); } } } diff --git a/src/inspector/V8Console.h b/src/inspector/V8Console.h index 6e07b079cd..413a804ad3 100644 --- a/src/inspector/V8Console.h +++ b/src/inspector/V8Console.h @@ -7,7 +7,7 @@ #include "src/inspector/Allocator.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8ConsoleMessage.cpp b/src/inspector/V8ConsoleMessage.cpp index da0e5ff0e7..cb8953b24b 100644 --- a/src/inspector/V8ConsoleMessage.cpp +++ b/src/inspector/V8ConsoleMessage.cpp @@ -12,7 +12,8 @@ #include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { @@ -307,7 +308,7 @@ void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, m_stackTrace ? m_stackTrace->buildInspectorObjectImpl() : nullptr); return; } - NOTREACHED(); + UNREACHABLE(); } std::unique_ptr diff --git a/src/inspector/V8ConsoleMessage.h b/src/inspector/V8ConsoleMessage.h index 1227dfb2f7..a6e9eafe2d 100644 --- a/src/inspector/V8ConsoleMessage.h +++ b/src/inspector/V8ConsoleMessage.h @@ -5,8 +5,8 @@ #ifndef V8_INSPECTOR_V8CONSOLEMESSAGE_H_ #define V8_INSPECTOR_V8CONSOLEMESSAGE_H_ -#include #include +#include "include/v8.h" #include "src/inspector/protocol/Console.h" #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" diff --git a/src/inspector/V8Debugger.cpp b/src/inspector/V8Debugger.cpp index dc7fb48599..1d4217cf93 100644 --- a/src/inspector/V8Debugger.cpp +++ b/src/inspector/V8Debugger.cpp @@ -7,14 +7,12 @@ #include "src/inspector/DebuggerScript.h" #include "src/inspector/ScriptBreakpoint.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8DebuggerAgentImpl.h" #include "src/inspector/V8InspectorImpl.h" #include "src/inspector/V8InternalValueType.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/V8ValueCopier.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" namespace v8_inspector { @@ -193,7 +191,7 @@ void V8Debugger::clearBreakpoints() { void V8Debugger::setBreakpointsActivated(bool activated) { if (!enabled()) { - NOTREACHED(); + UNREACHABLE(); return; } v8::HandleScope scope(m_isolate); @@ -260,9 +258,10 @@ void V8Debugger::breakProgram() { v8::HandleScope scope(m_isolate); v8::Local breakFunction; - if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(m_isolate->GetCurrentContext(), - &V8Debugger::breakProgramCallback, - v8::External::New(m_isolate, this), 0) + if (!v8::Function::New(m_isolate->GetCurrentContext(), + &V8Debugger::breakProgramCallback, + v8::External::New(m_isolate, this), 0, + v8::ConstructorBehavior::kThrow) .ToLocal(&breakFunction)) return; v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked(); @@ -593,7 +592,7 @@ void V8Debugger::handleV8AsyncTaskEvent(v8::Local context, else if (type == v8AsyncTaskEventDidHandle) asyncTaskFinished(ptr); else - NOTREACHED(); + UNREACHABLE(); } V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { @@ -603,7 +602,7 @@ V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { void V8Debugger::compileDebuggerScript() { if (!m_debuggerScript.IsEmpty()) { - NOTREACHED(); + UNREACHABLE(); return; } @@ -618,7 +617,7 @@ void V8Debugger::compileDebuggerScript() { v8::Local value; if (!m_inspector->compileAndRunInternalScript(debuggerContext(), scriptValue) .ToLocal(&value)) { - NOTREACHED(); + UNREACHABLE(); return; } DCHECK(value->IsObject()); @@ -633,7 +632,7 @@ v8::Local V8Debugger::debuggerContext() const { v8::MaybeLocal V8Debugger::functionScopes( v8::Local context, v8::Local function) { if (!enabled()) { - NOTREACHED(); + UNREACHABLE(); return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); } v8::Local argv[] = {function}; @@ -714,7 +713,7 @@ v8::MaybeLocal V8Debugger::internalProperties( v8::Local V8Debugger::collectionEntries( v8::Local context, v8::Local object) { if (!enabled()) { - NOTREACHED(); + UNREACHABLE(); return v8::Undefined(m_isolate); } v8::Local argv[] = {object}; @@ -735,7 +734,7 @@ v8::Local V8Debugger::collectionEntries( v8::Local V8Debugger::generatorObjectLocation( v8::Local context, v8::Local object) { if (!enabled()) { - NOTREACHED(); + UNREACHABLE(); return v8::Null(m_isolate); } v8::Local argv[] = {object}; diff --git a/src/inspector/V8Debugger.h b/src/inspector/V8Debugger.h index c1a1e39f5f..c4221b39ef 100644 --- a/src/inspector/V8Debugger.h +++ b/src/inspector/V8Debugger.h @@ -10,11 +10,10 @@ #include "src/inspector/V8DebuggerScript.h" #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" -#include "src/inspector/public/StringView.h" -#include "src/inspector/public/V8ContextInfo.h" -#include -#include +#include "include/v8-debug.h" +#include "include/v8-inspector.h" + #include namespace v8_inspector { diff --git a/src/inspector/V8DebuggerAgentImpl.cpp b/src/inspector/V8DebuggerAgentImpl.cpp index 6063e560c7..58bcd610c3 100644 --- a/src/inspector/V8DebuggerAgentImpl.cpp +++ b/src/inspector/V8DebuggerAgentImpl.cpp @@ -19,7 +19,8 @@ #include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" #include @@ -215,7 +216,7 @@ void V8DebuggerAgentImpl::restore() { String16 blackboxPattern; if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern)) { - if (!setBlackboxPattern(&error, blackboxPattern)) NOTREACHED(); + if (!setBlackboxPattern(&error, blackboxPattern)) UNREACHABLE(); } } diff --git a/src/inspector/V8DebuggerScript.h b/src/inspector/V8DebuggerScript.h index 08a0b63572..e3fc00562f 100644 --- a/src/inspector/V8DebuggerScript.h +++ b/src/inspector/V8DebuggerScript.h @@ -33,7 +33,7 @@ #include "src/inspector/Allocator.h" #include "src/inspector/String16.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8FunctionCall.cpp b/src/inspector/V8FunctionCall.cpp index 7c9df4a8b0..d8ffffa02c 100644 --- a/src/inspector/V8FunctionCall.cpp +++ b/src/inspector/V8FunctionCall.cpp @@ -31,12 +31,10 @@ #include "src/inspector/V8FunctionCall.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8Debugger.h" #include "src/inspector/V8InspectorImpl.h" -#include "src/inspector/public/V8InspectorClient.h" -#include +#include "include/v8-inspector.h" namespace v8_inspector { diff --git a/src/inspector/V8FunctionCall.h b/src/inspector/V8FunctionCall.h index 965d9a4236..91846b0447 100644 --- a/src/inspector/V8FunctionCall.h +++ b/src/inspector/V8FunctionCall.h @@ -33,7 +33,7 @@ #include "src/inspector/String16.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8HeapProfilerAgentImpl.cpp b/src/inspector/V8HeapProfilerAgentImpl.cpp index acfa212532..1d1dcddb09 100644 --- a/src/inspector/V8HeapProfilerAgentImpl.cpp +++ b/src/inspector/V8HeapProfilerAgentImpl.cpp @@ -10,10 +10,10 @@ #include "src/inspector/V8InspectorImpl.h" #include "src/inspector/V8InspectorSessionImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" -#include -#include +#include "include/v8-inspector.h" +#include "include/v8-profiler.h" +#include "include/v8-version.h" namespace v8_inspector { diff --git a/src/inspector/V8HeapProfilerAgentImpl.h b/src/inspector/V8HeapProfilerAgentImpl.h index d4e6073967..451d239fff 100644 --- a/src/inspector/V8HeapProfilerAgentImpl.h +++ b/src/inspector/V8HeapProfilerAgentImpl.h @@ -9,7 +9,7 @@ #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/HeapProfiler.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8InjectedScriptHost.cpp b/src/inspector/V8InjectedScriptHost.cpp index dd1008ab78..376a8f58ce 100644 --- a/src/inspector/V8InjectedScriptHost.cpp +++ b/src/inspector/V8InjectedScriptHost.cpp @@ -4,14 +4,15 @@ #include "src/inspector/V8InjectedScriptHost.h" +#include "src/base/macros.h" #include "src/inspector/InjectedScriptNative.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8Debugger.h" #include "src/inspector/V8InspectorImpl.h" #include "src/inspector/V8InternalValueType.h" #include "src/inspector/V8ValueCopier.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { @@ -24,7 +25,8 @@ void setFunctionProperty(v8::Local context, v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, external, 0) + if (!v8::Function::New(context, callback, external, 0, + v8::ConstructorBehavior::kThrow) .ToLocal(&func)) return; func->SetName(funcName); @@ -50,6 +52,7 @@ v8::Local V8InjectedScriptHost::create( bool success = injectedScriptHost->SetPrototype(context, v8::Null(isolate)) .FromMaybe(false); DCHECK(success); + USE(success); v8::Local debuggerExternal = v8::External::New(isolate, inspector); setFunctionProperty(context, injectedScriptHost, "internalConstructorName", @@ -198,7 +201,7 @@ void V8InjectedScriptHost::bindCallback( void V8InjectedScriptHost::proxyTargetValueCallback( const v8::FunctionCallbackInfo& info) { if (info.Length() != 1 || !info[0]->IsProxy()) { - NOTREACHED(); + UNREACHABLE(); return; } v8::Local target = info[0].As(); diff --git a/src/inspector/V8InjectedScriptHost.h b/src/inspector/V8InjectedScriptHost.h index 33f094820d..7d293af5a7 100644 --- a/src/inspector/V8InjectedScriptHost.h +++ b/src/inspector/V8InjectedScriptHost.h @@ -5,7 +5,7 @@ #ifndef V8_INSPECTOR_V8INJECTEDSCRIPTHOST_H_ #define V8_INSPECTOR_V8INJECTEDSCRIPTHOST_H_ -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8InspectorImpl.cpp b/src/inspector/V8InspectorImpl.cpp index ccaf5364ba..cffc821714 100644 --- a/src/inspector/V8InspectorImpl.cpp +++ b/src/inspector/V8InspectorImpl.cpp @@ -30,10 +30,8 @@ #include "src/inspector/V8InspectorImpl.h" -#include #include "src/inspector/InspectedContext.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8ConsoleAgentImpl.h" #include "src/inspector/V8ConsoleMessage.h" #include "src/inspector/V8Debugger.h" @@ -42,7 +40,8 @@ #include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-profiler.h" namespace v8_inspector { diff --git a/src/inspector/V8InspectorImpl.h b/src/inspector/V8InspectorImpl.h index d38ecfe906..80072d7fad 100644 --- a/src/inspector/V8InspectorImpl.h +++ b/src/inspector/V8InspectorImpl.h @@ -33,10 +33,10 @@ #include "src/inspector/Allocator.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8Inspector.h" -#include -#include +#include "include/v8-debug.h" +#include "include/v8-inspector.h" + #include namespace v8_inspector { diff --git a/src/inspector/V8InspectorSessionImpl.cpp b/src/inspector/V8InspectorSessionImpl.cpp index 31fe22108b..a891d6b7f7 100644 --- a/src/inspector/V8InspectorSessionImpl.cpp +++ b/src/inspector/V8InspectorSessionImpl.cpp @@ -18,8 +18,6 @@ #include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8SchemaAgentImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8ContextInfo.h" -#include "src/inspector/public/V8InspectorClient.h" namespace v8_inspector { diff --git a/src/inspector/V8InspectorSessionImpl.h b/src/inspector/V8InspectorSessionImpl.h index 2aaec78137..98706a1cfe 100644 --- a/src/inspector/V8InspectorSessionImpl.h +++ b/src/inspector/V8InspectorSessionImpl.h @@ -9,10 +9,9 @@ #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" #include "src/inspector/protocol/Schema.h" -#include "src/inspector/public/V8Inspector.h" -#include "src/inspector/public/V8InspectorSession.h" -#include +#include "include/v8-inspector.h" + #include namespace v8_inspector { diff --git a/src/inspector/V8InternalValueType.cpp b/src/inspector/V8InternalValueType.cpp index 21640e2c3b..2eade4ff56 100644 --- a/src/inspector/V8InternalValueType.cpp +++ b/src/inspector/V8InternalValueType.cpp @@ -29,7 +29,7 @@ v8::Local subtypeForInternalType(v8::Isolate* isolate, case V8InternalValueType::kScopeList: return toV8StringInternalized(isolate, "internal#scopeList"); } - NOTREACHED(); + UNREACHABLE(); return v8::Local(); } diff --git a/src/inspector/V8InternalValueType.h b/src/inspector/V8InternalValueType.h index bff8d96c4c..e648a0d4a3 100644 --- a/src/inspector/V8InternalValueType.h +++ b/src/inspector/V8InternalValueType.h @@ -5,7 +5,7 @@ #ifndef V8_INSPECTOR_V8INTERNALVALUETYPE_H_ #define V8_INSPECTOR_V8INTERNALVALUETYPE_H_ -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8ProfilerAgentImpl.cpp b/src/inspector/V8ProfilerAgentImpl.cpp index e6cb1236d1..c9c9cd61b9 100644 --- a/src/inspector/V8ProfilerAgentImpl.cpp +++ b/src/inspector/V8ProfilerAgentImpl.cpp @@ -4,7 +4,6 @@ #include "src/inspector/V8ProfilerAgentImpl.h" -#include #include "src/inspector/Atomics.h" #include "src/inspector/StringUtil.h" #include "src/inspector/V8Debugger.h" @@ -13,6 +12,8 @@ #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/protocol/Protocol.h" +#include "include/v8-profiler.h" + #include #define ENSURE_V8_VERSION(major, minor) \ diff --git a/src/inspector/V8Regex.cpp b/src/inspector/V8Regex.cpp index 5603ffc0ff..8db33ebc4c 100644 --- a/src/inspector/V8Regex.cpp +++ b/src/inspector/V8Regex.cpp @@ -5,9 +5,9 @@ #include "src/inspector/V8Regex.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8InspectorImpl.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" #include diff --git a/src/inspector/V8Regex.h b/src/inspector/V8Regex.h index e478f9082d..119a0461d2 100644 --- a/src/inspector/V8Regex.h +++ b/src/inspector/V8Regex.h @@ -8,7 +8,7 @@ #include "src/inspector/Allocator.h" #include "src/inspector/String16.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8RuntimeAgentImpl.cpp b/src/inspector/V8RuntimeAgentImpl.cpp index 3f28ef3ab1..a59dcf4d54 100644 --- a/src/inspector/V8RuntimeAgentImpl.cpp +++ b/src/inspector/V8RuntimeAgentImpl.cpp @@ -34,7 +34,6 @@ #include "src/inspector/InspectedContext.h" #include "src/inspector/RemoteObjectId.h" #include "src/inspector/StringUtil.h" -#include "src/inspector/V8Compat.h" #include "src/inspector/V8ConsoleMessage.h" #include "src/inspector/V8Debugger.h" #include "src/inspector/V8DebuggerAgentImpl.h" @@ -42,7 +41,8 @@ #include "src/inspector/V8InspectorSessionImpl.h" #include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/protocol/Protocol.h" -#include "src/inspector/public/V8InspectorClient.h" + +#include "include/v8-inspector.h" namespace v8_inspector { @@ -87,14 +87,16 @@ class ProtocolPromiseHandler { v8::Local wrapper = handler->m_wrapper.Get(inspector->isolate()); v8::Local thenCallbackFunction = - V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, thenCallback, wrapper, 0) + v8::Function::New(context, thenCallback, wrapper, 0, + v8::ConstructorBehavior::kThrow) .ToLocalChecked(); if (promise->Then(context, thenCallbackFunction).IsEmpty()) { rawCallback->sendFailure("Internal error"); return; } v8::Local catchCallbackFunction = - V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, catchCallback, wrapper, 0) + v8::Function::New(context, catchCallback, wrapper, 0, + v8::ConstructorBehavior::kThrow) .ToLocalChecked(); if (promise->Catch(context, catchCallbackFunction).IsEmpty()) { rawCallback->sendFailure("Internal error"); diff --git a/src/inspector/V8RuntimeAgentImpl.h b/src/inspector/V8RuntimeAgentImpl.h index c1d4fdb1a6..3bb653793d 100644 --- a/src/inspector/V8RuntimeAgentImpl.h +++ b/src/inspector/V8RuntimeAgentImpl.h @@ -35,7 +35,7 @@ #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/V8StackTraceImpl.cpp b/src/inspector/V8StackTraceImpl.cpp index c463676ee9..d552f25653 100644 --- a/src/inspector/V8StackTraceImpl.cpp +++ b/src/inspector/V8StackTraceImpl.cpp @@ -8,9 +8,9 @@ #include "src/inspector/V8Debugger.h" #include "src/inspector/protocol/Protocol.h" -#include -#include -#include +#include "include/v8-debug.h" +#include "include/v8-profiler.h" +#include "include/v8-version.h" namespace v8_inspector { diff --git a/src/inspector/V8StackTraceImpl.h b/src/inspector/V8StackTraceImpl.h index 877de5a164..7bc156a98f 100644 --- a/src/inspector/V8StackTraceImpl.h +++ b/src/inspector/V8StackTraceImpl.h @@ -8,7 +8,8 @@ #include "src/inspector/Allocator.h" #include "src/inspector/protocol/Forward.h" #include "src/inspector/protocol/Runtime.h" -#include "src/inspector/public/V8StackTrace.h" + +#include "include/v8-inspector.h" #include diff --git a/src/inspector/V8ValueCopier.h b/src/inspector/V8ValueCopier.h index 5c93882394..c24a5648a2 100644 --- a/src/inspector/V8ValueCopier.h +++ b/src/inspector/V8ValueCopier.h @@ -5,7 +5,7 @@ #ifndef V8_INSPECTOR_V8VALUECOPIER_H_ #define V8_INSPECTOR_V8VALUECOPIER_H_ -#include +#include "include/v8.h" namespace v8_inspector { diff --git a/src/inspector/inspector.gyp b/src/inspector/inspector.gyp index 5fc49b15ea..66f81142c9 100644 --- a/src/inspector/inspector.gyp +++ b/src/inspector/inspector.gyp @@ -2,112 +2,108 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -{ 'variables': { - 'protocol_path': '../../third_party/WebKit/Source/platform/inspector_protocol', - 'protocol_sources': [ - '<(SHARED_INTERMEDIATE_DIR)/inspector/Console.cpp', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Console.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Debugger.cpp', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Debugger.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/HeapProfiler.cpp', - '<(SHARED_INTERMEDIATE_DIR)/inspector/HeapProfiler.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Profiler.cpp', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Profiler.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/public/Debugger.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/public/Runtime.h', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Runtime.cpp', - '<(SHARED_INTERMEDIATE_DIR)/inspector/Runtime.h', - ] +{ + 'variables': { + 'protocol_path': '<(PRODUCT_DIR)/../../third_party/WebKit/Source/platform/inspector_protocol', }, + 'includes': [ + 'inspector.gypi', + '<(PRODUCT_DIR)/../../../third_party/WebKit/Source/platform/inspector_protocol/inspector_protocol.gypi', + ], 'targets': [ - { 'target_name': 'inspector_protocol_sources', + { 'target_name': 'inspector_injected_script', 'type': 'none', - 'variables': { - 'jinja_module_files': [ - # jinja2/__init__.py contains version string, so sufficient for package - '../third_party/jinja2/__init__.py', - '../third_party/markupsafe/__init__.py', # jinja2 dep - ] - }, 'actions': [ { - 'action_name': 'generate_inspector_protocol_sources', + 'action_name': 'convert_js_to_cpp_char_array', + 'inputs': [ + 'build/xxd.py', + '<(inspector_injected_script_source)', + ], + 'outputs': [ + '<(inspector_generated_injected_script)', + ], + 'action': [ + 'python', + 'build/xxd.py', + 'InjectedScriptSource_js', + 'InjectedScriptSource.js', + '<@(_outputs)' + ], + }, + ], + # Since this target generates header files, it needs to be a hard dependency. + 'hard_dependency': 1, + }, + { 'target_name': 'inspector_debugger_script', + 'type': 'none', + 'actions': [ + { + 'action_name': 'convert_js_to_cpp_char_array', + 'inputs': [ + 'build/xxd.py', + '<(inspector_debugger_script_source)', + ], + 'outputs': [ + '<(inspector_generated_debugger_script)', + ], + 'action': [ + 'python', + 'build/xxd.py', + 'DebuggerScript_js', + 'DebuggerScript.js', + '<@(_outputs)' + ], + }, + ], + # Since this target generates header files, it needs to be a hard dependency. + 'hard_dependency': 1, + }, + { 'target_name': 'protocol_compatibility', + 'type': 'none', + 'actions': [ + { + 'action_name': 'protocol_compatibility', 'inputs': [ - # Source generator script. - '<(protocol_path)/CodeGenerator.py', - # Source code templates. - '<(protocol_path)/Exported_h.template', - '<(protocol_path)/Imported_h.template', - '<(protocol_path)/TypeBuilder_h.template', - '<(protocol_path)/TypeBuilder_cpp.template', - # Protocol definition. 'js_protocol.json', ], 'outputs': [ - '<@(protocol_sources)', + '<@(SHARED_INTERMEDIATE_DIR)/src/js_protocol.stamp', + ], + 'action': [ + 'python', + '<(protocol_path)/CheckProtocolCompatibility.py', + '--stamp', '<@(_outputs)', + 'js_protocol.json', + ], + 'message': 'Generating inspector protocol sources from protocol json definition', + }, + ] + }, + { 'target_name': 'protocol_generated_sources', + 'type': 'none', + 'dependencies': [ 'protocol_compatibility' ], + 'actions': [ + { + 'action_name': 'protocol_generated_sources', + 'inputs': [ + 'js_protocol.json', + 'inspector_protocol_config.json', + '<@(inspector_protocol_files)', + ], + 'outputs': [ + '<@(inspector_generated_sources)', ], 'action': [ 'python', '<(protocol_path)/CodeGenerator.py', - '--protocol', 'js_protocol.json', - '--string_type', 'String16', - '--export_macro', 'PLATFORM_EXPORT', - '--output_dir', '<(SHARED_INTERMEDIATE_DIR)/inspector', - '--output_package', 'inspector', - '--exported_dir', '<(SHARED_INTERMEDIATE_DIR)/inspector/public', - '--exported_package', 'inspector/public', + '--jinja_dir', '<(PRODUCT_DIR)/../../third_party', + '--output_base', '<(SHARED_INTERMEDIATE_DIR)/src/inspector', + '--config', 'inspector_protocol_config.json', ], - 'message': 'Generating Inspector protocol backend sources from json definitions', + 'message': 'Generating inspector protocol sources from protocol json', }, ] }, - { 'target_name': 'inspector_protocol', - 'type': 'static_library', - 'dependencies': [ - 'inspector_protocol_sources', - ], - 'include_dirs+': [ - '<(protocol_path)/../..', - '<(SHARED_INTERMEDIATE_DIR)', - ], - 'defines': [ - 'V8_INSPECTOR_USE_STL', - ], - 'msvs_disabled_warnings': [ - 4267, # Truncation from size_t to int. - 4305, # Truncation from 'type1' to 'type2'. - 4324, # Struct padded due to declspec(align). - 4714, # Function marked forceinline not inlined. - 4800, # Value forced to bool. - 4996, # Deprecated function call. - ], - 'sources': [ - '<@(protocol_sources)', - '<(protocol_path)/Allocator.h', - '<(protocol_path)/Array.h', - '<(protocol_path)/BackendCallback.h', - '<(protocol_path)/CodeGenerator.py', - '<(protocol_path)/Collections.h', - '<(protocol_path)/DispatcherBase.cpp', - '<(protocol_path)/DispatcherBase.h', - '<(protocol_path)/ErrorSupport.cpp', - '<(protocol_path)/ErrorSupport.h', - '<(protocol_path)/FrontendChannel.h', - '<(protocol_path)/Maybe.h', - '<(protocol_path)/Object.cpp', - '<(protocol_path)/Object.h', - '<(protocol_path)/Parser.cpp', - '<(protocol_path)/Parser.h', - '<(protocol_path)/Platform.h', - '<(protocol_path)/PlatformSTL.h', - '<(protocol_path)/String16.cpp', - '<(protocol_path)/String16.h', - '<(protocol_path)/String16STL.cpp', - '<(protocol_path)/String16STL.h', - '<(protocol_path)/ValueConversions.h', - '<(protocol_path)/Values.cpp', - '<(protocol_path)/Values.h', - ] - }, ], } diff --git a/src/inspector/inspector.gypi b/src/inspector/inspector.gypi new file mode 100644 index 0000000000..748b2810cf --- /dev/null +++ b/src/inspector/inspector.gypi @@ -0,0 +1,97 @@ +# 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. + +{ + 'variables': { + 'inspector_generated_sources': [ + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Forward.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Protocol.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Protocol.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Console.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Console.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Debugger.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Debugger.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/HeapProfiler.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/HeapProfiler.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Profiler.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Profiler.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Runtime.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Runtime.h', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Schema.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/inspector/protocol/Schema.h', + '<(SHARED_INTERMEDIATE_DIR)/include/inspector/Debugger.h', + '<(SHARED_INTERMEDIATE_DIR)/include/inspector/Runtime.h', + '<(SHARED_INTERMEDIATE_DIR)/include/inspector/Schema.h', + ], + + 'inspector_injected_script_source': 'InjectedScriptSource.js', + 'inspector_generated_injected_script': '<(SHARED_INTERMEDIATE_DIR)/src/inspector/InjectedScriptSource.h', + 'inspector_debugger_script_source': 'DebuggerScript.js', + 'inspector_generated_debugger_script': '<(SHARED_INTERMEDIATE_DIR)/src/inspector/DebuggerScript.h', + + 'inspector_all_sources': [ + '<@(inspector_generated_sources)', + '<(inspector_generated_injected_script)', + '<(inspector_generated_debugger_script)', + '../../include/v8-inspector.h', + '../../include/v8-inspector-protocol.h', + 'inspector/Allocator.h', + 'inspector/Atomics.h', + 'inspector/InjectedScript.cpp', + 'inspector/InjectedScript.h', + 'inspector/InjectedScriptNative.cpp', + 'inspector/InjectedScriptNative.h', + 'inspector/InspectedContext.cpp', + 'inspector/InspectedContext.h', + 'inspector/JavaScriptCallFrame.cpp', + 'inspector/JavaScriptCallFrame.h', + 'inspector/ProtocolPlatform.h', + 'inspector/RemoteObjectId.cpp', + 'inspector/RemoteObjectId.h', + 'inspector/ScriptBreakpoint.h', + 'inspector/SearchUtil.cpp', + 'inspector/SearchUtil.h', + 'inspector/String16.cpp', + 'inspector/String16.h', + 'inspector/StringUtil.cpp', + 'inspector/StringUtil.h', + 'inspector/V8Console.cpp', + 'inspector/V8Console.h', + 'inspector/V8ConsoleAgentImpl.cpp', + 'inspector/V8ConsoleAgentImpl.h', + 'inspector/V8ConsoleMessage.cpp', + 'inspector/V8ConsoleMessage.h', + 'inspector/V8Debugger.cpp', + 'inspector/V8Debugger.h', + 'inspector/V8DebuggerAgentImpl.cpp', + 'inspector/V8DebuggerAgentImpl.h', + 'inspector/V8DebuggerScript.cpp', + 'inspector/V8DebuggerScript.h', + 'inspector/V8FunctionCall.cpp', + 'inspector/V8FunctionCall.h', + 'inspector/V8HeapProfilerAgentImpl.cpp', + 'inspector/V8HeapProfilerAgentImpl.h', + 'inspector/V8InjectedScriptHost.cpp', + 'inspector/V8InjectedScriptHost.h', + 'inspector/V8InspectorImpl.cpp', + 'inspector/V8InspectorImpl.h', + 'inspector/V8InspectorSessionImpl.cpp', + 'inspector/V8InspectorSessionImpl.h', + 'inspector/V8InternalValueType.cpp', + 'inspector/V8InternalValueType.h', + 'inspector/V8ProfilerAgentImpl.cpp', + 'inspector/V8ProfilerAgentImpl.h', + 'inspector/V8Regex.cpp', + 'inspector/V8Regex.h', + 'inspector/V8RuntimeAgentImpl.cpp', + 'inspector/V8RuntimeAgentImpl.h', + 'inspector/V8SchemaAgentImpl.cpp', + 'inspector/V8SchemaAgentImpl.h', + 'inspector/V8StackTraceImpl.cpp', + 'inspector/V8StackTraceImpl.h', + 'inspector/V8ValueCopier.cpp', + 'inspector/V8ValueCopier.h', + ] + } +} diff --git a/src/inspector/inspector_protocol_config.json b/src/inspector/inspector_protocol_config.json index 65942b1601..6f61ca2456 100644 --- a/src/inspector/inspector_protocol_config.json +++ b/src/inspector/inspector_protocol_config.json @@ -2,28 +2,24 @@ "protocol": { "path": "js_protocol.json", "package": "src/inspector/protocol", - "output": "v8_inspector/protocol", + "output": "protocol", "namespace": ["v8_inspector", "protocol"] }, "exported": { - "package": "src/inspector/public/protocol", - "output": "v8_inspector/public/protocol", - "string_header": "src/inspector/public/StringBuffer.h", + "package": "include/inspector", + "output": "../../include/inspector", + "string_header": "v8-inspector.h", "string_in": "StringView", "string_out": "std::unique_ptr", - "to_string_out": "StringBufferImpl::adopt(%s)" + "to_string_out": "StringBufferImpl::adopt(%s)", + "export_macro": "V8_EXPORT" }, "lib": { "package": "src/inspector/protocol", - "output": "v8_inspector/protocol", + "output": "protocol", "string_header": "src/inspector/StringUtil.h", "platform_header": "src/inspector/ProtocolPlatform.h" - }, - - "class_export": { - "macro": "PLATFORM_EXPORT", - "header": "platform/PlatformExport.h" } } diff --git a/src/inspector/public/StringBuffer.h b/src/inspector/public/StringBuffer.h deleted file mode 100644 index f229c47ada..0000000000 --- a/src/inspector/public/StringBuffer.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_PUBLIC_STRINGBUFFER_H_ -#define V8_INSPECTOR_PUBLIC_STRINGBUFFER_H_ - -#include "src/inspector/public/StringView.h" - -#include - -namespace v8_inspector { - -class PLATFORM_EXPORT StringBuffer { - public: - virtual ~StringBuffer() {} - virtual const StringView& string() = 0; - // This method copies contents. - static std::unique_ptr create(const StringView&); -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_STRINGBUFFER_H_ diff --git a/src/inspector/public/StringView.h b/src/inspector/public/StringView.h deleted file mode 100644 index e8e2ba1a43..0000000000 --- a/src/inspector/public/StringView.h +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ -#define V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ - -#include -#include - -namespace v8_inspector { - -class PLATFORM_EXPORT StringView { - public: - StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} - - StringView(const uint8_t* characters, unsigned length) - : m_is8Bit(true), m_length(length), m_characters8(characters) {} - - StringView(const uint16_t* characters, unsigned length) - : m_is8Bit(false), m_length(length), m_characters16(characters) {} - - bool is8Bit() const { return m_is8Bit; } - unsigned length() const { return m_length; } - - // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used - // here. - const uint8_t* characters8() const { return m_characters8; } - const uint16_t* characters16() const { return m_characters16; } - - private: - bool m_is8Bit; - unsigned m_length; - union { - const uint8_t* m_characters8; - const uint16_t* m_characters16; - }; -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ diff --git a/src/inspector/public/V8ContextInfo.h b/src/inspector/public/V8ContextInfo.h deleted file mode 100644 index 34a89af6e1..0000000000 --- a/src/inspector/public/V8ContextInfo.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_PUBLIC_V8CONTEXTINFO_H_ -#define V8_INSPECTOR_PUBLIC_V8CONTEXTINFO_H_ - -#include "src/inspector/public/StringView.h" - -#include - -namespace v8_inspector { - -class V8ContextInfo { - public: - V8ContextInfo(v8::Local context, int contextGroupId, - const StringView& humanReadableName) - : context(context), - contextGroupId(contextGroupId), - humanReadableName(humanReadableName), - hasMemoryOnConsole(false) {} - - v8::Local context; - // Each v8::Context is a part of a group. The group id is used to find - // appropriate - // V8DebuggerAgent to notify about events in the context. - // |contextGroupId| must be non-0. - int contextGroupId; - StringView humanReadableName; - StringView origin; - StringView auxData; - bool hasMemoryOnConsole; - - private: - // Disallow copying and allocating this one. - enum NotNullTagEnum { NotNullLiteral }; - void* operator new(size_t) = delete; - void* operator new(size_t, NotNullTagEnum, void*) = delete; - void* operator new(size_t, void*) = delete; - V8ContextInfo(const V8ContextInfo&) = delete; - V8ContextInfo& operator=(const V8ContextInfo&) = delete; -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_V8CONTEXTINFO_H_ diff --git a/src/inspector/public/V8Inspector.h b/src/inspector/public/V8Inspector.h deleted file mode 100644 index 48db2eddbc..0000000000 --- a/src/inspector/public/V8Inspector.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2015 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. - -#ifndef V8_INSPECTOR_PUBLIC_V8INSPECTOR_H_ -#define V8_INSPECTOR_PUBLIC_V8INSPECTOR_H_ - -#include "src/inspector/public/StringView.h" -#include "src/inspector/public/V8ContextInfo.h" - -#include - -namespace v8_inspector { - -class V8InspectorClient; -class V8InspectorSession; -class V8StackTrace; - -class PLATFORM_EXPORT V8Inspector { - public: - static std::unique_ptr create(v8::Isolate*, V8InspectorClient*); - virtual ~V8Inspector() {} - - // Contexts instrumentation. - virtual void contextCreated(const V8ContextInfo&) = 0; - virtual void contextDestroyed(v8::Local) = 0; - virtual void resetContextGroup(int contextGroupId) = 0; - - // Various instrumentation. - virtual void willExecuteScript(v8::Local, int scriptId) = 0; - virtual void didExecuteScript(v8::Local) = 0; - virtual void idleStarted() = 0; - virtual void idleFinished() = 0; - - // Async stack traces instrumentation. - virtual void asyncTaskScheduled(const StringView& taskName, void* task, - bool recurring) = 0; - virtual void asyncTaskCanceled(void* task) = 0; - virtual void asyncTaskStarted(void* task) = 0; - virtual void asyncTaskFinished(void* task) = 0; - virtual void allAsyncTasksCanceled() = 0; - - // Exceptions instrumentation. - virtual unsigned exceptionThrown( - v8::Local, const StringView& message, - v8::Local exception, const StringView& detailedMessage, - const StringView& url, unsigned lineNumber, unsigned columnNumber, - std::unique_ptr, int scriptId) = 0; - virtual void exceptionRevoked(v8::Local, unsigned exceptionId, - const StringView& message) = 0; - - // Connection. - class PLATFORM_EXPORT Channel { - public: - virtual ~Channel() {} - virtual void sendProtocolResponse(int callId, - const StringView& message) = 0; - virtual void sendProtocolNotification(const StringView& message) = 0; - virtual void flushProtocolNotifications() = 0; - }; - virtual std::unique_ptr connect( - int contextGroupId, Channel*, const StringView& state) = 0; - - // API methods. - virtual std::unique_ptr createStackTrace( - v8::Local) = 0; - virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_V8INSPECTOR_H_ diff --git a/src/inspector/public/V8InspectorClient.h b/src/inspector/public/V8InspectorClient.h deleted file mode 100644 index 7ddc69ebfa..0000000000 --- a/src/inspector/public/V8InspectorClient.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 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. - -#ifndef V8_INSPECTOR_PUBLIC_V8INSPECTORCLIENT_H_ -#define V8_INSPECTOR_PUBLIC_V8INSPECTORCLIENT_H_ - -#include "src/inspector/public/StringBuffer.h" -#include "src/inspector/public/StringView.h" - -#include - -namespace v8_inspector { - -class V8StackTrace; - -enum class V8ConsoleAPIType { kClear, kDebug, kLog, kInfo, kWarning, kError }; - -class PLATFORM_EXPORT V8InspectorClient { - public: - virtual ~V8InspectorClient() {} - - virtual void runMessageLoopOnPause(int contextGroupId) {} - virtual void quitMessageLoopOnPause() {} - virtual void runIfWaitingForDebugger(int contextGroupId) {} - - virtual void muteMetrics(int contextGroupId) {} - virtual void unmuteMetrics(int contextGroupId) {} - - virtual void beginUserGesture() {} - virtual void endUserGesture() {} - - virtual std::unique_ptr valueSubtype(v8::Local) { - return nullptr; - } - virtual bool formatAccessorsAsProperties(v8::Local) { - return false; - } - virtual bool isInspectableHeapObject(v8::Local) { return true; } - - virtual v8::Local ensureDefaultContextInGroup( - int contextGroupId) { - return v8::Local(); - } - virtual void beginEnsureAllContextsInGroup(int contextGroupId) {} - virtual void endEnsureAllContextsInGroup(int contextGroupId) {} - - virtual void installAdditionalCommandLineAPI(v8::Local, - v8::Local) {} - virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType, - const StringView& message, - const StringView& url, unsigned lineNumber, - unsigned columnNumber, V8StackTrace*) {} - virtual v8::MaybeLocal memoryInfo(v8::Isolate*, - v8::Local) { - return v8::MaybeLocal(); - } - - virtual void consoleTime(const StringView& title) {} - virtual void consoleTimeEnd(const StringView& title) {} - virtual void consoleTimeStamp(const StringView& title) {} - virtual double currentTimeMS() { return 0; } - typedef void (*TimerCallback)(void*); - virtual void startRepeatingTimer(double, TimerCallback, void* data) {} - virtual void cancelTimer(void* data) {} - - // TODO(dgozman): this was added to support service worker shadow page. We - // should not connect at all. - virtual bool canExecuteScripts(int contextGroupId) { return true; } -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_V8INSPECTORCLIENT_H_ diff --git a/src/inspector/public/V8InspectorSession.h b/src/inspector/public/V8InspectorSession.h deleted file mode 100644 index 64e41a4d64..0000000000 --- a/src/inspector/public/V8InspectorSession.h +++ /dev/null @@ -1,63 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_PUBLIC_V8INSPECTORSESSION_H_ -#define V8_INSPECTOR_PUBLIC_V8INSPECTORSESSION_H_ - -#include "src/inspector/public/StringBuffer.h" -#include "src/inspector/public/StringView.h" -#include "src/inspector/public/protocol/Debugger.h" -#include "src/inspector/public/protocol/Runtime.h" -#include "src/inspector/public/protocol/Schema.h" - -#include - -namespace v8_inspector { - -class PLATFORM_EXPORT V8InspectorSession { - public: - virtual ~V8InspectorSession() {} - - // Cross-context inspectable values (DOM nodes in different worlds, etc.). - class Inspectable { - public: - virtual v8::Local get(v8::Local) = 0; - virtual ~Inspectable() {} - }; - virtual void addInspectedObject(std::unique_ptr) = 0; - - // Dispatching protocol messages. - static bool canDispatchMethod(const StringView& method); - virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual std::unique_ptr stateJSON() = 0; - virtual std::vector> - supportedDomains() = 0; - - // Debugger actions. - virtual void schedulePauseOnNextStatement(const StringView& breakReason, - const StringView& breakDetails) = 0; - virtual void cancelPauseOnNextStatement() = 0; - virtual void breakProgram(const StringView& breakReason, - const StringView& breakDetails) = 0; - virtual void setSkipAllPauses(bool) = 0; - virtual void resume() = 0; - virtual void stepOver() = 0; - virtual std::vector> - searchInTextByLines(const StringView& text, const StringView& query, - bool caseSensitive, bool isRegex) = 0; - - // Remote objects. - virtual std::unique_ptr wrapObject( - v8::Local, v8::Local, - const StringView& groupName) = 0; - virtual bool unwrapObject(std::unique_ptr* error, - const StringView& objectId, v8::Local*, - v8::Local*, - std::unique_ptr* objectGroup) = 0; - virtual void releaseObjectGroup(const StringView&) = 0; -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_V8INSPECTORSESSION_H_ diff --git a/src/inspector/public/V8StackTrace.h b/src/inspector/public/V8StackTrace.h deleted file mode 100644 index e12b90763f..0000000000 --- a/src/inspector/public/V8StackTrace.h +++ /dev/null @@ -1,34 +0,0 @@ -// 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. - -#ifndef V8_INSPECTOR_PUBLIC_V8STACKTRACE_H_ -#define V8_INSPECTOR_PUBLIC_V8STACKTRACE_H_ - -#include "src/inspector/public/StringBuffer.h" -#include "src/inspector/public/StringView.h" -#include "src/inspector/public/protocol/Runtime.h" - -namespace v8_inspector { - -class V8StackTrace { - public: - virtual bool isEmpty() const = 0; - virtual StringView topSourceURL() const = 0; - virtual int topLineNumber() const = 0; - virtual int topColumnNumber() const = 0; - virtual StringView topScriptId() const = 0; - virtual StringView topFunctionName() const = 0; - - virtual ~V8StackTrace() {} - virtual std::unique_ptr - buildInspectorObject() const = 0; - virtual std::unique_ptr toString() const = 0; - - // Safe to pass between threads, drops async chain. - virtual std::unique_ptr clone() = 0; -}; - -} // namespace v8_inspector - -#endif // V8_INSPECTOR_PUBLIC_V8STACKTRACE_H_ diff --git a/src/v8.gyp b/src/v8.gyp index 5b34454478..12fd1575e4 100644 --- a/src/v8.gyp +++ b/src/v8.gyp @@ -34,10 +34,11 @@ 'warmup_script%': "", 'v8_extra_library_files%': [], 'v8_experimental_extra_library_files%': [], + 'v8_enable_inspector%': 0, 'mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot<(EXECUTABLE_SUFFIX)', 'mkpeephole_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkpeephole<(EXECUTABLE_SUFFIX)', }, - 'includes': ['../gypfiles/toolchain.gypi', '../gypfiles/features.gypi'], + 'includes': ['../gypfiles/toolchain.gypi', '../gypfiles/features.gypi', 'inspector/inspector.gypi'], 'targets': [ { 'target_name': 'v8', @@ -1735,6 +1736,30 @@ 'i18n.h', ], }], + ['v8_enable_inspector==1', { + 'sources': [ + '<@(inspector_all_sources)' + ], + 'dependencies': [ + 'inspector/inspector.gyp:protocol_generated_sources', + 'inspector/inspector.gyp:inspector_injected_script', + 'inspector/inspector.gyp:inspector_debugger_script', + ], + # TODO(dgozman): fix these warnings and enable them. + 'msvs_disabled_warnings': [ + 4267, # Truncation from size_t to int. + 4305, # Truncation from 'type1' to 'type2'. + 4324, # Struct padded due to declspec(align). + 4714, # Function marked forceinline not inlined. + 4800, # Value forced to bool. + 4996, # Deprecated function call. + ], + 'cflags': [ + '-Wno-zero-length-array', + '-Wno-shorten-64-to-32', + '-Wno-deprecated-declarations', + ], + }], ['OS=="win" and v8_enable_i18n_support==1', { 'dependencies': [ '<(icu_gyp_path):icudata',