diff --git a/deps/v8_inspector/.gitignore b/deps/v8_inspector/.gitignore deleted file mode 100644 index 2a6b83e201c455..00000000000000 --- a/deps/v8_inspector/.gitignore +++ /dev/null @@ -1 +0,0 @@ -platform/v8_inspector/build/rjsmin.pyc diff --git a/deps/v8_inspector/.gitmodules b/deps/v8_inspector/.gitmodules deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/deps/v8_inspector/README.md b/deps/v8_inspector/README.md index e3e5e14cab4a7a..d99d25f94ce3aa 100644 --- a/deps/v8_inspector/README.md +++ b/deps/v8_inspector/README.md @@ -1,10 +1,10 @@ V8 Inspector support for Node.js ================================ -This directory is a gathering of dependencies for Node.js support for the -[Chrome Debug Protocol][https://developer.chrome.com/devtools/docs/debugger-protocol]. +This repository is an intermediate repository that gathers the dependencies for +Node.js support for the [Chrome Debug Protocol][https://developer.chrome.com/devtools/docs/debugger-protocol]. -* platform/v8_inspector: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector -* platform/inspector_protocol: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol -* deps/jinja2: vendored from https://github.com/mitsuhiko/jinja2 -* deps/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe +* third_party/v8_inspector/platform/v8_inspector: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector +* third_party/v8_inspector/platform/inspector_protocol: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol +* third_party/jinja2: vendored from https://github.com/mitsuhiko/jinja2 +* third_party/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe diff --git a/deps/v8_inspector/platform/inspector_protocol/Collections.h b/deps/v8_inspector/platform/inspector_protocol/Collections.h deleted file mode 100644 index 6309284488683e..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/Collections.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Chromium 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 Collections_h -#define Collections_h - -#if V8_INSPECTOR_USE_STL -#include "platform/inspector_protocol/CollectionsSTL.h" -#else -#include "platform/inspector_protocol/CollectionsWTF.h" -#endif // V8_INSPECTOR_USE_STL - - -// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array. -template char (&ArrayLengthHelperFunction(T (&)[Size]))[Size]; -// GCC needs some help to deduce a 0 length array. -#if defined(__GNUC__) -template char (&ArrayLengthHelperFunction(T (&)[0]))[0]; -#endif -#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) - -#endif // !defined(Collections_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h b/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h deleted file mode 100644 index ee99cfd8bd855b..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2016 The Chromium 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 CollectionsSTL_h -#define CollectionsSTL_h - -#include "platform/inspector_protocol/Platform.h" -#include "platform/inspector_protocol/String16.h" - -#include -#include -#include - -namespace blink { -namespace protocol { - -template -class Vector { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - T& operator[](size_t i) { return at(i); } - const T& operator[](size_t i) const { return at(i); } - T& at(size_t i) { return m_impl[i]; } - const T& at(size_t i) const { return m_impl.at(i); } - T& last() { return m_impl[m_impl.size() - 1]; } - const T& last() const { return m_impl[m_impl.size() - 1]; } - void append(const T& t) { m_impl.push_back(t); } - void prepend(const T& t) { m_impl.insert(m_impl.begin(), t); } - void remove(size_t i) { m_impl.erase(m_impl.begin() + i); } - void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.pop_back(); } - -private: - std::vector m_impl; -}; - -template -class Vector> { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - Vector(Vector&& other) { m_impl.swap(other.m_impl); } - ~Vector() { clear(); } - - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - T* operator[](size_t i) { return at(i); } - const T* operator[](size_t i) const { return at(i); } - T* at(size_t i) { return m_impl[i]; } - const T* at(size_t i) const { return m_impl.at(i); } - T* last() { return m_impl[m_impl.size() - 1]; } - const T* last() const { return m_impl[m_impl.size() - 1]; } - void append(std::unique_ptr t) { m_impl.push_back(t.release()); } - void prepend(std::unique_ptr t) { m_impl.insert(m_impl.begin(), t.release()); } - - void remove(size_t i) - { - delete m_impl[i]; - m_impl.erase(m_impl.begin() + i); - } - - void clear() - { - for (auto t : m_impl) - delete t; - m_impl.clear(); - } - - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void swap(Vector&& other) { m_impl.swap(other.m_impl); } - void removeLast() - { - delete last(); - m_impl.pop_back(); - } - -private: - Vector(const Vector&) = delete; - Vector& operator=(const Vector&) = delete; - std::vector m_impl; -}; - -template -class HashMapIterator { -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair.first = m_impl->first; m_pair.second = &m_impl->second; return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator& other) const { return m_impl != other.m_impl; } - - HashMapIterator& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMapIterator, I> { -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair.first = m_impl->first; m_pair.second = m_impl->second; return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator, I>& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator, I>& other) const { return m_impl != other.m_impl; } - - HashMapIterator, I>& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMap { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator::iterator>; - using const_iterator = HashMapIterator::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - bool set(const K& k, const V& v) - { - bool isNew = m_impl.find(k) == m_impl.end(); - m_impl[k] = v; - return isNew; - } - bool contains(const K& k) const { return m_impl.find(k) != m_impl.end(); } - V get(const K& k) const { auto it = m_impl.find(k); return it == m_impl.end() ? V() : it->second; } - void remove(const K& k) { m_impl.erase(k); } - void clear() { m_impl.clear(); } - V take(const K& k) - { - V result = m_impl[k]; - m_impl.erase(k); - return result; - } - -private: - std::map m_impl; -}; - -template -class HashMap> { -public: - HashMap() { } - ~HashMap() { clear(); } - - using iterator = HashMapIterator, typename std::map::iterator>; - using const_iterator = HashMapIterator, typename std::map::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - bool set(const K& k, std::unique_ptr v) - { - bool isNew = m_impl.find(k) == m_impl.end(); - if (!isNew) - delete m_impl[k]; - m_impl[k] = v.release(); - return isNew; - } - bool contains(const K& k) const { return m_impl.find(k) != m_impl.end(); } - V* get(const K& k) const { auto it = m_impl.find(k); return it == m_impl.end() ? nullptr : it->second; } - std::unique_ptr take(const K& k) - { - if (!contains(k)) - return nullptr; - std::unique_ptr result(m_impl[k]); - delete m_impl[k]; - m_impl.erase(k); - return result; - } - void remove(const K& k) - { - delete m_impl[k]; - m_impl.erase(k); - } - - void clear() - { - for (auto pair : m_impl) - delete pair.second; - m_impl.clear(); - } - -private: - std::map m_impl; -}; - -template -class HashSet : public protocol::HashMap { -public: - void add(const K& k) { this->set(k, k); } -}; - -} // namespace platform -} // namespace blink - -#endif // !defined(CollectionsSTL_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h b/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h deleted file mode 100644 index 5d8fbf625f51b2..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Chromium 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 CollectionsWTF_h -#define CollectionsWTF_h - -#include "wtf/Allocator.h" -#include "wtf/HashMap.h" -#include "wtf/PtrUtil.h" -#include "wtf/Vector.h" -#include "wtf/VectorTraits.h" - -namespace blink { -namespace protocol { - -template -class Vector { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - typedef T* iterator; - typedef const T* const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - T& operator[](size_t i) { return at(i); } - const T& operator[](size_t i) const { return at(i); } - T& at(size_t i) { return m_impl.at(i); } - const T& at(size_t i) const { return m_impl.at(i); } - T& last() { return m_impl.last(); } - const T& last() const { return m_impl.last(); } - void append(const T& t) { m_impl.append(t); } - void prepend(const T& t) { m_impl.prepend(t); } - void remove(size_t i) { m_impl.remove(i); } - void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.removeLast(); } - -private: - WTF::Vector m_impl; -}; - -template -class Vector> { - WTF_MAKE_NONCOPYABLE(Vector); -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - Vector(Vector>&& other) : m_impl(std::move(other.m_impl)) { } - ~Vector() { } - - typedef std::unique_ptr* iterator; - typedef const std::unique_ptr* const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - T* operator[](size_t i) { return m_impl.at(i).get(); } - const T* operator[](size_t i) const { return m_impl.at(i).get(); } - T* at(size_t i) { return m_impl.at(i).get(); } - const T* at(size_t i) const { return m_impl.at(i).get(); } - T* last() { return m_impl.last().get(); } - const T* last() const { return m_impl.last(); } - void append(std::unique_ptr t) { m_impl.append(std::move(t)); } - void prepend(std::unique_ptr t) { m_impl.prepend(std::move(t)); } - void remove(size_t i) { m_impl.remove(i); } - void clear() { m_impl.clear(); } - void swap(Vector>& other) { m_impl.swap(other.m_impl); } - void swap(Vector>&& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.removeLast(); } - -private: - WTF::Vector> m_impl; -}; - -template -class HashMapIterator { - STACK_ALLOCATED(); -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair = std::make_pair(m_impl->key, &m_impl->value); return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator& other) const { return m_impl != other.m_impl; } - - HashMapIterator& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMapIterator, I> { - STACK_ALLOCATED(); -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair = std::make_pair(m_impl->key, m_impl->value.get()); return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator, I>& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator, I>& other) const { return m_impl != other.m_impl; } - - HashMapIterator, I>& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMap { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator::iterator>; - using const_iterator = HashMapIterator::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - bool set(const K& k, const V& v) { return m_impl.set(k, v).isNewEntry; } - bool contains(const K& k) const { return m_impl.contains(k); } - V get(const K& k) const { return m_impl.get(k); } - void remove(const K& k) { m_impl.remove(k); } - void clear() { m_impl.clear(); } - V take(const K& k) { return m_impl.take(k); } - -private: - WTF::HashMap m_impl; -}; - -template -class HashMap> { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator, typename WTF::HashMap>::iterator>; - using const_iterator = HashMapIterator, typename WTF::HashMap>::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - bool set(const K& k, std::unique_ptr v) { return m_impl.set(k, std::move(v)).isNewEntry; } - bool contains(const K& k) const { return m_impl.contains(k); } - V* get(const K& k) const { return m_impl.get(k); } - std::unique_ptr take(const K& k) { return m_impl.take(k); } - void remove(const K& k) { m_impl.remove(k); } - void clear() { m_impl.clear(); } - -private: - WTF::HashMap> m_impl; -}; - -template -class HashSet : public protocol::HashMap { -public: - void add(const K& k) { this->set(k, k); } -}; - -} // namespace platform -} // namespace blink - -#endif // !defined(CollectionsWTF_h) diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp b/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp deleted file mode 100644 index 14dba693e97653..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "platform/v8_inspector/V8DebuggerScript.h" - -namespace blink { - -V8DebuggerScript::V8DebuggerScript() - : m_startLine(0) - , m_startColumn(0) - , m_endLine(0) - , m_endColumn(0) - , m_executionContextId(0) - , m_isContentScript(false) - , m_isInternalScript(false) - , m_isLiveEdit(false) -{ -} - -String16 V8DebuggerScript::sourceURL() const -{ - return m_sourceURL.isEmpty() ? m_url : m_sourceURL; -} - -V8DebuggerScript& V8DebuggerScript::setURL(const String16& url) -{ - m_url = url; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSourceURL(const String16& sourceURL) -{ - m_sourceURL = sourceURL; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) -{ - m_sourceMappingURL = sourceMappingURL; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSource(const String16& source) -{ - m_source = source; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setHash(const String16& hash) -{ - m_hash = hash; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setStartLine(int startLine) -{ - m_startLine = startLine; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setStartColumn(int startColumn) -{ - m_startColumn = startColumn; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setEndLine(int endLine) -{ - m_endLine = endLine; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setEndColumn(int endColumn) -{ - m_endColumn = endColumn; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setExecutionContextId(int executionContextId) -{ - m_executionContextId = executionContextId; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsContentScript(bool isContentScript) -{ - m_isContentScript = isContentScript; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsInternalScript(bool isInternalScript) -{ - m_isInternalScript = isInternalScript; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsLiveEdit(bool isLiveEdit) -{ - m_isLiveEdit = isLiveEdit; - return *this; -} - -} // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h b/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h deleted file mode 100644 index 59487b86a9cfbb..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ConsoleAPITypes_h -#define ConsoleAPITypes_h - -namespace blink { - -enum MessageType { - LogMessageType = 1, - DirMessageType, - DirXMLMessageType, - TableMessageType, - TraceMessageType, - StartGroupMessageType, - StartGroupCollapsedMessageType, - EndGroupMessageType, - ClearMessageType, - AssertMessageType, - TimeEndMessageType, - CountMessageType -}; - -} // namespace blink - -#endif // ConsoleAPITypes_h diff --git a/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h b/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h deleted file mode 100644 index fb06fb8ed017ec..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2011 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ConsoleTypes_h -#define ConsoleTypes_h - -namespace blink { - -enum MessageSource { - XMLMessageSource, - JSMessageSource, - NetworkMessageSource, - ConsoleAPIMessageSource, - StorageMessageSource, - AppCacheMessageSource, - RenderingMessageSource, - SecurityMessageSource, - OtherMessageSource, - DeprecationMessageSource, -}; - -enum MessageLevel { - DebugMessageLevel = 4, - LogMessageLevel = 1, - InfoMessageLevel = 5, - WarningMessageLevel = 2, - ErrorMessageLevel = 3, - RevokedErrorMessageLevel = 6 -}; - -} // namespace blink - -#endif // ConsoleTypes_h diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h b/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h deleted file mode 100644 index c3c692f9959236..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Chromium 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 V8ToProtocolValue_h -#define V8ToProtocolValue_h - -#include "platform/inspector_protocol/Values.h" -#include - -namespace blink { - -PLATFORM_EXPORT std::unique_ptr toProtocolValue(v8::Local, v8::Local, int maxDepth = protocol::Value::maxDepth); - -} // namespace blink - -#endif // V8ToProtocolValue_h diff --git a/deps/v8_inspector/deps/jinja2/.gitignore b/deps/v8_inspector/third_party/jinja2/.gitignore similarity index 100% rename from deps/v8_inspector/deps/jinja2/.gitignore rename to deps/v8_inspector/third_party/jinja2/.gitignore diff --git a/deps/v8_inspector/deps/jinja2/.travis.yml b/deps/v8_inspector/third_party/jinja2/.travis.yml similarity index 100% rename from deps/v8_inspector/deps/jinja2/.travis.yml rename to deps/v8_inspector/third_party/jinja2/.travis.yml diff --git a/deps/v8_inspector/deps/jinja2/AUTHORS b/deps/v8_inspector/third_party/jinja2/AUTHORS similarity index 100% rename from deps/v8_inspector/deps/jinja2/AUTHORS rename to deps/v8_inspector/third_party/jinja2/AUTHORS diff --git a/deps/v8_inspector/deps/jinja2/CHANGES b/deps/v8_inspector/third_party/jinja2/CHANGES similarity index 100% rename from deps/v8_inspector/deps/jinja2/CHANGES rename to deps/v8_inspector/third_party/jinja2/CHANGES diff --git a/deps/v8_inspector/deps/jinja2/LICENSE b/deps/v8_inspector/third_party/jinja2/LICENSE similarity index 98% rename from deps/v8_inspector/deps/jinja2/LICENSE rename to deps/v8_inspector/third_party/jinja2/LICENSE index 31bf900e58e30f..10145a264342b7 100644 --- a/deps/v8_inspector/deps/jinja2/LICENSE +++ b/deps/v8_inspector/third_party/jinja2/LICENSE @@ -1,31 +1,31 @@ -Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. + +Some rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/v8_inspector/deps/jinja2/MANIFEST.in b/deps/v8_inspector/third_party/jinja2/MANIFEST.in similarity index 100% rename from deps/v8_inspector/deps/jinja2/MANIFEST.in rename to deps/v8_inspector/third_party/jinja2/MANIFEST.in diff --git a/deps/v8_inspector/deps/jinja2/Makefile b/deps/v8_inspector/third_party/jinja2/Makefile similarity index 100% rename from deps/v8_inspector/deps/jinja2/Makefile rename to deps/v8_inspector/third_party/jinja2/Makefile diff --git a/deps/v8_inspector/deps/jinja2/README.rst b/deps/v8_inspector/third_party/jinja2/README.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/README.rst rename to deps/v8_inspector/third_party/jinja2/README.rst diff --git a/deps/v8_inspector/deps/jinja2/artwork/jinjalogo.svg b/deps/v8_inspector/third_party/jinja2/artwork/jinjalogo.svg similarity index 100% rename from deps/v8_inspector/deps/jinja2/artwork/jinjalogo.svg rename to deps/v8_inspector/third_party/jinja2/artwork/jinjalogo.svg diff --git a/deps/v8_inspector/deps/jinja2/docs/Makefile b/deps/v8_inspector/third_party/jinja2/docs/Makefile similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/Makefile rename to deps/v8_inspector/third_party/jinja2/docs/Makefile diff --git a/deps/v8_inspector/deps/jinja2/docs/_static/.ignore b/deps/v8_inspector/third_party/jinja2/docs/_static/.ignore similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_static/.ignore rename to deps/v8_inspector/third_party/jinja2/docs/_static/.ignore diff --git a/deps/v8_inspector/deps/jinja2/docs/_static/jinja-small.png b/deps/v8_inspector/third_party/jinja2/docs/_static/jinja-small.png similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_static/jinja-small.png rename to deps/v8_inspector/third_party/jinja2/docs/_static/jinja-small.png diff --git a/deps/v8_inspector/deps/jinja2/docs/_templates/sidebarintro.html b/deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarintro.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_templates/sidebarintro.html rename to deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarintro.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_templates/sidebarlogo.html b/deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarlogo.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_templates/sidebarlogo.html rename to deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarlogo.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/LICENSE b/deps/v8_inspector/third_party/jinja2/docs/_themes/LICENSE similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/LICENSE rename to deps/v8_inspector/third_party/jinja2/docs/_themes/LICENSE diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/README b/deps/v8_inspector/third_party/jinja2/docs/_themes/README similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/README rename to deps/v8_inspector/third_party/jinja2/docs/_themes/README diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/layout.html b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/layout.html rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/layout.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/relations.html b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/relations.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/relations.html rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/relations.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t index 7d3b244ae13bb6..3291ba6fd18605 100644 --- a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t +++ b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t @@ -12,11 +12,11 @@ {% set sidebar_width = '220px' %} {% set font_family = 'Georgia, serif' %} {% set header_font_family = 'Crimson Text, ' ~ font_family %} - + @import url("basic.css"); - + /* -- page layout ----------------------------------------------------------- */ - + body { font-family: {{ font_family }}; font-size: 17px; @@ -47,7 +47,7 @@ div.sphinxsidebar { hr { border: 1px solid #B1B4B6; } - + div.body { background-color: #ffffff; color: #3E4349; @@ -58,7 +58,7 @@ img.floatingflask { padding: 0 0 10px 10px; float: right; } - + div.footer { width: {{ page_width }}; margin: 20px auto 30px auto; @@ -74,7 +74,7 @@ div.footer a { div.related { display: none; } - + div.sphinxsidebar a { color: #444; text-decoration: none; @@ -84,7 +84,7 @@ div.sphinxsidebar a { div.sphinxsidebar a:hover { border-bottom: 1px solid #999; } - + div.sphinxsidebar { font-size: 15px; line-height: 1.5; @@ -99,7 +99,7 @@ div.sphinxsidebarwrapper p.logo { margin: 0; text-align: center; } - + div.sphinxsidebar h3, div.sphinxsidebar h4 { font-family: {{ font_family }}; @@ -113,7 +113,7 @@ div.sphinxsidebar h4 { div.sphinxsidebar h4 { font-size: 20px; } - + div.sphinxsidebar h3 a { color: #444; } @@ -124,7 +124,7 @@ div.sphinxsidebar p.logo a:hover, div.sphinxsidebar h3 a:hover { border: none; } - + div.sphinxsidebar p { color: #555; margin: 10px 0; @@ -135,7 +135,7 @@ div.sphinxsidebar ul { padding: 0; color: #000; } - + div.sphinxsidebar input { border: 1px solid #ccc; font-family: {{ font_family }}; @@ -145,19 +145,19 @@ div.sphinxsidebar input { div.sphinxsidebar form.search input[name="q"] { width: 130px; } - + /* -- body styles ----------------------------------------------------------- */ - + a { color: #aa0000; text-decoration: underline; } - + a:hover { color: #dd0000; text-decoration: underline; } - + div.body h1, div.body h2, div.body h3, @@ -170,25 +170,25 @@ div.body h6 { padding: 0; color: black; } - + div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; } div.body h2 { font-size: 180%; } div.body h3 { font-size: 150%; } div.body h4 { font-size: 130%; } div.body h5 { font-size: 100%; } div.body h6 { font-size: 100%; } - + a.headerlink { color: #ddd; padding: 0 4px; text-decoration: none; } - + a.headerlink:hover { color: #444; background: #eaeaea; } - + div.body p, div.body dd, div.body li { line-height: 1.4em; } @@ -235,20 +235,20 @@ div.note { background-color: #eee; border: 1px solid #ccc; } - + div.seealso { background-color: #ffc; border: 1px solid #ff6; } - + div.topic { background-color: #eee; } - + p.admonition-title { display: inline; } - + p.admonition-title:after { content: ":"; } @@ -342,7 +342,7 @@ ul, ol { margin: 10px 0 10px 30px; padding: 0; } - + pre { background: #eee; padding: 7px 30px; @@ -359,7 +359,7 @@ dl dl pre { margin-left: -90px; padding-left: 90px; } - + tt { background-color: #E8EFF0; color: #222; diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/theme.conf b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/theme.conf similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/theme.conf rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/theme.conf diff --git a/deps/v8_inspector/deps/jinja2/docs/api.rst b/deps/v8_inspector/third_party/jinja2/docs/api.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/api.rst rename to deps/v8_inspector/third_party/jinja2/docs/api.rst index 04ba157fbba31c..088c8673208087 100644 --- a/deps/v8_inspector/deps/jinja2/docs/api.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/api.rst @@ -197,7 +197,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions For a more complex example you can provide a hint. For example the :func:`first` filter creates an undefined object that way:: - return environment.undefined('no first item, sequence was empty') + return environment.undefined('no first item, sequence was empty') If it the `name` or `obj` is known (for example because an attribute was accessed) it should be passed to the undefined object, even if @@ -714,7 +714,7 @@ Here a simple test that checks if a variable is a prime number:: if n % i == 0: return False return True - + You can register it on the template environment by updating the :attr:`~Environment.tests` dict on the environment:: diff --git a/deps/v8_inspector/deps/jinja2/docs/cache_extension.py b/deps/v8_inspector/third_party/jinja2/docs/cache_extension.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/cache_extension.py rename to deps/v8_inspector/third_party/jinja2/docs/cache_extension.py diff --git a/deps/v8_inspector/deps/jinja2/docs/changelog.rst b/deps/v8_inspector/third_party/jinja2/docs/changelog.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/changelog.rst rename to deps/v8_inspector/third_party/jinja2/docs/changelog.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/conf.py b/deps/v8_inspector/third_party/jinja2/docs/conf.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/conf.py rename to deps/v8_inspector/third_party/jinja2/docs/conf.py diff --git a/deps/v8_inspector/deps/jinja2/docs/contents.rst.inc b/deps/v8_inspector/third_party/jinja2/docs/contents.rst.inc similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/contents.rst.inc rename to deps/v8_inspector/third_party/jinja2/docs/contents.rst.inc diff --git a/deps/v8_inspector/deps/jinja2/docs/extensions.rst b/deps/v8_inspector/third_party/jinja2/docs/extensions.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/extensions.rst rename to deps/v8_inspector/third_party/jinja2/docs/extensions.rst index 955708ba4e67d2..0825fd4f9b7343 100644 --- a/deps/v8_inspector/deps/jinja2/docs/extensions.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/extensions.rst @@ -27,8 +27,8 @@ i18n Extension **Import name:** `jinja2.ext.i18n` -The i18n extension can be used in combination with `gettext`_ or `babel`_. If -the i18n extension is enabled Jinja2 provides a `trans` statement that marks +The i18n extension can be used in combination with `gettext`_ or `babel`_. If +the i18n extension is enabled Jinja2 provides a `trans` statement that marks the wrapped string as translatable and calls `gettext`. After enabling, dummy `_` function that forwards calls to `gettext` is added diff --git a/deps/v8_inspector/deps/jinja2/docs/faq.rst b/deps/v8_inspector/third_party/jinja2/docs/faq.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/faq.rst rename to deps/v8_inspector/third_party/jinja2/docs/faq.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/index.rst b/deps/v8_inspector/third_party/jinja2/docs/index.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/index.rst rename to deps/v8_inspector/third_party/jinja2/docs/index.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/integration.rst b/deps/v8_inspector/third_party/jinja2/docs/integration.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/integration.rst rename to deps/v8_inspector/third_party/jinja2/docs/integration.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/intro.rst b/deps/v8_inspector/third_party/jinja2/docs/intro.rst similarity index 98% rename from deps/v8_inspector/deps/jinja2/docs/intro.rst rename to deps/v8_inspector/third_party/jinja2/docs/intro.rst index b6da5ea5f12ad1..99c3582728f773 100644 --- a/deps/v8_inspector/deps/jinja2/docs/intro.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/intro.rst @@ -64,7 +64,7 @@ which will install the package via `distribute` in development mode. This also has the advantage that the C extensions are compiled. .. _download page: http://pypi.python.org/pypi/Jinja2 -.. _distribute: http://pypi.python.org/pypi/distribute +.. _distribute: http://pypi.python.org/pypi/distribute .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pypi.python.org/pypi/pip diff --git a/deps/v8_inspector/deps/jinja2/docs/jinjaext.py b/deps/v8_inspector/third_party/jinja2/docs/jinjaext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/jinjaext.py rename to deps/v8_inspector/third_party/jinja2/docs/jinjaext.py diff --git a/deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty b/deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty similarity index 98% rename from deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty rename to deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty index e93c8d1c6974e9..da811ce376bd12 100644 --- a/deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty +++ b/deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty @@ -22,7 +22,7 @@ %\sphinxlogo% {\center \vspace*{3cm} - \includegraphics{logo.pdf} + \includegraphics{logo.pdf} \vspace{3cm} \par {\rm\Huge \@title \par}% diff --git a/deps/v8_inspector/deps/jinja2/docs/latexindex.rst b/deps/v8_inspector/third_party/jinja2/docs/latexindex.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/latexindex.rst rename to deps/v8_inspector/third_party/jinja2/docs/latexindex.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/logo.pdf b/deps/v8_inspector/third_party/jinja2/docs/logo.pdf similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/logo.pdf rename to deps/v8_inspector/third_party/jinja2/docs/logo.pdf diff --git a/deps/v8_inspector/deps/jinja2/docs/sandbox.rst b/deps/v8_inspector/third_party/jinja2/docs/sandbox.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/sandbox.rst rename to deps/v8_inspector/third_party/jinja2/docs/sandbox.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/switching.rst b/deps/v8_inspector/third_party/jinja2/docs/switching.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/switching.rst rename to deps/v8_inspector/third_party/jinja2/docs/switching.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/templates.rst b/deps/v8_inspector/third_party/jinja2/docs/templates.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/templates.rst rename to deps/v8_inspector/third_party/jinja2/docs/templates.rst index 3c169247219908..d9102ecc1b636b 100644 --- a/deps/v8_inspector/deps/jinja2/docs/templates.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/templates.rst @@ -197,14 +197,14 @@ without the `trim_blocks` and `lstrip_blocks` options, this template:: gets rendered with blank lines inside the div::
- + yay - +
But with both `trim_blocks` and `lstrip_blocks` enabled, the template block lines are removed and other whitespace is preserved:: - +
yay
@@ -522,12 +522,12 @@ Working with Automatic Escaping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When automatic escaping is enabled, everything is escaped by default except -for values explicitly marked as safe. Variables and expressions +for values explicitly marked as safe. Variables and expressions can be marked as safe either in: a. the context dictionary by the application with `MarkupSafe.Markup`, or b. the template, with the `|safe` filter - + The main problem with this approach is that Python itself doesn't have the concept of tainted values; so whether a value is safe or unsafe can get lost. diff --git a/deps/v8_inspector/deps/jinja2/docs/tricks.rst b/deps/v8_inspector/third_party/jinja2/docs/tricks.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/tricks.rst rename to deps/v8_inspector/third_party/jinja2/docs/tricks.rst diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/cycle.py b/deps/v8_inspector/third_party/jinja2/examples/basic/cycle.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/cycle.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/cycle.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/debugger.py b/deps/v8_inspector/third_party/jinja2/examples/basic/debugger.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/debugger.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/debugger.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/inheritance.py b/deps/v8_inspector/third_party/jinja2/examples/basic/inheritance.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/inheritance.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/inheritance.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/templates/broken.html b/deps/v8_inspector/third_party/jinja2/examples/basic/templates/broken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/templates/broken.html rename to deps/v8_inspector/third_party/jinja2/examples/basic/templates/broken.html diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/templates/subbroken.html b/deps/v8_inspector/third_party/jinja2/examples/basic/templates/subbroken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/templates/subbroken.html rename to deps/v8_inspector/third_party/jinja2/examples/basic/templates/subbroken.html diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test_filter_and_linestatements.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test_filter_and_linestatements.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test_filter_and_linestatements.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test_filter_and_linestatements.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test_loop_filter.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test_loop_filter.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test_loop_filter.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test_loop_filter.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/translate.py b/deps/v8_inspector/third_party/jinja2/examples/basic/translate.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/translate.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/translate.py diff --git a/deps/v8_inspector/deps/jinja2/examples/bench.py b/deps/v8_inspector/third_party/jinja2/examples/bench.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/bench.py rename to deps/v8_inspector/third_party/jinja2/examples/bench.py diff --git a/deps/v8_inspector/deps/jinja2/examples/profile.py b/deps/v8_inspector/third_party/jinja2/examples/profile.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/profile.py rename to deps/v8_inspector/third_party/jinja2/examples/profile.py diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_form.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_form.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_form.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_form.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_input_field.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_input_field.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_input_field.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_input_field.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_textarea.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_textarea.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_textarea.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_textarea.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/djangoext.py b/deps/v8_inspector/third_party/jinja2/examples/rwbench/djangoext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/djangoext.py rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/djangoext.py diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/rwbench.py b/deps/v8_inspector/third_party/jinja2/examples/rwbench/rwbench.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/rwbench.py rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/rwbench.py diff --git a/deps/v8_inspector/deps/jinja2/ext/Vim/jinja.vim b/deps/v8_inspector/third_party/jinja2/ext/Vim/jinja.vim similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/Vim/jinja.vim rename to deps/v8_inspector/third_party/jinja2/ext/Vim/jinja.vim diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py similarity index 99% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py index 824d6a1c3679b5..ad9627ffbc3791 100644 --- a/deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py +++ b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py @@ -33,13 +33,13 @@ def write_my_node(writer, node): writer = Writer() writer.node_handlers[MyNode] = write_my_node convert_templates('/path/to/output/folder', writer=writer) - + Here is an example hos to automatically translate your django variables to jinja2:: - + import re # List of tuple (Match pattern, Replace pattern, Exclusion pattern) - + var_re = ((re.compile(r"(u|user)\.is_authenticated"), r"\1.is_authenticated()", None), (re.compile(r"\.non_field_errors"), r".non_field_errors()", None), (re.compile(r"\.label_tag"), r".label_tag()", None), @@ -47,7 +47,7 @@ def write_my_node(writer, node): (re.compile(r"\.as_table"), r".as_table()", None), (re.compile(r"\.as_widget"), r".as_widget()", None), (re.compile(r"\.as_hidden"), r".as_hidden()", None), - + (re.compile(r"\.get_([0-9_\w]+)_url"), r".get_\1_url()", None), (re.compile(r"\.url"), r".url()", re.compile(r"(form|calendar).url")), (re.compile(r"\.get_([0-9_\w]+)_display"), r".get_\1_display()", None), @@ -55,14 +55,14 @@ def write_my_node(writer, node): (re.compile(r"loop\.revcounter"), r"loop.revindex", None), (re.compile(r"request\.GET\.([0-9_\w]+)"), r"request.GET.get('\1', '')", None), (re.compile(r"request\.get_host"), r"request.get_host()", None), - + (re.compile(r"\.all(?!_)"), r".all()", None), (re.compile(r"\.all\.0"), r".all()[0]", None), (re.compile(r"\.([0-9])($|\s+)"), r"[\1]\2", None), (re.compile(r"\.items"), r".items()", None), ) writer = Writer(var_re=var_re) - + For details about the writing process have a look at the module code. :copyright: (c) 2009 by the Jinja Team. @@ -314,7 +314,7 @@ def translate_variable_name(self, var): """Performs variable name translation.""" if self.in_loop and var == 'forloop' or var.startswith('forloop.'): var = var[3:] - + for reg, rep, unless in self.var_re: no_unless = unless and unless.search(var) or True if reg.search(var) and no_unless: @@ -425,7 +425,7 @@ def if_condition(writer, node): join_with = 'and' if node.link_type == core_tags.IfNode.LinkTypes.or_: join_with = 'or' - + for idx, (ifnot, expr) in enumerate(node.bool_exprs): if idx: writer.write(' %s ' % join_with) @@ -734,22 +734,22 @@ def simple_tag(writer, node): writer._filters_warned.add(name) writer.warn('Filter %s probably doesn\'t exist in Jinja' % name) - + if not node.vars_to_resolve: # No argument, pass the request writer.start_variable() writer.write('request|') writer.write(name) writer.end_variable() - return - + return + first_var = node.vars_to_resolve[0] args = node.vars_to_resolve[1:] writer.start_variable() - + # Copied from Writer.filters() writer.node(first_var) - + writer.write('|') writer.write(name) if args: @@ -762,7 +762,7 @@ def simple_tag(writer, node): else: writer.literal(var.literal) writer.write(')') - writer.end_variable() + writer.end_variable() # get rid of node now, it shouldn't be used normally del node diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/example.py b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/example.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/example.py rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/example.py diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/index.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/index.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/index.html diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/layout.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/layout.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/layout.html diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/subtemplate.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/subtemplate.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/subtemplate.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/subtemplate.html diff --git a/deps/v8_inspector/deps/jinja2/ext/djangojinja2.py b/deps/v8_inspector/third_party/jinja2/ext/djangojinja2.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/djangojinja2.py rename to deps/v8_inspector/third_party/jinja2/ext/djangojinja2.py diff --git a/deps/v8_inspector/deps/jinja2/ext/inlinegettext.py b/deps/v8_inspector/third_party/jinja2/ext/inlinegettext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/inlinegettext.py rename to deps/v8_inspector/third_party/jinja2/ext/inlinegettext.py diff --git a/deps/v8_inspector/deps/jinja2/ext/jinja.el b/deps/v8_inspector/third_party/jinja2/ext/jinja.el similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/jinja.el rename to deps/v8_inspector/third_party/jinja2/ext/jinja.el diff --git a/deps/v8_inspector/deps/jinja2/jinja2/__init__.py b/deps/v8_inspector/third_party/jinja2/jinja2/__init__.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/__init__.py rename to deps/v8_inspector/third_party/jinja2/jinja2/__init__.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/_compat.py b/deps/v8_inspector/third_party/jinja2/jinja2/_compat.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/_compat.py rename to deps/v8_inspector/third_party/jinja2/jinja2/_compat.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/_stringdefs.py b/deps/v8_inspector/third_party/jinja2/jinja2/_stringdefs.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/_stringdefs.py rename to deps/v8_inspector/third_party/jinja2/jinja2/_stringdefs.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/bccache.py b/deps/v8_inspector/third_party/jinja2/jinja2/bccache.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/bccache.py rename to deps/v8_inspector/third_party/jinja2/jinja2/bccache.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/compiler.py b/deps/v8_inspector/third_party/jinja2/jinja2/compiler.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/compiler.py rename to deps/v8_inspector/third_party/jinja2/jinja2/compiler.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/constants.py b/deps/v8_inspector/third_party/jinja2/jinja2/constants.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/constants.py rename to deps/v8_inspector/third_party/jinja2/jinja2/constants.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/debug.py b/deps/v8_inspector/third_party/jinja2/jinja2/debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/debug.py rename to deps/v8_inspector/third_party/jinja2/jinja2/debug.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/defaults.py b/deps/v8_inspector/third_party/jinja2/jinja2/defaults.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/defaults.py rename to deps/v8_inspector/third_party/jinja2/jinja2/defaults.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/environment.py b/deps/v8_inspector/third_party/jinja2/jinja2/environment.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/environment.py rename to deps/v8_inspector/third_party/jinja2/jinja2/environment.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/exceptions.py b/deps/v8_inspector/third_party/jinja2/jinja2/exceptions.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/exceptions.py rename to deps/v8_inspector/third_party/jinja2/jinja2/exceptions.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/ext.py b/deps/v8_inspector/third_party/jinja2/jinja2/ext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/ext.py rename to deps/v8_inspector/third_party/jinja2/jinja2/ext.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/filters.py b/deps/v8_inspector/third_party/jinja2/jinja2/filters.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/filters.py rename to deps/v8_inspector/third_party/jinja2/jinja2/filters.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/lexer.py b/deps/v8_inspector/third_party/jinja2/jinja2/lexer.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/lexer.py rename to deps/v8_inspector/third_party/jinja2/jinja2/lexer.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/loaders.py b/deps/v8_inspector/third_party/jinja2/jinja2/loaders.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/loaders.py rename to deps/v8_inspector/third_party/jinja2/jinja2/loaders.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/meta.py b/deps/v8_inspector/third_party/jinja2/jinja2/meta.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/meta.py rename to deps/v8_inspector/third_party/jinja2/jinja2/meta.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/nodes.py b/deps/v8_inspector/third_party/jinja2/jinja2/nodes.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/nodes.py rename to deps/v8_inspector/third_party/jinja2/jinja2/nodes.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/optimizer.py b/deps/v8_inspector/third_party/jinja2/jinja2/optimizer.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/optimizer.py rename to deps/v8_inspector/third_party/jinja2/jinja2/optimizer.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/parser.py b/deps/v8_inspector/third_party/jinja2/jinja2/parser.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/parser.py rename to deps/v8_inspector/third_party/jinja2/jinja2/parser.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/runtime.py b/deps/v8_inspector/third_party/jinja2/jinja2/runtime.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/runtime.py rename to deps/v8_inspector/third_party/jinja2/jinja2/runtime.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/sandbox.py b/deps/v8_inspector/third_party/jinja2/jinja2/sandbox.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/sandbox.py rename to deps/v8_inspector/third_party/jinja2/jinja2/sandbox.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/tests.py b/deps/v8_inspector/third_party/jinja2/jinja2/tests.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/tests.py rename to deps/v8_inspector/third_party/jinja2/jinja2/tests.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/utils.py b/deps/v8_inspector/third_party/jinja2/jinja2/utils.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/utils.py rename to deps/v8_inspector/third_party/jinja2/jinja2/utils.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/visitor.py b/deps/v8_inspector/third_party/jinja2/jinja2/visitor.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/visitor.py rename to deps/v8_inspector/third_party/jinja2/jinja2/visitor.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/jinja2-debug.py b/deps/v8_inspector/third_party/jinja2/scripts/jinja2-debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/scripts/jinja2-debug.py rename to deps/v8_inspector/third_party/jinja2/scripts/jinja2-debug.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/make-release.py b/deps/v8_inspector/third_party/jinja2/scripts/make-release.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/scripts/make-release.py rename to deps/v8_inspector/third_party/jinja2/scripts/make-release.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/pylintrc b/deps/v8_inspector/third_party/jinja2/scripts/pylintrc similarity index 99% rename from deps/v8_inspector/deps/jinja2/scripts/pylintrc rename to deps/v8_inspector/third_party/jinja2/scripts/pylintrc index 6ebf385bcee24e..4f85b49066fe0b 100644 --- a/deps/v8_inspector/deps/jinja2/scripts/pylintrc +++ b/deps/v8_inspector/third_party/jinja2/scripts/pylintrc @@ -1,11 +1,11 @@ # lint Python modules using external checkers. -# +# # This is the main checker controling the other ones and the reports # generation. It is itself both a raw checker and an astng checker in order # to: # * handle message activation / deactivation at the module level # * handle some basic but necessary stats'data (number of classes, methods...) -# +# [MASTER] # Specify a configuration file. @@ -92,7 +92,7 @@ comment=no # * undefined variables # * redefinition of variable from builtins or from an outer scope # * use of variable before assigment -# +# [VARIABLES] # Tells wether we should check for unused import in __init__ files. @@ -107,7 +107,7 @@ additional-builtins= # try to find bugs in the code using type inference -# +# [TYPECHECK] # Tells wether missing members accessed in mixin class should be ignored. A @@ -132,7 +132,7 @@ acquired-members=REQUEST,acl_users,aq_parent # * dangerous default values as arguments # * redefinition of function / method / class # * uses of the global statement -# +# [BASIC] # Required attributes for module, separated by a comma @@ -183,7 +183,7 @@ bad-functions=apply,input # checks for sign of poor/misdesign: # * number of methods, attributes, local variables... # * size, complexity of functions, methods -# +# [DESIGN] # Maximum number of arguments for function / method @@ -219,7 +219,7 @@ max-public-methods=20 # * relative / wildcard imports # * cyclic imports # * uses of deprecated modules -# +# [IMPORTS] # Deprecated modules which should not be used, separated by a comma @@ -245,7 +245,7 @@ int-import-graph= # * attributes not defined in the __init__ method # * supported interfaces implementation # * unreachable code -# +# [CLASSES] # List of interface methods to ignore, separated by a comma. This is used for @@ -259,7 +259,7 @@ defining-attr-methods=__init__,__new__,setUp # checks for similarities and duplicated code. This computation may be # memory / CPU intensive, so you should disable it if you experiments some # problems. -# +# [SIMILARITIES] # Minimum lines number of a similarity. @@ -275,7 +275,7 @@ ignore-docstrings=yes # checks for: # * warning notes in the code like FIXME, XXX # * PEP 263: source code with non ascii character but no encoding declaration -# +# [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. @@ -287,7 +287,7 @@ notes=FIXME,XXX,TODO # * strict indentation # * line length # * use of <> instead of != -# +# [FORMAT] # Maximum number of characters on a single line. diff --git a/deps/v8_inspector/deps/jinja2/setup.cfg b/deps/v8_inspector/third_party/jinja2/setup.cfg similarity index 100% rename from deps/v8_inspector/deps/jinja2/setup.cfg rename to deps/v8_inspector/third_party/jinja2/setup.cfg diff --git a/deps/v8_inspector/deps/jinja2/setup.py b/deps/v8_inspector/third_party/jinja2/setup.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/setup.py rename to deps/v8_inspector/third_party/jinja2/setup.py diff --git a/deps/v8_inspector/deps/jinja2/tests/conftest.py b/deps/v8_inspector/third_party/jinja2/tests/conftest.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/conftest.py rename to deps/v8_inspector/third_party/jinja2/tests/conftest.py diff --git a/deps/v8_inspector/deps/jinja2/tests/res/__init__.py b/deps/v8_inspector/third_party/jinja2/tests/res/__init__.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/__init__.py rename to deps/v8_inspector/third_party/jinja2/tests/res/__init__.py diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/broken.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/broken.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/foo/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/foo/test.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/syntaxerror.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/syntaxerror.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/test.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html diff --git a/deps/v8_inspector/deps/jinja2/tests/test_api.py b/deps/v8_inspector/third_party/jinja2/tests/test_api.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_api.py rename to deps/v8_inspector/third_party/jinja2/tests/test_api.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_bytecode_cache.py b/deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_bytecode_cache.py rename to deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_core_tags.py b/deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_core_tags.py rename to deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_debug.py b/deps/v8_inspector/third_party/jinja2/tests/test_debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_debug.py rename to deps/v8_inspector/third_party/jinja2/tests/test_debug.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_ext.py b/deps/v8_inspector/third_party/jinja2/tests/test_ext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_ext.py rename to deps/v8_inspector/third_party/jinja2/tests/test_ext.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_filters.py b/deps/v8_inspector/third_party/jinja2/tests/test_filters.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_filters.py rename to deps/v8_inspector/third_party/jinja2/tests/test_filters.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_imports.py b/deps/v8_inspector/third_party/jinja2/tests/test_imports.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_imports.py rename to deps/v8_inspector/third_party/jinja2/tests/test_imports.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_inheritance.py b/deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_inheritance.py rename to deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_lexnparse.py b/deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_lexnparse.py rename to deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_loader.py b/deps/v8_inspector/third_party/jinja2/tests/test_loader.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_loader.py rename to deps/v8_inspector/third_party/jinja2/tests/test_loader.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_regression.py b/deps/v8_inspector/third_party/jinja2/tests/test_regression.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_regression.py rename to deps/v8_inspector/third_party/jinja2/tests/test_regression.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_security.py b/deps/v8_inspector/third_party/jinja2/tests/test_security.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_security.py rename to deps/v8_inspector/third_party/jinja2/tests/test_security.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_tests.py b/deps/v8_inspector/third_party/jinja2/tests/test_tests.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_tests.py rename to deps/v8_inspector/third_party/jinja2/tests/test_tests.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_utils.py b/deps/v8_inspector/third_party/jinja2/tests/test_utils.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_utils.py rename to deps/v8_inspector/third_party/jinja2/tests/test_utils.py diff --git a/deps/v8_inspector/deps/jinja2/tox.ini b/deps/v8_inspector/third_party/jinja2/tox.ini similarity index 100% rename from deps/v8_inspector/deps/jinja2/tox.ini rename to deps/v8_inspector/third_party/jinja2/tox.ini diff --git a/deps/v8_inspector/deps/markupsafe/.gitignore b/deps/v8_inspector/third_party/markupsafe/.gitignore similarity index 100% rename from deps/v8_inspector/deps/markupsafe/.gitignore rename to deps/v8_inspector/third_party/markupsafe/.gitignore diff --git a/deps/v8_inspector/deps/markupsafe/.travis.yml b/deps/v8_inspector/third_party/markupsafe/.travis.yml similarity index 100% rename from deps/v8_inspector/deps/markupsafe/.travis.yml rename to deps/v8_inspector/third_party/markupsafe/.travis.yml diff --git a/deps/v8_inspector/deps/markupsafe/AUTHORS b/deps/v8_inspector/third_party/markupsafe/AUTHORS similarity index 100% rename from deps/v8_inspector/deps/markupsafe/AUTHORS rename to deps/v8_inspector/third_party/markupsafe/AUTHORS diff --git a/deps/v8_inspector/deps/markupsafe/CHANGES b/deps/v8_inspector/third_party/markupsafe/CHANGES similarity index 100% rename from deps/v8_inspector/deps/markupsafe/CHANGES rename to deps/v8_inspector/third_party/markupsafe/CHANGES diff --git a/deps/v8_inspector/deps/markupsafe/LICENSE b/deps/v8_inspector/third_party/markupsafe/LICENSE similarity index 100% rename from deps/v8_inspector/deps/markupsafe/LICENSE rename to deps/v8_inspector/third_party/markupsafe/LICENSE diff --git a/deps/v8_inspector/deps/markupsafe/MANIFEST.in b/deps/v8_inspector/third_party/markupsafe/MANIFEST.in similarity index 100% rename from deps/v8_inspector/deps/markupsafe/MANIFEST.in rename to deps/v8_inspector/third_party/markupsafe/MANIFEST.in diff --git a/deps/v8_inspector/deps/markupsafe/Makefile b/deps/v8_inspector/third_party/markupsafe/Makefile similarity index 100% rename from deps/v8_inspector/deps/markupsafe/Makefile rename to deps/v8_inspector/third_party/markupsafe/Makefile diff --git a/deps/v8_inspector/deps/markupsafe/README.rst b/deps/v8_inspector/third_party/markupsafe/README.rst similarity index 100% rename from deps/v8_inspector/deps/markupsafe/README.rst rename to deps/v8_inspector/third_party/markupsafe/README.rst diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_basic.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_basic.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_basic.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_basic.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_largestring.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_largestring.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_largestring.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_largestring.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_long_empty_string.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_long_empty_string.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_long_empty_string.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_long_empty_string.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_long_suffix.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_long_suffix.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_long_suffix.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_long_suffix.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_short_empty_string.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_short_empty_string.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_short_empty_string.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_short_empty_string.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/runbench.py b/deps/v8_inspector/third_party/markupsafe/bench/runbench.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/runbench.py rename to deps/v8_inspector/third_party/markupsafe/bench/runbench.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/__init__.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/__init__.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/__init__.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/__init__.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_compat.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_compat.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_compat.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_compat.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_constants.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_constants.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_constants.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_constants.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_native.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_native.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_native.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_native.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_speedups.c b/deps/v8_inspector/third_party/markupsafe/markupsafe/_speedups.c similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_speedups.c rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_speedups.c diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/tests.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/tests.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/tests.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/tests.py diff --git a/deps/v8_inspector/deps/markupsafe/setup.py b/deps/v8_inspector/third_party/markupsafe/setup.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/setup.py rename to deps/v8_inspector/third_party/markupsafe/setup.py diff --git a/deps/v8_inspector/deps/markupsafe/tox.ini b/deps/v8_inspector/third_party/markupsafe/tox.ini similarity index 100% rename from deps/v8_inspector/deps/markupsafe/tox.ini rename to deps/v8_inspector/third_party/markupsafe/tox.ini diff --git a/deps/v8_inspector/third_party/v8_inspector/LICENSE b/deps/v8_inspector/third_party/v8_inspector/LICENSE new file mode 100644 index 00000000000000..a32e00ce6be362 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/v8_inspector/platform/inspector_protocol/Allocator.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Allocator.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Allocator.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Allocator.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Array.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h similarity index 87% rename from deps/v8_inspector/platform/inspector_protocol/Array.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h index b75f51742977c7..d92af3a5ed7d05 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Array.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h @@ -5,13 +5,14 @@ #ifndef Array_h #define Array_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/ErrorSupport.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/ValueConversions.h" #include "platform/inspector_protocol/Values.h" +#include + namespace blink { namespace protocol { @@ -33,9 +34,9 @@ class ArrayBase { errors->push(); std::unique_ptr> result(new Array()); for (size_t i = 0; i < array->size(); ++i) { - errors->setName(String16::number(i)); + errors->setName(String16::fromInteger(i)); T item = FromValue::parse(array->at(i), errors); - result->m_vector.append(item); + result->m_vector.push_back(item); } errors->pop(); if (errors->hasErrors()) @@ -45,7 +46,7 @@ class ArrayBase { void addItem(const T& value) { - m_vector.append(value); + m_vector.push_back(value); } size_t length() @@ -67,7 +68,7 @@ class ArrayBase { } private: - protocol::Vector m_vector; + std::vector m_vector; }; template<> class Array : public ArrayBase {}; @@ -94,9 +95,9 @@ class Array { std::unique_ptr> result(new Array()); errors->push(); for (size_t i = 0; i < array->size(); ++i) { - errors->setName(String16::number(i)); + errors->setName(String16::fromInteger(i)); std::unique_ptr item = FromValue::parse(array->at(i), errors); - result->m_vector.append(std::move(item)); + result->m_vector.push_back(std::move(item)); } errors->pop(); if (errors->hasErrors()) @@ -106,7 +107,7 @@ class Array { void addItem(std::unique_ptr value) { - m_vector.append(std::move(value)); + m_vector.push_back(std::move(value)); } size_t length() @@ -116,7 +117,7 @@ class Array { T* get(size_t index) { - return m_vector[index]; + return m_vector[index].get(); } std::unique_ptr serialize() @@ -128,7 +129,7 @@ class Array { } private: - protocol::Vector> m_vector; + std::vector> m_vector; }; } // namespace platform diff --git a/deps/v8_inspector/platform/inspector_protocol/BackendCallback.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/BackendCallback.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/BackendCallback.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/BackendCallback.h diff --git a/deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py index 4c11161a3cad63..c785c79b528fd1 100644 --- a/deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py @@ -25,13 +25,15 @@ # Insert at 1 so at front to override system libraries, and # after path[0] == invoking script dir third_party_dir = os.path.normpath(os.path.join( - module_path, os.pardir, os.pardir, os.pardir, os.pardir)) + module_path, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, + "third_party")) if os.path.isdir(third_party_dir): sys.path.insert(1, third_party_dir) # In Node, it is in deps folder deps_dir = os.path.normpath(os.path.join( - module_path, os.pardir, os.pardir, "deps")) + module_path, os.pardir, os.pardir, os.pardir, os.pardir, "third_party")) + if os.path.isdir(deps_dir): sys.path.insert(1, os.path.join(deps_dir, "jinja2")) sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) @@ -215,8 +217,8 @@ def create_primitive_type_definition(type): "boolean": "false" } jsontypes = { - "number": "TypeNumber", - "integer": "TypeNumber", + "number": "TypeDouble", + "integer": "TypeInteger", "boolean": "TypeBoolean", } return { diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h new file mode 100644 index 00000000000000..a89bef413811e3 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h @@ -0,0 +1,46 @@ +// Copyright 2016 The Chromium 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 Collections_h +#define Collections_h + +#include + +#if defined(__APPLE__) && !defined(_LIBCPP_VERSION) +#include +#include + +namespace blink { +namespace protocol { + +template using HashMap = std::map; +template using HashSet = std::set; + +} // namespace protocol +} // namespace blink + +#else +#include +#include + +namespace blink { +namespace protocol { + +template using HashMap = std::unordered_map; +template using HashSet = std::unordered_set; + +} // namespace protocol +} // namespace blink + +#endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) + +// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array. +template char (&ArrayLengthHelperFunction(T (&)[Size]))[Size]; +// GCC needs some help to deduce a 0 length array. +#if defined(__GNUC__) +template char (&ArrayLengthHelperFunction(T (&)[0]))[0]; +#endif +#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) + +#endif // !defined(Collections_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp similarity index 94% rename from deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp index 69798726515c11..49422eba09a9ca 100644 --- a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp @@ -18,7 +18,7 @@ DispatcherBase::WeakPtr::WeakPtr(DispatcherBase* dispatcher) : m_dispatcher(disp DispatcherBase::WeakPtr::~WeakPtr() { if (m_dispatcher) - m_dispatcher->m_weakPtrs.remove(this); + m_dispatcher->m_weakPtrs.erase(this); } DispatcherBase::Callback::Callback(std::unique_ptr backendImpl, int callId) @@ -73,7 +73,7 @@ void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError } std::unique_ptr responseMessage = DictionaryValue::create(); - responseMessage->setNumber("id", callId); + responseMessage->setInteger("id", callId); responseMessage->setObject("result", std::move(result)); if (m_frontendChannel) m_frontendChannel->sendProtocolResponse(callId, responseMessage->toJSONString()); @@ -92,14 +92,14 @@ void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError static void reportProtocolError(FrontendChannel* frontendChannel, int callId, DispatcherBase::CommonErrorCode code, const String16& errorMessage, ErrorSupport* errors) { std::unique_ptr error = DictionaryValue::create(); - error->setNumber("code", code); + error->setInteger("code", code); error->setString("message", errorMessage); DCHECK(error); if (errors && errors->hasErrors()) error->setString("data", errors->errors()); std::unique_ptr message = DictionaryValue::create(); message->setObject("error", std::move(error)); - message->setNumber("id", callId); + message->setInteger("id", callId); frontendChannel->sendProtocolResponse(callId, message->toJSONString()); } @@ -113,14 +113,14 @@ void DispatcherBase::clearFrontend() { m_frontendChannel = nullptr; for (auto& weak : m_weakPtrs) - weak.first->dispose(); + weak->dispose(); m_weakPtrs.clear(); } std::unique_ptr DispatcherBase::weakPtr() { std::unique_ptr weak(new DispatcherBase::WeakPtr(this)); - m_weakPtrs.add(weak.get()); + m_weakPtrs.insert(weak.get()); return weak; } @@ -129,7 +129,7 @@ UberDispatcher::UberDispatcher(FrontendChannel* frontendChannel) void UberDispatcher::registerBackend(const String16& name, std::unique_ptr dispatcher) { - m_dispatchers.set(name, std::move(dispatcher)); + m_dispatchers[name] = std::move(dispatcher); } void UberDispatcher::dispatch(const String16& message) @@ -143,7 +143,7 @@ void UberDispatcher::dispatch(const String16& message) int callId = 0; protocol::Value* callIdValue = messageObject->get("id"); - bool success = callIdValue->asNumber(&callId); + bool success = callIdValue->asInteger(&callId); if (!success) return; diff --git a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.h diff --git a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp index dc9e66373ee271..0ad89ade1c47d0 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp @@ -29,12 +29,12 @@ void ErrorSupport::setName(const String16& name) void ErrorSupport::push() { - m_path.append(String16()); + m_path.push_back(String16()); } void ErrorSupport::pop() { - m_path.removeLast(); + m_path.pop_back(); } void ErrorSupport::addError(const String16& error) @@ -42,12 +42,12 @@ void ErrorSupport::addError(const String16& error) String16Builder builder; for (size_t i = 0; i < m_path.size(); ++i) { if (i) - builder.append("."); + builder.append('.'); builder.append(m_path[i]); } builder.append(": "); builder.append(error); - m_errors.append(builder.toString()); + m_errors.push_back(builder.toString()); } bool ErrorSupport::hasErrors() diff --git a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h similarity index 86% rename from deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h index bb7e064934b01f..56ac442435262b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h @@ -5,10 +5,11 @@ #ifndef ErrorSupport_h #define ErrorSupport_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include + namespace blink { namespace protocol { @@ -28,8 +29,8 @@ class PLATFORM_EXPORT ErrorSupport { String16 errors(); private: - protocol::Vector m_path; - protocol::Vector m_errors; + std::vector m_path; + std::vector m_errors; String16* m_errorString; }; diff --git a/deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/FrontendChannel.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/FrontendChannel.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Maybe.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/Maybe.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h index 3fcd081d89f12a..cf372e0bbe2015 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Maybe.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h @@ -18,7 +18,7 @@ class String16; template class Maybe { public: - Maybe() { } + Maybe() : m_value() { } Maybe(std::unique_ptr value) : m_value(std::move(value)) { } void operator=(std::unique_ptr value) { m_value = std::move(value); } T* fromJust() const { DCHECK(m_value); return m_value.get(); } diff --git a/deps/v8_inspector/platform/inspector_protocol/OWNERS b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/OWNERS similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/OWNERS rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/OWNERS diff --git a/deps/v8_inspector/platform/inspector_protocol/Object.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Object.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/Object.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Object.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Parser.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/Parser.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp index 1c267f871a96b2..4193108b279162 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Parser.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp @@ -382,7 +382,11 @@ std::unique_ptr buildValue(const UChar* start, const UChar* end, const UC double value = String16::charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok); if (!ok) return nullptr; - result = FundamentalValue::create(value); + int number = static_cast(value); + if (number == value) + result = FundamentalValue::create(number); + else + result = FundamentalValue::create(value); break; } case StringLiteral: { diff --git a/deps/v8_inspector/platform/inspector_protocol/Parser.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Parser.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.h diff --git a/deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp similarity index 88% rename from deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp index 1dfeb4a4fbb983..1a8f44289f2a7b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp @@ -41,13 +41,13 @@ TEST(ParserTest, Reading) EXPECT_EQ(Value::TypeNull, root->type()); root = parseJSON("40 /* comment */"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(40, intVal); root = parseJSON("/**/ 40 /* multi-line\n comment */ // more comment"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(40, intVal); root = parseJSON("true // comment"); ASSERT_TRUE(root.get()); @@ -63,11 +63,11 @@ TEST(ParserTest, Reading) EXPECT_EQ(2u, list->size()); tmpValue = list->at(0); ASSERT_TRUE(tmpValue); - EXPECT_TRUE(tmpValue->asNumber(&intVal)); + EXPECT_TRUE(tmpValue->asInteger(&intVal)); EXPECT_EQ(1, intVal); tmpValue = list->at(1); ASSERT_TRUE(tmpValue); - EXPECT_TRUE(tmpValue->asNumber(&intVal)); + EXPECT_TRUE(tmpValue->asInteger(&intVal)); EXPECT_EQ(3, intVal); root = parseJSON("[1, /*a*/2, 3]"); ASSERT_TRUE(root.get()); @@ -76,23 +76,23 @@ TEST(ParserTest, Reading) EXPECT_EQ(3u, list->size()); root = parseJSON("/* comment **/42"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(42, intVal); root = parseJSON( "/* comment **/\n" "// */ 43\n" "44"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(44, intVal); // Test number formats root = parseJSON("43"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(43, intVal); // According to RFC4627, oct, hex, and leading zeros are invalid JSON. @@ -107,9 +107,9 @@ TEST(ParserTest, Reading) // clause). root = parseJSON("0"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); intVal = 1; - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(0, intVal); // Numbers that overflow ints should succeed, being internally promoted to @@ -117,58 +117,58 @@ TEST(ParserTest, Reading) root = parseJSON("2147483648"); ASSERT_TRUE(root.get()); double doubleVal; - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(2147483648.0, doubleVal); root = parseJSON("-2147483649"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(-2147483649.0, doubleVal); // Parse a double root = parseJSON("43.1"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(43.1, doubleVal); root = parseJSON("4.3e-1"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(.43, doubleVal); root = parseJSON("2.1e0"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(2.1, doubleVal); root = parseJSON("2.1e+0001"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(21.0, doubleVal); root = parseJSON("0.01"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(0.01, doubleVal); root = parseJSON("1.00"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(1.0, doubleVal); // Fractional parts must have a digit before and after the decimal point. @@ -312,7 +312,7 @@ TEST(ParserTest, Reading) protocol::DictionaryValue* objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); doubleVal = 0.0; - EXPECT_TRUE(objectVal->getNumber("number", &doubleVal)); + EXPECT_TRUE(objectVal->getDouble("number", &doubleVal)); EXPECT_DOUBLE_EQ(9.87654321, doubleVal); protocol::Value* nullVal = objectVal->get("null"); ASSERT_TRUE(nullVal); @@ -363,14 +363,14 @@ TEST(ParserTest, Reading) objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); int integerValue = 0; - EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("a.b", &integerValue)); EXPECT_EQ(3, integerValue); - EXPECT_TRUE(objectVal->getNumber("c", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("c", &integerValue)); EXPECT_EQ(2, integerValue); innerObject = objectVal->getObject("d.e.f"); ASSERT_TRUE(innerObject); EXPECT_EQ(1U, innerObject->size()); - EXPECT_TRUE(innerObject->getNumber("g.h.i.j", &integerValue)); + EXPECT_TRUE(innerObject->getInteger("g.h.i.j", &integerValue)); EXPECT_EQ(1, integerValue); root = parseJSON("{\"a\":{\"b\":2},\"a.b\":1}"); @@ -380,9 +380,9 @@ TEST(ParserTest, Reading) ASSERT_TRUE(objectVal); innerObject = objectVal->getObject("a"); ASSERT_TRUE(innerObject); - EXPECT_TRUE(innerObject->getNumber("b", &integerValue)); + EXPECT_TRUE(innerObject->getInteger("b", &integerValue)); EXPECT_EQ(2, integerValue); - EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("a.b", &integerValue)); EXPECT_EQ(1, integerValue); // Invalid, no closing brace @@ -469,7 +469,7 @@ TEST(ParserTest, Reading) root = parseJSON("10"); ASSERT_TRUE(root.get()); - EXPECT_TRUE(root->asNumber(&integerValue)); + EXPECT_TRUE(root->asInteger(&integerValue)); EXPECT_EQ(10, integerValue); root = parseJSON("\"root\""); diff --git a/deps/v8_inspector/platform/inspector_protocol/Platform.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Platform.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Platform.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Platform.h diff --git a/deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h similarity index 90% rename from deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h index 3e687b994c951e..33ca199b1f4e3b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h @@ -122,6 +122,7 @@ template class unique_ptr { unique_ptr() : m_ptr(nullptr) {} unique_ptr(std::nullptr_t) : m_ptr(nullptr) {} + unique_ptr(const unique_ptr&); unique_ptr(unique_ptr&&); template ::value>::type> unique_ptr(unique_ptr&&); @@ -134,7 +135,10 @@ template class unique_ptr { PtrType get() const { return m_ptr; } void reset(PtrType = nullptr); - PtrType release(); + PtrType release() + { + return this->internalRelease(); + } ValueType& operator*() const { DCHECK(m_ptr); return *m_ptr; } PtrType operator->() const { DCHECK(m_ptr); return m_ptr; } @@ -146,7 +150,7 @@ template class unique_ptr { unique_ptr& operator=(std::nullptr_t) { reset(); return *this; } - + unique_ptr& operator=(const unique_ptr&); unique_ptr& operator=(unique_ptr&&); template unique_ptr& operator=(unique_ptr&&); @@ -157,6 +161,12 @@ template class unique_ptr { explicit unique_ptr(PtrType ptr) : m_ptr(ptr) {} private: + PtrType internalRelease() const + { + PtrType ptr = m_ptr; + m_ptr = nullptr; + return ptr; + } // We should never have two unique_ptrs for the same underlying object // (otherwise we'll get double-destruction), so these equality operators @@ -172,7 +182,7 @@ template class unique_ptr { return false; } - PtrType m_ptr; + mutable PtrType m_ptr; }; @@ -180,16 +190,10 @@ template inline void unique_ptr::reset(PtrType ptr) { PtrType p = m_ptr; m_ptr = ptr; + DCHECK(!p || m_ptr != p); OwnedPtrDeleter::deletePtr(p); } -template inline typename unique_ptr::PtrType unique_ptr::release() -{ - PtrType ptr = m_ptr; - m_ptr = nullptr; - return ptr; -} - template inline typename unique_ptr::ValueType& unique_ptr::operator[](std::ptrdiff_t i) const { static_assert(is_array::value, "elements access is possible for arrays only"); @@ -198,8 +202,13 @@ template inline typename unique_ptr::ValueType& unique_ptr::o return m_ptr[i]; } +template inline unique_ptr::unique_ptr(const unique_ptr& o) + : m_ptr(o.internalRelease()) +{ +} + template inline unique_ptr::unique_ptr(unique_ptr&& o) - : m_ptr(o.release()) + : m_ptr(o.internalRelease()) { } @@ -210,13 +219,15 @@ template inline unique_ptr::unique_ptr(unique_ptr&& static_assert(!is_array::value, "pointers to array must never be converted"); } -template inline unique_ptr& unique_ptr::operator=(unique_ptr&& o) +template inline unique_ptr& unique_ptr::operator=(const unique_ptr& o) { - PtrType ptr = m_ptr; - m_ptr = o.release(); - DCHECK(!ptr || m_ptr != ptr); - OwnedPtrDeleter::deletePtr(ptr); + reset(o.internalRelease()); + return *this; +} +template inline unique_ptr& unique_ptr::operator=(unique_ptr&& o) +{ + reset(o.internalRelease()); return *this; } diff --git a/deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformWTF.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformWTF.h diff --git a/deps/v8_inspector/platform/inspector_protocol/String16.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/String16.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16.h diff --git a/deps/v8_inspector/platform/inspector_protocol/String16STL.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/String16STL.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp index 08c3e448c3b294..4883f4ceda46e1 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16STL.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp @@ -562,20 +562,14 @@ std::string String16::utf8() const char* buffer = bufferVector.data(); const UChar* characters = m_impl.data(); - bool strict = false; - ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), strict); + ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), false); DCHECK(result != targetExhausted); // (length * 3) should be sufficient for any conversion // Only produced from strict conversion. - if (result == sourceIllegal) { - DCHECK(strict); - return std::string(); - } + DCHECK(result != sourceIllegal); // Check for an unconverted high surrogate. if (result == sourceExhausted) { - if (strict) - return std::string(); // This should be one unpaired high surrogate. Treat it the same // was as an unpaired high surrogate would have been handled in // the middle of a string with non-strict conversion - which is diff --git a/deps/v8_inspector/platform/inspector_protocol/String16STL.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/String16STL.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h index e76e9775fb9ebc..703e5b0f025d94 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16STL.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h @@ -42,7 +42,7 @@ class String16 { const UChar* characters16() const { return m_impl.c_str(); } std::string utf8() const; static String16 fromUTF8(const char* stringStart, size_t length); - static String16 number(int i) { return String16(String16::intToString(i).c_str()); } + static String16 fromInteger(int i) { return String16(String16::intToString(i).c_str()); } static String16 fromDouble(double d) { return String16(String16::doubleToString(d).c_str()); } static String16 fromDoubleFixedPrecision(double d, int len) { return String16(String16::doubleToString(d).c_str()); } @@ -136,7 +136,7 @@ class String16 { // presubmit: allow wstring wstring m_impl; mutable bool has_hash = false; - mutable std::size_t hash_code; + mutable std::size_t hash_code = 0; }; static inline bool isSpaceOrNewline(UChar c) @@ -170,7 +170,12 @@ class String16Builder { void appendNumber(int i) { - m_impl = m_impl + String16::number(i).impl(); + m_impl = m_impl + String16::fromInteger(i).impl(); + } + + void appendNumber(double d) + { + m_impl = m_impl + String16::fromDoubleFixedPrecision(d, 6).impl(); } void append(const UChar* c, size_t length) @@ -238,6 +243,20 @@ class String { }; } // namespace WTF +#if !defined(__APPLE__) || defined(_LIBCPP_VERSION) + +namespace std { +template<> struct hash { + std::size_t operator()(const String16& string) const + { + return string.hash(); + } +}; + +} // namespace std + +#endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) + using String = WTF::String; #endif // !defined(String16STL_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/String16WTF.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/String16WTF.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/String16WTF.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/String16WTF.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h index 57a91d82c6f68d..19c56256f0dec4 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16WTF.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h @@ -11,6 +11,7 @@ #include "wtf/text/StringConcatenate.h" #include "wtf/text/StringHash.h" #include "wtf/text/StringToNumber.h" +#include "wtf/text/StringView.h" #include "wtf/text/WTFString.h" namespace blink { @@ -34,13 +35,14 @@ class PLATFORM_EXPORT String16 { String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { } bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); } operator WTF::String() const { return m_impl; } + operator WTF::StringView() const { return StringView(m_impl); } operator WebString() { return m_impl; } const WTF::String& impl() const { return m_impl; } String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); } ~String16() { } - static String16 number(int i) { return String::number(i); } + static String16 fromInteger(int i) { return String::number(i); } static String16 fromDouble(double number) { return Decimal::fromDouble(number).toString(); } static String16 fromDoubleFixedPrecision(double number, int precision) { return String::numberToStringFixedWidth(number, precision); } @@ -75,13 +77,14 @@ class PLATFORM_EXPORT String16 { class String16Builder { public: String16Builder() { } - void append(const String16& str) { m_impl.append(StringView(str)); }; + void append(const String16& str) { m_impl.append(str); }; void append(UChar c) { m_impl.append(c); }; void append(LChar c) { m_impl.append(c); }; void append(char c) { m_impl.append(c); }; void append(const UChar* c, size_t size) { m_impl.append(c, size); }; void append(const char* characters, unsigned length) { m_impl.append(characters, length); } void appendNumber(int number) { m_impl.appendNumber(number); } + void appendNumber(double number) { m_impl.appendNumber(number); } String16 toString() { return m_impl.toString(); } void reserveCapacity(unsigned newCapacity) { m_impl.reserveCapacity(newCapacity); } @@ -138,4 +141,14 @@ struct HashTraits : SimpleClassHashTraits { } // namespace WTF +namespace std { +template<> struct hash { + std::size_t operator()(const String16& string) const + { + return StringHash::hash(string.impl()); + } +}; + +} // namespace std + #endif // !defined(String16WTF_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template index 1aeef458f8d4ba..909fea4e71a7ff 100644 --- a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template @@ -140,7 +140,7 @@ public: {% for command in domain.commands %} {% if "redirect" in command %}{% continue %}{% endif %} {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %} - m_dispatchMap.set("{{domain.domain}}.{{command.name}}", &DispatcherImpl::{{command.name}}); + m_dispatchMap["{{domain.domain}}.{{command.name}}"] = &DispatcherImpl::{{command.name}}; {% endfor %} } ~DispatcherImpl() override { } @@ -169,7 +169,7 @@ void DispatcherImpl::dispatch(int callId, const String16& method, std::unique_pt } protocol::ErrorSupport errors; - ((*this).*(*it->second))(callId, std::move(messageObject), &errors); + (this->*(it->second))(callId, std::move(messageObject), &errors); } {% for command in domain.commands %} diff --git a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template diff --git a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/ValueConversions.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h similarity index 95% rename from deps/v8_inspector/platform/inspector_protocol/ValueConversions.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h index b82f04f588f7f1..dd7b2e78641054 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h @@ -64,7 +64,7 @@ struct FromValue { static int parse(protocol::Value* value, ErrorSupport* errors) { int result = 0; - bool success = value ? value->asNumber(&result) : false; + bool success = value ? value->asInteger(&result) : false; if (!success) errors->addError("integer value expected"); return result; @@ -76,7 +76,7 @@ struct FromValue { static double parse(protocol::Value* value, ErrorSupport* errors) { double result = 0; - bool success = value ? value->asNumber(&result) : false; + bool success = value ? value->asDouble(&result) : false; if (!success) errors->addError("double value expected"); return result; @@ -112,8 +112,10 @@ struct FromValue { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { bool success = !!value; - if (!success) + if (!success) { errors->addError("value expected"); + return nullptr; + } return value->clone(); } }; diff --git a/deps/v8_inspector/platform/inspector_protocol/Values.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp similarity index 72% rename from deps/v8_inspector/platform/inspector_protocol/Values.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp index 9cc1ca51bf484a..7d4ec242ae4c51 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Values.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp @@ -6,6 +6,8 @@ #include "platform/inspector_protocol/Parser.h" #include "platform/inspector_protocol/String16.h" + +#include #include namespace blink { @@ -75,12 +77,12 @@ bool Value::asBoolean(bool*) const return false; } -bool Value::asNumber(double*) const +bool Value::asDouble(double*) const { return false; } -bool Value::asNumber(int*) const +bool Value::asInteger(int*) const { return false; } @@ -117,42 +119,56 @@ bool FundamentalValue::asBoolean(bool* output) const return true; } -bool FundamentalValue::asNumber(double* output) const +bool FundamentalValue::asDouble(double* output) const { - if (type() != TypeNumber) - return false; - *output = m_doubleValue; - return true; + if (type() == TypeDouble) { + *output = m_doubleValue; + return true; + } + if (type() == TypeInteger) { + *output = m_integerValue; + return true; + } + return false; } -bool FundamentalValue::asNumber(int* output) const +bool FundamentalValue::asInteger(int* output) const { - if (type() != TypeNumber) + if (type() != TypeInteger) return false; - *output = static_cast(m_doubleValue); + *output = m_integerValue; return true; } void FundamentalValue::writeJSON(String16Builder* output) const { - DCHECK(type() == TypeBoolean || type() == TypeNumber); + DCHECK(type() == TypeBoolean || type() == TypeInteger || type() == TypeDouble); if (type() == TypeBoolean) { if (m_boolValue) output->append(trueString, 4); else output->append(falseString, 5); - } else if (type() == TypeNumber) { + } else if (type() == TypeDouble) { if (!std::isfinite(m_doubleValue)) { output->append(nullString, 4); return; } output->append(String16::fromDouble(m_doubleValue)); + } else if (type() == TypeInteger) { + output->append(String16::fromInteger(m_integerValue)); } } std::unique_ptr FundamentalValue::clone() const { - return type() == TypeNumber ? FundamentalValue::create(m_doubleValue) : FundamentalValue::create(m_boolValue); + switch (type()) { + case TypeDouble: return FundamentalValue::create(m_doubleValue); + case TypeInteger: return FundamentalValue::create(m_integerValue); + case TypeBoolean: return FundamentalValue::create(m_boolValue); + default: + NOTREACHED(); + } + return nullptr; } bool StringValue::asString(String16* output) const @@ -181,7 +197,12 @@ void DictionaryValue::setBoolean(const String16& name, bool value) setValue(name, FundamentalValue::create(value)); } -void DictionaryValue::setNumber(const String16& name, double value) +void DictionaryValue::setInteger(const String16& name, int value) +{ + setValue(name, FundamentalValue::create(value)); +} + +void DictionaryValue::setDouble(const String16& name, double value) { setValue(name, FundamentalValue::create(value)); } @@ -193,23 +214,17 @@ void DictionaryValue::setString(const String16& name, const String16& value) void DictionaryValue::setValue(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } void DictionaryValue::setObject(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } void DictionaryValue::setArray(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } bool DictionaryValue::getBoolean(const String16& name, bool* output) const @@ -220,6 +235,22 @@ bool DictionaryValue::getBoolean(const String16& name, bool* output) const return value->asBoolean(output); } +bool DictionaryValue::getInteger(const String16& name, int* output) const +{ + Value* value = get(name); + if (!value) + return false; + return value->asInteger(output); +} + +bool DictionaryValue::getDouble(const String16& name, double* output) const +{ + Value* value = get(name); + if (!value) + return false; + return value->asDouble(output); +} + bool DictionaryValue::getString(const String16& name, String16* output) const { protocol::Value* value = get(name); @@ -243,13 +274,13 @@ protocol::Value* DictionaryValue::get(const String16& name) const Dictionary::const_iterator it = m_data.find(name); if (it == m_data.end()) return nullptr; - return it->second; + return it->second.get(); } DictionaryValue::Entry DictionaryValue::at(size_t index) const { - String16 key = m_order[index]; - return std::make_pair(key, m_data.get(key)); + const String16 key = m_order[index]; + return std::make_pair(key, m_data.find(key)->second.get()); } bool DictionaryValue::booleanProperty(const String16& name, bool defaultValue) const @@ -259,22 +290,24 @@ bool DictionaryValue::booleanProperty(const String16& name, bool defaultValue) c return result; } -double DictionaryValue::numberProperty(const String16& name, double defaultValue) const +int DictionaryValue::integerProperty(const String16& name, int defaultValue) const +{ + int result = defaultValue; + getInteger(name, &result); + return result; +} + +double DictionaryValue::doubleProperty(const String16& name, double defaultValue) const { double result = defaultValue; - getNumber(name, &result); + getDouble(name, &result); return result; } void DictionaryValue::remove(const String16& name) { - m_data.remove(name); - for (size_t i = 0; i < m_order.size(); ++i) { - if (m_order[i] == name) { - m_order.remove(i); - break; - } - } + m_data.erase(name); + m_order.erase(std::remove(m_order.begin(), m_order.end(), name), m_order.end()); } void DictionaryValue::writeJSON(String16Builder* output) const @@ -297,9 +330,9 @@ std::unique_ptr DictionaryValue::clone() const std::unique_ptr result = DictionaryValue::create(); for (size_t i = 0; i < m_order.size(); ++i) { String16 key = m_order[i]; - Value* value = m_data.get(key); - DCHECK(value); - result->setValue(key, value->clone()); + Dictionary::const_iterator value = m_data.find(key); + DCHECK(value != m_data.cend() && value->second); + result->setValue(key, value->second->clone()); } return std::move(result); } @@ -316,10 +349,12 @@ ListValue::~ListValue() void ListValue::writeJSON(String16Builder* output) const { output->append('['); - for (Vector>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) { - if (it != m_data.begin()) + bool first = true; + for (const std::unique_ptr& value : m_data) { + if (!first) output->append(','); - (*it)->writeJSON(output); + value->writeJSON(output); + first = false; } output->append(']'); } @@ -327,8 +362,8 @@ void ListValue::writeJSON(String16Builder* output) const std::unique_ptr ListValue::clone() const { std::unique_ptr result = ListValue::create(); - for (Vector>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) - result->pushValue((*it)->clone()); + for (const std::unique_ptr& value : m_data) + result->pushValue(value->clone()); return std::move(result); } @@ -340,13 +375,13 @@ ListValue::ListValue() void ListValue::pushValue(std::unique_ptr value) { DCHECK(value); - m_data.append(std::move(value)); + m_data.push_back(std::move(value)); } protocol::Value* ListValue::at(size_t index) { DCHECK_LT(index, m_data.size()); - return m_data[index]; + return m_data[index].get(); } } // namespace protocol diff --git a/deps/v8_inspector/platform/inspector_protocol/Values.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h similarity index 82% rename from deps/v8_inspector/platform/inspector_protocol/Values.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h index e4a719286fb67d..07a2cac9249f47 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Values.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h @@ -10,6 +10,8 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include + namespace blink { namespace protocol { @@ -32,7 +34,8 @@ class PLATFORM_EXPORT Value { enum ValueType { TypeNull = 0, TypeBoolean, - TypeNumber, + TypeInteger, + TypeDouble, TypeString, TypeObject, TypeArray @@ -43,8 +46,8 @@ class PLATFORM_EXPORT Value { bool isNull() const { return m_type == TypeNull; } virtual bool asBoolean(bool* output) const; - virtual bool asNumber(double* output) const; - virtual bool asNumber(int* output) const; + virtual bool asDouble(double* output) const; + virtual bool asInteger(int* output) const; virtual bool asString(String16* output) const; String16 toJSONString() const; @@ -80,19 +83,20 @@ class PLATFORM_EXPORT FundamentalValue : public Value { } bool asBoolean(bool* output) const override; - bool asNumber(double* output) const override; - bool asNumber(int* output) const override; + bool asDouble(double* output) const override; + bool asInteger(int* output) const override; void writeJSON(String16Builder* output) const override; std::unique_ptr clone() const override; private: explicit FundamentalValue(bool value) : Value(TypeBoolean), m_boolValue(value) { } - explicit FundamentalValue(int value) : Value(TypeNumber), m_doubleValue((double)value) { } - explicit FundamentalValue(double value) : Value(TypeNumber), m_doubleValue(value) { } + explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(value) { } + explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(value) { } union { bool m_boolValue; double m_doubleValue; + int m_integerValue; }; }; @@ -145,20 +149,16 @@ class PLATFORM_EXPORT DictionaryValue : public Value { size_t size() const { return m_data.size(); } void setBoolean(const String16& name, bool); - void setNumber(const String16& name, double); + void setInteger(const String16& name, int); + void setDouble(const String16& name, double); void setString(const String16& name, const String16&); void setValue(const String16& name, std::unique_ptr); void setObject(const String16& name, std::unique_ptr); void setArray(const String16& name, std::unique_ptr); bool getBoolean(const String16& name, bool* output) const; - template bool getNumber(const String16& name, T* output) const - { - Value* value = get(name); - if (!value) - return false; - return value->asNumber(output); - } + bool getInteger(const String16& name, int* output) const; + bool getDouble(const String16& name, double* output) const; bool getString(const String16& name, String16* output) const; DictionaryValue* getObject(const String16& name) const; @@ -167,17 +167,27 @@ class PLATFORM_EXPORT DictionaryValue : public Value { Entry at(size_t index) const; bool booleanProperty(const String16& name, bool defaultValue) const; - double numberProperty(const String16& name, double defaultValue) const; + int integerProperty(const String16& name, int defaultValue) const; + double doubleProperty(const String16& name, double defaultValue) const; void remove(const String16& name); ~DictionaryValue() override; private: DictionaryValue(); + template + void set(const String16& key, std::unique_ptr& value) + { + DCHECK(value); + bool isNew = m_data.find(key) == m_data.end(); + m_data[key] = std::move(value); + if (isNew) + m_order.push_back(key); + } using Dictionary = protocol::HashMap>; Dictionary m_data; - protocol::Vector m_order; + std::vector m_order; }; class PLATFORM_EXPORT ListValue : public Value { @@ -211,7 +221,7 @@ class PLATFORM_EXPORT ListValue : public Value { private: ListValue(); - protocol::Vector> m_data; + std::vector> m_data; }; } // namespace protocol diff --git a/deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version similarity index 99% rename from deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version index 65738d6f38be9c..838a3ed2dd815a 100755 --- a/deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version @@ -4,7 +4,7 @@ # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Inspector protocol validator. -# +# # Tests that subsequent protocol changes are not breaking backwards compatibility. # Following violations are reported: # @@ -39,7 +39,7 @@ # - Event has been removed # - Required event parameter was removed or changed to optional # - Parameter type has changed. -# +# # For the parameters with composite types the above checks are also applied # recursively to every property of the type. # @@ -197,7 +197,7 @@ def extract_type(typed_object, types_map, errors): ref = typed_object["$ref"] if not ref in types_map: errors.append("Can not resolve type: %s" % ref) - types_map[ref] = { "id": "", "type": "object" } + types_map[ref] = { "id": "", "type": "object" } return types_map[ref] diff --git a/deps/v8_inspector/platform/v8_inspector/Atomics.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/Atomics.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/Atomics.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/Atomics.h diff --git a/deps/v8_inspector/platform/v8_inspector/DebuggerScript.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js similarity index 98% rename from deps/v8_inspector/platform/v8_inspector/DebuggerScript.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js index 85d214e06efad6..5b534f322160f3 100644 --- a/deps/v8_inspector/platform/v8_inspector/DebuggerScript.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js @@ -92,9 +92,9 @@ DebuggerScript.getFunctionScopes = function(fun) /** * @param {Object} object - * @return {?GeneratorObjectDetails} + * @return {?RawLocation} */ -DebuggerScript.getGeneratorObjectDetails = function(object) +DebuggerScript.getGeneratorObjectLocation = function(object) { var mirror = MakeMirror(object, true /* transient */); if (!mirror.isGenerator()) @@ -103,21 +103,16 @@ DebuggerScript.getGeneratorObjectDetails = function(object) var funcMirror = generatorMirror.func(); if (!funcMirror.resolved()) return null; - var result = { - "function": funcMirror.value(), - "functionName": funcMirror.debugName(), - "status": generatorMirror.status() - }; - var script = funcMirror.script(); var location = generatorMirror.sourceLocation() || funcMirror.sourceLocation(); + var script = funcMirror.script(); if (script && location) { - result["location"] = { - "scriptId": String(script.id()), - "lineNumber": location.line, - "columnNumber": location.column + return { + scriptId: "" + script.id(), + lineNumber: location.line, + columnNumber: location.column }; } - return result; + return null; } /** diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp index 868fdeabb4a10b..302b635ed47a1b 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp @@ -47,13 +47,9 @@ #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8Debugger.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" using blink::protocol::Array; using blink::protocol::Debugger::CallFrame; -using blink::protocol::Debugger::CollectionEntry; -using blink::protocol::Debugger::FunctionDetails; -using blink::protocol::Debugger::GeneratorObjectDetails; using blink::protocol::Runtime::PropertyDescriptor; using blink::protocol::Runtime::InternalPropertyDescriptor; using blink::protocol::Runtime::RemoteObject; @@ -149,7 +145,7 @@ void InjectedScript::releaseObject(const String16& objectId) if (!object) return; int boundId = 0; - if (!object->getNumber("id", &boundId)) + if (!object->getInteger("id", &boundId)) return; m_native->unbind(boundId); } @@ -187,7 +183,6 @@ bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Localdebugger(), m_context->context(), v8Value(), "wrapObjectsInArray"); function.appendArgument(array); function.appendArgument(groupName); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(forceValueType); function.appendArgument(generatePreview); bool hadException = false; @@ -213,7 +207,6 @@ v8::MaybeLocal InjectedScript::wrapValue(ErrorString* errorString, v8 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapObject"); function.appendArgument(value); function.appendArgument(groupName); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(forceValueType); function.appendArgument(generatePreview); bool hadException = false; @@ -227,7 +220,6 @@ std::unique_ptr InjectedScript::wrapTable(v8::L { v8::HandleScope handles(m_context->isolate()); V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapTable"); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(table); if (columns.IsEmpty()) function.appendArgument(false); @@ -271,14 +263,6 @@ void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) DCHECK(!hadException); } -bool InjectedScript::canAccessInspectedWindow() const -{ - v8::Local callingContext = m_context->isolate()->GetCallingContext(); - if (callingContext.IsEmpty()) - return true; - return m_context->debugger()->client()->callingContextCanAccessContext(callingContext, m_context->context()); -} - v8::Local InjectedScript::v8Value() const { return m_value.Get(m_context->isolate()); @@ -322,20 +306,16 @@ v8::MaybeLocal InjectedScript::resolveCallArgument(ErrorString* error std::unique_ptr InjectedScript::createExceptionDetails(v8::Local message) { - std::unique_ptr exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create().setText(toProtocolString(message->Get())).build(); - exceptionDetailsObject->setUrl(toProtocolStringWithTypeCheck(message->GetScriptResourceName())); - exceptionDetailsObject->setScriptId(String16::number(message->GetScriptOrigin().ScriptID()->Value())); - - v8::Maybe lineNumber = message->GetLineNumber(m_context->context()); - if (lineNumber.IsJust()) - exceptionDetailsObject->setLine(lineNumber.FromJust()); - v8::Maybe columnNumber = message->GetStartColumn(m_context->context()); - if (columnNumber.IsJust()) - exceptionDetailsObject->setColumn(columnNumber.FromJust()); + std::unique_ptr exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create() + .setText(toProtocolString(message->Get())) + .setScriptId(String16::fromInteger(message->GetScriptOrigin().ScriptID()->Value())) + .setLineNumber(message->GetLineNumber(m_context->context()).FromMaybe(1) - 1) + .setColumnNumber(message->GetStartColumn(m_context->context()).FromMaybe(0)) + .build(); v8::Local stackTrace = message->GetStackTrace(); if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) - exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject()); + exceptionDetailsObject->setStackTrace(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject()); return exceptionDetailsObject; } @@ -414,7 +394,7 @@ void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() { DCHECK(!m_ignoreExceptionsAndMuteConsole); m_ignoreExceptionsAndMuteConsole = true; - m_debugger->client()->muteConsole(); + m_debugger->client()->muteWarningsAndDeprecations(m_contextGroupId); m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions); } @@ -448,7 +428,7 @@ InjectedScript::Scope::~Scope() { if (m_ignoreExceptionsAndMuteConsole) { setPauseOnExceptionsState(m_previousPauseOnExceptionsState); - m_debugger->client()->unmuteConsole(); + m_debugger->client()->unmuteWarningsAndDeprecations(m_contextGroupId); } if (m_userGesture) m_debugger->client()->endUserGesture(); diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h similarity index 99% rename from deps/v8_inspector/platform/v8_inspector/InjectedScript.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h index 7dae28aba92cce..ab847ee0412906 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h @@ -159,7 +159,6 @@ class InjectedScript final { private: InjectedScript(InspectedContext*, v8::Local, std::unique_ptr); - bool canAccessInspectedWindow() const; v8::Local v8Value() const; v8::MaybeLocal wrapValue(ErrorString*, v8::Local, const String16& groupName, bool forceValueType, bool generatePreview) const; v8::Local commandLineAPI(); diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp similarity index 79% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp index 89e48fcbf13cc4..4f0eff93c41aaa 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp @@ -43,20 +43,21 @@ int InjectedScriptNative::bind(v8::Local value, const String16& group if (m_lastBoundObjectId <= 0) m_lastBoundObjectId = 1; int id = m_lastBoundObjectId++; - m_idToWrappedObject.set(id, wrapUnique(new v8::Global(m_isolate, value))); + m_idToWrappedObject[id] = wrapUnique(new v8::Global(m_isolate, value)); addObjectToGroup(id, groupName); return id; } void InjectedScriptNative::unbind(int id) { - m_idToWrappedObject.remove(id); - m_idToObjectGroupName.remove(id); + m_idToWrappedObject.erase(id); + m_idToObjectGroupName.erase(id); } v8::Local InjectedScriptNative::objectForId(int id) { - return m_idToWrappedObject.contains(id) ? m_idToWrappedObject.get(id)->Get(m_isolate) : v8::Local(); + auto iter = m_idToWrappedObject.find(id); + return iter != m_idToWrappedObject.end() ? iter->second->Get(m_isolate) : v8::Local(); } void InjectedScriptNative::addObjectToGroup(int objectId, const String16& groupName) @@ -65,13 +66,8 @@ void InjectedScriptNative::addObjectToGroup(int objectId, const String16& groupN return; if (objectId <= 0) return; - m_idToObjectGroupName.set(objectId, groupName); - auto it = m_nameToObjectGroup.find(groupName); - if (it == m_nameToObjectGroup.end()) { - m_nameToObjectGroup.set(groupName, protocol::Vector()); - it = m_nameToObjectGroup.find(groupName); - } - it->second->append(objectId); + m_idToObjectGroupName[objectId] = groupName; + m_nameToObjectGroup[groupName].push_back(objectId); // Creates an empty vector if key is not there } void InjectedScriptNative::releaseObjectGroup(const String16& groupName) @@ -81,16 +77,18 @@ void InjectedScriptNative::releaseObjectGroup(const String16& groupName) NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName); if (groupIt == m_nameToObjectGroup.end()) return; - for (int id : *groupIt->second) + for (int id : groupIt->second) unbind(id); - m_nameToObjectGroup.remove(groupName); + m_nameToObjectGroup.erase(groupIt); } String16 InjectedScriptNative::groupName(int objectId) const { if (objectId <= 0) return String16(); - return m_idToObjectGroupName.get(objectId); + IdToObjectGroupName::const_iterator iterator = m_idToObjectGroupName.find(objectId); + return iterator != m_idToObjectGroupName.end() ? iterator->second : String16(); } } // namespace blink + diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h similarity index 93% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h index 63d2a30f3c3165..c8082fe95edd61 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h @@ -10,6 +10,8 @@ #include "platform/inspector_protocol/String16.h" #include +#include + namespace blink { class InjectedScriptNative final { @@ -35,7 +37,7 @@ class InjectedScriptNative final { protocol::HashMap>> m_idToWrappedObject; typedef protocol::HashMap IdToObjectGroupName; IdToObjectGroupName m_idToObjectGroupName; - typedef protocol::HashMap> NameToObjectGroup; + typedef protocol::HashMap> NameToObjectGroup; NameToObjectGroup m_nameToObjectGroup; }; diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js similarity index 91% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js index 0e0c4f8d28065b..d2b3b2725ee665 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js @@ -199,6 +199,20 @@ InjectedScript.primitiveTypes = { __proto__: null } +/** + * @type {!Map} + * @const + */ +InjectedScript.closureTypes = new Map([ + ["local", "Local"], + ["closure", "Closure"], + ["catch", "Catch"], + ["block", "Block"], + ["script", "Script"], + ["with", "With Block"], + ["global", "Global"] +]); + InjectedScript.prototype = { /** * @param {*} object @@ -210,75 +224,61 @@ InjectedScript.prototype = { return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllCollection(object); }, + /** + * @param {*} object + * @return {boolean} + */ + _shouldPassByValue: function(object) + { + return typeof object === "object" && InjectedScriptHost.subtype(object) === "internal#location"; + }, + /** * @param {*} object * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview * @return {!RuntimeAgent.RemoteObject} */ - wrapObject: function(object, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapObject: function(object, groupName, forceValueType, generatePreview) { - if (canAccessInspectedGlobalObject) - return this._wrapObject(object, groupName, forceValueType, generatePreview); - return this._fallbackWrapper(object); + return this._wrapObject(object, groupName, forceValueType, generatePreview); }, /** * @param {!Array} array * @param {string} property * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview */ - wrapPropertyInArray: function(array, property, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapPropertyInArray: function(array, property, groupName, forceValueType, generatePreview) { for (var i = 0; i < array.length; ++i) { if (typeof array[i] === "object" && property in array[i]) - array[i][property] = this.wrapObject(array[i][property], groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview); + array[i][property] = this.wrapObject(array[i][property], groupName, forceValueType, generatePreview); } }, /** * @param {!Array<*>} array * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview */ - wrapObjectsInArray: function(array, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapObjectsInArray: function(array, groupName, forceValueType, generatePreview) { for (var i = 0; i < array.length; ++i) - array[i] = this.wrapObject(array[i], groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview); - }, - - /** - * @param {*} object - * @return {!RuntimeAgent.RemoteObject} - */ - _fallbackWrapper: function(object) - { - var result = { __proto__: null }; - result.type = typeof object; - if (this.isPrimitiveValue(object)) - result.value = object; - else - result.description = toString(object); - return /** @type {!RuntimeAgent.RemoteObject} */ (result); + array[i] = this.wrapObject(array[i], groupName, forceValueType, generatePreview); }, /** - * @param {boolean} canAccessInspectedGlobalObject * @param {!Object} table * @param {!Array.|string|boolean} columns * @return {!RuntimeAgent.RemoteObject} */ - wrapTable: function(canAccessInspectedGlobalObject, table, columns) + wrapTable: function(table, columns) { - if (!canAccessInspectedGlobalObject) - return this._fallbackWrapper(table); var columnNames = null; if (typeof columns === "string") columns = [columns]; @@ -338,10 +338,20 @@ InjectedScript.prototype = { */ getProperties: function(object, objectGroupName, ownProperties, accessorPropertiesOnly, generatePreview) { + var subtype = this._subtype(object); + if (subtype === "internal#scope") { + // Internally, scope contains object with scope variables and additional information like type, + // we use additional information for preview and would like to report variables as scope + // properties. + object = object.object; + } + var descriptors = []; var iter = this._propertyDescriptors(object, ownProperties, accessorPropertiesOnly, undefined); // Go over properties, wrap object values. for (var descriptor of iter) { + if (subtype === "internal#scopeList" && descriptor.name === "length") + continue; if ("get" in descriptor) descriptor.get = this._wrapObject(descriptor.get, objectGroupName); if ("set" in descriptor) @@ -635,9 +645,34 @@ InjectedScript.prototype = { } } + if (subtype === "internal#entry") { + if ("key" in obj) + return "{" + this._describeIncludingPrimitives(obj.key) + " => " + this._describeIncludingPrimitives(obj.value) + "}"; + return this._describeIncludingPrimitives(obj.value); + } + + if (subtype === "internal#scopeList") + return "Scopes[" + obj.length + "]"; + + if (subtype === "internal#scope") + return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (obj.name ? " (" + obj.name + ")" : ""); + return className; }, + /** + * @param {*} value + * @return {string} + */ + _describeIncludingPrimitives: function(value) + { + if (typeof value === "string") + return "\"" + value.replace(/\n/g, "\u21B5") + "\""; + if (value === null) + return "" + value; + return this.isPrimitiveValue(value) ? toStringDescription(value) : (this._describe(value) || ""); + }, + /** * @param {boolean} enabled */ @@ -697,6 +732,13 @@ InjectedScript.RemoteObject = function(object, objectGroupName, doNotBind, force return; } + if (injectedScript._shouldPassByValue(object)) { + this.value = object; + this.subtype = injectedScript._subtype(object); + this.description = injectedScript._describeIncludingPrimitives(object); + return; + } + object = /** @type {!Object} */ (object); if (!doNotBind) @@ -827,7 +869,12 @@ InjectedScript.RemoteObject.prototype = { // Add internal properties to preview. var rawInternalProperties = InjectedScriptHost.getInternalProperties(object) || []; var internalProperties = []; + var entries = null; for (var i = 0; i < rawInternalProperties.length; i += 2) { + if (rawInternalProperties[i] === "[[Entries]]") { + entries = /** @type {!Array<*>} */(rawInternalProperties[i + 1]); + continue; + } push(internalProperties, { name: rawInternalProperties[i], value: rawInternalProperties[i + 1], @@ -839,7 +886,7 @@ InjectedScript.RemoteObject.prototype = { this._appendPropertyDescriptors(preview, internalProperties, propertiesThreshold, secondLevelKeys, isTable); if (this.subtype === "map" || this.subtype === "set" || this.subtype === "iterator") - this._appendEntriesPreview(object, preview, skipEntriesPreview); + this._appendEntriesPreview(entries, preview, skipEntriesPreview); } catch (e) {} @@ -947,13 +994,12 @@ InjectedScript.RemoteObject.prototype = { }, /** - * @param {!Object} object + * @param {?Array<*>} entries * @param {!RuntimeAgent.ObjectPreview} preview * @param {boolean=} skipEntriesPreview */ - _appendEntriesPreview: function(object, preview, skipEntriesPreview) + _appendEntriesPreview: function(entries, preview, skipEntriesPreview) { - var entries = InjectedScriptHost.collectionEntries(object); if (!entries) return; if (skipEntriesPreview) { diff --git a/deps/v8_inspector/platform/v8_inspector/InspectedContext.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/InspectedContext.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp diff --git a/deps/v8_inspector/platform/v8_inspector/InspectedContext.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h similarity index 97% rename from deps/v8_inspector/platform/v8_inspector/InspectedContext.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h index 284679ddc0ca10..ecff5e4012f008 100644 --- a/deps/v8_inspector/platform/v8_inspector/InspectedContext.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h @@ -6,7 +6,7 @@ #define InspectedContext_h #include "platform/inspector_protocol/Allocator.h" -#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" #include diff --git a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp index c72cadcafe2612..8bcc475f401d72 100644 --- a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp @@ -95,7 +95,7 @@ v8::Local JavaScriptCallFrame::details() const v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local func = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "details"))); - return v8::Local::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + return v8::Local::Cast(func->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr).ToLocalChecked()); } v8::MaybeLocal JavaScriptCallFrame::evaluate(v8::Local expression) @@ -103,7 +103,7 @@ v8::MaybeLocal JavaScriptCallFrame::evaluate(v8::Local exp v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotasks); v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local evalFunction = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "evaluate"))); - return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, 1, &expression); + return evalFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 1, &expression); } v8::MaybeLocal JavaScriptCallFrame::restart() @@ -112,7 +112,7 @@ v8::MaybeLocal JavaScriptCallFrame::restart() v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local restartFunction = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "restart"))); v8::Debug::SetLiveEditEnabled(m_isolate, true); - v8::MaybeLocal result = restartFunction->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr); + v8::MaybeLocal result = restartFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); v8::Debug::SetLiveEditEnabled(m_isolate, false); return result; } @@ -127,7 +127,7 @@ v8::MaybeLocal JavaScriptCallFrame::setVariableValue(int scopeNumber, variableName, newValue }; - return setVariableValueFunction->Call(m_isolate->GetCurrentContext(), callFrame, PROTOCOL_ARRAY_LENGTH(argv), argv); + return setVariableValueFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, PROTOCOL_ARRAY_LENGTH(argv), argv); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h similarity index 96% rename from deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h index 6f9693522eaba9..959f8172ee31da 100644 --- a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h @@ -36,6 +36,8 @@ #include "platform/inspector_protocol/String16.h" #include +#include + namespace blink { class JavaScriptCallFrame { @@ -67,7 +69,7 @@ class JavaScriptCallFrame { v8::Global m_callFrame; }; -using JavaScriptCallFrames = protocol::Vector>; +using JavaScriptCallFrames = std::vector>; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/OWNERS b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/OWNERS similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/OWNERS rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/OWNERS diff --git a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp similarity index 85% rename from deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp index 9a2a6c00886e96..e9aaf26d51e028 100644 --- a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp @@ -19,7 +19,7 @@ std::unique_ptr RemoteObjectIdBase::parseInjectedScri return nullptr; std::unique_ptr parsedObjectId(protocol::DictionaryValue::cast(parsedValue.release())); - bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScriptId); + bool success = parsedObjectId->getInteger("injectedScriptId", &m_injectedScriptId); if (success) return parsedObjectId; return nullptr; @@ -36,7 +36,7 @@ std::unique_ptr RemoteObjectId::parse(ErrorString* errorString, return nullptr; } - bool success = parsedObjectId->getNumber("id", &result->m_id); + bool success = parsedObjectId->getInteger("id", &result->m_id); if (!success) { *errorString = "Invalid remote object id"; return nullptr; @@ -55,7 +55,7 @@ std::unique_ptr RemoteCallFrameId::parse(ErrorString* errorSt return nullptr; } - bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal); + bool success = parsedObjectId->getInteger("ordinal", &result->m_frameOrdinal); if (!success) { *errorString = "Invalid call frame id"; return nullptr; @@ -66,7 +66,7 @@ std::unique_ptr RemoteCallFrameId::parse(ErrorString* errorSt String16 RemoteCallFrameId::serialize(int injectedScriptId, int frameOrdinal) { - return "{\"ordinal\":" + String16::number(frameOrdinal) + ",\"injectedScriptId\":" + String16::number(injectedScriptId) + "}"; + return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) + ",\"injectedScriptId\":" + String16::fromInteger(injectedScriptId) + "}"; } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.h diff --git a/deps/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8Compat.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h similarity index 97% rename from deps/v8_inspector/platform/v8_inspector/V8Compat.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h index 30492b3af7a8e9..0f5b12cbb6cb07 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8Compat.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h @@ -23,6 +23,6 @@ class V8_EXPORT MicrotasksScope { } // namespace v8 -#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1) #endif // V8Compat_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8Console.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp similarity index 87% rename from deps/v8_inspector/platform/v8_inspector/V8Console.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp index d10b326d151f67..f7e142deeadbf3 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8Console.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp @@ -9,6 +9,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/V8Compat.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" @@ -16,8 +17,6 @@ #include "platform/v8_inspector/V8RuntimeAgentImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/ConsoleAPITypes.h" -#include "platform/v8_inspector/public/ConsoleTypes.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" namespace blink { @@ -77,26 +76,48 @@ class ConsoleHelper { return m_debuggerClient; } - void addMessage(MessageType type, MessageLevel level, String16 emptyText, int skipArgumentCount) + void reportCall(ConsoleAPIType type) { - if (emptyText.isEmpty() && !m_info.Length()) + if (!m_info.Length()) return; - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, type, level, m_info.Length() <= skipArgumentCount ? emptyText : String16(), &m_info, skipArgumentCount); + std::vector> arguments; + for (int i = 0; i < m_info.Length(); ++i) + arguments.push_back(m_info[i]); + reportCall(type, arguments); } - void addMessage(MessageType type, MessageLevel level, const String16& message) + void reportCallWithDefaultArgument(ConsoleAPIType type, const String16& message) { - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, type, level, message, nullptr, 0 /* skipArgumentsCount */); + std::vector> arguments; + for (int i = 0; i < m_info.Length(); ++i) + arguments.push_back(m_info[i]); + if (!m_info.Length()) + arguments.push_back(toV8String(m_isolate, message)); + reportCall(type, arguments); } - void addDeprecationMessage(const char* id, const String16& message) + void reportCallWithArgument(ConsoleAPIType type, const String16& message) + { + std::vector> arguments(1, toV8String(m_isolate, message)); + reportCall(type, arguments); + } + + void reportCall(ConsoleAPIType type, const std::vector>& arguments) + { + InspectedContext* inspectedContext = ensureInspectedContext(); + if (!inspectedContext) + return; + V8DebuggerImpl* debugger = inspectedContext->debugger(); + std::unique_ptr message = V8ConsoleMessage::createForConsoleAPI(debugger->client()->currentTimeMS(), type, arguments, debugger->captureStackTrace(false), inspectedContext); + debugger->ensureConsoleMessageStorage(inspectedContext->contextGroupId())->addMessage(std::move(message)); + } + + void reportDeprecatedCall(const char* id, const String16& message) { if (checkAndSetPrivateFlagOnConsole(id, false)) return; - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, LogMessageType, WarningMessageLevel, message, nullptr, 0 /* skipArgumentsCount */); + std::vector> arguments(1, toV8String(m_isolate, message)); + reportCall(ConsoleAPIType::kWarning, arguments); } bool firstArgToBoolean(bool defaultValue) @@ -250,13 +271,13 @@ void createBoundFunctionProperty(v8::Local context, v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!v8::Function::New(context, callback, console).ToLocal(&func)) + if (!v8::Function::New(context, callback, console, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) return; func->SetName(funcName); if (description) { v8::Local returnValue = toV8String(context->GetIsolate(), description); v8::Local toStringFunction; - if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toStringFunction)) + if (v8::Function::New(context, returnDataCallback, returnValue, 0, v8::ConstructorBehavior::kThrow).ToLocal(&toStringFunction)) func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction); } if (!console->Set(context, funcName, func).FromMaybe(false)) @@ -267,67 +288,67 @@ void createBoundFunctionProperty(v8::Local context, v8::Local& info) { - ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDebug); } void V8Console::errorCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kError); } void V8Console::infoCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kInfo); } void V8Console::logCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kLog); } void V8Console::warnCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kWarning); } void V8Console::dirCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDir); } void V8Console::dirxmlCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDirXML); } void V8Console::tableCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kTable); } void V8Console::traceCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, String16("console.trace"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kTrace, String16("console.trace")); } void V8Console::groupCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, String16("console.group"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, String16("console.group")); } void V8Console::groupCollapsedCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLevel, String16("console.groupCollapsed"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed, String16("console.groupCollapsed")); } void V8Console::groupEndCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, String16("console.groupEnd"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup, String16("console.groupEnd")); } void V8Console::clearCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, String16("console.clear"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kClear, String16("console.clear")); } void V8Console::countCallback(const v8::FunctionCallbackInfo& info) @@ -337,9 +358,9 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo& info) String16 title = helper.firstArgToString(String16()); String16 identifier; if (title.isEmpty()) { - std::unique_ptr stackTrace = V8StackTraceImpl::capture(nullptr, 1); + std::unique_ptr stackTrace = V8StackTraceImpl::capture(nullptr, 0, 1); if (stackTrace) - identifier = stackTrace->topSourceURL() + ":" + String16::number(stackTrace->topLineNumber()); + identifier = stackTrace->topSourceURL() + ":" + String16::fromInteger(stackTrace->topLineNumber()); } else { identifier = title + "@"; } @@ -349,7 +370,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo& info) return; int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; helper.setIntOnMap(countMap, identifier, count); - helper.addMessage(CountMessageType, DebugMessageLevel, title + ": " + String16::number(count)); + helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + String16::fromInteger(count)); } void V8Console::assertCallback(const v8::FunctionCallbackInfo& info) @@ -357,14 +378,21 @@ void V8Console::assertCallback(const v8::FunctionCallbackInfo& info) ConsoleHelper helper(info); if (helper.firstArgToBoolean(false)) return; - helper.addMessage(AssertMessageType, ErrorMessageLevel, String16("console.assert"), 1); + + std::vector> arguments; + for (int i = 1; i < info.Length(); ++i) + arguments.push_back(info[i]); + if (info.Length() < 2) + arguments.push_back(toV8String(info.GetIsolate(), String16("console.assert"))); + helper.reportCall(ConsoleAPIType::kAssert, arguments); + if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) debuggerAgent->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::Assert, nullptr); } void V8Console::markTimelineCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#markTimelineDeprecated", "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#markTimelineDeprecated", "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead."); timeStampCallback(info); } @@ -412,19 +440,19 @@ static void timeEndFunction(const v8::FunctionCallbackInfo& info, boo return; double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeMap, protocolTitle, 0.0); String16 message = protocolTitle + ": " + String16::fromDoubleFixedPrecision(elapsed, 3) + "ms"; - helper.addMessage(TimeEndMessageType, DebugMessageLevel, message); + helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); } } void V8Console::timelineCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#timeline", "'console.timeline' is deprecated. Please use 'console.time' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#timeline", "'console.timeline' is deprecated. Please use 'console.time' instead."); timeFunction(info, true); } void V8Console::timelineEndCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#timelineEnd", "'console.timelineEnd' is deprecated. Please use 'console.timeEnd' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#timelineEnd", "'console.timelineEnd' is deprecated. Please use 'console.timeEnd' instead."); timeEndFunction(info, true); } @@ -507,7 +535,7 @@ static void setFunctionBreakpoint(ConsoleHelper& helper, v8::Local V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent(); if (!debuggerAgent) return; - String16 scriptId = String16::number(function->ScriptId()); + String16 scriptId = String16::fromInteger(function->ScriptId()); int lineNumber = function->GetScriptLineNumber(); int columnNumber = function->GetScriptColumnNumber(); if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::Function::kLineOffsetNotFound) @@ -661,7 +689,7 @@ v8::Local V8Console::createConsole(InspectedContext* inspectedContex DCHECK(success); if (hasMemoryAttribute) - console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Function::New(isolate, V8Console::memorySetterCallback), static_cast(v8::None), v8::DEFAULT); + console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), v8::Function::New(context, V8Console::memorySetterCallback, v8::Local(), 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), static_cast(v8::None), v8::DEFAULT); console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext)); return console; diff --git a/deps/v8_inspector/platform/v8_inspector/V8Console.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Console.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp new file mode 100644 index 00000000000000..ab4017532f4bd8 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp @@ -0,0 +1,88 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" + +#include "platform/v8_inspector/V8ConsoleMessage.h" +#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8StackTraceImpl.h" + +namespace blink { + +namespace ConsoleAgentState { +static const char consoleEnabled[] = "consoleEnabled"; +} + +V8ConsoleAgentImpl::V8ConsoleAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) + : m_session(session) + , m_state(state) + , m_frontend(frontendChannel) + , m_enabled(false) +{ +} + +V8ConsoleAgentImpl::~V8ConsoleAgentImpl() +{ +} + +void V8ConsoleAgentImpl::enable(ErrorString* errorString) +{ + if (m_enabled) + return; + m_state->setBoolean(ConsoleAgentState::consoleEnabled, true); + m_enabled = true; + m_session->debugger()->enableStackCapturingIfNeeded(); + reportAllMessages(); +} + +void V8ConsoleAgentImpl::disable(ErrorString* errorString) +{ + if (!m_enabled) + return; + m_session->debugger()->disableStackCapturingIfNeeded(); + m_state->setBoolean(ConsoleAgentState::consoleEnabled, false); + m_enabled = false; +} + +void V8ConsoleAgentImpl::clearMessages(ErrorString* errorString) +{ +} + +void V8ConsoleAgentImpl::restore() +{ + if (!m_state->booleanProperty(ConsoleAgentState::consoleEnabled, false)) + return; + ErrorString ignored; + enable(&ignored); +} + +void V8ConsoleAgentImpl::messageAdded(V8ConsoleMessage* message) +{ + if (m_enabled) + reportMessage(message, true); +} + +bool V8ConsoleAgentImpl::enabled() +{ + return m_enabled; +} + +void V8ConsoleAgentImpl::reportAllMessages() +{ + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + for (const auto& message : storage->messages()) { + if (message->origin() == V8MessageOrigin::kConsole) + reportMessage(message.get(), false); + } +} + +void V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message, bool generatePreview) +{ + DCHECK(message->origin() == V8MessageOrigin::kConsole); + message->reportToFrontend(&m_frontend); + m_frontend.flush(); +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h new file mode 100644 index 00000000000000..bc897ac352e289 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h @@ -0,0 +1,45 @@ +// Copyright 2016 The Chromium 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 V8ConsoleAgentImpl_h +#define V8ConsoleAgentImpl_h + +#include "platform/inspector_protocol/Allocator.h" +#include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Console.h" + +namespace blink { + +class V8ConsoleMessage; +class V8InspectorSessionImpl; + +class V8ConsoleAgentImpl : public protocol::Console::Backend { + PROTOCOL_DISALLOW_COPY(V8ConsoleAgentImpl); +public: + V8ConsoleAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state); + ~V8ConsoleAgentImpl() override; + + void enable(ErrorString*) override; + void disable(ErrorString*) override; + void clearMessages(ErrorString*) override; + + void restore(); + void messageAdded(V8ConsoleMessage*); + void reset(); + bool enabled(); + +private: + void reportAllMessages(); + void reportMessage(V8ConsoleMessage*, bool generatePreview); + + V8InspectorSessionImpl* m_session; + protocol::DictionaryValue* m_state; + protocol::Console::Frontend m_frontend; + bool m_enabled; +}; + +} // namespace blink + + +#endif // !defined(V8ConsoleAgentImpl_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp new file mode 100644 index 00000000000000..42fe95bdfcd890 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp @@ -0,0 +1,440 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8ConsoleMessage.h" + +#include "platform/v8_inspector/InspectedContext.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8RuntimeAgentImpl.h" +#include "platform/v8_inspector/V8StackTraceImpl.h" +#include "platform/v8_inspector/V8StringUtil.h" +#include "platform/v8_inspector/public/V8DebuggerClient.h" + +namespace blink { + +namespace { + +String16 consoleAPITypeValue(ConsoleAPIType type) +{ + switch (type) { + case ConsoleAPIType::kLog: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; + case ConsoleAPIType::kDebug: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + case ConsoleAPIType::kInfo: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Info; + case ConsoleAPIType::kError: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Error; + case ConsoleAPIType::kWarning: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Warning; + case ConsoleAPIType::kClear: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Clear; + case ConsoleAPIType::kDir: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Dir; + case ConsoleAPIType::kDirXML: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Dirxml; + case ConsoleAPIType::kTable: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Table; + case ConsoleAPIType::kTrace: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Trace; + case ConsoleAPIType::kStartGroup: return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroup; + case ConsoleAPIType::kStartGroupCollapsed: return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroupCollapsed; + case ConsoleAPIType::kEndGroup: return protocol::Runtime::ConsoleAPICalled::TypeEnum::EndGroup; + case ConsoleAPIType::kAssert: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Assert; + case ConsoleAPIType::kTimeEnd: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + case ConsoleAPIType::kCount: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + } + return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; +} + +const unsigned maxConsoleMessageCount = 1000; +const unsigned maxArrayItemsLimit = 10000; +const unsigned maxStackDepthLimit = 32; + +class V8ValueStringBuilder { +public: + static String16 toString(v8::Local value, v8::Isolate* isolate) + { + V8ValueStringBuilder builder(isolate); + if (!builder.append(value)) + return String16(); + return builder.toString(); + } + +private: + enum { + IgnoreNull = 1 << 0, + IgnoreUndefined = 1 << 1, + }; + + V8ValueStringBuilder(v8::Isolate* isolate) + : m_arrayLimit(maxArrayItemsLimit) + , m_isolate(isolate) + , m_tryCatch(isolate) + { + } + + bool append(v8::Local value, unsigned ignoreOptions = 0) + { + if (value.IsEmpty()) + return true; + if ((ignoreOptions & IgnoreNull) && value->IsNull()) + return true; + if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined()) + return true; + if (value->IsString()) + return append(v8::Local::Cast(value)); + if (value->IsStringObject()) + return append(v8::Local::Cast(value)->ValueOf()); + if (value->IsSymbol()) + return append(v8::Local::Cast(value)); + if (value->IsSymbolObject()) + return append(v8::Local::Cast(value)->ValueOf()); + if (value->IsNumberObject()) { + m_builder.appendNumber(v8::Local::Cast(value)->ValueOf()); + return true; + } + if (value->IsBooleanObject()) { + m_builder.append(v8::Local::Cast(value)->ValueOf() ? "true" : "false"); + return true; + } + if (value->IsArray()) + return append(v8::Local::Cast(value)); + if (value->IsProxy()) { + m_builder.append("[object Proxy]"); + return true; + } + if (value->IsObject() + && !value->IsDate() + && !value->IsFunction() + && !value->IsNativeError() + && !value->IsRegExp()) { + v8::Local object = v8::Local::Cast(value); + v8::Local stringValue; + if (object->ObjectProtoToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue)) + return append(stringValue); + } + v8::Local stringValue; + if (!value->ToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue)) + return false; + return append(stringValue); + } + + bool append(v8::Local array) + { + for (const auto& it : m_visitedArrays) { + if (it == array) + return true; + } + uint32_t length = array->Length(); + if (length > m_arrayLimit) + return false; + if (m_visitedArrays.size() > maxStackDepthLimit) + return false; + + bool result = true; + m_arrayLimit -= length; + m_visitedArrays.push_back(array); + for (uint32_t i = 0; i < length; ++i) { + if (i) + m_builder.append(','); + if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) { + result = false; + break; + } + } + m_visitedArrays.pop_back(); + return result; + } + + bool append(v8::Local symbol) + { + m_builder.append("Symbol("); + bool result = append(symbol->Name(), IgnoreUndefined); + m_builder.append(')'); + return result; + } + + bool append(v8::Local string) + { + if (m_tryCatch.HasCaught()) + return false; + if (!string.IsEmpty()) + m_builder.append(toProtocolString(string)); + return true; + } + + String16 toString() + { + if (m_tryCatch.HasCaught()) + return String16(); + return m_builder.toString(); + } + + uint32_t m_arrayLimit; + v8::Isolate* m_isolate; + String16Builder m_builder; + std::vector> m_visitedArrays; + v8::TryCatch m_tryCatch; +}; + +} // namespace + +V8ConsoleMessage::V8ConsoleMessage(V8MessageOrigin origin, double timestamp, const String16& message) + : m_origin(origin) + , m_timestamp(timestamp) + , m_message(message) + , m_lineNumber(0) + , m_columnNumber(0) + , m_scriptId(0) + , m_contextId(0) + , m_type(ConsoleAPIType::kLog) + , m_exceptionId(0) + , m_revokedExceptionId(0) +{ +} + +V8ConsoleMessage::~V8ConsoleMessage() +{ +} + +void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + m_url = url; + m_lineNumber = lineNumber; + m_columnNumber = columnNumber; + m_stackTrace = std::move(stackTrace); + m_scriptId = scriptId; +} + +void V8ConsoleMessage::reportToFrontend(protocol::Console::Frontend* frontend) const +{ + DCHECK(m_origin == V8MessageOrigin::kConsole); + std::unique_ptr result = + protocol::Console::ConsoleMessage::create() + .setSource(protocol::Console::ConsoleMessage::SourceEnum::ConsoleApi) + .setLevel(protocol::Console::ConsoleMessage::LevelEnum::Log) + .setText(m_message) + .build(); + result->setLine(static_cast(m_lineNumber)); + result->setColumn(static_cast(m_columnNumber)); + result->setUrl(m_url); + frontend->messageAdded(std::move(result)); +} + +std::unique_ptr> V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (!m_arguments.size() || !m_contextId) + return nullptr; + InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + if (!inspectedContext) + return nullptr; + + v8::Isolate* isolate = inspectedContext->isolate(); + v8::HandleScope handles(isolate); + v8::Local context = inspectedContext->context(); + + std::unique_ptr> args = protocol::Array::create(); + if (m_type == ConsoleAPIType::kTable && generatePreview) { + v8::Local table = m_arguments[0]->Get(isolate); + v8::Local columns = m_arguments.size() > 1 ? m_arguments[1]->Get(isolate) : v8::Local(); + std::unique_ptr wrapped = session->wrapTable(context, table, columns); + if (wrapped) + args->addItem(std::move(wrapped)); + else + args = nullptr; + } else { + for (size_t i = 0; i < m_arguments.size(); ++i) { + std::unique_ptr wrapped = session->wrapObject(context, m_arguments[i]->Get(isolate), "console", generatePreview); + if (!wrapped) { + args = nullptr; + break; + } + args->addItem(std::move(wrapped)); + } + } + return args; +} + +void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (m_origin == V8MessageOrigin::kException) { + // TODO(dgozman): unify with InjectedScript::createExceptionDetails. + std::unique_ptr details = protocol::Runtime::ExceptionDetails::create() + .setText(m_message) + .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) + .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) + .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String16()) + .build(); + if (!m_url.isEmpty()) + details->setUrl(m_url); + if (m_stackTrace) + details->setStackTrace(m_stackTrace->buildInspectorObject()); + + std::unique_ptr exception = wrapException(session, generatePreview); + + if (exception) + frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(details), std::move(exception), m_contextId); + else + frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(details)); + return; + } + if (m_origin == V8MessageOrigin::kRevokedException) { + frontend->exceptionRevoked(m_message, m_revokedExceptionId); + return; + } + if (m_origin == V8MessageOrigin::kConsole) { + std::unique_ptr> arguments = wrapArguments(session, generatePreview); + if (!arguments) { + arguments = protocol::Array::create(); + if (!m_message.isEmpty()) { + std::unique_ptr messageArg = protocol::Runtime::RemoteObject::create().setType(protocol::Runtime::RemoteObject::TypeEnum::String).build(); + messageArg->setValue(protocol::StringValue::create(m_message)); + arguments->addItem(std::move(messageArg)); + } + } + frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(arguments), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr); + return; + } + NOTREACHED(); +} + +std::unique_ptr V8ConsoleMessage::wrapException(V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (!m_arguments.size() || !m_contextId) + return nullptr; + DCHECK_EQ(1u, m_arguments.size()); + InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + if (!inspectedContext) + return nullptr; + + v8::Isolate* isolate = inspectedContext->isolate(); + v8::HandleScope handles(isolate); + // TODO(dgozman): should we use different object group? + return session->wrapObject(inspectedContext->context(), m_arguments[0]->Get(isolate), "console", generatePreview); +} + +V8MessageOrigin V8ConsoleMessage::origin() const +{ + return m_origin; +} + +ConsoleAPIType V8ConsoleMessage::type() const +{ + return m_type; +} + +// static +std::unique_ptr V8ConsoleMessage::createForConsoleAPI(double timestamp, ConsoleAPIType type, const std::vector>& arguments, std::unique_ptr stackTrace, InspectedContext* context) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16())); + if (stackTrace && !stackTrace->isEmpty()) { + message->m_url = stackTrace->topSourceURL(); + message->m_lineNumber = stackTrace->topLineNumber(); + message->m_columnNumber = stackTrace->topColumnNumber(); + } + message->m_stackTrace = std::move(stackTrace); + message->m_type = type; + message->m_contextId = context->contextId(); + for (size_t i = 0; i < arguments.size(); ++i) + message->m_arguments.push_back(wrapUnique(new v8::Global(context->isolate(), arguments.at(i)))); + if (arguments.size()) + message->m_message = V8ValueStringBuilder::toString(arguments[0], context->isolate()); + + MessageLevel level = LogMessageLevel; + if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || type == ConsoleAPIType::kTimeEnd) + level = DebugMessageLevel; + if (type == ConsoleAPIType::kError || type == ConsoleAPIType::kAssert) + level = ErrorMessageLevel; + if (type == ConsoleAPIType::kWarning) + level = WarningMessageLevel; + if (type == ConsoleAPIType::kInfo) + level = InfoMessageLevel; + context->debugger()->client()->consoleAPIMessage(context->contextGroupId(), level, message->m_message, message->m_url, message->m_lineNumber, message->m_columnNumber, message->m_stackTrace.get()); + + return message; +} + +// static +std::unique_ptr V8ConsoleMessage::createForException(double timestamp, const String16& messageText, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId, v8::Isolate* isolate, int contextId, v8::Local exception, unsigned exceptionId) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kException, timestamp, messageText)); + message->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId); + message->m_exceptionId = exceptionId; + if (contextId && !exception.IsEmpty()) { + message->m_contextId = contextId; + message->m_arguments.push_back(wrapUnique(new v8::Global(isolate, exception))); + } + return message; +} + +// static +std::unique_ptr V8ConsoleMessage::createForRevokedException(double timestamp, const String16& messageText, unsigned revokedExceptionId) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kRevokedException, timestamp, messageText)); + message->m_revokedExceptionId = revokedExceptionId; + return message; +} + +void V8ConsoleMessage::contextDestroyed(int contextId) +{ + if (contextId != m_contextId) + return; + m_contextId = 0; + if (m_message.isEmpty()) + m_message = ""; + Arguments empty; + m_arguments.swap(empty); +} + +// ------------------------ V8ConsoleMessageStorage ---------------------------- + +V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8DebuggerImpl* debugger, int contextGroupId) + : m_debugger(debugger) + , m_contextGroupId(contextGroupId) + , m_expiredCount(0) +{ +} + +V8ConsoleMessageStorage::~V8ConsoleMessageStorage() +{ + clear(); + notifyClear(); +} + +void V8ConsoleMessageStorage::addMessage(std::unique_ptr message) +{ + if (message->type() == ConsoleAPIType::kClear) { + clear(); + notifyClear(); + } + + V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId); + if (session) { + if (message->origin() == V8MessageOrigin::kConsole) + session->consoleAgent()->messageAdded(message.get()); + session->runtimeAgent()->messageAdded(message.get()); + } + + DCHECK(m_messages.size() <= maxConsoleMessageCount); + if (m_messages.size() == maxConsoleMessageCount) { + ++m_expiredCount; + m_messages.pop_front(); + } + m_messages.push_back(std::move(message)); +} + +void V8ConsoleMessageStorage::clear() +{ + m_messages.clear(); + m_expiredCount = 0; + if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId)) + session->releaseObjectGroup("console"); +} + +void V8ConsoleMessageStorage::contextDestroyed(int contextId) +{ + for (size_t i = 0; i < m_messages.size(); ++i) + m_messages[i]->contextDestroyed(contextId); +} + +void V8ConsoleMessageStorage::notifyClear() +{ + if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId)) + session->client()->consoleCleared(); +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h new file mode 100644 index 00000000000000..923a84e9269080 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h @@ -0,0 +1,110 @@ +// Copyright 2016 The Chromium 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 V8ConsoleMessage_h +#define V8ConsoleMessage_h + +#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Console.h" +#include "platform/v8_inspector/protocol/Runtime.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" +#include "platform/v8_inspector/public/V8StackTrace.h" +#include +#include + +namespace blink { + +class InspectedContext; +class V8DebuggerImpl; +class V8InspectorSessionImpl; +class V8StackTrace; + +enum class V8MessageOrigin { kConsole, kException, kRevokedException }; + +enum class ConsoleAPIType { kLog, kDebug, kInfo, kError, kWarning, kDir, kDirXML, kTable, kTrace, kStartGroup, kStartGroupCollapsed, kEndGroup, kClear, kAssert, kTimeEnd, kCount }; + +class V8ConsoleMessage { +public: + ~V8ConsoleMessage(); + + static std::unique_ptr createForConsoleAPI( + double timestamp, + ConsoleAPIType, + const std::vector>& arguments, + std::unique_ptr, + InspectedContext*); + + static std::unique_ptr createForException( + double timestamp, + const String16& message, + const String16& url, + unsigned lineNumber, + unsigned columnNumber, + std::unique_ptr, + int scriptId, + v8::Isolate*, + int contextId, + v8::Local exception, + unsigned exceptionId); + + static std::unique_ptr createForRevokedException( + double timestamp, + const String16& message, + unsigned revokedExceptionId); + + V8MessageOrigin origin() const; + void reportToFrontend(protocol::Console::Frontend*) const; + void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*, bool generatePreview) const; + ConsoleAPIType type() const; + void contextDestroyed(int contextId); + +private: + V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message); + + using Arguments = std::vector>>; + std::unique_ptr> wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const; + std::unique_ptr wrapException(V8InspectorSessionImpl*, bool generatePreview) const; + void setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId); + + V8MessageOrigin m_origin; + double m_timestamp; + String16 m_message; + String16 m_url; + unsigned m_lineNumber; + unsigned m_columnNumber; + std::unique_ptr m_stackTrace; + int m_scriptId; + int m_contextId; + ConsoleAPIType m_type; + unsigned m_exceptionId; + unsigned m_revokedExceptionId; + Arguments m_arguments; +}; + +class V8ConsoleMessageStorage { +public: + V8ConsoleMessageStorage(V8DebuggerImpl*, int contextGroupId); + ~V8ConsoleMessageStorage(); + + int contextGroupId() { return m_contextGroupId; } + int expiredCount() { return m_expiredCount; } + const std::deque>& messages() const { return m_messages; } + + void addMessage(std::unique_ptr); + void contextDestroyed(int contextId); + void clear(); + +private: + void notifyClear(); + + V8DebuggerImpl* m_debugger; + int m_contextGroupId; + int m_expiredCount; + std::deque> m_messages; +}; + +} // namespace blink + +#endif // V8ConsoleMessage_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp similarity index 66% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp index e95d4af0f57210..2b232efc2e714b 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp @@ -19,26 +19,18 @@ #include "platform/v8_inspector/public/V8ContentSearchUtil.h" #include "platform/v8_inspector/public/V8Debugger.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" + +#include using blink::protocol::Array; using blink::protocol::Maybe; using blink::protocol::Debugger::BreakpointId; using blink::protocol::Debugger::CallFrame; -using blink::protocol::Debugger::CollectionEntry; using blink::protocol::Runtime::ExceptionDetails; -using blink::protocol::Debugger::FunctionDetails; -using blink::protocol::Debugger::GeneratorObjectDetails; using blink::protocol::Runtime::ScriptId; using blink::protocol::Runtime::StackTrace; using blink::protocol::Runtime::RemoteObject; -namespace { -static const char v8AsyncTaskEventEnqueue[] = "enqueue"; -static const char v8AsyncTaskEventWillHandle[] = "willHandle"; -static const char v8AsyncTaskEventDidHandle[] = "didHandle"; -} - namespace blink { namespace DebuggerAgentState { @@ -75,7 +67,7 @@ static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) static String16 generateBreakpointId(const String16& scriptId, int lineNumber, int columnNumber, V8DebuggerAgentImpl::BreakpointSource source) { - return scriptId + ":" + String16::number(lineNumber) + ":" + String16::number(columnNumber) + breakpointIdSuffix(source); + return scriptId + ":" + String16::fromInteger(lineNumber) + ":" + String16::fromInteger(columnNumber) + breakpointIdSuffix(source); } static bool positionComparator(const std::pair& a, const std::pair& b) @@ -85,61 +77,6 @@ static bool positionComparator(const std::pair& a, const std::pairappend(hexDigits[number & 0xF]); - number >>= 4; - } -} - -// Hash algorithm for substrings is described in "Über die Komplexität der Multiplikation in -// eingeschränkten Branchingprogrammmodellen" by Woelfe. -// http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000 -static String16 calculateHash(const String16& str) -{ - static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, 0x81ABE279 }; - static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; - static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, 0x8F462907 }; - - uint64_t hashes[] = { 0, 0, 0, 0, 0 }; - uint64_t zi[] = { 1, 1, 1, 1, 1 }; - - const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes); - - size_t current = 0; - const uint32_t* data = nullptr; - data = reinterpret_cast(str.characters16()); - for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) { - uint32_t v = data[i]; - uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; - hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; - zi[current] = (zi[current] * random[current]) % prime[current]; - current = current == hashesSize - 1 ? 0 : current + 1; - } - if (str.sizeInBytes() % 4) { - uint32_t v = 0; - for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeInBytes(); ++i) { - v <<= 8; - v |= reinterpret_cast(data)[i]; - } - uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; - hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; - zi[current] = (zi[current] * random[current]) % prime[current]; - current = current == hashesSize - 1 ? 0 : current + 1; - } - - for (size_t i = 0; i < hashesSize; ++i) - hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; - - String16Builder hash; - for (size_t i = 0; i < hashesSize; ++i) - appendUnsignedAsHex(hashes[i], &hash); - return hash.toString(); -} - static bool hasInternalError(ErrorString* errorString, bool hasError) { if (hasError) @@ -172,7 +109,6 @@ V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc , m_recursionLevelForStepOut(0) , m_recursionLevelForStepFrame(0) , m_skipAllPauses(false) - , m_maxAsyncCallStackDepth(0) { clearBreakDetails(); } @@ -197,14 +133,13 @@ void V8DebuggerAgentImpl::enable() m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); debugger().debuggerAgentEnabled(); - protocol::Vector compiledScripts; + std::vector> compiledScripts; debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts); for (size_t i = 0; i < compiledScripts.size(); i++) - didParseSource(compiledScripts[i]); + didParseSource(std::move(compiledScripts[i]), true); // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends debugger().setBreakpointsActivated(true); - m_session->changeInstrumentationCounter(+1); } bool V8DebuggerAgentImpl::enabled() @@ -229,11 +164,10 @@ void V8DebuggerAgentImpl::disable(ErrorString*) { if (!enabled()) return; - m_session->changeInstrumentationCounter(-1); m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::DictionaryValue::create()); - m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImpl::DontPauseOnExceptions); - m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0); + m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImpl::DontPauseOnExceptions); + m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); if (!m_pausedContext.IsEmpty()) debugger().continueProgram(); @@ -244,7 +178,7 @@ void V8DebuggerAgentImpl::disable(ErrorString*) m_scripts.clear(); m_blackboxedPositions.clear(); m_breakpointIdToDebuggerBreakpointIds.clear(); - internalSetAsyncCallStackDepth(0); + m_debugger->setAsyncCallStackDepth(this, 0); m_continueToLocationBreakpointId = String16(); clearBreakDetails(); m_scheduledDebuggerStep = NoStep; @@ -261,16 +195,6 @@ void V8DebuggerAgentImpl::disable(ErrorString*) m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); } -void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) -{ - if (depth <= 0) { - m_maxAsyncCallStackDepth = 0; - allAsyncTasksCanceled(); - } else { - m_maxAsyncCallStackDepth = depth; - } -} - void V8DebuggerAgentImpl::restore() { DCHECK(!m_enabled); @@ -283,15 +207,15 @@ void V8DebuggerAgentImpl::restore() ErrorString error; int pauseState = V8DebuggerImpl::DontPauseOnExceptions; - m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); + m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); setPauseOnExceptionsImpl(&error, pauseState); DCHECK(error.isEmpty()); m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); int asyncCallStackDepth = 0; - m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackDepth); - internalSetAsyncCallStackDepth(asyncCallStackDepth); + m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackDepth); + m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); String16 blackboxPattern; if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern)) { @@ -317,8 +241,8 @@ static std::unique_ptr buildObjectForBreakpointCookie { std::unique_ptr breakpointObject = protocol::DictionaryValue::create(); breakpointObject->setString(DebuggerAgentState::url, url); - breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); - breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); + breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); + breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber); breakpointObject->setString(DebuggerAgentState::condition, condition); breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); return breakpointObject; @@ -360,7 +284,7 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, String16 condition = optionalCondition.fromMaybe(""); bool isRegex = optionalURLRegex.isJust(); - String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16::number(lineNumber) + ":" + String16::number(columnNumber); + String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16::fromInteger(lineNumber) + ":" + String16::fromInteger(columnNumber); protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); if (!breakpointsCookie) { std::unique_ptr newValue = protocol::DictionaryValue::create(); @@ -375,7 +299,7 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, isRegex)); ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); - for (auto& script : m_scripts) { + for (const auto& script : m_scripts) { if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) continue; std::unique_ptr location = resolveBreakpoint(breakpointId, script.first, breakpoint, UserBreakpointSource); @@ -410,7 +334,7 @@ void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, String16 condition = optionalCondition.fromMaybe(""); String16 breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumber, UserBreakpointSource); - if (m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) { + if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != m_breakpointIdToDebuggerBreakpointIds.end()) { *errorString = "Breakpoint at specified location already exists."; return; } @@ -438,14 +362,14 @@ void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterator = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.end()) return; - protocol::Vector* ids = debuggerBreakpointIdsIterator->second; - for (size_t i = 0; i < ids->size(); ++i) { - const String16& debuggerBreakpointId = ids->at(i); + const std::vector& ids = debuggerBreakpointIdsIterator->second; + for (size_t i = 0; i < ids.size(); ++i) { + const String16& debuggerBreakpointId = ids[i]; debugger().removeBreakpoint(debuggerBreakpointId); - m_serverBreakpoints.remove(debuggerBreakpointId); + m_serverBreakpoints.erase(debuggerBreakpointId); } - m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); + m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); } void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, @@ -475,7 +399,8 @@ void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr { if (!assertPaused(errorString)) return; - m_pausedCallFrames.swap(debugger().currentCallFrames()); + JavaScriptCallFrames frames = debugger().currentCallFrames(); + m_pausedCallFrames.swap(frames); *callFrames = currentCallFrames(errorString); if (!*callFrames) return; @@ -487,7 +412,7 @@ bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() DCHECK(enabled()); JavaScriptCallFrames callFrames = debugger().currentCallFrames(); for (size_t index = 0; index < callFrames.size(); ++index) { - if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index])) + if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) return false; } return true; @@ -496,32 +421,34 @@ bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() { DCHECK(enabled()); - return isCallFrameWithUnknownScriptOrBlackboxed(m_pausedCallFrames.size() ? m_pausedCallFrames[0] : nullptr); + JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[0].get() : nullptr; + return isCallFrameWithUnknownScriptOrBlackboxed(frame); } bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCallFrame* frame) { if (!frame) return true; - ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID())); + ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(frame->sourceID())); if (it == m_scripts.end()) { // Unknown scripts are blackboxed. return true; } if (m_blackboxPattern) { - String16 scriptSourceURL = it->second->sourceURL(); + const String16& scriptSourceURL = it->second->sourceURL(); if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceURL) != -1) return true; } - auto itBlackboxedPositions = m_blackboxedPositions.find(String16::number(frame->sourceID())); + auto itBlackboxedPositions = m_blackboxedPositions.find(String16::fromInteger(frame->sourceID())); if (itBlackboxedPositions == m_blackboxedPositions.end()) return false; - protocol::Vector>* ranges = itBlackboxedPositions->second; - auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pair(frame->line(), frame->column()), positionComparator); + const std::vector>& ranges = itBlackboxedPositions->second; + auto itRange = std::lower_bound(ranges.begin(), ranges.end(), + std::make_pair(frame->line(), frame->column()), positionComparator); // Ranges array contains positions in script where blackbox state is changed. // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blackboxed... - return std::distance(ranges->begin(), itRange) % 2; + return std::distance(ranges.begin(), itRange) % 2; } V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame) @@ -566,8 +493,7 @@ std::unique_ptr V8DebuggerAgentImpl::resolveBreakp ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); if (scriptIterator == m_scripts.end()) return nullptr; - V8DebuggerScript* script = scriptIterator->second; - if (breakpoint.lineNumber < script->startLine() || script->endLine() < breakpoint.lineNumber) + if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIterator->second->endLine() < breakpoint.lineNumber) return nullptr; int actualLineNumber; @@ -576,14 +502,10 @@ std::unique_ptr V8DebuggerAgentImpl::resolveBreakp if (debuggerBreakpointId.isEmpty()) return nullptr; - m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, source)); + m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, source); CHECK(!breakpointId.isEmpty()); - if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) - m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector()); - - BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterator = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); - debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); + m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakpointId); return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber); } @@ -592,9 +514,10 @@ void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc const Maybe& optionalIsRegex, std::unique_ptr>* results) { + v8::HandleScope handles(m_isolate); ScriptsMap::iterator it = m_scripts.find(scriptId); if (it != m_scripts.end()) - *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->second->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); + *results = V8ContentSearchUtil::searchInTextByLines(m_session, toProtocolString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); else *error = String16("No script for id: " + scriptId); } @@ -606,23 +529,25 @@ void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, Maybe>* newCallFrames, Maybe* stackChanged, Maybe* asyncStackTrace, - Maybe* optOutCompileError) + Maybe* optOutCompileError) { if (!checkEnabled(errorString)) return; - if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) + + v8::HandleScope handles(m_isolate); + v8::Local newSource = toV8String(m_isolate, newContent); + if (!debugger().setScriptSource(scriptId, newSource, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) return; + ScriptsMap::iterator it = m_scripts.find(scriptId); + if (it != m_scripts.end()) + it->second->setSource(m_isolate, newSource); + std::unique_ptr> callFrames = currentCallFrames(errorString); if (!callFrames) return; *newCallFrames = std::move(callFrames); *asyncStackTrace = currentAsyncStackTrace(); - - ScriptsMap::iterator it = m_scripts.find(scriptId); - if (it == m_scripts.end()) - return; - it->second->setSource(newContent); } void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, @@ -646,7 +571,8 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, *errorString = "Internal error"; return; } - m_pausedCallFrames.swap(debugger().currentCallFrames()); + JavaScriptCallFrames frames = debugger().currentCallFrames(); + m_pausedCallFrames.swap(frames); *newCallFrames = currentCallFrames(errorString); if (!*newCallFrames) @@ -663,106 +589,8 @@ void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc *error = "No script for id: " + scriptId; return; } - *scriptSource = it->second->source(); -} - -void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const String16& functionId, std::unique_ptr* details) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), functionId); - if (!scope.initialize()) - return; - if (!scope.object()->IsFunction()) { - *errorString = "Value with given id is not a function"; - return; - } - v8::Local function = scope.object().As(); - - v8::Local scopesValue; - v8::Local scopes; - if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValue->IsArray()) { - scopes = scopesValue.As(); - if (!scope.injectedScript()->wrapPropertyInArray(errorString, scopes, toV8StringInternalized(m_isolate, "object"), scope.objectGroupName())) - return; - } - - std::unique_ptr functionDetails = FunctionDetails::create() - .setLocation(buildProtocolLocation(String16::number(function->ScriptId()), function->GetScriptLineNumber(), function->GetScriptColumnNumber())) - .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName())) - .setIsGenerator(function->IsGeneratorFunction()).build(); - - if (!scopes.IsEmpty()) { - protocol::ErrorSupport errorSupport; - std::unique_ptr> scopeChain = protocol::Array::parse(toProtocolValue(scope.context(), scopes).get(), &errorSupport); - if (hasInternalError(errorString, errorSupport.hasErrors())) - return; - functionDetails->setScopeChain(std::move(scopeChain)); - } - - *details = std::move(functionDetails); -} - -void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, const String16& objectId, std::unique_ptr* outDetails) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); - if (!scope.initialize()) - return; - if (!scope.object()->IsObject()) { - *errorString = "Value with given id is not an Object"; - return; - } - v8::Local object = scope.object().As(); - - v8::Local detailsObject; - v8::Local detailsValue = debugger().generatorObjectDetails(object); - if (hasInternalError(errorString, !detailsValue->IsObject() || !detailsValue->ToObject(scope.context()).ToLocal(&detailsObject))) - return; - - if (!scope.injectedScript()->wrapObjectProperty(errorString, detailsObject, toV8StringInternalized(m_isolate, "function"), scope.objectGroupName())) - return; - - protocol::ErrorSupport errors; - std::unique_ptr protocolDetails = GeneratorObjectDetails::parse(toProtocolValue(scope.context(), detailsObject).get(), &errors); - if (hasInternalError(errorString, !protocolDetails)) - return; - *outDetails = std::move(protocolDetails); -} - -void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const String16& objectId, std::unique_ptr>* outEntries) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); - if (!scope.initialize()) - return; - if (!scope.object()->IsObject()) { - *errorString = "Object with given id is not a collection"; - return; - } - v8::Local object = scope.object().As(); - - v8::Local entriesValue = m_debugger->collectionEntries(object); - if (hasInternalError(errorString, entriesValue.IsEmpty())) - return; - if (entriesValue->IsUndefined()) { - *errorString = "Object with given id is not a collection"; - return; - } - if (hasInternalError(errorString, !entriesValue->IsArray())) - return; - v8::Local entriesArray = entriesValue.As(); - if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "key"), scope.objectGroupName())) - return; - if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "value"), scope.objectGroupName())) - return; - protocol::ErrorSupport errors; - std::unique_ptr> entries = protocol::Array::parse(toProtocolValue(scope.context(), entriesArray).get(), &errors); - if (hasInternalError(errorString, !entries)) - return; - *outEntries = std::move(entries); + v8::HandleScope handles(m_isolate); + *scriptSource = toProtocolString(it->second->source(m_isolate)); } void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) @@ -797,26 +625,6 @@ void V8DebuggerAgentImpl::cancelPauseOnNextStatement() debugger().setPauseOnNextStatement(false); } -bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const -{ - return m_maxAsyncCallStackDepth; -} - -void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local context, const String16& eventType, const String16& eventName, int id) -{ - DCHECK(m_maxAsyncCallStackDepth); - // The scopes for the ids are defined by the eventName namespaces. There are currently two namespaces: "Object." and "Promise.". - void* ptr = reinterpret_cast(id * 4 + (eventName[0] == 'P' ? 2 : 0) + 1); - if (eventType == v8AsyncTaskEventEnqueue) - asyncTaskScheduled(eventName, ptr, false); - else if (eventType == v8AsyncTaskEventWillHandle) - asyncTaskStarted(ptr); - else if (eventType == v8AsyncTaskEventDidHandle) - asyncTaskFinished(ptr); - else - NOTREACHED(); -} - void V8DebuggerAgentImpl::pause(ErrorString* errorString) { if (!checkEnabled(errorString)) @@ -846,7 +654,7 @@ void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) if (!assertPaused(errorString)) return; // StepOver at function return point should fallback to StepInto. - JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[0] : nullptr; + JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrames[0].get() : nullptr; if (frame && frame->isAtReturn()) { stepInto(errorString); return; @@ -903,7 +711,7 @@ void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int if (debugger().getPauseOnExceptionsState() != pauseState) *errorString = "Internal error. Could not change pause on exceptions state"; else - m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, pauseState); + m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); } void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, @@ -982,71 +790,8 @@ void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d { if (!checkEnabled(errorString)) return; - m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); - internalSetAsyncCallStackDepth(depth); -} - -void V8DebuggerAgentImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) -{ - if (!m_maxAsyncCallStackDepth) - return; - v8::HandleScope scope(m_isolate); - std::unique_ptr chain = V8StackTraceImpl::capture(this, V8StackTrace::maxCallStackSizeToCapture, taskName); - if (chain) { - m_asyncTaskStacks.set(task, std::move(chain)); - if (recurring) - m_recurringTasks.add(task); - } -} - -void V8DebuggerAgentImpl::asyncTaskCanceled(void* task) -{ - if (!m_maxAsyncCallStackDepth) - return; - m_asyncTaskStacks.remove(task); - m_recurringTasks.remove(task); -} - -void V8DebuggerAgentImpl::asyncTaskStarted(void* task) -{ - // Not enabled, return. - if (!m_maxAsyncCallStackDepth) - return; - - m_currentTasks.append(task); - V8StackTraceImpl* stack = m_asyncTaskStacks.get(task); - // Needs to support following order of events: - // - asyncTaskScheduled - // <-- attached here --> - // - asyncTaskStarted - // - asyncTaskCanceled <-- canceled before finished - // <-- async stack requested here --> - // - asyncTaskFinished - m_currentStacks.append(stack ? stack->cloneImpl() : nullptr); -} - -void V8DebuggerAgentImpl::asyncTaskFinished(void* task) -{ - if (!m_maxAsyncCallStackDepth) - return; - // We could start instrumenting half way and the stack is empty. - if (!m_currentStacks.size()) - return; - - DCHECK(m_currentTasks.last() == task); - m_currentTasks.removeLast(); - - m_currentStacks.removeLast(); - if (!m_recurringTasks.contains(task)) - m_asyncTaskStacks.remove(task); -} - -void V8DebuggerAgentImpl::allAsyncTasksCanceled() -{ - m_asyncTaskStacks.clear(); - m_recurringTasks.clear(); - m_currentStacks.clear(); - m_currentTasks.clear(); + m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); + m_debugger->setAsyncCallStackDepth(this, depth); } void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::unique_ptr> patterns) @@ -1058,10 +803,13 @@ void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni } String16Builder patternBuilder; - patternBuilder.append("("); - for (size_t i = 0; i < patterns->length() - 1; ++i) - patternBuilder.append(patterns->get(i) + "|"); - patternBuilder.append(patterns->get(patterns->length() - 1) + ")"); + patternBuilder.append('('); + for (size_t i = 0; i < patterns->length() - 1; ++i) { + patternBuilder.append(patterns->get(i)); + patternBuilder.append("|"); + } + patternBuilder.append(patterns->get(patterns->length() - 1)); + patternBuilder.append(')'); String16 pattern = patternBuilder.toString(); if (!setBlackboxPattern(errorString, pattern)) return; @@ -1079,30 +827,32 @@ bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str return true; } -void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16& scriptId, std::unique_ptr> inPositions) +void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16& scriptId, + std::unique_ptr> inPositions) { - if (!m_scripts.contains(scriptId)) { + if (m_scripts.find(scriptId) == m_scripts.end()) { *error = "No script with passed id."; return; } if (!inPositions->length()) { - m_blackboxedPositions.remove(scriptId); + m_blackboxedPositions.erase(scriptId); return; } - protocol::Vector> positions(inPositions->length()); - for (size_t i = 0; i < positions.size(); ++i) { + std::vector> positions; + positions.reserve(inPositions->length()); + for (size_t i = 0; i < inPositions->length(); ++i) { protocol::Debugger::ScriptPosition* position = inPositions->get(i); - if (position->getLine() < 0) { + if (position->getLineNumber() < 0) { *error = "Position missing 'line' or 'line' < 0."; return; } - if (position->getColumn() < 0) { + if (position->getColumnNumber() < 0) { *error = "Position missing 'column' or 'column' < 0."; return; } - positions[i] = std::make_pair(position->getLine(), position->getColumn()); + positions.push_back(std::make_pair(position->getLineNumber(), position->getColumnNumber())); } for (size_t i = 1; i < positions.size(); ++i) { @@ -1114,7 +864,7 @@ void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 return; } - m_blackboxedPositions.set(scriptId, positions); + m_blackboxedPositions[scriptId] = positions; } void V8DebuggerAgentImpl::willExecuteScript(int scriptId) @@ -1124,7 +874,7 @@ void V8DebuggerAgentImpl::willExecuteScript(int scriptId) if (m_scheduledDebuggerStep != StepInto) return; // Skip unknown scripts (e.g. InjectedScript). - if (!m_scripts.contains(String16::number(scriptId))) + if (m_scripts.find(String16::fromInteger(scriptId)) == m_scripts.end()) return; schedulePauseOnNextStatementIfSteppingInto(); } @@ -1172,19 +922,14 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) return Array::create(); ErrorString ignored; - InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(m_pausedContext.Get(m_isolate))); - if (!topFrameInjectedScript) { - // Context has been reported as removed while on pause. - return Array::create(); - } - v8::HandleScope handles(m_isolate); - v8::Local context = topFrameInjectedScript->context()->context(); - v8::Context::Scope contextScope(context); + v8::Local debuggerContext = v8::Debug::GetDebugContext(m_isolate); + v8::Context::Scope contextScope(debuggerContext); v8::Local objects = v8::Array::New(m_isolate); + for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++frameOrdinal) { - JavaScriptCallFrame* currentCallFrame = m_pausedCallFrames[frameOrdinal]; + const std::unique_ptr& currentCallFrame = m_pausedCallFrames[frameOrdinal]; v8::Local details = currentCallFrame->details(); if (hasInternalError(errorString, details.IsEmpty())) @@ -1192,34 +937,42 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt int contextId = currentCallFrame->contextId(); InjectedScript* injectedScript = contextId ? m_session->findInjectedScript(&ignored, contextId) : nullptr; - if (!injectedScript) - injectedScript = topFrameInjectedScript; - String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->context()->contextId(), frameOrdinal); - if (hasInternalError(errorString, !details->Set(context, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false))) + String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdinal); + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false))) return Array::create(); - v8::Local scopeChain; - if (hasInternalError(errorString, !details->Get(context, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray())) - return Array::create(); - v8::Local scopeChainArray = scopeChain.As(); - if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup)) - return Array::create(); - - if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) - return Array::create(); - - if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) { - if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup)) + if (injectedScript) { + v8::Local scopeChain; + if (hasInternalError(errorString, !details->Get(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray())) + return Array::create(); + v8::Local scopeChainArray = scopeChain.As(); + if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + if (details->Has(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) { + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + } + } else { + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain"), v8::Array::New(m_isolate, 0)).FromMaybe(false))) + return Array::create(); + v8::Local remoteObject = v8::Object::New(m_isolate); + if (hasInternalError(errorString, !remoteObject->Set(debuggerContext, toV8StringInternalized(m_isolate, "type"), toV8StringInternalized(m_isolate, "undefined")).FromMaybe(false))) + return Array::create(); + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "this"), remoteObject).FromMaybe(false))) + return Array::create(); + if (hasInternalError(errorString, !details->Delete(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false))) return Array::create(); } - if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, details).FromMaybe(false))) + if (hasInternalError(errorString, !objects->Set(debuggerContext, frameOrdinal, details).FromMaybe(false))) return Array::create(); } protocol::ErrorSupport errorSupport; - std::unique_ptr> callFrames = Array::parse(toProtocolValue(context, objects).get(), &errorSupport); + std::unique_ptr> callFrames = Array::parse(toProtocolValue(debuggerContext, objects).get(), &errorSupport); if (hasInternalError(errorString, !callFrames)) return Array::create(); return callFrames; @@ -1227,60 +980,50 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt std::unique_ptr V8DebuggerAgentImpl::currentAsyncStackTrace() { - if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStacks.size() || !m_currentStacks.last()) - return nullptr; - - return m_currentStacks.last()->buildInspectorObjectForTail(this); -} - -V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() -{ - if (!m_currentStacks.size()) + if (m_pausedContext.IsEmpty()) return nullptr; - return m_currentStacks.last(); + V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); + return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nullptr; } -void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScript) +void V8DebuggerAgentImpl::didParseSource(std::unique_ptr script, bool success) { - V8DebuggerScript script = parsedScript.script; - + v8::HandleScope handles(m_isolate); + String16 scriptSource = toProtocolString(script->source(m_isolate)); bool isDeprecatedSourceURL = false; - if (!parsedScript.success) - script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL)); - else if (script.hasSourceURL()) - V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL); + if (!success) + script->setSourceURL(V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL)); + else if (script->hasSourceURL()) + V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL); bool isDeprecatedSourceMappingURL = false; - if (!parsedScript.success) - script.setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL)); - else if (!script.sourceMappingURL().isEmpty()) - V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL); - - script.setHash(calculateHash(script.source())); - - int executionContextId = script.executionContextId(); - bool isContentScript = script.isContentScript(); - bool isInternalScript = script.isInternalScript(); - bool isLiveEdit = script.isLiveEdit(); - bool hasSourceURL = script.hasSourceURL(); - String16 scriptURL = script.sourceURL(); - String16 sourceMapURL = script.sourceMappingURL(); + if (!success) + script->setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL)); + else if (!script->sourceMappingURL().isEmpty()) + V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL); + + bool isContentScript = script->isContentScript(); + bool isInternalScript = script->isInternalScript(); + bool isLiveEdit = script->isLiveEdit(); + bool hasSourceURL = script->hasSourceURL(); + String16 scriptId = script->scriptId(); + String16 scriptURL = script->sourceURL(); bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceMappingURL; - const Maybe& sourceMapURLParam = sourceMapURL; + const Maybe& sourceMapURLParam = script->sourceMappingURL(); const bool* isContentScriptParam = isContentScript ? &isContentScript : nullptr; const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : nullptr; const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &deprecatedCommentWasUsed : nullptr; - if (parsedScript.success) - m_frontend.scriptParsed(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); + if (success) + m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); else - m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); + m_frontend.scriptFailedToParse(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); - m_scripts.set(parsedScript.scriptId, script); + m_scripts[scriptId] = std::move(script); - if (scriptURL.isEmpty() || !parsedScript.success) + if (scriptURL.isEmpty() || !success) return; protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); @@ -1297,24 +1040,24 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr if (!matches(m_debugger, scriptURL, url, isRegex)) continue; ScriptBreakpoint breakpoint; - breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.lineNumber); - breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoint.columnNumber); + breakpointObject->getInteger(DebuggerAgentState::lineNumber, &breakpoint.lineNumber); + breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoint.columnNumber); breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.condition); - std::unique_ptr location = resolveBreakpoint(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); + std::unique_ptr location = resolveBreakpoint(cookie.first, scriptId, breakpoint, UserBreakpointSource); if (location) m_frontend.breakpointResolved(cookie.first, std::move(location)); } } -V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local context, v8::Local exception, const protocol::Vector& hitBreakpoints, bool isPromiseRejection) +V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local context, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection) { JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); - JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr; + JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()->get() : nullptr; V8DebuggerAgentImpl::SkipPauseRequest result; if (m_skipAllPauses) result = RequestContinue; - else if (!hitBreakpoints.isEmpty()) + else if (!hitBreakpoints.empty()) result = RequestNoSkip; // Don't skip explicit breakpoints even if set in frameworks. else if (!exception.IsEmpty()) result = shouldSkipExceptionPause(topCallFrame); @@ -1331,13 +1074,14 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::LocalfindInjectedScript(&ignored, V8Debugger::contextId(context)); + InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8DebuggerImpl::contextId(context)); if (injectedScript) { m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; ErrorString errorString; @@ -1352,10 +1096,10 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Localsecond->first; + const String16& localId = breakpointIterator->second.first; hitBreakpointIds->addItem(localId); - BreakpointSource source = breakpointIterator->second->second; + BreakpointSource source = breakpointIterator->second.second; if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other && source == DebugCommandBreakpointSource) m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCommand; } @@ -1440,7 +1184,6 @@ void V8DebuggerAgentImpl::reset() m_scripts.clear(); m_blackboxedPositions.clear(); m_breakpointIdToDebuggerBreakpointIds.clear(); - allAsyncTasksCanceled(); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h similarity index 82% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h index ab04bb50a43a11..b6aea619e10318 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h @@ -10,6 +10,8 @@ #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/protocol/Debugger.h" +#include + namespace blink { class JavaScriptCallFrame; @@ -84,21 +86,12 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { Maybe>* optOutCallFrames, Maybe* optOutStackChanged, Maybe* optOutAsyncStackTrace, - Maybe* optOutCompileError) override; + Maybe* optOutCompileError) override; void restartFrame(ErrorString*, const String16& callFrameId, std::unique_ptr>* newCallFrames, Maybe* asyncStackTrace) override; void getScriptSource(ErrorString*, const String16& scriptId, String16* scriptSource) override; - void getFunctionDetails(ErrorString*, - const String16& functionId, - std::unique_ptr*) override; - void getGeneratorObjectDetails(ErrorString*, - const String16& objectId, - std::unique_ptr*) override; - void getCollectionEntries(ErrorString*, - const String16& objectId, - std::unique_ptr>*) override; void pause(ErrorString*) override; void resume(ErrorString*) override; void stepOver(ErrorString*) override; @@ -138,27 +131,16 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { void breakProgram(const String16& breakReason, std::unique_ptr data); void breakProgramOnException(const String16& breakReason, std::unique_ptr data); - // Async call stacks implementation. - void asyncTaskScheduled(const String16& taskName, void* task, bool recurring); - void asyncTaskCanceled(void* task); - void asyncTaskStarted(void* task); - void asyncTaskFinished(void* task); - void allAsyncTasksCanceled(); - void reset(); // Interface for V8DebuggerImpl - SkipPauseRequest didPause(v8::Local, v8::Local exception, const protocol::Vector& hitBreakpoints, bool isPromiseRejection); + SkipPauseRequest didPause(v8::Local, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection); void didContinue(); - void didParseSource(const V8DebuggerParsedScript&); - bool v8AsyncTaskEventsEnabled() const; - void didReceiveV8AsyncTaskEvent(v8::Local, const String16& eventType, const String16& eventName, int id); + void didParseSource(std::unique_ptr, bool success); void willExecuteScript(int scriptId); void didExecuteScript(); v8::Isolate* isolate() { return m_isolate; } - int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } - V8StackTraceImpl* currentAsyncCallChain(); private: bool checkEnabled(ErrorString*); @@ -190,8 +172,8 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { bool setBlackboxPattern(ErrorString*, const String16& pattern); - using ScriptsMap = protocol::HashMap; - using BreakpointIdToDebuggerBreakpointIdsMap = protocol::HashMap>; + using ScriptsMap = protocol::HashMap>; + using BreakpointIdToDebuggerBreakpointIdsMap = protocol::HashMap>; using DebugServerBreakpointToBreakpointIdAndSourceMap = protocol::HashMap>; using MuteBreakpoins = protocol::HashMap>; @@ -227,14 +209,8 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { int m_recursionLevelForStepFrame; bool m_skipAllPauses; - using AsyncTaskToStackTrace = protocol::HashMap>; - AsyncTaskToStackTrace m_asyncTaskStacks; - protocol::HashSet m_recurringTasks; - int m_maxAsyncCallStackDepth; - protocol::Vector m_currentTasks; - protocol::Vector> m_currentStacks; std::unique_ptr m_blackboxPattern; - protocol::HashMap>> m_blackboxedPositions; + protocol::HashMap>> m_blackboxedPositions; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp similarity index 59% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp index 387bc4b86693a1..4d84b32cece21b 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp @@ -36,8 +36,12 @@ #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/ScriptBreakpoint.h" #include "platform/v8_inspector/V8Compat.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" +#include "platform/v8_inspector/V8InjectedScriptHost.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8InternalValueType.h" #include "platform/v8_inspector/V8RuntimeAgentImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -50,6 +54,9 @@ namespace { const char stepIntoV8MethodName[] = "stepIntoStatement"; const char stepOutV8MethodName[] = "stepOutOfFunction"; volatile int s_lastContextId = 0; +static const char v8AsyncTaskEventEnqueue[] = "enqueue"; +static const char v8AsyncTaskEventWillHandle[] = "willHandle"; +static const char v8AsyncTaskEventDidHandle[] = "didHandle"; inline v8::Local v8Boolean(bool value, v8::Isolate* isolate) { @@ -77,9 +84,12 @@ std::unique_ptr V8Debugger::create(v8::Isolate* isolate, V8DebuggerC V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) : m_isolate(isolate) , m_client(client) + , m_capturingStackTracesCount(0) + , m_lastExceptionId(0) , m_enabledAgentsCount(0) , m_breakpointsActivated(true) , m_runningNestedMessageLoop(false) + , m_maxAsyncCallStackDepth(0) { } @@ -102,6 +112,7 @@ void V8DebuggerImpl::disable() clearBreakpoints(); m_debuggerScript.Reset(); m_debuggerContext.Reset(); + allAsyncTasksCanceled(); v8::Debug::SetDebugEventListener(m_isolate, nullptr); } @@ -110,7 +121,8 @@ bool V8DebuggerImpl::enabled() const return !m_debuggerScript.IsEmpty(); } -int V8Debugger::contextId(v8::Local context) +// static +int V8DebuggerImpl::contextId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -127,7 +139,8 @@ int V8Debugger::contextId(v8::Local context) return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); } -static int getGroupId(v8::Local context) +// static +int V8DebuggerImpl::getGroupId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -157,10 +170,13 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId { if (!contextGroupId) return nullptr; - V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); - if (session && session->debuggerAgent()->enabled()) - return session->debuggerAgent(); - return nullptr; + SessionMap::iterator it = m_sessions.find(contextGroupId); + if (it == m_sessions.end()) + return nullptr; + V8DebuggerAgentImpl* agent = it->second->debuggerAgent(); + if (!agent->enabled()) + return nullptr; + return agent; } V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local context) @@ -168,7 +184,7 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local& result) +void V8DebuggerImpl::getCompiledScripts(int contextGroupId, std::vector>& result) { v8::HandleScope scope(m_isolate); v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); @@ -181,9 +197,11 @@ void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::VectorIsArray()); v8::Local scriptsArray = v8::Local::Cast(value); - result.resize(scriptsArray->Length()); - for (unsigned i = 0; i < scriptsArray->Length(); ++i) - result[i] = createParsedScript(v8::Local::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i))), true); + result.reserve(scriptsArray->Length()); + for (unsigned i = 0; i < scriptsArray->Length(); ++i) { + v8::Local scriptObject = v8::Local::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i))); + result.push_back(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope))); + } } String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation) @@ -298,7 +316,7 @@ void V8DebuggerImpl::breakProgram() v8::HandleScope scope(m_isolate); v8::Local breakFunction; - if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::breakProgramCallback, v8::External::New(m_isolate, this)).ToLocal(&breakFunction)) + if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::breakProgramCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction)) return; v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked(); } @@ -351,7 +369,7 @@ void V8DebuggerImpl::clearStepping() callDebuggerMethod("clearStepping", 0, argv); } -bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& newContent, bool preview, ErrorString* error, Maybe* errorData, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) +bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString* error, Maybe* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) { class EnableLiveEditScope { public: @@ -376,7 +394,7 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n if (!isPaused()) contextScope = wrapUnique(new v8::Context::Scope(debuggerContext())); - v8::Local argv[] = { toV8String(m_isolate, sourceID), toV8String(m_isolate, newContent), v8Boolean(preview, m_isolate) }; + v8::Local argv[] = { toV8String(m_isolate, sourceID), newSource, v8Boolean(preview, m_isolate) }; v8::Local v8result; { @@ -402,17 +420,20 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n { *stackChanged = resultTuple->Get(1)->BooleanValue(); // Call stack may have changed after if the edited function was on the stack. - if (!preview && isPaused()) - newCallFrames->swap(currentCallFrames()); + if (!preview && isPaused()) { + JavaScriptCallFrames frames = currentCallFrames(); + newCallFrames->swap(frames); + } return true; } // Compile error. case 1: { - *errorData = protocol::Debugger::SetScriptSourceError::create() - .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2))) - .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value()) - .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value()).build(); + *exceptionDetails = protocol::Runtime::ExceptionDetails::create() + .setText(toProtocolStringWithTypeCheck(resultTuple->Get(2))) + .setScriptId(String16("0")) + .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1) + .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1).build(); return false; } } @@ -444,7 +465,7 @@ JavaScriptCallFrames V8DebuggerImpl::currentCallFrames(int limit) if (!callFrameValue->IsObject()) return JavaScriptCallFrames(); v8::Local callFrameObject = callFrameValue.As(); - callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Local::Cast(callFrameObject))); + callFrames.push_back(JavaScriptCallFrame::create(debuggerContext(), v8::Local::Cast(callFrameObject))); } return callFrames; } @@ -475,13 +496,13 @@ void V8DebuggerImpl::handleProgramBreak(v8::Local pausedContext, v8 if (!agent) return; - protocol::Vector breakpointIds; + std::vector breakpointIds; if (!hitBreakpointNumbers.IsEmpty()) { - breakpointIds.resize(hitBreakpointNumbers->Length()); + breakpointIds.reserve(hitBreakpointNumbers->Length()); for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { v8::Local hitBreakpointNumber = hitBreakpointNumbers->Get(i); DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32()); - breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value()); + breakpointIds.push_back(String16::fromInteger(hitBreakpointNumber->Int32Value())); } } @@ -539,6 +560,12 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local eventContext = eventDetails.GetEventContext(); DCHECK(!eventContext.IsEmpty()); + if (event == v8::AsyncTaskEvent) { + v8::HandleScope scope(m_isolate); + handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), eventDetails.GetEventData()); + return; + } + V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext); if (agent) { v8::HandleScope scope(m_isolate); @@ -547,8 +574,8 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local argv[] = { eventDetails.GetEventData() }; v8::Local value = callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked(); DCHECK(value->IsObject()); - v8::Local object = v8::Local::Cast(value); - agent->didParseSource(createParsedScript(object, event == v8::AfterCompile)); + v8::Local scriptObject = v8::Local::Cast(value); + agent->didParseSource(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope)), event == v8::AfterCompile); } else if (event == v8::Exception) { v8::Local eventData = eventDetails.GetEventData(); v8::Local exception = callInternalGetterFunction(eventData, "exception"); @@ -560,42 +587,35 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local hitBreakpoints = callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked(); DCHECK(hitBreakpoints->IsArray()); handleProgramBreak(eventContext, eventDetails.GetExecutionState(), v8::Local(), hitBreakpoints.As()); - } else if (event == v8::AsyncTaskEvent) { - if (agent->v8AsyncTaskEventsEnabled()) - handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExecutionState(), eventDetails.GetEventData()); } } } -void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Local context, v8::Local executionState, v8::Local eventData) +void V8DebuggerImpl::handleV8AsyncTaskEvent(v8::Local context, v8::Local executionState, v8::Local eventData) { + if (!m_maxAsyncCallStackDepth) + return; + String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "type")); String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "name")); int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)->Value(); - agent->didReceiveV8AsyncTaskEvent(context, type, name, id); + // The scopes for the ids are defined by the eventData.name namespaces. There are currently two namespaces: "Object." and "Promise.". + void* ptr = reinterpret_cast(id * 4 + (name[0] == 'P' ? 2 : 0) + 1); + if (type == v8AsyncTaskEventEnqueue) + asyncTaskScheduled(name, ptr, false); + else if (type == v8AsyncTaskEventWillHandle) + asyncTaskStarted(ptr); + else if (type == v8AsyncTaskEventDidHandle) + asyncTaskFinished(ptr); + else + NOTREACHED(); } -V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local object, bool success) +V8StackTraceImpl* V8DebuggerImpl::currentAsyncCallChain() { - v8::Local id = object->Get(v8InternalizedString("id")); - DCHECK(!id.IsEmpty() && id->IsInt32()); - - V8DebuggerParsedScript parsedScript; - parsedScript.scriptId = String16::number(id->Int32Value()); - parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("name")))) - .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceURL")))) - .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceMappingURL")))) - .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("source")))) - .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(m_isolate)->Value()) - .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInteger(m_isolate)->Value()) - .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_isolate)->Value()) - .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(m_isolate)->Value()) - .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))->ToBoolean(m_isolate)->Value()) - .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"))->ToBoolean(m_isolate)->Value()) - .setExecutionContextId(object->Get(v8InternalizedString("executionContextId"))->ToInteger(m_isolate)->Value()) - .setIsLiveEdit(inLiveEditScope); - parsedScript.success = success; - return parsedScript; + if (!m_currentStacks.size()) + return nullptr; + return m_currentStacks.back().get(); } void V8DebuggerImpl::compileDebuggerScript() @@ -634,27 +654,118 @@ v8::MaybeLocal V8DebuggerImpl::functionScopes(v8::Local return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); } v8::Local argv[] = { function }; - return callDebuggerMethod("getFunctionScopes", 1, argv); + v8::Local scopesValue; + if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue) || !scopesValue->IsArray()) + return v8::MaybeLocal(); + v8::Local scopes = scopesValue.As(); + v8::Local context = m_debuggerContext.Get(m_isolate); + if (!markAsInternal(context, scopes, V8InternalValueType::kScopeList)) + return v8::MaybeLocal(); + if (!markArrayEntriesAsInternal(context, scopes, V8InternalValueType::kScope)) + return v8::MaybeLocal(); + if (!scopes->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) + return v8::Undefined(m_isolate); + return scopes; +} + +v8::MaybeLocal V8DebuggerImpl::internalProperties(v8::Local context, v8::Local value) +{ + v8::Local properties; + if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) + return v8::MaybeLocal(); + if (value->IsFunction()) { + v8::Local function = value.As(); + v8::Local location = functionLocation(context, function); + if (location->IsObject()) { + properties->Set(properties->Length(), v8InternalizedString("[[FunctionLocation]]")); + properties->Set(properties->Length(), location); + } + if (function->IsGeneratorFunction()) { + properties->Set(properties->Length(), v8InternalizedString("[[IsGenerator]]")); + properties->Set(properties->Length(), v8::True(m_isolate)); + } + } + if (!enabled()) + return properties; + if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakSet() || value->IsSetIterator() || value->IsMapIterator()) { + v8::Local entries = collectionEntries(context, v8::Local::Cast(value)); + if (entries->IsArray()) { + properties->Set(properties->Length(), v8InternalizedString("[[Entries]]")); + properties->Set(properties->Length(), entries); + } + } + if (value->IsGeneratorObject()) { + v8::Local location = generatorObjectLocation(v8::Local::Cast(value)); + if (location->IsObject()) { + properties->Set(properties->Length(), v8InternalizedString("[[GeneratorLocation]]")); + properties->Set(properties->Length(), location); + } + } + if (value->IsFunction()) { + v8::Local function = value.As(); + v8::Local boundFunction = function->GetBoundFunction(); + v8::Local scopes; + if (boundFunction->IsUndefined() && functionScopes(function).ToLocal(&scopes)) { + properties->Set(properties->Length(), v8InternalizedString("[[Scopes]]")); + properties->Set(properties->Length(), scopes); + } + } + return properties; } -v8::Local V8DebuggerImpl::generatorObjectDetails(v8::Local& object) +v8::Local V8DebuggerImpl::collectionEntries(v8::Local context, v8::Local object) { if (!enabled()) { NOTREACHED(); - return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); + return v8::Undefined(m_isolate); } v8::Local argv[] = { object }; - return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalChecked(); + v8::Local entriesValue = callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); + if (!entriesValue->IsArray()) + return v8::Undefined(m_isolate); + v8::Local entries = entriesValue.As(); + if (!markArrayEntriesAsInternal(context, entries, V8InternalValueType::kEntry)) + return v8::Undefined(m_isolate); + if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) + return v8::Undefined(m_isolate); + return entries; } -v8::Local V8DebuggerImpl::collectionEntries(v8::Local& object) +v8::Local V8DebuggerImpl::generatorObjectLocation(v8::Local object) { if (!enabled()) { NOTREACHED(); - return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); + return v8::Null(m_isolate); } v8::Local argv[] = { object }; - return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); + v8::Local location = callDebuggerMethod("getGeneratorObjectLocation", 1, argv).ToLocalChecked(); + if (!location->IsObject()) + return v8::Null(m_isolate); + v8::Local context = m_debuggerContext.Get(m_isolate); + if (!markAsInternal(context, v8::Local::Cast(location), V8InternalValueType::kLocation)) + return v8::Null(m_isolate); + return location; +} + +v8::Local V8DebuggerImpl::functionLocation(v8::Local context, v8::Local function) +{ + int scriptId = function->ScriptId(); + if (scriptId == v8::UnboundScript::kNoScriptId) + return v8::Null(m_isolate); + int lineNumber = function->GetScriptLineNumber(); + int columnNumber = function->GetScriptColumnNumber(); + if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::Function::kLineOffsetNotFound) + return v8::Null(m_isolate); + v8::Local location = v8::Object::New(m_isolate); + if (!location->Set(context, v8InternalizedString("scriptId"), toV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false)) + return v8::Null(m_isolate); + if (!location->Set(context, v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) + return v8::Null(m_isolate); + if (!location->Set(context, v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false)) + return v8::Null(m_isolate); + if (!markAsInternal(context, location, V8InternalValueType::kLocation)) + return v8::Null(m_isolate); + return location; } bool V8DebuggerImpl::isPaused() @@ -725,24 +836,59 @@ v8::Local V8DebuggerImpl::compileInternalScript(v8::Localsecond.get(); +} + std::unique_ptr V8DebuggerImpl::createStackTrace(v8::Local stackTrace) { - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentContext()); - return V8StackTraceImpl::create(agent, stackTrace, V8StackTrace::maxCallStackSizeToCapture); + int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; + return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTraceImpl::maxCallStackSizeToCapture); } std::unique_ptr V8DebuggerImpl::connect(int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state) { - DCHECK(!m_sessions.contains(contextGroupId)); - std::unique_ptr session = V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state); - m_sessions.set(contextGroupId, session.get()); + DCHECK(m_sessions.find(contextGroupId) == m_sessions.cend()); + std::unique_ptr session = + V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state); + m_sessions[contextGroupId] = session.get(); return std::move(session); } void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session) { - DCHECK(m_sessions.contains(session->contextGroupId())); - m_sessions.remove(session->contextGroupId()); + DCHECK(m_sessions.find(session->contextGroupId()) != m_sessions.end()); + m_sessions.erase(session->contextGroupId()); +} + +InspectedContext* V8DebuggerImpl::getContext(int groupId, int contextId) const +{ + ContextsByGroupMap::const_iterator contextGroupIt = m_contexts.find(groupId); + if (contextGroupIt == m_contexts.end()) + return nullptr; + + ContextByIdMap::iterator contextIt = contextGroupIt->second->find(contextId); + if (contextIt == contextGroupIt->second->end()) + return nullptr; + + return contextIt->second.get(); } void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) @@ -750,44 +896,144 @@ void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) DCHECK(info.context->GetIsolate() == m_isolate); // TODO(dgozman): make s_lastContextId non-static. int contextId = atomicIncrement(&s_lastContextId); - String16 debugData = String16::number(info.contextGroupId) + "," + String16::number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); + String16 debugData = String16::fromInteger(info.contextGroupId) + "," + String16::fromInteger(contextId) + "," + (info.isDefault ? "default" : "nondefault"); v8::HandleScope scope(m_isolate); v8::Context::Scope contextScope(info.context); info.context->SetEmbedderData(static_cast(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); - if (!m_contexts.contains(info.contextGroupId)) - m_contexts.set(info.contextGroupId, wrapUnique(new ContextByIdMap())); - DCHECK(!m_contexts.get(info.contextGroupId)->contains(contextId)); + ContextsByGroupMap::iterator contextIt = m_contexts.find(info.contextGroupId); + if (contextIt == m_contexts.end()) + contextIt = m_contexts.insert(std::make_pair(info.contextGroupId, wrapUnique(new ContextByIdMap()))).first; - std::unique_ptr contextOwner(new InspectedContext(this, info, contextId)); - InspectedContext* inspectedContext = contextOwner.get(); - m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner)); + const auto& contextById = contextIt->second; - if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) - session->runtimeAgent()->reportExecutionContextCreated(inspectedContext); + DCHECK(contextById->find(contextId) == contextById->cend()); + InspectedContext* context = new InspectedContext(this, info, contextId); + (*contextById)[contextId] = wrapUnique(context); + SessionMap::iterator sessionIt = m_sessions.find(info.contextGroupId); + if (sessionIt != m_sessions.end()) + sessionIt->second->runtimeAgent()->reportExecutionContextCreated(context); } void V8DebuggerImpl::contextDestroyed(v8::Local context) { - int contextId = V8Debugger::contextId(context); + int contextId = V8DebuggerImpl::contextId(context); int contextGroupId = getGroupId(context); - if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)->contains(contextId)) - return; - InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(contextId); - if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) - session->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext); + ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); + if (storageIt != m_consoleStorageMap.end()) + storageIt->second->contextDestroyed(contextId); + + InspectedContext* inspectedContext = getContext(contextGroupId, contextId); + if (!inspectedContext) + return; - m_contexts.get(contextGroupId)->remove(contextId); - if (m_contexts.get(contextGroupId)->isEmpty()) - m_contexts.remove(contextGroupId); + SessionMap::iterator iter = m_sessions.find(contextGroupId); + if (iter != m_sessions.end()) + iter->second->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext); + discardInspectedContext(contextGroupId, contextId); } void V8DebuggerImpl::resetContextGroup(int contextGroupId) { - if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) - session->reset(); - m_contexts.remove(contextGroupId); + m_consoleStorageMap.erase(contextGroupId); + SessionMap::iterator session = m_sessions.find(contextGroupId); + if (session != m_sessions.end()) + session->second->reset(); + m_contexts.erase(contextGroupId); +} + +void V8DebuggerImpl::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) +{ + if (depth <= 0) + m_maxAsyncCallStackDepthMap.erase(agent); + else + m_maxAsyncCallStackDepthMap[agent] = depth; + + int maxAsyncCallStackDepth = 0; + for (const auto& pair : m_maxAsyncCallStackDepthMap) { + if (pair.second > maxAsyncCallStackDepth) + maxAsyncCallStackDepth = pair.second; + } + + if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) + return; + + if (maxAsyncCallStackDepth && !m_maxAsyncCallStackDepth) + m_client->enableAsyncInstrumentation(); + else if (!maxAsyncCallStackDepth && m_maxAsyncCallStackDepth) + m_client->disableAsyncInstrumentation(); + + m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; + if (!maxAsyncCallStackDepth) + allAsyncTasksCanceled(); +} + +void V8DebuggerImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) +{ + if (!m_maxAsyncCallStackDepth) + return; + v8::HandleScope scope(m_isolate); + int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; + std::unique_ptr chain = V8StackTraceImpl::capture(this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName); + if (chain) { + m_asyncTaskStacks[task] = std::move(chain); + if (recurring) + m_recurringTasks.insert(task); + } +} + +void V8DebuggerImpl::asyncTaskCanceled(void* task) +{ + if (!m_maxAsyncCallStackDepth) + return; + m_asyncTaskStacks.erase(task); + m_recurringTasks.erase(task); +} + +void V8DebuggerImpl::asyncTaskStarted(void* task) +{ + // Not enabled, return. + if (!m_maxAsyncCallStackDepth) + return; + + m_currentTasks.push_back(task); + AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find(task); + // Needs to support following order of events: + // - asyncTaskScheduled + // <-- attached here --> + // - asyncTaskStarted + // - asyncTaskCanceled <-- canceled before finished + // <-- async stack requested here --> + // - asyncTaskFinished + std::unique_ptr stack; + if (stackIt != m_asyncTaskStacks.end() && stackIt->second) + stack = stackIt->second->cloneImpl(); + m_currentStacks.push_back(std::move(stack)); +} + +void V8DebuggerImpl::asyncTaskFinished(void* task) +{ + if (!m_maxAsyncCallStackDepth) + return; + // We could start instrumenting half way and the stack is empty. + if (!m_currentStacks.size()) + return; + + DCHECK(m_currentTasks.back() == task); + m_currentTasks.pop_back(); + + m_currentStacks.pop_back(); + if (m_recurringTasks.find(task) == m_recurringTasks.end()) + m_asyncTaskStacks.erase(task); +} + +void V8DebuggerImpl::allAsyncTasksCanceled() +{ + m_asyncTaskStacks.clear(); + m_recurringTasks.clear(); + m_currentStacks.clear(); + m_currentTasks.clear(); } void V8DebuggerImpl::willExecuteScript(v8::Local context, int scriptId) @@ -812,10 +1058,64 @@ void V8DebuggerImpl::idleFinished() m_isolate->GetCpuProfiler()->SetIdle(false); } -std::unique_ptr V8DebuggerImpl::captureStackTrace(size_t maxStackSize) +void V8DebuggerImpl::logToConsole(v8::Local context, v8::Local arg1, v8::Local arg2) +{ + int contextGroupId = getGroupId(context); + InspectedContext* inspectedContext = getContext(contextGroupId, contextId(context)); + if (!inspectedContext) + return; + std::vector> arguments; + if (!arg1.IsEmpty()) + arguments.push_back(arg1); + if (!arg2.IsEmpty()) + arguments.push_back(arg2); + ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::createForConsoleAPI(m_client->currentTimeMS(), ConsoleAPIType::kLog, arguments, captureStackTrace(false), inspectedContext)); +} + +void V8DebuggerImpl::exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + unsigned exceptionId = ++m_lastExceptionId; + std::unique_ptr consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, m_isolate, 0, v8::Local(), exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); +} + +unsigned V8DebuggerImpl::promiseRejected(v8::Local context, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + int contextGroupId = getGroupId(context); + if (!contextGroupId) + return 0; + unsigned exceptionId = ++m_lastExceptionId; + std::unique_ptr consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, m_isolate, contextId(context), exception, exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); + return exceptionId; +} + +void V8DebuggerImpl::promiseRejectionRevoked(v8::Local context, unsigned promiseRejectionId) +{ + int contextGroupId = getGroupId(context); + if (!contextGroupId) + return; + + std::unique_ptr consoleMessage = V8ConsoleMessage::createForRevokedException(m_client->currentTimeMS(), "Handler added to rejected promise", promiseRejectionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); +} + +std::unique_ptr V8DebuggerImpl::captureStackTrace(bool fullStack) { - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentContext()); - return V8StackTraceImpl::capture(agent, maxStackSize); + if (!m_isolate->InContext()) + return nullptr; + + v8::HandleScope handles(m_isolate); + int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); + if (!contextGroupId) + return nullptr; + + size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; + SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); + if (sessionIt != m_sessions.end() && sessionIt->second->runtimeAgent()->enabled()) + stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; + + return V8StackTraceImpl::capture(this, contextGroupId, stackSize); } v8::Local V8DebuggerImpl::regexContext() @@ -827,23 +1127,25 @@ v8::Local V8DebuggerImpl::regexContext() void V8DebuggerImpl::discardInspectedContext(int contextGroupId, int contextId) { - if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)->contains(contextId)) + if (!getContext(contextGroupId, contextId)) return; - m_contexts.get(contextGroupId)->remove(contextId); - if (m_contexts.get(contextGroupId)->isEmpty()) - m_contexts.remove(contextGroupId); + m_contexts[contextGroupId]->erase(contextId); + if (m_contexts[contextGroupId]->empty()) + m_contexts.erase(contextGroupId); } const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGroupId) { - if (!m_contexts.contains(contextGroupId)) - return nullptr; - return m_contexts.get(contextGroupId); + ContextsByGroupMap::iterator iter = m_contexts.find(contextGroupId); + return iter == m_contexts.end() ? nullptr : iter->second.get(); } V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupId) { - return contextGroupId ? m_sessions.get(contextGroupId) : nullptr; + if (!contextGroupId) + return nullptr; + SessionMap::iterator iter = m_sessions.find(contextGroupId); + return iter == m_sessions.end() ? nullptr : iter->second; } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h similarity index 69% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h index b62a2a003a5661..0be86bfb28ae52 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h @@ -31,6 +31,7 @@ #ifndef V8DebuggerImpl_h #define V8DebuggerImpl_h +#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Maybe.h" #include "platform/inspector_protocol/Platform.h" #include "platform/v8_inspector/JavaScriptCallFrame.h" @@ -40,6 +41,9 @@ #include #include +#include + +#include namespace blink { @@ -47,9 +51,11 @@ using protocol::Maybe; struct ScriptBreakpoint; class InspectedContext; +class V8ConsoleMessageStorage; class V8DebuggerAgentImpl; class V8InspectorSessionImpl; class V8RuntimeAgentImpl; +class V8StackTraceImpl; class V8DebuggerImpl : public V8Debugger { PROTOCOL_DISALLOW_COPY(V8DebuggerImpl); @@ -57,6 +63,9 @@ class V8DebuggerImpl : public V8Debugger { V8DebuggerImpl(v8::Isolate*, V8DebuggerClient*); ~V8DebuggerImpl() override; + static int contextId(v8::Local); + static int getGroupId(v8::Local); + bool enabled() const; String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation); @@ -80,22 +89,24 @@ class V8DebuggerImpl : public V8Debugger { void stepOutOfFunction(); void clearStepping(); - bool setScriptSource(const String16& sourceID, const String16& newContent, bool preview, ErrorString*, Maybe*, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged); + bool setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString*, Maybe*, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged); JavaScriptCallFrames currentCallFrames(int limit = 0); // Each script inherits debug data from v8::Context where it has been compiled. // Only scripts whose debug data matches |contextGroupId| will be reported. // Passing 0 will result in reporting all scripts. - void getCompiledScripts(int contextGroupId, protocol::Vector&); + void getCompiledScripts(int contextGroupId, std::vector>&); void debuggerAgentEnabled(); void debuggerAgentDisabled(); - bool isPaused() override; + bool isPaused(); v8::Local pausedContext() { return m_pausedContext; } + int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } + V8StackTraceImpl* currentAsyncCallChain(); + void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int); v8::MaybeLocal functionScopes(v8::Local); - v8::Local generatorObjectDetails(v8::Local&); - v8::Local collectionEntries(v8::Local&); + v8::MaybeLocal internalProperties(v8::Local, v8::Local); v8::Isolate* isolate() const { return m_isolate; } V8DebuggerClient* client() { return m_client; } @@ -106,6 +117,10 @@ class V8DebuggerImpl : public V8Debugger { v8::Local compileInternalScript(v8::Local, v8::Local, const String16& fileName); v8::Local regexContext(); + void enableStackCapturingIfNeeded(); + void disableStackCapturingIfNeeded(); + V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId); + // V8Debugger implementation std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) override; void contextCreated(const V8ContextInfo&) override; @@ -115,14 +130,24 @@ class V8DebuggerImpl : public V8Debugger { void didExecuteScript(v8::Local) override; void idleStarted() override; void idleFinished() override; + void logToConsole(v8::Local, v8::Local arg1, v8::Local arg2) override; + void exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) override; + unsigned promiseRejected(v8::Local, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) override; + void promiseRejectionRevoked(v8::Local, unsigned promiseRejectionId) override; std::unique_ptr createStackTrace(v8::Local) override; - std::unique_ptr captureStackTrace(size_t maxStackSize) override; + std::unique_ptr captureStackTrace(bool fullStack) override; + void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) override; + void asyncTaskCanceled(void* task) override; + void asyncTaskStarted(void* task) override; + void asyncTaskFinished(void* task) override; + void allAsyncTasksCanceled() override; using ContextByIdMap = protocol::HashMap>; void discardInspectedContext(int contextGroupId, int contextId); const ContextByIdMap* contextGroup(int contextGroupId); void disconnect(V8InspectorSessionImpl*); V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId); + InspectedContext* getContext(int groupId, int contextId) const; private: void enable(); @@ -135,8 +160,6 @@ class V8DebuggerImpl : public V8Debugger { v8::Local debuggerContext() const; void clearBreakpoints(); - V8DebuggerParsedScript createParsedScript(v8::Local sourceObject, bool success); - static void breakProgramCallback(const v8::FunctionCallbackInfo&); void handleProgramBreak(v8::Local pausedContext, v8::Local executionState, v8::Local exception, v8::Local hitBreakpoints, bool isPromiseRejection = false); static void v8DebugEventCallback(const v8::Debug::EventDetails&); @@ -145,14 +168,23 @@ class V8DebuggerImpl : public V8Debugger { v8::Local v8InternalizedString(const char*) const; - void handleV8AsyncTaskEvent(V8DebuggerAgentImpl*, v8::Local, v8::Local executionState, v8::Local eventData); + void handleV8AsyncTaskEvent(v8::Local, v8::Local executionState, v8::Local eventData); + + using ContextsByGroupMap = protocol::HashMap>; + + v8::Local collectionEntries(v8::Local, v8::Local); + v8::Local generatorObjectLocation(v8::Local); + v8::Local functionLocation(v8::Local, v8::Local); v8::Isolate* m_isolate; V8DebuggerClient* m_client; - using ContextsByGroupMap = protocol::HashMap>; ContextsByGroupMap m_contexts; using SessionMap = protocol::HashMap; SessionMap m_sessions; + using ConsoleStorageMap = protocol::HashMap>; + ConsoleStorageMap m_consoleStorageMap; + int m_capturingStackTracesCount; + unsigned m_lastExceptionId; int m_enabledAgentsCount; bool m_breakpointsActivated; v8::Global m_debuggerScript; @@ -161,6 +193,14 @@ class V8DebuggerImpl : public V8Debugger { v8::Local m_pausedContext; bool m_runningNestedMessageLoop; v8::Global m_regexContext; + + using AsyncTaskToStackTrace = protocol::HashMap>; + AsyncTaskToStackTrace m_asyncTaskStacks; + protocol::HashSet m_recurringTasks; + int m_maxAsyncCallStackDepth; + std::vector m_currentTasks; + std::vector> m_currentStacks; + protocol::HashMap m_maxAsyncCallStackDepthMap; }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp new file mode 100644 index 00000000000000..91a060b954e023 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp @@ -0,0 +1,121 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8DebuggerScript.h" + +#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/V8StringUtil.h" + +namespace blink { + +static const LChar hexDigits[17] = "0123456789ABCDEF"; + +static void appendUnsignedAsHex(unsigned number, String16Builder* destination) +{ + for (size_t i = 0; i < 8; ++i) { + destination->append(hexDigits[number & 0xF]); + number >>= 4; + } +} + +// Hash algorithm for substrings is described in "Über die Komplexität der Multiplikation in +// eingeschränkten Branchingprogrammmodellen" by Woelfe. +// http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000 +static String16 calculateHash(const String16& str) +{ + static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, 0x81ABE279 }; + static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; + static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, 0x8F462907 }; + + uint64_t hashes[] = { 0, 0, 0, 0, 0 }; + uint64_t zi[] = { 1, 1, 1, 1, 1 }; + + const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes); + + size_t current = 0; + const uint32_t* data = nullptr; + data = reinterpret_cast(str.characters16()); + for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) { + uint32_t v = data[i]; + uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; + hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; + zi[current] = (zi[current] * random[current]) % prime[current]; + current = current == hashesSize - 1 ? 0 : current + 1; + } + if (str.sizeInBytes() % 4) { + uint32_t v = 0; + for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeInBytes(); ++i) { + v <<= 8; + v |= reinterpret_cast(data)[i]; + } + uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; + hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; + zi[current] = (zi[current] * random[current]) % prime[current]; + current = current == hashesSize - 1 ? 0 : current + 1; + } + + for (size_t i = 0; i < hashesSize; ++i) + hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; + + String16Builder hash; + for (size_t i = 0; i < hashesSize; ++i) + appendUnsignedAsHex(hashes[i], &hash); + return hash.toString(); +} + +V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, v8::Local object, bool isLiveEdit) +{ + v8::Local idValue = object->Get(toV8StringInternalized(isolate, "id")); + DCHECK(!idValue.IsEmpty() && idValue->IsInt32()); + m_id = String16::fromInteger(idValue->Int32Value()); + + m_url = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "name"))); + m_sourceURL = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "sourceURL"))); + m_sourceMappingURL = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "sourceMappingURL"))); + m_startLine = object->Get(toV8StringInternalized(isolate, "startLine"))->ToInteger(isolate)->Value(); + m_startColumn = object->Get(toV8StringInternalized(isolate, "startColumn"))->ToInteger(isolate)->Value(); + m_endLine = object->Get(toV8StringInternalized(isolate, "endLine"))->ToInteger(isolate)->Value(); + m_endColumn = object->Get(toV8StringInternalized(isolate, "endColumn"))->ToInteger(isolate)->Value(); + m_isContentScript = object->Get(toV8StringInternalized(isolate, "isContentScript"))->ToBoolean(isolate)->Value(); + m_isInternalScript = object->Get(toV8StringInternalized(isolate, "isInternalScript"))->ToBoolean(isolate)->Value(); + m_executionContextId = object->Get(toV8StringInternalized(isolate, "executionContextId"))->ToInteger(isolate)->Value(); + m_isLiveEdit = isLiveEdit; + + v8::Local sourceValue = object->Get(toV8StringInternalized(isolate, "source")); + if (!sourceValue.IsEmpty() && sourceValue->IsString()) + setSource(isolate, sourceValue.As()); +} + +V8DebuggerScript::~V8DebuggerScript() +{ +} + +String16 V8DebuggerScript::sourceURL() const +{ + return m_sourceURL.isEmpty() ? m_url : m_sourceURL; +} + +v8::Local V8DebuggerScript::source(v8::Isolate* isolate) const +{ + return m_source.Get(isolate); +} + +void V8DebuggerScript::setSourceURL(const String16& sourceURL) +{ + m_sourceURL = sourceURL; +} + +void V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) +{ + m_sourceMappingURL = sourceMappingURL; +} + +void V8DebuggerScript::setSource(v8::Isolate* isolate, v8::Local source) +{ + m_source.Reset(isolate, source); + m_hash = calculateHash(toProtocolString(source)); +} + +} // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h similarity index 77% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h index 55080be0dacea7..60d93d81986493 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h @@ -37,15 +37,17 @@ namespace blink { class V8DebuggerScript { - PROTOCOL_DISALLOW_NEW(); + PROTOCOL_DISALLOW_COPY(V8DebuggerScript); public: - V8DebuggerScript(); + V8DebuggerScript(v8::Isolate*, v8::Local, bool isLiveEdit); + ~V8DebuggerScript(); + String16 scriptId() const { return m_id; } String16 url() const { return m_url; } bool hasSourceURL() const { return !m_sourceURL.isEmpty(); } String16 sourceURL() const; String16 sourceMappingURL() const { return m_sourceMappingURL; } - String16 source() const { return m_source; } + v8::Local source(v8::Isolate*) const; String16 hash() const { return m_hash; } int startLine() const { return m_startLine; } int startColumn() const { return m_startColumn; } @@ -56,25 +58,16 @@ class V8DebuggerScript { bool isInternalScript() const { return m_isInternalScript; } bool isLiveEdit() const { return m_isLiveEdit; } - V8DebuggerScript& setURL(const String16&); - V8DebuggerScript& setSourceURL(const String16&); - V8DebuggerScript& setSourceMappingURL(const String16&); - V8DebuggerScript& setSource(const String16&); - V8DebuggerScript& setHash(const String16&); - V8DebuggerScript& setStartLine(int); - V8DebuggerScript& setStartColumn(int); - V8DebuggerScript& setEndLine(int); - V8DebuggerScript& setEndColumn(int); - V8DebuggerScript& setExecutionContextId(int); - V8DebuggerScript& setIsContentScript(bool); - V8DebuggerScript& setIsInternalScript(bool); - V8DebuggerScript& setIsLiveEdit(bool); + void setSourceURL(const String16&); + void setSourceMappingURL(const String16&); + void setSource(v8::Isolate*, v8::Local); private: + String16 m_id; String16 m_url; String16 m_sourceURL; String16 m_sourceMappingURL; - String16 m_source; + v8::Global m_source; String16 m_hash; int m_startLine; int m_startColumn; @@ -86,12 +79,6 @@ class V8DebuggerScript { bool m_isLiveEdit; }; -struct V8DebuggerParsedScript { - String16 scriptId; - V8DebuggerScript script; - bool success; -}; - } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp index 83e24d79be63fc..73edc7260f0719 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp @@ -50,27 +50,27 @@ V8FunctionCall::V8FunctionCall(V8DebuggerImpl* debugger, v8::Local void V8FunctionCall::appendArgument(v8::Local value) { - m_arguments.append(value); + m_arguments.push_back(value); } void V8FunctionCall::appendArgument(const String16& argument) { - m_arguments.append(toV8String(m_context->GetIsolate(), argument)); + m_arguments.push_back(toV8String(m_context->GetIsolate(), argument)); } void V8FunctionCall::appendArgument(int argument) { - m_arguments.append(v8::Number::New(m_context->GetIsolate(), argument)); + m_arguments.push_back(v8::Number::New(m_context->GetIsolate(), argument)); } void V8FunctionCall::appendArgument(bool argument) { - m_arguments.append(argument ? v8::True(m_context->GetIsolate()) : v8::False(m_context->GetIsolate())); + m_arguments.push_back(argument ? v8::True(m_context->GetIsolate()) : v8::False(m_context->GetIsolate())); } void V8FunctionCall::appendUndefinedArgument() { - m_arguments.append(v8::Undefined(m_context->GetIsolate())); + m_arguments.push_back(v8::Undefined(m_context->GetIsolate())); } v8::Local V8FunctionCall::call(bool& hadException, bool reportExceptions) diff --git a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h index 1c94d240aa91de..0b9d4e2a5096f1 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h @@ -31,7 +31,6 @@ #ifndef V8FunctionCall_h #define V8FunctionCall_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/String16.h" #include @@ -58,7 +57,7 @@ class V8FunctionCall { protected: V8DebuggerImpl* m_debugger; v8::Local m_context; - protocol::Vector> m_arguments; + std::vector> m_arguments; v8::Local m_name; v8::Local m_value; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp index 3281d1ba1dab48..240dc3d27492e9 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp @@ -45,14 +45,12 @@ class HeapSnapshotProgress final : public v8::ActivityControl { class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolver { public: - explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session) : m_offset(0), m_session(session) - { - m_strings.resize(10000); - } + explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session) + : m_offset(0), m_strings(10000), m_session(session) {} const char* GetName(v8::Local object) override { - int contextId = V8Debugger::contextId(object->CreationContext()); + int contextId = V8DebuggerImpl::contextId(object->CreationContext()); if (!contextId) return ""; ErrorString errorString; @@ -75,7 +73,7 @@ class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolv private: size_t m_offset; - protocol::Vector m_strings; + std::vector m_strings; V8InspectorSessionImpl* m_session; }; @@ -171,7 +169,7 @@ void V8HeapProfilerAgentImpl::restore() #if V8_MAJOR_VERSION >= 5 if (m_state->booleanProperty(HeapProfilerAgentState::samplingHeapProfilerEnabled, false)) { ErrorString error; - double samplingInterval = m_state->numberProperty(HeapProfilerAgentState::samplingHeapProfilerInterval, -1); + double samplingInterval = m_state->doubleProperty(HeapProfilerAgentState::samplingHeapProfilerInterval, -1); DCHECK_GE(samplingInterval, 0); startSampling(&error, Maybe(samplingInterval)); } @@ -260,7 +258,7 @@ void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const return; } - *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe("")); + *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe(""), false); if (!result) *error = "Object is not available"; } @@ -297,7 +295,7 @@ void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const St return; v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); - *heapSnapshotObjectId = String16::number(id); + *heapSnapshotObjectId = String16::fromInteger(id); } void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() @@ -343,7 +341,7 @@ void V8HeapProfilerAgentImpl::startSampling(ErrorString* errorString, const Mayb } const unsigned defaultSamplingInterval = 1 << 15; double samplingIntervalValue = samplingInterval.fromMaybe(defaultSamplingInterval); - m_state->setNumber(HeapProfilerAgentState::samplingHeapProfilerInterval, samplingIntervalValue); + m_state->setDouble(HeapProfilerAgentState::samplingHeapProfilerInterval, samplingIntervalValue); m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled, true); #if V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= 5002 profiler->StartSamplingHeapProfiler(static_cast(samplingIntervalValue), 128, v8::HeapProfiler::kSamplingForceGC); @@ -363,12 +361,15 @@ std::unique_ptr buildSampingHea size_t selfSize = 0; for (const auto& allocation : node->allocations) selfSize += allocation.size * allocation.count; - std::unique_ptr result = protocol::HeapProfiler::SamplingHeapProfileNode::create() + std::unique_ptr callFrame = protocol::Runtime::CallFrame::create() .setFunctionName(toProtocolString(node->name)) - .setScriptId(String16::number(node->script_id)) + .setScriptId(String16::fromInteger(node->script_id)) .setUrl(toProtocolString(node->script_name)) - .setLineNumber(node->line_number) - .setColumnNumber(node->column_number) + .setLineNumber(node->line_number - 1) + .setColumnNumber(node->column_number - 1) + .build(); + std::unique_ptr result = protocol::HeapProfiler::SamplingHeapProfileNode::create() + .setCallFrame(std::move(callFrame)) .setSelfSize(selfSize) .setChildren(std::move(children)).build(); return result; diff --git a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp index e7f9bed382349b..afa5138f6ec245 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp @@ -8,6 +8,7 @@ #include "platform/v8_inspector/InjectedScriptNative.h" #include "platform/v8_inspector/V8Compat.h" #include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InternalValueType.h" #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" @@ -19,7 +20,7 @@ void setFunctionProperty(v8::Local context, v8::Local o { v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!v8::Function::New(context, callback, external).ToLocal(&func)) + if (!v8::Function::New(context, callback, external, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) return; func->SetName(funcName); if (!obj->Set(context, funcName, func).FromMaybe(false)) @@ -46,7 +47,6 @@ v8::Local V8InjectedScriptHost::create(v8::Local contex setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedScriptHost::isTypedArrayCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScriptHost::subtypeCallback, debuggerExternal); - setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8InjectedScriptHost::collectionEntriesCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHost::bindCallback, debuggerExternal); @@ -91,6 +91,13 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo value = info[0]; + if (value->IsObject()) { + v8::Local internalType = v8InternalValueTypeFrom(isolate->GetCurrentContext(), v8::Local::Cast(value)); + if (internalType->IsString()) { + info.GetReturnValue().Set(internalType); + return; + } + } if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject()) { info.GetReturnValue().Set(toV8StringInternalized(isolate, "array")); return; @@ -134,23 +141,12 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo& info) -{ - if (info.Length() < 1 || !info[0]->IsObject()) - return; - - v8::Local object = info[0].As(); - info.GetReturnValue().Set(unwrapDebugger(info)->collectionEntries(object)); -} - void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallbackInfo& info) { - if (info.Length() < 1 || !info[0]->IsObject()) + if (info.Length() < 1) return; - - v8::Local object = info[0].As(); v8::Local properties; - if (v8::Debug::GetInternalProperties(info.GetIsolate(), object).ToLocal(&properties)) + if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentContext(), info[0]).ToLocal(&properties)) info.GetReturnValue().Set(properties); } @@ -183,15 +179,18 @@ void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun } } - V8DebuggerClient* client = unwrapDebugger(info)->client(); - client->muteWarningsAndDeprecations(); + V8DebuggerImpl* debugger = unwrapDebugger(info); + int contextGroupId = V8DebuggerImpl::getGroupId(context); + if (contextGroupId) + debugger->client()->muteWarningsAndDeprecations(contextGroupId); v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local result; if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result)) info.GetReturnValue().Set(result); - client->unmuteWarningsAndDeprecations(); + if (contextGroupId) + debugger->client()->unmuteWarningsAndDeprecations(contextGroupId); } void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo& info) diff --git a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h index d21bbdd33e3d28..bf49fa71f40cea 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h @@ -21,13 +21,11 @@ class V8InjectedScriptHost { // We expect that debugger outlives any JS context and thus V8InjectedScriptHost (owned by JS) // is destroyed before debugger. static v8::Local create(v8::Local, V8DebuggerImpl*); - private: static void internalConstructorNameCallback(const v8::FunctionCallbackInfo&); static void formatAccessorsAsProperties(const v8::FunctionCallbackInfo&); static void isTypedArrayCallback(const v8::FunctionCallbackInfo&); static void subtypeCallback(const v8::FunctionCallbackInfo&); - static void collectionEntriesCallback(const v8::FunctionCallbackInfo&); static void getInternalPropertiesCallback(const v8::FunctionCallbackInfo&); static void suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo&); static void bindCallback(const v8::FunctionCallbackInfo&); diff --git a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp similarity index 81% rename from deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp index 1c584e713e07b3..88aac8c894d41a 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp @@ -8,6 +8,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" @@ -23,7 +24,7 @@ const char V8InspectorSession::backtraceObjectGroup[] = "backtrace"; // static bool V8InspectorSession::isV8ProtocolMethod(const String16& method) { - return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime."); + return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.") || method.startWith("Console."); } std::unique_ptr V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state) @@ -36,13 +37,13 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con , m_debugger(debugger) , m_client(client) , m_customObjectFormatterEnabled(false) - , m_instrumentationCounter(0) , m_dispatcher(channel) , m_state(nullptr) , m_runtimeAgent(nullptr) , m_debuggerAgent(nullptr) , m_heapProfilerAgent(nullptr) , m_profilerAgent(nullptr) + , m_consoleAgent(nullptr) { if (savedState) { std::unique_ptr state = protocol::parseJSON(*savedState); @@ -66,17 +67,22 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel, agentState(protocol::HeapProfiler::Metainfo::domainName))); protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.get()); + m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState(protocol::Console::Metainfo::domainName))); + protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); + if (savedState) { m_runtimeAgent->restore(); m_debuggerAgent->restore(); m_heapProfilerAgent->restore(); m_profilerAgent->restore(); + m_consoleAgent->restore(); } } V8InspectorSessionImpl::~V8InspectorSessionImpl() { ErrorString errorString; + m_consoleAgent->disable(&errorString); m_profilerAgent->disable(&errorString); m_heapProfilerAgent->disable(&errorString); m_debuggerAgent->disable(&errorString); @@ -111,13 +117,17 @@ void V8InspectorSessionImpl::discardInjectedScripts() if (!contexts) return; - protocol::Vector keys; + std::vector keys; + keys.reserve(contexts->size()); for (auto& idContext : *contexts) - keys.append(idContext.first); + keys.push_back(idContext.first); for (auto& key : keys) { contexts = m_debugger->contextGroup(m_contextGroupId); - if (contexts && contexts->contains(key)) - contexts->get(key)->discardInjectedScript(); // This may destroy some contexts. + if (!contexts) + continue; + auto contextIt = contexts->find(key); + if (contextIt != contexts->end()) + contextIt->second->discardInjectedScript(); // This may destroy some contexts. } } @@ -129,12 +139,13 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr } const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); - if (!contexts || !contexts->contains(contextId)) { + auto contextsIt = contexts ? contexts->find(contextId) : contexts->end(); + if (contextsIt == contexts->end()) { *errorString = "Cannot find context with specified id"; return nullptr; } - InspectedContext* context = contexts->get(contextId); + const std::unique_ptr& context = contextsIt->second; if (!context->getInjectedScript()) { context->createInjectedScript(); if (!context->getInjectedScript()) { @@ -158,16 +169,19 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) if (!contexts) return; - protocol::Vector keys; + std::vector keys; for (auto& idContext : *contexts) - keys.append(idContext.first); + keys.push_back(idContext.first); for (auto& key : keys) { contexts = m_debugger->contextGroup(m_contextGroupId); - if (contexts && contexts->contains(key)) { - InjectedScript* injectedScript = contexts->get(key)->getInjectedScript(); - if (injectedScript) - injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. - } + if (!contexts) + continue; + auto contextsIt = contexts->find(key); + if (contextsIt == contexts->end()) + continue; + InjectedScript* injectedScript = contextsIt->second->getInjectedScript(); + if (injectedScript) + injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. } } @@ -193,7 +207,7 @@ v8::Local V8InspectorSessionImpl::findObject(ErrorString* errorString std::unique_ptr V8InspectorSessionImpl::wrapObject(v8::Local context, v8::Local value, const String16& groupName, bool generatePreview) { ErrorString errorString; - InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8DebuggerImpl::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapObject(&errorString, value, groupName, false, generatePreview); @@ -202,7 +216,7 @@ std::unique_ptr V8InspectorSessionImpl::wrapObj std::unique_ptr V8InspectorSessionImpl::wrapTable(v8::Local context, v8::Local table, v8::Local columns) { ErrorString errorString; - InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8DebuggerImpl::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapTable(table, columns); @@ -227,17 +241,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) if (!contexts) return; for (auto& idContext : *contexts) - agent->reportExecutionContextCreated(idContext.second); -} - -void V8InspectorSessionImpl::changeInstrumentationCounter(int delta) -{ - DCHECK_GE(m_instrumentationCounter + delta, 0); - if (!m_instrumentationCounter) - m_client->startInstrumenting(); - m_instrumentationCounter += delta; - if (!m_instrumentationCounter) - m_client->stopInstrumenting(); + agent->reportExecutionContextCreated(idContext.second.get()); } void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) @@ -252,16 +256,16 @@ String16 V8InspectorSessionImpl::stateJSON() void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr inspectable) { - m_inspectedObjects.prepend(std::move(inspectable)); - while (m_inspectedObjects.size() > kInspectedObjectBufferSize) - m_inspectedObjects.removeLast(); + m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable)); + if (m_inspectedObjects.size() > kInspectedObjectBufferSize) + m_inspectedObjects.resize(kInspectedObjectBufferSize); } V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigned num) { if (num >= m_inspectedObjects.size()) return nullptr; - return m_inspectedObjects[num]; + return m_inspectedObjects[num].get(); } void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) @@ -279,11 +283,6 @@ void V8InspectorSessionImpl::breakProgram(const String16& breakReason, std::uniq m_debuggerAgent->breakProgram(breakReason, std::move(data)); } -void V8InspectorSessionImpl::breakProgramOnException(const String16& breakReason, std::unique_ptr data) -{ - m_debuggerAgent->breakProgramOnException(breakReason, std::move(data)); -} - void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { ErrorString errorString; @@ -302,29 +301,4 @@ void V8InspectorSessionImpl::stepOver() m_debuggerAgent->stepOver(&errorString); } -void V8InspectorSessionImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) -{ - m_debuggerAgent->asyncTaskScheduled(taskName, task, recurring); -} - -void V8InspectorSessionImpl::asyncTaskCanceled(void* task) -{ - m_debuggerAgent->asyncTaskCanceled(task); -} - -void V8InspectorSessionImpl::asyncTaskStarted(void* task) -{ - m_debuggerAgent->asyncTaskStarted(task); -} - -void V8InspectorSessionImpl::asyncTaskFinished(void* task) -{ - m_debuggerAgent->asyncTaskFinished(task); -} - -void V8InspectorSessionImpl::allAsyncTasksCanceled() -{ - m_debuggerAgent->allAsyncTasksCanceled(); -} - } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h similarity index 84% rename from deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h index bf90eb241dafaf..21753dac21b98a 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h @@ -6,7 +6,6 @@ #define V8InspectorSessionImpl_h #include "platform/inspector_protocol/Allocator.h" -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/DispatcherBase.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" @@ -16,10 +15,13 @@ #include +#include + namespace blink { class InjectedScript; class RemoteObjectIdBase; +class V8ConsoleAgentImpl; class V8DebuggerAgentImpl; class V8DebuggerImpl; class V8HeapProfilerAgentImpl; @@ -34,6 +36,7 @@ class V8InspectorSessionImpl : public V8InspectorSession { V8DebuggerImpl* debugger() const { return m_debugger; } V8InspectorSessionClient* client() const { return m_client; } + V8ConsoleAgentImpl* consoleAgent() { return m_consoleAgent.get(); } V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); } V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); } V8RuntimeAgentImpl* runtimeAgent() { return m_runtimeAgent.get(); } @@ -45,7 +48,6 @@ class V8InspectorSessionImpl : public V8InspectorSession { void discardInjectedScripts(); void reportAllContexts(V8RuntimeAgentImpl*); void setCustomObjectFormatterEnabled(bool); - void changeInstrumentationCounter(int delta); // V8InspectorSession implementation. void dispatchProtocolMessage(const String16& message) override; @@ -54,19 +56,13 @@ class V8InspectorSessionImpl : public V8InspectorSession { void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) override; void cancelPauseOnNextStatement() override; void breakProgram(const String16& breakReason, std::unique_ptr data) override; - void breakProgramOnException(const String16& breakReason, std::unique_ptr data) override; void setSkipAllPauses(bool) override; void resume() override; void stepOver() override; - void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) override; - void asyncTaskCanceled(void* task) override; - void asyncTaskStarted(void* task) override; - void asyncTaskFinished(void* task) override; - void allAsyncTasksCanceled() override; void releaseObjectGroup(const String16& objectGroup) override; v8::Local findObject(ErrorString*, const String16& objectId, v8::Local* = nullptr, String16* groupName = nullptr) override; - std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview = false) override; - std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns) override; + std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview) override; + std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns); V8InspectorSession::Inspectable* inspectedObject(unsigned num); static const unsigned kInspectedObjectBufferSize = 5; @@ -79,7 +75,6 @@ class V8InspectorSessionImpl : public V8InspectorSession { V8DebuggerImpl* m_debugger; V8InspectorSessionClient* m_client; bool m_customObjectFormatterEnabled; - int m_instrumentationCounter; protocol::UberDispatcher m_dispatcher; std::unique_ptr m_state; @@ -88,7 +83,8 @@ class V8InspectorSessionImpl : public V8InspectorSession { std::unique_ptr m_debuggerAgent; std::unique_ptr m_heapProfilerAgent; std::unique_ptr m_profilerAgent; - protocol::Vector> m_inspectedObjects; + std::unique_ptr m_consoleAgent; + std::vector> m_inspectedObjects; }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp new file mode 100644 index 00000000000000..52e7677fd709e2 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp @@ -0,0 +1,72 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8InternalValueType.h" + +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/V8StringUtil.h" + +namespace blink { + +namespace { + +v8::Local internalSubtypePrivate(v8::Isolate* isolate) +{ + return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8InternalType#internalSubtype")); +} + +v8::Local subtypeForInternalType(v8::Isolate* isolate, V8InternalValueType type) +{ + switch (type) { + case V8InternalValueType::kEntry: + return toV8StringInternalized(isolate, "internal#entry"); + case V8InternalValueType::kLocation: + return toV8StringInternalized(isolate, "internal#location"); + case V8InternalValueType::kScope: + return toV8StringInternalized(isolate, "internal#scope"); + case V8InternalValueType::kScopeList: + return toV8StringInternalized(isolate, "internal#scopeList"); + } + NOTREACHED(); + return v8::Local(); +} + +} // namespace + +bool markAsInternal(v8::Local context, v8::Local object, V8InternalValueType type) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + v8::Local subtype = subtypeForInternalType(isolate, type); + return object->SetPrivate(context, privateValue, subtype).FromMaybe(false); +} + +bool markArrayEntriesAsInternal(v8::Local context, v8::Local array, V8InternalValueType type) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + v8::Local subtype = subtypeForInternalType(isolate, type); + for (size_t i = 0; i < array->Length(); ++i) { + v8::Local entry; + if (!array->Get(context, i).ToLocal(&entry) || !entry->IsObject()) + return false; + if (!entry.As()->SetPrivate(context, privateValue, subtype).FromMaybe(false)) + return false; + } + return true; +} + +v8::Local v8InternalValueTypeFrom(v8::Local context, v8::Local object) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + if (!object->HasPrivate(context, privateValue).FromMaybe(false)) + return v8::Null(isolate); + v8::Local subtypeValue; + if (!object->GetPrivate(context, privateValue).ToLocal(&subtypeValue) || !subtypeValue->IsString()) + return v8::Null(isolate); + return subtypeValue; +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h new file mode 100644 index 00000000000000..4bb71720f055c4 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h @@ -0,0 +1,21 @@ +// Copyright 2016 The Chromium 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 V8InternalValueType_h +#define V8InternalValueType_h + +#include + +namespace blink { + +enum class V8InternalValueType { kEntry, kLocation, kScope, kScopeList }; + +bool markAsInternal(v8::Local, v8::Local, V8InternalValueType); +bool markArrayEntriesAsInternal(v8::Local, v8::Local, V8InternalValueType); +v8::Local v8InternalValueTypeFrom(v8::Local, v8::Local); + + +} // namespace blink + +#endif // V8InternalValueType_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp index 92762f73dc8e9d..0761f87e0d7a26 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp @@ -11,6 +11,8 @@ #include "platform/v8_inspector/V8StringUtil.h" #include +#include + namespace blink { namespace ProfilerAgentState { @@ -28,7 +30,7 @@ std::unique_ptr> buildInsp if (!lineCount) return array; - protocol::Vector entries(lineCount); + std::vector entries(lineCount); if (node->GetLineTicks(&entries[0], lineCount)) { for (unsigned i = 0; i < lineCount; i++) { std::unique_ptr line = protocol::Profiler::PositionTickInfo::create() @@ -54,14 +56,16 @@ std::unique_ptr buildInspectorObjectFor(v8:: std::unique_ptr> positionTicks = buildInspectorObjectForPositionTicks(node); - std::unique_ptr result = protocol::Profiler::CPUProfileNode::create() + std::unique_ptr callFrame = protocol::Runtime::CallFrame::create() .setFunctionName(toProtocolString(node->GetFunctionName())) - .setScriptId(String16::number(node->GetScriptId())) + .setScriptId(String16::fromInteger(node->GetScriptId())) .setUrl(toProtocolString(node->GetScriptResourceName())) - .setLineNumber(node->GetLineNumber()) - .setColumnNumber(node->GetColumnNumber()) + .setLineNumber(node->GetLineNumber() - 1) + .setColumnNumber(node->GetColumnNumber() - 1) + .build(); + std::unique_ptr result = protocol::Profiler::CPUProfileNode::create() + .setCallFrame(std::move(callFrame)) .setHitCount(node->GetHitCount()) - .setCallUID(node->GetCallUid()) .setChildren(std::move(children)) .setPositionTicks(std::move(positionTicks)) .setDeoptReason(node->GetBailoutReason()) @@ -140,7 +144,7 @@ void V8ProfilerAgentImpl::consoleProfile(const String16& title) if (!m_enabled) return; String16 id = nextProfileId(); - m_startedProfiles.append(ProfileDescriptor(id, title)); + m_startedProfiles.push_back(ProfileDescriptor(id, title)); startProfiling(id); m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title); } @@ -153,17 +157,17 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) String16 resolvedTitle; // Take last started profile if no title was passed. if (title.isEmpty()) { - if (m_startedProfiles.isEmpty()) + if (m_startedProfiles.empty()) return; - id = m_startedProfiles.last().m_id; - resolvedTitle = m_startedProfiles.last().m_title; - m_startedProfiles.removeLast(); + id = m_startedProfiles.back().m_id; + resolvedTitle = m_startedProfiles.back().m_title; + m_startedProfiles.pop_back(); } else { for (size_t i = 0; i < m_startedProfiles.size(); i++) { if (m_startedProfiles[i].m_title == title) { resolvedTitle = title; id = m_startedProfiles[i].m_id; - m_startedProfiles.remove(i); + m_startedProfiles.erase(m_startedProfiles.begin() + i); break; } } @@ -183,14 +187,12 @@ void V8ProfilerAgentImpl::enable(ErrorString*) return; m_enabled = true; m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); - m_session->changeInstrumentationCounter(+1); } void V8ProfilerAgentImpl::disable(ErrorString* errorString) { if (!m_enabled) return; - m_session->changeInstrumentationCounter(-1); for (size_t i = m_startedProfiles.size(); i > 0; --i) stopProfiling(m_startedProfiles[i - 1].m_id, false); m_startedProfiles.clear(); @@ -205,7 +207,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) *error = "Cannot change sampling interval when profiling."; return; } - m_state->setNumber(ProfilerAgentState::samplingInterval, interval); + m_state->setInteger(ProfilerAgentState::samplingInterval, interval); m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); } @@ -215,9 +217,8 @@ void V8ProfilerAgentImpl::restore() if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) return; m_enabled = true; - m_session->changeInstrumentationCounter(+1); int interval = 0; - m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); + m_state->getInteger(ProfilerAgentState::samplingInterval, &interval); if (interval) m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, false)) { @@ -262,7 +263,7 @@ void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr V8ProfilerAgentImpl::stopProfili bool V8ProfilerAgentImpl::isRecording() const { - return m_recordingCPUProfile || !m_startedProfiles.isEmpty(); + return m_recordingCPUProfile || !m_startedProfiles.empty(); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h index 7fa5f49b4684e1..03b8f703ae1215 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h @@ -9,6 +9,8 @@ #include "platform/inspector_protocol/String16.h" #include "platform/v8_inspector/protocol/Profiler.h" +#include + namespace v8 { class Isolate; } @@ -50,7 +52,7 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { bool m_enabled; bool m_recordingCPUProfile; class ProfileDescriptor; - protocol::Vector m_startedProfiles; + std::vector m_startedProfiles; String16 m_frontendInitiatedProfileId; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8Regex.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Regex.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp diff --git a/deps/v8_inspector/platform/v8_inspector/V8Regex.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Regex.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp similarity index 89% rename from deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp index dc45b11875ec86..c9a235ae29e5fd 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp @@ -34,6 +34,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -87,11 +88,13 @@ void V8RuntimeAgentImpl::evaluate( if (executionContextId.isJust()) { contextId = executionContextId.fromJust(); } else { - contextId = m_debugger->client()->ensureDefaultContextInGroup(m_session->contextGroupId()); - if (!contextId) { + v8::HandleScope handles(m_debugger->isolate()); + v8::Local defaultContext = m_debugger->client()->ensureDefaultContextInGroup(m_session->contextGroupId()); + if (defaultContext.IsEmpty()) { *errorString = "Cannot find default execution context"; return; } + contextId = V8DebuggerImpl::contextId(defaultContext); } InjectedScript::ContextScope scope(errorString, m_debugger, m_session->contextGroupId(), contextId); @@ -218,7 +221,7 @@ void V8RuntimeAgentImpl::getProperties( if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropertiesOnly.fromMaybe(false)) return; v8::Local propertiesArray; - if (hasInternalError(errorString, !v8::Debug::GetInternalProperties(m_debugger->isolate(), scope.object()).ToLocal(&propertiesArray))) + if (hasInternalError(errorString, !m_debugger->internalProperties(scope.context(), scope.object()).ToLocal(&propertiesArray))) return; std::unique_ptr> propertiesProtocolArray = protocol::Array::create(); for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) { @@ -264,6 +267,12 @@ void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enab m_session->setCustomObjectFormatterEnabled(enabled); } +void V8RuntimeAgentImpl::discardConsoleEntries(ErrorString*) +{ + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + storage->clear(); +} + void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, const String16& expression, const String16& sourceURL, @@ -293,9 +302,9 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, if (!persistScript) return; - String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId()); + String16 scriptValueId = String16::fromInteger(script->GetUnboundScript()->GetId()); std::unique_ptr> global(new v8::Global(m_debugger->isolate(), script)); - m_compiledScripts.set(scriptValueId, std::move(global)); + m_compiledScripts[scriptValueId] = std::move(global); *scriptId = scriptValueId; } @@ -313,7 +322,8 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString, return; } - if (!m_compiledScripts.contains(scriptId)) { + auto it = m_compiledScripts.find(scriptId); + if (it == m_compiledScripts.end()) { *errorString = "Script execution failed"; return; } @@ -325,7 +335,8 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString, if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); - std::unique_ptr> scriptWrapper = m_compiledScripts.take(scriptId); + std::unique_ptr> scriptWrapper = std::move(it->second); + m_compiledScripts.erase(it); v8::Local script = scriptWrapper->Get(m_debugger->isolate()); if (script.IsEmpty()) { *errorString = "Script execution failed"; @@ -358,11 +369,14 @@ void V8RuntimeAgentImpl::enable(ErrorString* errorString) { if (m_enabled) return; - m_session->changeInstrumentationCounter(+1); + m_session->client()->runtimeEnabled(); m_enabled = true; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, true); - v8::HandleScope handles(m_debugger->isolate()); + m_session->debugger()->enableStackCapturingIfNeeded(); m_session->reportAllContexts(this); + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + for (const auto& message : storage->messages()) + reportMessage(message.get(), false); } void V8RuntimeAgentImpl::disable(ErrorString* errorString) @@ -371,9 +385,10 @@ void V8RuntimeAgentImpl::disable(ErrorString* errorString) return; m_enabled = false; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); + m_session->debugger()->disableStackCapturingIfNeeded(); m_session->discardInjectedScripts(); reset(); - m_session->changeInstrumentationCounter(-1); + m_session->client()->runtimeDisabled(); } void V8RuntimeAgentImpl::reset() @@ -416,4 +431,16 @@ void V8RuntimeAgentImpl::inspect(std::unique_ptrreportToFrontend(&m_frontend, m_session, generatePreview); + m_frontend.flush(); +} + } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h index 7eb2b135450c4c..7b33379a0c29c0 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h @@ -42,6 +42,7 @@ namespace blink { class InjectedScript; class InspectedContext; class RemoteObjectIdBase; +class V8ConsoleMessage; class V8DebuggerImpl; class V8InspectorSessionImpl; @@ -95,6 +96,7 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { void releaseObjectGroup(ErrorString*, const String16& objectGroup) override; void run(ErrorString*) override; void setCustomObjectFormatterEnabled(ErrorString*, bool) override; + void discardConsoleEntries(ErrorString*) override; void compileScript(ErrorString*, const String16& expression, const String16& sourceURL, @@ -115,8 +117,12 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { void reportExecutionContextCreated(InspectedContext*); void reportExecutionContextDestroyed(InspectedContext*); void inspect(std::unique_ptr objectToInspect, std::unique_ptr hints); + void messageAdded(V8ConsoleMessage*); + bool enabled() const { return m_enabled; } private: + void reportMessage(V8ConsoleMessage*, bool generatePreview); + V8InspectorSessionImpl* m_session; protocol::DictionaryValue* m_state; protocol::Runtime::Frontend m_frontend; diff --git a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp similarity index 70% rename from deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp index 650c71eb957f20..343234c02278cc 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp @@ -6,7 +6,6 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -18,9 +17,16 @@ namespace blink { namespace { +static const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast( + v8::StackTrace::kLineNumber | + v8::StackTrace::kColumnOffset | + v8::StackTrace::kScriptId | + v8::StackTrace::kScriptNameOrSourceURL | + v8::StackTrace::kFunctionName); + V8StackTraceImpl::Frame toFrame(v8::Local frame) { - String16 scriptId = String16::number(frame->GetScriptId()); + String16 scriptId = String16::fromInteger(frame->GetScriptId()); String16 sourceName; v8::Local sourceNameValue(frame->GetScriptNameOrSourceURL()); if (!sourceNameValue.IsEmpty()) @@ -36,7 +42,7 @@ V8StackTraceImpl::Frame toFrame(v8::Local frame) return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLineNumber, sourceColumn); } -void toFramesVector(v8::Local stackTrace, protocol::Vector& frames, size_t maxStackSize, v8::Isolate* isolate) +void toFramesVector(v8::Local stackTrace, std::vector& frames, size_t maxStackSize, v8::Isolate* isolate) { DCHECK(isolate->InContext()); int frameCount = stackTrace->GetFrameCount(); @@ -44,7 +50,7 @@ void toFramesVector(v8::Local stackTrace, protocol::Vector stackFrame = stackTrace->GetFrame(i); - frames.append(toFrame(stackFrame)); + frames.push_back(toFrame(stackFrame)); } } @@ -66,6 +72,8 @@ V8StackTraceImpl::Frame::Frame(const String16& functionName, const String16& scr , m_lineNumber(lineNumber) , m_columnNumber(column) { + DCHECK(m_lineNumber != v8::Message::kNoLineNumberInfo); + DCHECK(m_columnNumber != v8::Message::kNoColumnInfo); } V8StackTraceImpl::Frame::~Frame() @@ -80,8 +88,8 @@ std::unique_ptr V8StackTraceImpl::Frame::buildInsp .setFunctionName(m_functionName) .setScriptId(m_scriptId) .setUrl(m_scriptName) - .setLineNumber(m_lineNumber) - .setColumnNumber(m_columnNumber) + .setLineNumber(m_lineNumber - 1) + .setColumnNumber(m_columnNumber - 1) .build(); } @@ -90,19 +98,32 @@ V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scriptName.isolatedCopy(), m_lineNumber, m_columnNumber); } -std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* agent, v8::Local stackTrace, size_t maxStackSize, const String16& description) +// static +void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(v8::Isolate* isolate, bool capture) +{ + isolate->SetCaptureStackTraceForUncaughtExceptions(capture, V8StackTraceImpl::maxCallStackSizeToCapture, stackTraceOptions); +} + +// static +std::unique_ptr V8StackTraceImpl::create(V8DebuggerImpl* debugger, int contextGroupId, v8::Local stackTrace, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); - protocol::Vector frames; + std::vector frames; if (!stackTrace.IsEmpty()) toFramesVector(stackTrace, frames, maxStackSize, isolate); int maxAsyncCallChainDepth = 1; V8StackTraceImpl* asyncCallChain = nullptr; - if (agent && maxStackSize > 1) { - asyncCallChain = agent->currentAsyncCallChain(); - maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth(); + if (debugger && maxStackSize > 1) { + asyncCallChain = debugger->currentAsyncCallChain(); + maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); + } + // Do not accidentally append async call chain from another group. This should not + // happen if we have proper instrumentation, but let's double-check to be safe. + if (contextGroupId && asyncCallChain && asyncCallChain->m_contextGroupId && asyncCallChain->m_contextGroupId != contextGroupId) { + asyncCallChain = nullptr; + maxAsyncCallChainDepth = 1; } // Only the top stack in the chain may be empty, so ensure that second stack is non-empty (it's the top of appended chain). @@ -112,7 +133,7 @@ std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* if (stackTrace.IsEmpty() && !asyncCallChain) return nullptr; - std::unique_ptr result(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr)); + std::unique_ptr result(new V8StackTraceImpl(contextGroupId, description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr)); // Crop to not exceed maxAsyncCallChainDepth. V8StackTraceImpl* deepest = result.get(); @@ -126,7 +147,7 @@ std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* return result; } -std::unique_ptr V8StackTraceImpl::capture(V8DebuggerAgentImpl* agent, size_t maxStackSize, const String16& description) +std::unique_ptr V8StackTraceImpl::capture(V8DebuggerImpl* debugger, int contextGroupId, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); @@ -137,7 +158,7 @@ std::unique_ptr V8StackTraceImpl::capture(V8DebuggerAgentImpl* #endif stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, stackTraceOptions); } - return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description); + return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, maxStackSize, description); } std::unique_ptr V8StackTraceImpl::clone() @@ -147,8 +168,8 @@ std::unique_ptr V8StackTraceImpl::clone() std::unique_ptr V8StackTraceImpl::cloneImpl() { - protocol::Vector framesCopy(m_frames); - return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m_parent->cloneImpl() : nullptr)); + std::vector framesCopy(m_frames); + return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description, framesCopy, m_parent ? m_parent->cloneImpl() : nullptr)); } std::unique_ptr V8StackTraceImpl::isolatedCopy() @@ -158,14 +179,15 @@ std::unique_ptr V8StackTraceImpl::isolatedCopy() std::unique_ptr V8StackTraceImpl::isolatedCopyImpl() { - protocol::Vector frames; + std::vector frames; for (size_t i = 0; i < m_frames.size(); i++) - frames.append(m_frames.at(i).isolatedCopy()); - return wrapUnique(new V8StackTraceImpl(m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); + frames.push_back(m_frames.at(i).isolatedCopy()); + return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); } -V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector& frames, std::unique_ptr parent) - : m_description(description) +V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, const String16& description, std::vector& frames, std::unique_ptr parent) + : m_contextGroupId(contextGroupId) + , m_description(description) , m_parent(std::move(parent)) { m_frames.swap(frames); @@ -220,11 +242,11 @@ std::unique_ptr V8StackTraceImpl::buildInspectorO return stackTrace; } -std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8DebuggerAgentImpl* agent) const +std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8DebuggerImpl* debugger) const { v8::HandleScope handleScope(v8::Isolate::GetCurrent()); // Next call collapses possible empty stack and ensures maxAsyncCallChainDepth. - std::unique_ptr fullChain = V8StackTraceImpl::create(agent, v8::Local(), V8StackTrace::maxCallStackSizeToCapture); + std::unique_ptr fullChain = V8StackTraceImpl::create(debugger, m_contextGroupId, v8::Local(), V8StackTraceImpl::maxCallStackSizeToCapture); if (!fullChain || !fullChain->m_parent) return nullptr; return fullChain->m_parent->buildInspectorObject(); diff --git a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h similarity index 76% rename from deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h index 721789319bb297..63b59e8d9009b3 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h @@ -5,14 +5,15 @@ #ifndef V8StackTraceImpl_h #define V8StackTraceImpl_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Platform.h" #include "platform/v8_inspector/public/V8StackTrace.h" +#include + namespace blink { class TracedValue; -class V8DebuggerAgentImpl; +class V8DebuggerImpl; // Note: async stack trace may have empty top stack with non-empty tail to indicate // that current native-only state had some async story. @@ -20,6 +21,8 @@ class V8DebuggerAgentImpl; class V8StackTraceImpl final : public V8StackTrace { PROTOCOL_DISALLOW_COPY(V8StackTraceImpl); public: + static const size_t maxCallStackSizeToCapture = 200; + class Frame { public: Frame(); @@ -45,14 +48,15 @@ class V8StackTraceImpl final : public V8StackTrace { int m_columnNumber; }; - static std::unique_ptr create(V8DebuggerAgentImpl*, v8::Local, size_t maxStackSize, const String16& description = String16()); - static std::unique_ptr capture(V8DebuggerAgentImpl*, size_t maxStackSize, const String16& description = String16()); + static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, bool capture); + static std::unique_ptr create(V8DebuggerImpl*, int contextGroupId, v8::Local, size_t maxStackSize, const String16& description = String16()); + static std::unique_ptr capture(V8DebuggerImpl*, int contextGroupId, size_t maxStackSize, const String16& description = String16()); std::unique_ptr clone() override; std::unique_ptr cloneImpl(); std::unique_ptr isolatedCopy() override; std::unique_ptr isolatedCopyImpl(); - std::unique_ptr buildInspectorObjectForTail(V8DebuggerAgentImpl*) const; + std::unique_ptr buildInspectorObjectForTail(V8DebuggerImpl*) const; ~V8StackTraceImpl() override; // V8StackTrace implementation. @@ -66,10 +70,11 @@ class V8StackTraceImpl final : public V8StackTrace { String16 toString() const override; private: - V8StackTraceImpl(const String16& description, protocol::Vector& frames, std::unique_ptr parent); + V8StackTraceImpl(int contextGroupId, const String16& description, std::vector& frames, std::unique_ptr parent); + int m_contextGroupId; String16 m_description; - protocol::Vector m_frames; + std::vector m_frames; std::unique_ptr m_parent; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp index e47981e72ccc97..4ba7898bc58162 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp @@ -9,7 +9,6 @@ #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8Regex.h" #include "platform/v8_inspector/public/V8ContentSearchUtil.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" namespace blink { @@ -95,9 +94,9 @@ String16 createSearchRegexSource(const String16& text) return result.toString(); } -std::unique_ptr> lineEndings(const String16& text) +std::unique_ptr> lineEndings(const String16& text) { - std::unique_ptr> result(new protocol::Vector()); + std::unique_ptr> result(new std::vector()); unsigned start = 0; while (start < text.length()) { @@ -105,21 +104,21 @@ std::unique_ptr> lineEndings(const String16& text) if (lineEnd == kNotFound) break; - result->append(static_cast(lineEnd)); + result->push_back(static_cast(lineEnd)); start = lineEnd + 1; } - result->append(text.length()); + result->push_back(text.length()); return result; } -protocol::Vector> scriptRegexpMatchesByLines(const V8Regex& regex, const String16& text) +std::vector> scriptRegexpMatchesByLines(const V8Regex& regex, const String16& text) { - protocol::Vector> result; + std::vector> result; if (text.isEmpty()) return result; - std::unique_ptr> endings(lineEndings(text)); + std::unique_ptr> endings(lineEndings(text)); unsigned size = endings->size(); unsigned start = 0; for (unsigned lineNumber = 0; lineNumber < size; ++lineNumber) { @@ -130,7 +129,7 @@ protocol::Vector> scriptRegexpMatchesByLines(const V8Re int matchLength; if (regex.match(line, 0, &matchLength) != -1) - result.append(std::pair(lineNumber, line)); + result.push_back(std::pair(lineNumber, line)); start = lineEnd + 1; } @@ -199,7 +198,7 @@ std::unique_ptr> searchInTextBy { std::unique_ptr> result = protocol::Array::create(); std::unique_ptr regex = createSearchRegex(static_cast(session)->debugger(), query, caseSensitive, isRegex); - protocol::Vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); + std::vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); for (const auto& match : matches) result->addItem(buildObjectForSearchMatch(match.first, match.second)); @@ -224,8 +223,13 @@ std::unique_ptr toProtocolValue(v8::Local context, return protocol::Value::null(); if (value->IsBoolean()) return protocol::FundamentalValue::create(value.As()->Value()); - if (value->IsNumber()) - return protocol::FundamentalValue::create(value.As()->Value()); + if (value->IsNumber()) { + double doubleValue = value.As()->Value(); + int intValue = static_cast(doubleValue); + if (intValue == doubleValue) + return protocol::FundamentalValue::create(intValue); + return protocol::FundamentalValue::create(doubleValue); + } if (value->IsString()) return protocol::StringValue::create(toProtocolString(value.As())); if (value->IsArray()) { diff --git a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h similarity index 76% rename from deps/v8_inspector/platform/v8_inspector/V8StringUtil.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h index c1c506baae8140..2d42613d41614d 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h @@ -6,10 +6,13 @@ #define V8StringUtil_h #include "platform/inspector_protocol/String16.h" +#include "platform/inspector_protocol/Values.h" #include namespace blink { +std::unique_ptr toProtocolValue(v8::Local, v8::Local, int maxDepth = protocol::Value::maxDepth); + v8::Local toV8String(v8::Isolate*, const String16&); v8::Local toV8StringInternalized(v8::Isolate*, const String16&); diff --git a/deps/v8_inspector/platform/v8_inspector/build/rjsmin.py b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/rjsmin.py similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/build/rjsmin.py rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/rjsmin.py diff --git a/deps/v8_inspector/platform/v8_inspector/build/xxd.py b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/xxd.py similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/build/xxd.py rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/xxd.py diff --git a/deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js similarity index 98% rename from deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js index 25d07542792e92..cf2a0457c4c1b3 100644 --- a/deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js @@ -18,14 +18,6 @@ var Scope; }} */ var RawLocation; -/** @typedef {{ - function: function(), - functionName: string, - status: string, - location: (!RawLocation|undefined) - }} */ -var GeneratorObjectDetails; - /** @typedef {{ id: number, name: string, diff --git a/deps/v8_inspector/platform/v8_inspector/injected_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/injected_script_externs.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js index 218010938c10e3..5fba025caab2b8 100644 --- a/deps/v8_inspector/platform/v8_inspector/injected_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js @@ -32,12 +32,6 @@ InjectedScriptHostClass.prototype.subtype = function(obj) {} */ InjectedScriptHostClass.prototype.isTypedArray = function(obj) {} -/** - * @param {!Object} obj - * @return {?Array.<*>} - */ -InjectedScriptHostClass.prototype.collectionEntries = function(obj) {} - /** * @param {*} obj * @return {!Array.<*>} diff --git a/deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol-1.1.json similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol-1.1.json diff --git a/deps/v8_inspector/platform/v8_inspector/js_protocol.json b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/js_protocol.json rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json index 9ae7e60cb025ac..78548bc8402aeb 100644 --- a/deps/v8_inspector/platform/v8_inspector/js_protocol.json +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json @@ -133,16 +133,23 @@ { "id": "ExceptionDetails", "type": "object", - "description": "Detailed information on exception (or error) that was thrown during script compilation or execution.", + "hidden": true, + "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.", "properties": [ { "name": "text", "type": "string", "description": "Exception text." }, - { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, - { "name": "scriptId", "type": "string", "optional": true, "description": "Script ID of the message origin." }, - { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message." }, - { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message." }, - { "name": "stack", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." } + { "name": "scriptId", "$ref": "ScriptId", "description": "Script ID of the exception location." }, + { "name": "lineNumber", "type": "integer", "description": "Line number of the exception location (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "Column number of the exception location (0-based)." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the exception location, to be used when the script was not reported." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace if available." } ] }, + { + "id": "Timestamp", + "type": "number", + "description": "Number of milliseconds since epoch.", + "hidden": true + }, { "id": "CallFrame", "type": "object", @@ -151,8 +158,8 @@ { "name": "functionName", "type": "string", "description": "JavaScript function name." }, { "name": "scriptId", "$ref": "ScriptId", "description": "JavaScript script id." }, { "name": "url", "type": "string", "description": "JavaScript script name or url." }, - { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number." }, - { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number." } + { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number (0-based)." } ] }, { @@ -162,7 +169,7 @@ "properties": [ { "name": "description", "type": "string", "optional": true, "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call." }, { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "JavaScript function name." }, - { "name": "parent", "$ref": "StackTrace", "optional": true, "hidden": true, "hidden": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } + { "name": "parent", "$ref": "StackTrace", "optional": true, "hidden": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } ] } ], @@ -246,6 +253,11 @@ "hidden": true, "description": "Disables reporting of execution contexts creation." }, + { + "name": "discardConsoleEntries", + "hidden": true, + "description": "Discards collected exceptions and console API calls." + }, { "name": "setCustomObjectFormatterEnabled", "parameters": [ @@ -307,6 +319,39 @@ "name": "executionContextsCleared", "description": "Issued when all executionContexts were cleared in browser" }, + { + "name": "exceptionThrown", + "description": "Issued when exception was thrown and unhandled.", + "parameters": [ + { "name": "exceptionId", "type": "integer", "description": "Exception id." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp of the exception." }, + { "name": "details", "$ref": "ExceptionDetails" }, + { "name": "exception", "$ref": "RemoteObject", "optional": true, "description": "Exception object." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Identifier of the context where exception happened." } + ], + "hidden": true + }, + { + "name": "exceptionRevoked", + "description": "Issued when unhandled exception was revoked.", + "parameters": [ + { "name": "message", "type": "string", "description": "Message describing why exception was revoked." }, + { "name": "exceptionId", "type": "integer", "description": "The id of revoked exception, as reported in exceptionUnhandled." } + ], + "hidden": true + }, + { + "name": "consoleAPICalled", + "description": "Issued when console API was called.", + "parameters": [ + { "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd"], "description": "Type of the call." }, + { "name": "args", "type": "array", "items": { "$ref": "RemoteObject" }, "description": "Call arguments." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Identifier of the context where the call was made." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "Stack trace captured when the call was made." } + ], + "hidden": true + }, { "name": "inspectRequested", "parameters": [ @@ -347,45 +392,11 @@ "hidden": true, "type": "object", "properties": [ - { "name": "line", "type": "integer" }, - { "name": "column", "type": "integer" } + { "name": "lineNumber", "type": "integer" }, + { "name": "columnNumber", "type": "integer" } ], "description": "Location in the source code." }, - { - "id": "FunctionDetails", - "hidden": true, - "type": "object", - "properties": [ - { "name": "location", "$ref": "Location", "optional": true, "description": "Location of the function, none for native functions." }, - { "name": "functionName", "type": "string", "description": "Name of the function." }, - { "name": "isGenerator", "type": "boolean", "description": "Whether this is a generator function." }, - { "name": "scopeChain", "type": "array", "optional": true, "items": { "$ref": "Scope" }, "description": "Scope chain for this closure." } - ], - "description": "Information about the function." - }, - { - "id": "GeneratorObjectDetails", - "hidden": true, - "type": "object", - "properties": [ - { "name": "function", "$ref": "Runtime.RemoteObject", "description": "Generator function." }, - { "name": "functionName", "type": "string", "description": "Name of the generator function." }, - { "name": "status", "type": "string", "enum": ["running", "suspended", "closed"], "description": "Current generator object status." }, - { "name": "location", "$ref": "Location", "optional": true, "description": "If suspended, location where generator function was suspended (e.g. location of the last 'yield'). Otherwise, location of the generator function." } - ], - "description": "Information about the generator object." - }, - { - "id": "CollectionEntry", - "hidden": true, - "type": "object", - "properties": [ - { "name": "key", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Entry key of a map-like collection, otherwise not provided." }, - { "name": "value", "$ref": "Runtime.RemoteObject", "description": "Entry value." } - ], - "description": "Collection entry." - }, { "id": "CallFrame", "type": "object", @@ -412,17 +423,6 @@ ], "description": "Scope description." }, - { - "id": "SetScriptSourceError", - "type": "object", - "properties": [ - { "name": "message", "type": "string", "description": "Compiler error message" }, - { "name": "lineNumber", "type": "integer", "description": "Compile error line number (1-based)" }, - { "name": "columnNumber", "type": "integer", "description": "Compile error column number (1-based)" } - ], - "description": "Error data for setScriptSource command. Contains uncompilable script source error.", - "hidden": true - }, { "id": "SearchMatch", "type": "object", @@ -551,7 +551,7 @@ { "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." }, { "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes.", "hidden": true }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true }, - { "name": "compileError", "optional": true, "$ref": "SetScriptSourceError", "description": "Error data if any." } + { "name": "compileError", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Error data if any." } ], "description": "Edits JavaScript source live." }, @@ -577,39 +577,6 @@ ], "description": "Returns source for the script with given id." }, - { - "name": "getFunctionDetails", - "hidden": true, - "parameters": [ - { "name": "functionId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the function to get details for." } - ], - "returns": [ - { "name": "details", "$ref": "FunctionDetails", "description": "Information about the function." } - ], - "description": "Returns detailed information on given function." - }, - { - "name": "getGeneratorObjectDetails", - "hidden": true, - "parameters": [ - { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the generator object to get details for." } - ], - "returns": [ - { "name": "details", "$ref": "GeneratorObjectDetails", "description": "Information about the generator object." } - ], - "description": "Returns detailed information on given generator object." - }, - { - "name": "getCollectionEntries", - "hidden": true, - "parameters": [ - { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the collection to get entries for." } - ], - "returns": [ - { "name": "entries", "type": "array", "items": { "$ref": "CollectionEntry" }, "description": "Array of collection entries." } - ], - "description": "Returns entries of given collection." - }, { "name": "setPauseOnExceptions", "parameters": [ @@ -733,7 +700,7 @@ "name": "paused", "parameters": [ { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." }, - { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "CSPViolation", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." }, + { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." }, { "name": "data", "type": "object", "optional": true, "description": "Object containing break-specific auxiliary properties." }, { "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs", "hidden": true }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true } @@ -746,6 +713,64 @@ } ] }, + { + "domain": "Console", + "description": "This domain is deprecated - use Runtime or Log instead.", + "dependencies": ["Runtime"], + "deprecated": true, + "types": [ + { + "id": "ConsoleMessage", + "type": "object", + "description": "Console message.", + "properties": [ + { "name": "source", "type": "string", "enum": ["xml", "javascript", "network", "console-api", "storage", "appcache", "rendering", "security", "other", "deprecation", "worker"], "description": "Message source." }, + { "name": "level", "type": "string", "enum": ["log", "warning", "error", "debug", "info"], "description": "Message severity." }, + { "name": "text", "type": "string", "description": "Message text." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, + { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message (1-based)." }, + { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message (1-based)." } + ] + } + ], + "commands": [ + { + "name": "enable", + "description": "Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification." + }, + { + "name": "disable", + "description": "Disables console domain, prevents further console messages from being reported to the client." + }, + { + "name": "clearMessages", + "description": "Does nothing." + } + ], + "events": [ + { + "name": "messageAdded", + "parameters": [ + { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + ], + "description": "Issued when new console message is added." + }, + { + "name": "messageRepeatCountUpdated", + "parameters": [ + { "name": "count", "type": "integer", "description": "New repeat count value." }, + { "name": "timestamp", "$ref": "Runtime.Timestamp", "description": "Timestamp of most recent message in batch.", "hidden": true } + ], + "description": "Not issued.", + "deprecated": true + }, + { + "name": "messagesCleared", + "description": "Not issued.", + "deprecated": true + } + ] + }, { "domain": "Profiler", "dependencies": ["Runtime", "Debugger"], @@ -756,13 +781,8 @@ "type": "object", "description": "CPU Profile node. Holds callsite information, execution statistics and child nodes.", "properties": [ - { "name": "functionName", "type": "string", "description": "Function name." }, - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." }, - { "name": "url", "type": "string", "description": "URL." }, - { "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." }, - { "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, { "name": "hitCount", "type": "integer", "description": "Number of samples where this node was on top of the call stack." }, - { "name": "callUID", "type": "number", "description": "Call UID." }, { "name": "children", "type": "array", "items": { "$ref": "CPUProfileNode" }, "description": "Child nodes." }, { "name": "deoptReason", "type": "string", "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."}, { "name": "id", "type": "integer", "description": "Unique id of the node." }, @@ -822,7 +842,6 @@ { "name": "id", "type": "string" }, { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profile()." }, { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as argument to console.profile()." } - ], "description": "Sent when new profile recodring is started using console.profile() call." }, @@ -852,11 +871,7 @@ "type": "object", "description": "Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.", "properties": [ - { "name": "functionName", "type": "string", "description": "Function name." }, - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." }, - { "name": "url", "type": "string", "description": "URL." }, - { "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." }, - { "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, { "name": "selfSize", "type": "number", "description": "Allocations size in bytes for the node excluding children." }, { "name": "children", "type": "array", "items": { "$ref": "SamplingHeapProfileNode" }, "description": "Child nodes." } ] @@ -888,7 +903,6 @@ "parameters": [ { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped." } ] - }, { "name": "takeHeapSnapshot", diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h new file mode 100644 index 00000000000000..73c1878e9e3d84 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h @@ -0,0 +1,20 @@ +// Copyright 2016 The Chromium 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 V8ConsoleTypes_h +#define V8ConsoleTypes_h + +namespace blink { + +enum MessageLevel { + DebugMessageLevel = 4, + LogMessageLevel = 1, + InfoMessageLevel = 5, + WarningMessageLevel = 2, + ErrorMessageLevel = 3 +}; + +} + +#endif // !defined(V8ConsoleTypes_h) diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h similarity index 94% rename from deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h index 35cf12331f88c9..a932b7a4664c92 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h @@ -7,6 +7,7 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Debugger.h" namespace blink { diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h index 43ce46f9f6a35f..0dc1de29da75e5 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h @@ -5,7 +5,6 @@ #ifndef V8ContextInfo_h #define V8ContextInfo_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/String16.h" #include @@ -33,6 +32,7 @@ class V8ContextInfo { bool isDefault; const String16 origin; const String16 humanReadableName; + // TODO(dgozman): aux data? const String16 frameId; bool hasMemoryOnConsole; }; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h similarity index 50% rename from deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h index b605d8a15e9fa4..da3dcacf555b15 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h @@ -7,6 +7,7 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" #include @@ -19,7 +20,6 @@ class V8InspectorSessionClient; class V8StackTrace; namespace protocol { -class DictionaryValue; class FrontendChannel; } @@ -28,23 +28,37 @@ class PLATFORM_EXPORT V8Debugger { static std::unique_ptr create(v8::Isolate*, V8DebuggerClient*); virtual ~V8Debugger() { } - // TODO(dgozman): make this non-static? - static int contextId(v8::Local); - + // Contexts instrumentation. virtual void contextCreated(const V8ContextInfo&) = 0; virtual void contextDestroyed(v8::Local) = 0; - // TODO(dgozman): remove this one. 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; - virtual std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) = 0; - virtual bool isPaused() = 0; + // Async call stacks instrumentation. + virtual void asyncTaskScheduled(const String16& 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; + // Runtime instrumentation. + // TODO(dgozman): can we pass exception object? + virtual void exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) = 0; + virtual unsigned promiseRejected(v8::Local, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) = 0; + virtual void promiseRejectionRevoked(v8::Local, unsigned promiseRejectionId) = 0; + + // TODO(dgozman): can we remove this method? + virtual void logToConsole(v8::Local, v8::Local arg1, v8::Local arg2) = 0; + + // API methods. + virtual std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) = 0; virtual std::unique_ptr createStackTrace(v8::Local) = 0; - virtual std::unique_ptr captureStackTrace(size_t maxStackSize) = 0; + virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h similarity index 73% rename from deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h index e927d4cc664c81..3747f66707d051 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h @@ -6,23 +6,22 @@ #define V8DebuggerClient_h #include "platform/inspector_protocol/Platform.h" -#include "platform/v8_inspector/public/ConsoleAPITypes.h" -#include "platform/v8_inspector/public/ConsoleTypes.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" #include "platform/v8_inspector/public/V8ContextInfo.h" #include namespace blink { +class V8StackTrace; + class PLATFORM_EXPORT V8DebuggerClient { public: virtual ~V8DebuggerClient() { } virtual void runMessageLoopOnPause(int contextGroupId) = 0; virtual void quitMessageLoopOnPause() = 0; - virtual void muteWarningsAndDeprecations() = 0; - virtual void unmuteWarningsAndDeprecations() = 0; - virtual void muteConsole() = 0; - virtual void unmuteConsole() = 0; + virtual void muteWarningsAndDeprecations(int contextGroupId) = 0; + virtual void unmuteWarningsAndDeprecations(int contextGroupId) = 0; virtual void beginUserGesture() = 0; virtual void endUserGesture() = 0; virtual bool callingContextCanAccessContext(v8::Local calling, v8::Local target) = 0; @@ -30,15 +29,17 @@ class PLATFORM_EXPORT V8DebuggerClient { virtual bool formatAccessorsAsProperties(v8::Local) = 0; virtual bool isExecutionAllowed() = 0; virtual double currentTimeMS() = 0; - virtual int ensureDefaultContextInGroup(int contextGroupId) = 0; + virtual v8::Local ensureDefaultContextInGroup(int contextGroupId) = 0; virtual bool isInspectableHeapObject(v8::Local) = 0; + virtual void enableAsyncInstrumentation() = 0; + virtual void disableAsyncInstrumentation() = 0; virtual void installAdditionalCommandLineAPI(v8::Local, v8::Local) = 0; - virtual void reportMessageToConsole(v8::Local, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo* arguments, unsigned skipArgumentCount) = 0; virtual void consoleTime(const String16& title) = 0; virtual void consoleTimeEnd(const String16& title) = 0; virtual void consoleTimeStamp(const String16& title) = 0; + virtual void consoleAPIMessage(int contextGroupId, MessageLevel, const String16& message, const String16& url, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) = 0; virtual v8::MaybeLocal memoryInfo(v8::Isolate*, v8::Local) = 0; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp similarity index 89% rename from deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp index fadab16d7ebd1e..f118dcacf3ce5a 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp @@ -13,6 +13,7 @@ namespace blink { V8Inspector::V8Inspector(v8::Isolate* isolate, v8::Local context) + : m_context(context) { m_debugger = V8Debugger::create(isolate, this); m_debugger->contextCreated(V8ContextInfo(context, 1, true, "", @@ -55,21 +56,17 @@ void V8Inspector::dispatchMessageFromFrontend(const String16& message) m_session->dispatchProtocolMessage(message); } -int V8Inspector::ensureDefaultContextInGroup(int contextGroupId) +v8::Local V8Inspector::ensureDefaultContextInGroup(int) { - return 1; + return m_context; } -void V8Inspector::muteConsole() -{ -} - -void V8Inspector::unmuteConsole() +bool V8Inspector::isExecutionAllowed() { - + return true; } -bool V8Inspector::isExecutionAllowed() +bool V8Inspector::canExecuteScripts() { return true; } diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h similarity index 73% rename from deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h index 38bbc88774cf9c..4dbb797d50935f 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h @@ -38,40 +38,42 @@ class V8Inspector : public V8DebuggerClient, V8InspectorSessionClient { bool callingContextCanAccessContext(v8::Local calling, v8::Local target) override; String16 valueSubtype(v8::Local) override; bool formatAccessorsAsProperties(v8::Local) override; - void muteWarningsAndDeprecations() override { } - void unmuteWarningsAndDeprecations() override { } + void muteWarningsAndDeprecations(int) override { } + void unmuteWarningsAndDeprecations(int) override { } double currentTimeMS() override { return 0; }; - void muteConsole() override; - void unmuteConsole() override; bool isExecutionAllowed() override; - int ensureDefaultContextInGroup(int contextGroupId) override; + v8::Local ensureDefaultContextInGroup(int contextGroupId) override; void beginUserGesture() override { } void endUserGesture() override { } bool isInspectableHeapObject(v8::Local) override { return true; } void consoleTime(const String16& title) override { } void consoleTimeEnd(const String16& title) override { } void consoleTimeStamp(const String16& title) override { } + void consoleAPIMessage(int contextGroupId, MessageLevel, const String16& message, const String16& url, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) override { } v8::MaybeLocal memoryInfo(v8::Isolate*, v8::Local) override { return v8::MaybeLocal(); } - void reportMessageToConsole(v8::Local, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo* arguments, unsigned skipArgumentCount) override { } void installAdditionalCommandLineAPI(v8::Local, v8::Local) override { } - - // V8InspectorSessionClient - void startInstrumenting() override { } - void stopInstrumenting() override { } - void resumeStartup() override { } - bool canExecuteScripts() override { return true; } - void profilingStarted() override { } - void profilingStopped() override { } + void enableAsyncInstrumentation() override { } + void disableAsyncInstrumentation() override { } void startRepeatingTimer(double, TimerCallback, void* data) override { } void cancelTimer(void* data) override { } + // V8InspectorSessionClient + void runtimeEnabled() override { }; + void runtimeDisabled() override { }; + void resumeStartup() override { }; + bool canExecuteScripts() override; + void profilingStarted() override { }; + void profilingStopped() override { }; + void consoleCleared() override { }; + std::unique_ptr m_debugger; std::unique_ptr m_session; String16 m_state; + v8::Local m_context; }; } diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h similarity index 64% rename from deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h index e9ad175afc830b..2103467e44087b 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h @@ -12,15 +12,9 @@ namespace blink { -class V8DebuggerAgent; -class V8HeapProfilerAgent; -class V8InspectorSessionClient; -class V8ProfilerAgent; -class V8RuntimeAgent; - class PLATFORM_EXPORT V8InspectorSession { public: - static const char backtraceObjectGroup[]; + virtual ~V8InspectorSession() { } // Cross-context inspectable values (DOM nodes in different worlds, etc.). class Inspectable { @@ -28,34 +22,25 @@ class PLATFORM_EXPORT V8InspectorSession { virtual v8::Local get(v8::Local) = 0; virtual ~Inspectable() { } }; + virtual void addInspectedObject(std::unique_ptr) = 0; - virtual ~V8InspectorSession() { } - + // Dispatching protocol messages. + // TODO(dgozman): generate this one. static bool isV8ProtocolMethod(const String16& method); virtual void dispatchProtocolMessage(const String16& message) = 0; virtual String16 stateJSON() = 0; - virtual void addInspectedObject(std::unique_ptr) = 0; - // API for the embedder to report native activities. + // Debugger actions. virtual void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) = 0; virtual void cancelPauseOnNextStatement() = 0; virtual void breakProgram(const String16& breakReason, std::unique_ptr data) = 0; - virtual void breakProgramOnException(const String16& breakReason, std::unique_ptr data) = 0; virtual void setSkipAllPauses(bool) = 0; virtual void resume() = 0; virtual void stepOver() = 0; - // API to report async call stacks. - virtual void asyncTaskScheduled(const String16& 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; - - // API to work with remote objects. - virtual std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview = false) = 0; - // FIXME: remove when InspectorConsoleAgent moves into V8 inspector. - virtual std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns) = 0; + // Remote objects. + static const char backtraceObjectGroup[]; + virtual std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview) = 0; virtual v8::Local findObject(ErrorString*, const String16& objectId, v8::Local* = nullptr, String16* objectGroup = nullptr) = 0; virtual void releaseObjectGroup(const String16&) = 0; }; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h similarity index 68% rename from deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h index 87772b3cca241e..e9e7c33ea83fd2 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h @@ -5,23 +5,23 @@ #ifndef V8InspectorSessionClient_h #define V8InspectorSessionClient_h -#include "platform/inspector_protocol/FrontendChannel.h" #include "platform/inspector_protocol/Platform.h" #include namespace blink { -class PLATFORM_EXPORT V8InspectorSessionClient -{ +class PLATFORM_EXPORT V8InspectorSessionClient { public: virtual ~V8InspectorSessionClient() { } - virtual void startInstrumenting() = 0; - virtual void stopInstrumenting() = 0; + virtual void runtimeEnabled() = 0; + virtual void runtimeDisabled() = 0; virtual void resumeStartup() = 0; + // TODO(dgozman): this was added to support service worker shadow page. We should not connect at all. virtual bool canExecuteScripts() = 0; virtual void profilingStarted() = 0; virtual void profilingStopped() = 0; + virtual void consoleCleared() = 0; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h similarity index 74% rename from deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h index 6d5c4804c4be35..beee1155f6e87f 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h @@ -13,19 +13,9 @@ namespace blink { -class TracedValue; - -const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast( - v8::StackTrace::kLineNumber | - v8::StackTrace::kColumnOffset | - v8::StackTrace::kScriptId | - v8::StackTrace::kScriptNameOrSourceURL | - v8::StackTrace::kFunctionName); - +// TODO(dgozman): migrate to V8SourceLocation. class V8StackTrace { public: - static const size_t maxCallStackSizeToCapture = 200; - virtual bool isEmpty() const = 0; virtual String16 topSourceURL() const = 0; virtual int topLineNumber() const = 0; diff --git a/deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp index a9b31dc1d4a4af..6de6017c6931af 100644 --- a/deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp @@ -57,8 +57,8 @@ ['debug_devtools=="node"', { # Node build 'jinja_module_files': [ - '../../deps/jinja2/jinja2/__init__.py', - '../../deps/markupsafe/markupsafe/__init__.py', # jinja2 dep + '../../../jinja2/jinja2/__init__.py', + '../../../markupsafe/markupsafe/__init__.py', # jinja2 dep ], }, { 'jinja_module_files': [ @@ -83,6 +83,8 @@ 'js_protocol.json', ], 'outputs': [ + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.cpp', + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.h', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h', '<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp', @@ -143,11 +145,13 @@ ], 'include_dirs': [ '../..', - '../../../v8/include', - '../../../v8', + '../../../../../v8/include', + '../../../../../v8', '<(SHARED_INTERMEDIATE_DIR)/blink', ], 'sources': [ + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.cpp', + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.h', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h', '<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp', @@ -160,7 +164,6 @@ '../inspector_protocol/Allocator.h', '../inspector_protocol/Array.h', '../inspector_protocol/Collections.h', - '../inspector_protocol/CollectionsSTL.h', '../inspector_protocol/DispatcherBase.cpp', '../inspector_protocol/DispatcherBase.h', '../inspector_protocol/ErrorSupport.cpp', @@ -193,6 +196,10 @@ 'RemoteObjectId.h', 'V8Console.cpp', 'V8Console.h', + 'V8ConsoleAgentImpl.cpp', + 'V8ConsoleAgentImpl.h', + 'V8ConsoleMessage.cpp', + 'V8ConsoleMessage.h', 'V8DebuggerAgentImpl.cpp', 'V8DebuggerAgentImpl.h', 'V8DebuggerImpl.cpp', @@ -207,6 +214,8 @@ 'V8InjectedScriptHost.h', 'V8InspectorSessionImpl.cpp', 'V8InspectorSessionImpl.h', + 'V8InternalValueType.cpp', + 'V8InternalValueType.h', 'V8ProfilerAgentImpl.cpp', 'V8ProfilerAgentImpl.h', 'V8Regex.cpp', @@ -227,10 +236,9 @@ 'public/V8Inspector.h', 'public/V8InspectorSession.h', 'public/V8StackTrace.h', - 'public/V8ToProtocolValue.h', - '<(blink_platform_output_dir/v8_inspector/DebuggerScript.h', - '<(blink_platform_output_dir/v8_inspector/InjectedScriptSource.h', + '<(blink_platform_output_dir)/v8_inspector/DebuggerScript.h', + '<(blink_platform_output_dir)/v8_inspector/InjectedScriptSource.h', ], }, ], # targets diff --git a/node.gyp b/node.gyp index d6fb9b2449c9fb..5452027a5bf5f5 100644 --- a/node.gyp +++ b/node.gyp @@ -306,6 +306,7 @@ 'defines': [ 'HAVE_INSPECTOR=1', 'V8_INSPECTOR_USE_STL=1', + 'V8_INSPECTOR_USE_OLD_STL=1', ], 'sources': [ 'src/inspector_agent.cc', @@ -314,11 +315,11 @@ 'src/inspector-agent.h', ], 'dependencies': [ - 'deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp:v8_inspector_stl', + 'deps/v8_inspector/third_party/v8_inspector/platform/' + 'v8_inspector/v8_inspector.gyp:v8_inspector_stl', ], 'include_dirs': [ - 'deps/v8_inspector', - 'deps/v8_inspector/deps/wtf', # temporary + 'deps/v8_inspector/third_party/v8_inspector', '<(SHARED_INTERMEDIATE_DIR)/blink', # for inspector ], }, { diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index d8233f41dc2de9..66928e09b114c0 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -36,7 +36,7 @@ const char TAG_CONNECT[] = "#connect"; const char TAG_DISCONNECT[] = "#disconnect"; const char DEVTOOLS_PATH[] = "/node"; -const char DEVTOOLS_HASH[] = "521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef"; +const char DEVTOOLS_HASH[] = "851972d6da7463c353d712d2cb6c1ec23fa6c4fe"; void PrintDebuggerReadyMessage(int port) { fprintf(stderr, "Debugger listening on port %d.\n"