diff --git a/deps/v8_inspector/README.md b/deps/v8_inspector/README.md index d99d25f94ce3aa..60578c90324ed0 100644 --- a/deps/v8_inspector/README.md +++ b/deps/v8_inspector/README.md @@ -7,4 +7,5 @@ Node.js support for the [Chrome Debug Protocol][https://developer.chrome.com/dev * 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 + * The `tests/` directory `ext/jinja.el` file have been deleted. * third_party/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h index d92af3a5ed7d05..720182258b9533 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h @@ -17,7 +17,7 @@ namespace blink { namespace protocol { template -class ArrayBase { +class Array { public: static std::unique_ptr> create() { @@ -31,12 +31,12 @@ class ArrayBase { errors->addError("array expected"); return nullptr; } - errors->push(); std::unique_ptr> result(new Array()); + errors->push(); for (size_t i = 0; i < array->size(); ++i) { errors->setName(String16::fromInteger(i)); - T item = FromValue::parse(array->at(i), errors); - result->m_vector.push_back(item); + std::unique_ptr item = ValueConversions::parse(array->at(i), errors); + result->m_vector.push_back(std::move(item)); } errors->pop(); if (errors->hasErrors()) @@ -44,9 +44,9 @@ class ArrayBase { return result; } - void addItem(const T& value) + void addItem(std::unique_ptr value) { - m_vector.push_back(value); + m_vector.push_back(std::move(value)); } size_t length() @@ -54,31 +54,25 @@ class ArrayBase { return m_vector.size(); } - T get(size_t index) + T* get(size_t index) { - return m_vector[index]; + return m_vector[index].get(); } std::unique_ptr serialize() { std::unique_ptr result = ListValue::create(); for (auto& item : m_vector) - result->pushValue(toValue(item)); + result->pushValue(ValueConversions::serialize(item)); return result; } private: - std::vector m_vector; + std::vector> m_vector; }; -template<> class Array : public ArrayBase {}; -template<> class Array : public ArrayBase {}; -template<> class Array : public ArrayBase {}; -template<> class Array : public ArrayBase {}; -template<> class Array : public ArrayBase {}; - template -class Array { +class ArrayBase { public: static std::unique_ptr> create() { @@ -92,12 +86,12 @@ class Array { errors->addError("array expected"); return nullptr; } - std::unique_ptr> result(new Array()); errors->push(); + std::unique_ptr> result(new Array()); for (size_t i = 0; i < array->size(); ++i) { errors->setName(String16::fromInteger(i)); - std::unique_ptr item = FromValue::parse(array->at(i), errors); - result->m_vector.push_back(std::move(item)); + T item = ValueConversions::parse(array->at(i), errors); + result->m_vector.push_back(item); } errors->pop(); if (errors->hasErrors()) @@ -105,9 +99,9 @@ class Array { return result; } - void addItem(std::unique_ptr value) + void addItem(const T& value) { - m_vector.push_back(std::move(value)); + m_vector.push_back(value); } size_t length() @@ -115,23 +109,29 @@ class Array { return m_vector.size(); } - T* get(size_t index) + T get(size_t index) { - return m_vector[index].get(); + return m_vector[index]; } std::unique_ptr serialize() { std::unique_ptr result = ListValue::create(); for (auto& item : m_vector) - result->pushValue(toValue(item)); + result->pushValue(ValueConversions::serialize(item)); return result; } private: - std::vector> m_vector; + std::vector m_vector; }; +template<> class Array : public ArrayBase {}; +template<> class Array : public ArrayBase {}; +template<> class Array : public ArrayBase {}; +template<> class Array : public ArrayBase {}; +template<> class Array : public ArrayBase {}; + } // namespace platform } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py index c785c79b528fd1..0b09c8e90401dd 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py @@ -24,11 +24,18 @@ # In Blink, jinja2 is in chromium's third_party directory. # 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( +blink_third_party_dir = os.path.normpath(os.path.join( 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) +if os.path.isdir(blink_third_party_dir): + sys.path.insert(1, blink_third_party_dir) + +# In V8, it is in third_party folder +v8_third_party_dir = os.path.normpath(os.path.join( + module_path, os.pardir, os.pardir, "third_party")) + +if os.path.isdir(v8_third_party_dir): + sys.path.insert(1, v8_third_party_dir) # In Node, it is in deps folder deps_dir = os.path.normpath(os.path.join( @@ -43,10 +50,13 @@ cmdline_parser = optparse.OptionParser() cmdline_parser.add_option("--protocol") cmdline_parser.add_option("--include") +cmdline_parser.add_option("--include_package") cmdline_parser.add_option("--string_type") cmdline_parser.add_option("--export_macro") cmdline_parser.add_option("--output_dir") cmdline_parser.add_option("--output_package") +cmdline_parser.add_option("--exported_dir") +cmdline_parser.add_option("--exported_package") try: arg_options, arg_values = cmdline_parser.parse_args() @@ -54,12 +64,23 @@ if not protocol_file: raise Exception("Protocol directory must be specified") include_file = arg_options.include + include_package = arg_options.include_package + if include_file and not include_package: + raise Exception("Include package must be specified when using include file") + if include_package and not include_file: + raise Exception("Include file must be specified when using include package") output_dirname = arg_options.output_dir if not output_dirname: raise Exception("Output directory must be specified") output_package = arg_options.output_package if not output_package: raise Exception("Output package must be specified") + exported_dirname = arg_options.exported_dir + if not exported_dirname: + exported_dirname = os.path.join(output_dirname, "exported") + exported_package = arg_options.exported_package + if not exported_package: + exported_package = os.path.join(output_package, "exported") string_type = arg_options.string_type if not string_type: raise Exception("String type must be specified") @@ -84,30 +105,38 @@ def up_to_date(): os.path.getmtime(__file__), os.path.getmtime(os.path.join(templates_dir, "TypeBuilder_h.template")), os.path.getmtime(os.path.join(templates_dir, "TypeBuilder_cpp.template")), + os.path.getmtime(os.path.join(templates_dir, "Exported_h.template")), + os.path.getmtime(os.path.join(templates_dir, "Imported_h.template")), os.path.getmtime(protocol_file)) for domain in parsed_json["domains"]: name = domain["domain"] - h_path = os.path.join(output_dirname, name + ".h") - cpp_path = os.path.join(output_dirname, name + ".cpp") - if not os.path.exists(h_path) or not os.path.exists(cpp_path): - return False - generated_ts = max(os.path.getmtime(h_path), os.path.getmtime(cpp_path)) - if generated_ts < template_ts: - return False + paths = [] + if name in generate_domains: + paths = [os.path.join(output_dirname, name + ".h"), os.path.join(output_dirname, name + ".cpp")] + if domain["has_exports"]: + paths.append(os.path.join(exported_dirname, name + ".h")) + if name in include_domains and domain["has_exports"]: + paths = [os.path.join(output_dirname, name + '.h')] + for path in paths: + if not os.path.exists(path): + return False + generated_ts = os.path.getmtime(path) + if generated_ts < template_ts: + return False return True -if up_to_date(): - sys.exit() - - def to_title_case(name): return name[:1].upper() + name[1:] def dash_to_camelcase(word): - return "".join(to_title_case(x) or "-" for x in word.split("-")) + prefix = "" + if word[0] == "-": + prefix = "Negative" + word = word[1:] + return prefix + "".join(to_title_case(x) or "-" for x in word.split("-")) def initialize_jinja_env(cache_dir): @@ -144,12 +173,47 @@ def patch_full_qualified_refs_in_domain(json, domain_name): continue if json["$ref"].find(".") == -1: json["$ref"] = domain_name + "." + json["$ref"] + return for domain in json_api["domains"]: patch_full_qualified_refs_in_domain(domain, domain["domain"]) +def calculate_exports(): + def calculate_exports_in_json(json_value): + has_exports = False + if isinstance(json_value, list): + for item in json_value: + has_exports = calculate_exports_in_json(item) or has_exports + if isinstance(json_value, dict): + has_exports = ("exported" in json_value and json_value["exported"]) or has_exports + for key in json_value: + has_exports = calculate_exports_in_json(json_value[key]) or has_exports + return has_exports + + json_api["has_exports"] = False + for domain_json in json_api["domains"]: + domain_json["has_exports"] = calculate_exports_in_json(domain_json) + json_api["has_exports"] = json_api["has_exports"] or domain_json["has_exports"] + + +def create_include_type_definition(domain_name, type): + # pylint: disable=W0622 + return { + "return_type": "std::unique_ptr" % (domain_name, type["id"]), + "pass_type": "std::unique_ptr" % (domain_name, type["id"]), + "to_raw_type": "%s.get()", + "to_pass_type": "std::move(%s)", + "to_rvalue": "std::move(%s)", + "type": "std::unique_ptr" % (domain_name, type["id"]), + "raw_type": "protocol::%s::API::%s" % (domain_name, type["id"]), + "raw_pass_type": "protocol::%s::API::%s*" % (domain_name, type["id"]), + "raw_return_type": "protocol::%s::API::%s*" % (domain_name, type["id"]), + } + + def create_user_type_definition(domain_name, type): + # pylint: disable=W0622 return { "return_type": "std::unique_ptr" % (domain_name, type["id"]), "pass_type": "std::unique_ptr" % (domain_name, type["id"]), @@ -164,6 +228,7 @@ def create_user_type_definition(domain_name, type): def create_object_type_definition(): + # pylint: disable=W0622 return { "return_type": "std::unique_ptr", "pass_type": "std::unique_ptr", @@ -178,6 +243,7 @@ def create_object_type_definition(): def create_any_type_definition(): + # pylint: disable=W0622 return { "return_type": "std::unique_ptr", "pass_type": "std::unique_ptr", @@ -192,6 +258,7 @@ def create_any_type_definition(): def create_string_type_definition(domain): + # pylint: disable=W0622 return { "return_type": string_type, "pass_type": ("const %s&" % string_type), @@ -206,6 +273,7 @@ def create_string_type_definition(domain): def create_primitive_type_definition(type): + # pylint: disable=W0622 typedefs = { "number": "double", "integer": "int", @@ -244,6 +312,7 @@ def create_primitive_type_definition(type): def wrap_array_definition(type): + # pylint: disable=W0622 return { "return_type": "std::unique_ptr>" % type["raw_type"], "pass_type": "std::unique_ptr>" % type["raw_type"], @@ -265,15 +334,18 @@ def create_type_definitions(): if not ("types" in domain): continue for type in domain["types"]: - if type["type"] == "object": - type_definitions[domain["domain"] + "." + type["id"]] = create_user_type_definition(domain["domain"], type) + type_name = domain["domain"] + "." + type["id"] + if type["type"] == "object" and domain["domain"] in include_domains: + type_definitions[type_name] = create_include_type_definition(domain["domain"], type) + elif type["type"] == "object": + type_definitions[type_name] = create_user_type_definition(domain["domain"], type) elif type["type"] == "array": items_type = type["items"]["type"] - type_definitions[domain["domain"] + "." + type["id"]] = wrap_array_definition(type_definitions[items_type]) + type_definitions[type_name] = wrap_array_definition(type_definitions[items_type]) elif type["type"] == domain["domain"] + ".string": - type_definitions[domain["domain"] + "." + type["id"]] = create_string_type_definition(domain["domain"]) + type_definitions[type_name] = create_string_type_definition(domain["domain"]) else: - type_definitions[domain["domain"] + "." + type["id"]] = create_primitive_type_definition(type["type"]) + type_definitions[type_name] = create_primitive_type_definition(type["type"]) def type_definition(name): @@ -303,7 +375,25 @@ def has_disable(commands): return False +def generate(domain_object, template, file_name): + template_context = { + "domain": domain_object, + "join_arrays": join_arrays, + "resolve_type": resolve_type, + "type_definition": type_definition, + "has_disable": has_disable, + "export_macro": export_macro, + "output_package": output_package, + "exported_package": exported_package, + "include_package": include_package + } + out_file = output_file(file_name) + out_file.write(template.render(template_context)) + out_file.close() + + generate_domains = [] +include_domains = [] json_api = {} json_api["domains"] = parsed_json["domains"] @@ -314,44 +404,33 @@ def has_disable(commands): input_file = open(include_file, "r") json_string = input_file.read() parsed_json = json.loads(json_string) + for domain in parsed_json["domains"]: + include_domains.append(domain["domain"]) json_api["domains"] += parsed_json["domains"] - patch_full_qualified_refs() +calculate_exports() create_type_definitions() +if up_to_date(): + sys.exit() if not os.path.exists(output_dirname): os.mkdir(output_dirname) -jinja_env = initialize_jinja_env(output_dirname) - -h_template_name = "/TypeBuilder_h.template" -cpp_template_name = "/TypeBuilder_cpp.template" -h_template = jinja_env.get_template(h_template_name) -cpp_template = jinja_env.get_template(cpp_template_name) - - -def generate(domain): - class_name = domain["domain"] - h_file_name = output_dirname + "/" + class_name + ".h" - cpp_file_name = output_dirname + "/" + class_name + ".cpp" - - template_context = { - "domain": domain, - "join_arrays": join_arrays, - "resolve_type": resolve_type, - "type_definition": type_definition, - "has_disable": has_disable, - "export_macro": export_macro, - "output_package": output_package, - } - h_file = output_file(h_file_name) - cpp_file = output_file(cpp_file_name) - h_file.write(h_template.render(template_context)) - cpp_file.write(cpp_template.render(template_context)) - h_file.close() - cpp_file.close() +if json_api["has_exports"] and not os.path.exists(exported_dirname): + os.mkdir(exported_dirname) +jinja_env = initialize_jinja_env(output_dirname) +h_template = jinja_env.get_template("/TypeBuilder_h.template") +cpp_template = jinja_env.get_template("/TypeBuilder_cpp.template") +exported_template = jinja_env.get_template("/Exported_h.template") +imported_template = jinja_env.get_template("/Imported_h.template") for domain in json_api["domains"]: + class_name = domain["domain"] if domain["domain"] in generate_domains: - generate(domain) + generate(domain, h_template, output_dirname + "/" + class_name + ".h") + generate(domain, cpp_template, output_dirname + "/" + class_name + ".cpp") + if domain["has_exports"]: + generate(domain, exported_template, exported_dirname + "/" + class_name + ".h") + if domain["domain"] in include_domains and domain["has_exports"]: + generate(domain, imported_template, output_dirname + "/" + class_name + ".h") diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp index 49422eba09a9ca..8f154f42ac286f 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp @@ -34,7 +34,7 @@ void DispatcherBase::Callback::dispose() void DispatcherBase::Callback::sendIfActive(std::unique_ptr partialMessage, const ErrorString& invocationError) { - if (!m_backendImpl->get()) + if (!m_backendImpl || !m_backendImpl->get()) return; m_backendImpl->get()->sendResponse(m_callId, invocationError, nullptr, std::move(partialMessage)); m_backendImpl = nullptr; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Exported_h.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Exported_h.template new file mode 100644 index 00000000000000..5cfabc53cf1fbe --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Exported_h.template @@ -0,0 +1,65 @@ +// This file is generated + +// Copyright (c) 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 protocol_{{domain.domain}}_api_h +#define protocol_{{domain.domain}}_api_h + +{% if export_macro == "PLATFORM_EXPORT" %} +#include "platform/inspector_protocol/Platform.h" +{% else %} +#include "core/CoreExport.h" +{% endif %} +#include "platform/inspector_protocol/String16.h" + +namespace blink { +namespace protocol { +namespace {{domain.domain}} { +namespace API { + +// ------------- Enums. + {% for type in domain.types %} + {% if ("enum" in type) and type.exported %} + +namespace {{type.id}}Enum { + {% for literal in type.enum %} +{{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; + {% endfor %} +} // {{type.id}}Enum + {% endif %} + {% endfor %} + {% for command in join_arrays(domain, ["commands", "events"]) %} + {% for param in join_arrays(command, ["parameters", "returns"]) %} + {% if ("enum" in param) and (param.exported) %} + +namespace {{command.name | to_title_case}} { +namespace {{param.name | to_title_case}}Enum { + {% for literal in param.enum %} +{{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; + {% endfor %} +} // {{param.name | to_title_case}}Enum +} // {{command.name | to_title_case }} + {% endif %} + {% endfor %} + {% endfor %} + +// ------------- Types. + {% for type in domain.types %} + {% if not (type.type == "object") or not ("properties" in type) or not (type.exported) %}{% continue %}{% endif %} + +class {{export_macro}} {{type.id}} { +public: + virtual String16 toJSONString() const = 0; + virtual ~{{type.id}}() { } + static std::unique_ptr fromJSONString(const String16& json); +}; + {% endfor %} + +} // namespace API +} // namespace {{domain.domain}} +} // namespace protocol +} // namespace blink + +#endif // !defined(protocol_{{domain.domain}}_api_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Imported_h.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Imported_h.template new file mode 100644 index 00000000000000..a9abdad172642e --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Imported_h.template @@ -0,0 +1,49 @@ +// This file is generated + +// Copyright (c) 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 protocol_{{domain.domain}}_imported_h +#define protocol_{{domain.domain}}_imported_h + +#include "platform/inspector_protocol/ErrorSupport.h" +#include "platform/inspector_protocol/ValueConversions.h" +#include "platform/inspector_protocol/Values.h" +#include "{{include_package}}/{{domain.domain}}.h" + +namespace blink { +namespace protocol { + {% for type in domain.types %} + {% if not (type.type == "object") or not ("properties" in type) or not (type.exported) %}{% continue %}{% endif %} + +template<> +struct ValueConversions<{{domain.domain}}::API::{{type.id}}> { + static std::unique_ptr<{{domain.domain}}::API::{{type.id}}> parse(protocol::Value* value, ErrorSupport* errors) + { + if (!value) { + errors->addError("value expected"); + return nullptr; + } + std::unique_ptr<{{domain.domain}}::API::{{type.id}}> result = {{domain.domain}}::API::{{type.id}}::fromJSONString(value->toJSONString()); + if (!result) + errors->addError("cannot parse"); + return result; + } + + static std::unique_ptr serialize({{domain.domain}}::API::{{type.id}}* value) + { + return SerializedValue::create(value->toJSONString()); + } + + static std::unique_ptr serialize(const std::unique_ptr<{{domain.domain}}::API::{{type.id}}>& value) + { + return SerializedValue::create(value->toJSONString()); + } +}; + {% endfor %} + +} // namespace protocol +} // namespace blink + +#endif // !defined(protocol_{{domain.domain}}_imported_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp index 4883f4ceda46e1..10c7fa61017dd7 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp @@ -113,14 +113,6 @@ inline char upperNibbleToASCIIHexDigit(char c) return nibble < 10 ? '0' + nibble : 'A' + nibble - 10; } -template inline bool isASCIIAlphaCaselessEqual(CharType cssCharacter, char character) -{ - // This function compares a (preferrably) constant ASCII - // lowercase letter to any input character. - DCHECK(character >= 'a' && character <= 'z'); - return LIKELY(toASCIILowerUnchecked(cssCharacter) == character); -} - inline int inlineUTF8SequenceLengthNonASCII(char b0) { if ((b0 & 0xC0) != 0xC0) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h index 703e5b0f025d94..4dd4369ebdd788 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h @@ -5,6 +5,7 @@ #ifndef String16STL_h #define String16STL_h +#include #include #include #include @@ -141,7 +142,7 @@ class String16 { static inline bool isSpaceOrNewline(UChar c) { - return false; + return std::isspace(c); // NOLINT } class String16Builder { diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template index 909fea4e71a7ff..e3c2fa1de6761d 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template @@ -7,6 +7,7 @@ #include "{{output_package}}/{{domain.domain}}.h" #include "platform/inspector_protocol/DispatcherBase.h" +#include "platform/inspector_protocol/Parser.h" namespace blink { namespace protocol { @@ -15,6 +16,7 @@ namespace {{domain.domain}} { // ------------- Enum values from types. const char Metainfo::domainName[] = "{{domain.domain}}"; +const char Metainfo::commandPrefix[] = "{{domain.domain}}."; {% for type in domain.types %} {% if "enum" in type %} @@ -22,7 +24,17 @@ namespace {{type.id}}Enum { {% for literal in type.enum %} const char* {{ literal | dash_to_camelcase}} = "{{literal}}"; {% endfor %} -} // {{type.id}}Enum +} // namespace {{type.id}}Enum + {% if type.exported %} + +namespace API { +namespace {{type.id}}Enum { + {% for literal in type.enum %} +const char* {{ literal | dash_to_camelcase}} = "{{literal}}"; + {% endfor %} +} // namespace {{type.id}}Enum +} // namespace API + {% endif %} {% endif %} {% for property in type.properties %} {% if "enum" in property %} @@ -49,11 +61,11 @@ std::unique_ptr<{{type.id}}> {{type.id}}::parse(protocol::Value* value, ErrorSup {% if property.optional %} if ({{property.name}}Value) { errors->setName("{{property.name}}"); - result->m_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); + result->m_{{property.name}} = ValueConversions<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); } {% else %} errors->setName("{{property.name}}"); - result->m_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); + result->m_{{property.name}} = ValueConversions<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); {% endif %} {% endfor %} errors->pop(); @@ -68,9 +80,9 @@ std::unique_ptr {{type.id}}::serialize() const {% for property in type.properties %} {% if property.optional %} if (m_{{property.name}}.isJust()) - result->setValue("{{property.name}}", toValue(m_{{property.name}}.fromJust())); + result->setValue("{{property.name}}", ValueConversions<{{resolve_type(property).raw_type}}>::serialize(m_{{property.name}}.fromJust())); {% else %} - result->setValue("{{property.name}}", toValue({{resolve_type(property).to_raw_type % ("m_" + property.name)}})); + result->setValue("{{property.name}}", ValueConversions<{{resolve_type(property).raw_type}}>::serialize({{resolve_type(property).to_raw_type % ("m_" + property.name)}})); {% endif %} {% endfor %} return result; @@ -81,6 +93,23 @@ std::unique_ptr<{{type.id}}> {{type.id}}::clone() const ErrorSupport errors; return parse(serialize().get(), &errors); } + {% if type.exported %} + +String16 {{type.id}}::toJSONString() const +{ + return serialize()->toJSONString(); +} + +// static +std::unique_ptr API::{{type.id}}::fromJSONString(const String16& json) +{ + ErrorSupport errors; + std::unique_ptr value = parseJSON(json); + if (!value) + return nullptr; + return protocol::{{domain.domain}}::{{type.id}}::parse(value.get(), &errors); +} + {% endif %} {% endfor %} // ------------- Enum values from params. @@ -94,8 +123,20 @@ namespace {{param.name | to_title_case}}Enum { {% for literal in param.enum %} const char* {{ literal | to_title_case}} = "{{literal}}"; {% endfor %} -} // {{param.name | to_title_case}}Enum -} // {{command.name | to_title_case }} +} // namespace {{param.name | to_title_case}}Enum +} // namespace {{command.name | to_title_case }} + {% if param.exported %} + +namespace API { +namespace {{command.name | to_title_case}} { +namespace {{param.name | to_title_case}}Enum { + {% for literal in param.enum %} +const char* {{ literal | to_title_case}} = "{{literal}}"; + {% endfor %} +} // namespace {{param.name | to_title_case}}Enum +} // namespace {{command.name | to_title_case }} +} // namespace API + {% endif %} {% endif %} {% endfor %} {% endfor %} @@ -119,9 +160,9 @@ void Frontend::{{event.name}}( {% for parameter in event.parameters %} {% if "optional" in parameter %} if ({{parameter.name}}.isJust()) - paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust())); + paramsObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{parameter.name}}.fromJust())); {% else %} - paramsObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}})); + paramsObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{resolve_type(parameter).to_raw_type % parameter.name}})); {% endif %} {% endfor %} jsonMessage->setObject("params", std::move(paramsObject)); @@ -196,9 +237,9 @@ public: {% for parameter in command.returns %} {% if "optional" in parameter %} if ({{parameter.name}}.isJust()) - resultObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust())); + resultObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{parameter.name}}.fromJust())); {% else %} - resultObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}})); + resultObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{resolve_type(parameter).to_raw_type % parameter.name}})); {% endif %} {% endfor %} sendIfActive(std::move(resultObject), ErrorString()); @@ -225,11 +266,11 @@ void DispatcherImpl::{{command.name}}(int callId, std::unique_ptr in_{{property.name}}; if ({{property.name}}Value) { errors->setName("{{property.name}}"); - in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); + in_{{property.name}} = ValueConversions<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); } {% else %} errors->setName("{{property.name}}"); - {{resolve_type(property).type}} in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); + {{resolve_type(property).type}} in_{{property.name}} = ValueConversions<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors); {% endif %} {% endfor %} errors->pop(); @@ -253,6 +294,7 @@ void DispatcherImpl::{{command.name}}(int callId, std::unique_ptr weak = weakPtr(); + {% if not("async" in command) %} ErrorString error; m_backend->{{command.name}}(&error {%- for property in command.parameters -%} @@ -262,29 +304,38 @@ void DispatcherImpl::{{command.name}}(int callId, std::unique_ptrsetValue("{{parameter.name}}", toValue(out_{{parameter.name}}.fromJust())); - {% else %} - result->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % ("out_" + parameter.name)}})); - {% endif %} - {% endfor %} + result->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize(out_{{parameter.name}}.fromJust())); + {% else %} + result->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{resolve_type(parameter).to_raw_type % ("out_" + parameter.name)}})); + {% endif %} + {% endfor %} } if (weak->get()) weak->get()->sendResponse(callId, error, std::move(result)); - {% elif not("async" in command) %} + {% else %} if (weak->get()) weak->get()->sendResponse(callId, error); + {% endif %} + {%- else %} + m_backend->{{command.name}}( + {%- for property in command.parameters -%} + {%- if "optional" in property -%} + in_{{property.name}}, + {%- else -%} + {{resolve_type(property).to_pass_type % ("in_" + property.name)}}, + {%- endif -%} + {%- endfor -%} + std::move(callback)); {% endif %} } {% endfor %} diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template index 05ca81d3a5714e..83310065e0f0da 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template @@ -23,9 +23,14 @@ #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/Values.h" #include "platform/inspector_protocol/ValueConversions.h" +// For each imported domain we generate a ValueConversions struct instead of a full domain definition +// and include Domain::API version from there. {% for name in domain.dependencies %} #include "{{output_package}}/{{name}}.h" {% endfor %} +{% if domain["has_exports"] %} +#include "{{exported_package}}/{{domain.domain}}.h" +{% endif %} namespace blink { namespace protocol { @@ -53,7 +58,7 @@ namespace {{type.id}}Enum { {% for literal in type.enum %} {{export_macro}} extern const char* {{ literal | dash_to_camelcase}}; {% endfor %} -} // {{type.id}}Enum +} // namespace {{type.id}}Enum {% endif %} {% endfor %} {% for command in join_arrays(domain, ["commands", "events"]) %} @@ -77,7 +82,8 @@ namespace {{param.name | to_title_case}}Enum { {% set type_def = type_definition(domain.domain + "." + type.id)%} // {{type.description}} -class {{export_macro}} {{type.id}} { +class {{export_macro}} {{type.id}} {% if type.exported %}: public API::{{type.id}} {% endif %}{ + PROTOCOL_DISALLOW_COPY({{type.id}}); public: static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSupport* errors); @@ -103,6 +109,9 @@ public: std::unique_ptr serialize() const; std::unique_ptr<{{type.id}}> clone() const; + {% if type.exported %} + String16 toJSONString() const override; + {% endif %} template class {{type.id}}Builder { @@ -205,16 +214,21 @@ public: ) = 0; }; {% endif %} - virtual void {{command.name}}(ErrorString* + virtual void {{command.name}}( + {%- if not("async" in command) -%} + ErrorString* + {%- endif -%} {%- for parameter in command.parameters -%} + {%- if (not loop.first) or not("async" in command) -%}, {% endif -%} {%- if "optional" in parameter -%} - , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} + const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} {%- else -%} - , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} + {{resolve_type(parameter).pass_type}} in_{{parameter.name}} {%- endif -%} {%- endfor -%} {%- if "async" in command -%} - , std::unique_ptr<{{command.name | to_title_case}}Callback> callback + {%- if command.parameters -%}, {% endif -%} + std::unique_ptr<{{command.name | to_title_case}}Callback> callback {%- else -%} {%- for parameter in command.returns -%} {%- if "optional" in parameter -%} @@ -276,6 +290,7 @@ public: using FrontendClass = Frontend; using DispatcherClass = Dispatcher; static const char domainName[]; + static const char commandPrefix[]; }; } // namespace {{domain.domain}} diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp deleted file mode 100644 index 98b8e7f5dff48d..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp +++ /dev/null @@ -1,51 +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. - -#include "platform/inspector_protocol/ValueConversions.h" - -namespace blink { -namespace protocol { - -std::unique_ptr toValue(int value) -{ - return FundamentalValue::create(value); -} - -std::unique_ptr toValue(double value) -{ - return FundamentalValue::create(value); -} - -std::unique_ptr toValue(bool value) -{ - return FundamentalValue::create(value); -} - -std::unique_ptr toValue(const String16& param) -{ - return StringValue::create(param); -} - -std::unique_ptr toValue(const String& param) -{ - return StringValue::create(param); -} - -std::unique_ptr toValue(Value* param) -{ - return param->clone(); -} - -std::unique_ptr toValue(DictionaryValue* param) -{ - return param->clone(); -} - -std::unique_ptr toValue(ListValue* param) -{ - return param->clone(); -} - -} // namespace protocol -} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h index dd7b2e78641054..ba1d08047aa6bf 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h @@ -13,42 +13,26 @@ namespace blink { namespace protocol { -PLATFORM_EXPORT std::unique_ptr toValue(int value); - -PLATFORM_EXPORT std::unique_ptr toValue(double value); - -PLATFORM_EXPORT std::unique_ptr toValue(bool value); - -PLATFORM_EXPORT std::unique_ptr toValue(const String16& param); - -PLATFORM_EXPORT std::unique_ptr toValue(const String& param); - -PLATFORM_EXPORT std::unique_ptr toValue(protocol::Value* param); - -PLATFORM_EXPORT std::unique_ptr toValue(protocol::DictionaryValue* param); - -PLATFORM_EXPORT std::unique_ptr toValue(protocol::ListValue* param); - -template std::unique_ptr toValue(T* param) -{ - return param->serialize(); -} - -template std::unique_ptr toValue(const std::unique_ptr& param) -{ - return toValue(param.get()); -} - template -struct FromValue { +struct ValueConversions { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { return T::parse(value, errors); } + + static std::unique_ptr serialize(T* value) + { + return value->serialize(); + } + + static std::unique_ptr serialize(const std::unique_ptr& value) + { + return value->serialize(); + } }; template<> -struct FromValue { +struct ValueConversions { static bool parse(protocol::Value* value, ErrorSupport* errors) { bool result = false; @@ -57,10 +41,15 @@ struct FromValue { errors->addError("boolean value expected"); return result; } + + static std::unique_ptr serialize(bool value) + { + return FundamentalValue::create(value); + } }; template<> -struct FromValue { +struct ValueConversions { static int parse(protocol::Value* value, ErrorSupport* errors) { int result = 0; @@ -69,10 +58,15 @@ struct FromValue { errors->addError("integer value expected"); return result; } + + static std::unique_ptr serialize(int value) + { + return FundamentalValue::create(value); + } }; template<> -struct FromValue { +struct ValueConversions { static double parse(protocol::Value* value, ErrorSupport* errors) { double result = 0; @@ -81,10 +75,15 @@ struct FromValue { errors->addError("double value expected"); return result; } + + static std::unique_ptr serialize(double value) + { + return FundamentalValue::create(value); + } }; template<> -struct FromValue { +struct ValueConversions { static String parse(protocol::Value* value, ErrorSupport* errors) { String16 result; @@ -93,10 +92,15 @@ struct FromValue { errors->addError("string value expected"); return result; } + + static std::unique_ptr serialize(const String& value) + { + return StringValue::create(value); + } }; template<> -struct FromValue { +struct ValueConversions { static String16 parse(protocol::Value* value, ErrorSupport* errors) { String16 result; @@ -105,10 +109,15 @@ struct FromValue { errors->addError("string value expected"); return result; } + + static std::unique_ptr serialize(const String16& value) + { + return StringValue::create(value); + } }; template<> -struct FromValue { +struct ValueConversions { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { bool success = !!value; @@ -118,10 +127,20 @@ struct FromValue { } return value->clone(); } + + static std::unique_ptr serialize(Value* value) + { + return value->clone(); + } + + static std::unique_ptr serialize(const std::unique_ptr& value) + { + return value->clone(); + } }; template<> -struct FromValue { +struct ValueConversions { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { bool success = value && value->type() == protocol::Value::TypeObject; @@ -129,10 +148,20 @@ struct FromValue { errors->addError("object expected"); return DictionaryValue::cast(value->clone()); } + + static std::unique_ptr serialize(DictionaryValue* value) + { + return value->clone(); + } + + static std::unique_ptr serialize(const std::unique_ptr& value) + { + return value->clone(); + } }; template<> -struct FromValue { +struct ValueConversions { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { bool success = value && value->type() == protocol::Value::TypeArray; @@ -140,15 +169,15 @@ struct FromValue { errors->addError("list expected"); return ListValue::cast(value->clone()); } -}; -template class Array; + static std::unique_ptr serialize(ListValue* value) + { + return value->clone(); + } -template -struct FromValue> { - static std::unique_ptr> parse(protocol::Value* value, ErrorSupport* errors) + static std::unique_ptr serialize(const std::unique_ptr& value) { - return protocol::Array::parse(value, errors); + return value->clone(); } }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp index 7d4ec242ae4c51..5b8f13b4930e27 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp @@ -92,6 +92,11 @@ bool Value::asString(String16*) const return false; } +bool Value::asSerialized(String16*) const +{ + return false; +} + String16 Value::toJSONString() const { String16Builder result; @@ -188,6 +193,23 @@ std::unique_ptr StringValue::clone() const return StringValue::create(m_stringValue); } +bool SerializedValue::asSerialized(String16* output) const +{ + *output = m_serializedValue; + return true; +} + +void SerializedValue::writeJSON(String16Builder* output) const +{ + DCHECK(type() == TypeSerialized); + output->append(m_serializedValue); +} + +std::unique_ptr SerializedValue::clone() const +{ + return SerializedValue::create(m_serializedValue); +} + DictionaryValue::~DictionaryValue() { } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h index 07a2cac9249f47..48a2012758a16b 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h @@ -38,7 +38,8 @@ class PLATFORM_EXPORT Value { TypeDouble, TypeString, TypeObject, - TypeArray + TypeArray, + TypeSerialized }; ValueType type() const { return m_type; } @@ -49,6 +50,7 @@ class PLATFORM_EXPORT Value { virtual bool asDouble(double* output) const; virtual bool asInteger(int* output) const; virtual bool asString(String16* output) const; + virtual bool asSerialized(String16* output) const; String16 toJSONString() const; virtual void writeJSON(String16Builder* output) const; @@ -123,6 +125,24 @@ class PLATFORM_EXPORT StringValue : public Value { String16 m_stringValue; }; +class PLATFORM_EXPORT SerializedValue : public Value { +public: + static std::unique_ptr create(const String16& value) + { + return wrapUnique(new SerializedValue(value)); + } + + bool asSerialized(String16* output) const override; + void writeJSON(String16Builder* output) const override; + std::unique_ptr clone() const override; + +private: + explicit SerializedValue(const String16& value) : Value(TypeSerialized), m_serializedValue(value) { } + explicit SerializedValue(const char* value) : Value(TypeSerialized), m_serializedValue(value) { } + + String16 m_serializedValue; +}; + class PLATFORM_EXPORT DictionaryValue : public Value { public: using Entry = std::pair; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version index 838a3ed2dd815a..0c01e163bbd3f8 100755 --- a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version @@ -60,7 +60,7 @@ except ImportError: def list_to_map(items, key): result = {} for item in items: - if not "hidden" in item: + if not "experimental" in item and not "hidden" in item: result[item[key]] = item return result @@ -287,7 +287,7 @@ def self_test(): { "name": "requestWillBeSent", "parameters": [ - { "name": "frameId", "type": "string", "hidden": True }, + { "name": "frameId", "type": "string", "experimental": True }, { "name": "request", "$ref": "Request" }, { "name": "becameOptional", "type": "string" }, { "name": "removedRequired", "type": "string" }, @@ -451,7 +451,8 @@ def main(): load_domains_and_baselines(arg_values[1], domains, baseline_domains) expected_errors = [ - "Debugger.globalObjectCleared: event has been removed" + "Debugger.globalObjectCleared: event has been removed", + "Runtime.executionContextCreated.context parameter->Runtime.ExecutionContextDescription.frameId: required property has been removed" ] errors = compare_schemas(baseline_domains, domains, False) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js index 5b534f322160f3..cd9a2bd56dd860 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js @@ -141,14 +141,22 @@ DebuggerScript._executionContextId = function(contextData) { if (!contextData) return 0; - var firstComma = contextData.indexOf(","); - if (firstComma === -1) - return 0; - var secondComma = contextData.indexOf(",", firstComma + 1); - if (secondComma === -1) + var match = contextData.match(/^[^,]*,([^,]*),.*$/); + if (!match) return 0; + return parseInt(match[1], 10) || 0; +} - return parseInt(contextData.substring(firstComma + 1, secondComma), 10) || 0; +/** + * @param {string|undefined} contextData + * @return {string} + */ +DebuggerScript._executionContextAuxData = function(contextData) +{ + if (!contextData) + return ""; + var match = contextData.match(/^[^,]*,[^,]*,(.*)$/); + return match ? match[1] : ""; } /** @@ -168,7 +176,7 @@ DebuggerScript.getScripts = function(contextGroupId) if (!script.context_data) continue; // Context data is a string in the following format: - // ,,("default"|"nondefault") + // ,, if (script.context_data.indexOf(contextDataPrefix) !== 0) continue; } @@ -208,7 +216,8 @@ DebuggerScript._formatScript = function(script) endLine: endLine, endColumn: endColumn, executionContextId: DebuggerScript._executionContextId(script.context_data), - isContentScript: !!script.context_data && script.context_data.endsWith(",nondefault"), + // Note that we cannot derive aux data from context id because of compilation cache. + executionContextAuxData: DebuggerScript._executionContextAuxData(script.context_data), isInternalScript: script.is_debugger_script }; } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp index 302b635ed47a1b..3b4552ee8d9147 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp @@ -39,14 +39,13 @@ #include "platform/v8_inspector/RemoteObjectId.h" #include "platform/v8_inspector/V8Compat.h" #include "platform/v8_inspector/V8Console.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8FunctionCall.h" #include "platform/v8_inspector/V8InjectedScriptHost.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #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/V8InspectorClient.h" using blink::protocol::Array; using blink::protocol::Debugger::CallFrame; @@ -72,7 +71,7 @@ std::unique_ptr InjectedScript::create(InspectedContext* inspect v8::Context::Scope scope(context); std::unique_ptr injectedScriptNative(new InjectedScriptNative(isolate)); - v8::Local scriptHostWrapper = V8InjectedScriptHost::create(context, inspectedContext->debugger()); + v8::Local scriptHostWrapper = V8InjectedScriptHost::create(context, inspectedContext->inspector()); injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); // Inject javascript into the context. The compiled script is supposed to evaluate into @@ -82,7 +81,7 @@ std::unique_ptr InjectedScript::create(InspectedContext* inspect // to create and configure InjectedScript instance that is going to be used by the inspector. String16 injectedScriptSource(reinterpret_cast(InjectedScriptSource_js), sizeof(InjectedScriptSource_js)); v8::Local value; - if (!inspectedContext->debugger()->compileAndRunInternalScript(context, toV8String(isolate, injectedScriptSource)).ToLocal(&value)) + if (!inspectedContext->inspector()->compileAndRunInternalScript(context, toV8String(isolate, injectedScriptSource)).ToLocal(&value)) return nullptr; DCHECK(value->IsFunction()); v8::Local function = v8::Local::Cast(value); @@ -111,7 +110,7 @@ InjectedScript::~InjectedScript() void InjectedScript::getProperties(ErrorString* errorString, v8::Local object, const String16& groupName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, std::unique_ptr>* properties, Maybe* exceptionDetails) { v8::HandleScope handles(m_context->isolate()); - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "getProperties"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "getProperties"); function.appendArgument(object); function.appendArgument(groupName); function.appendArgument(ownProperties); @@ -127,7 +126,7 @@ void InjectedScript::getProperties(ErrorString* errorString, v8::Local protocolValue = toProtocolValue(function.context(), resultValue); + std::unique_ptr protocolValue = toProtocolValue(m_context->context(), resultValue); if (hasInternalError(errorString, !protocolValue)) return; protocol::ErrorSupport errors(errorString); @@ -179,7 +178,7 @@ bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local array, v8::Local property, const String16& groupName, bool forceValueType, bool generatePreview) const { - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapPropertyInArray"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "wrapPropertyInArray"); function.appendArgument(array); function.appendArgument(property); function.appendArgument(groupName); @@ -192,7 +191,7 @@ bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local array, const String16& groupName, bool forceValueType, bool generatePreview) const { - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapObjectsInArray"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "wrapObjectsInArray"); function.appendArgument(array); function.appendArgument(groupName); function.appendArgument(forceValueType); @@ -204,7 +203,7 @@ bool InjectedScript::wrapObjectsInArray(ErrorString* errorString, v8::Local InjectedScript::wrapValue(ErrorString* errorString, v8::Local value, const String16& groupName, bool forceValueType, bool generatePreview) const { - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapObject"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "wrapObject"); function.appendArgument(value); function.appendArgument(groupName); function.appendArgument(forceValueType); @@ -219,7 +218,7 @@ v8::MaybeLocal InjectedScript::wrapValue(ErrorString* errorString, v8 std::unique_ptr InjectedScript::wrapTable(v8::Local table, v8::Local columns) const { v8::HandleScope handles(m_context->isolate()); - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapTable"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "wrapTable"); function.appendArgument(table); if (columns.IsEmpty()) function.appendArgument(false); @@ -256,7 +255,7 @@ void InjectedScript::releaseObjectGroup(const String16& objectGroup) void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) { v8::HandleScope handles(m_context->isolate()); - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "setCustomObjectFormatterEnabled"); + V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "setCustomObjectFormatterEnabled"); function.appendArgument(enabled); bool hadException = false; function.call(hadException); @@ -290,12 +289,12 @@ v8::MaybeLocal InjectedScript::resolveCallArgument(ErrorString* error return v8::MaybeLocal(); return object; } - if (callArgument->hasValue()) { - String16 value = callArgument->getValue(nullptr)->toJSONString(); - if (callArgument->getType(String16()) == "number") - value = "Number(" + value + ")"; + if (callArgument->hasValue() || callArgument->hasUnserializableValue()) { + String16 value = callArgument->hasValue() ? + callArgument->getValue(nullptr)->toJSONString() : + "Number(\"" + callArgument->getUnserializableValue("") + "\")"; v8::Local object; - if (!m_context->debugger()->compileAndRunInternalScript(m_context->context(), toV8String(m_context->isolate(), value)).ToLocal(&object)) { + if (!m_context->inspector()->compileAndRunInternalScript(m_context->context(), toV8String(m_context->isolate(), value)).ToLocal(&object)) { *errorString = "Couldn't parse value object in call argument"; return v8::MaybeLocal(); } @@ -315,7 +314,7 @@ std::unique_ptr InjectedScript::createExcep v8::Local stackTrace = message->GetStackTrace(); if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) - exceptionDetailsObject->setStackTrace(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject()); + exceptionDetailsObject->setStackTrace(m_context->inspector()->debugger()->createStackTrace(stackTrace)->buildInspectorObjectImpl()); return exceptionDetailsObject; } @@ -353,15 +352,15 @@ v8::Local InjectedScript::commandLineAPI() return m_commandLineAPI.Get(m_context->isolate()); } -InjectedScript::Scope::Scope(ErrorString* errorString, V8DebuggerImpl* debugger, int contextGroupId) +InjectedScript::Scope::Scope(ErrorString* errorString, V8InspectorImpl* inspector, int contextGroupId) : m_errorString(errorString) - , m_debugger(debugger) + , m_inspector(inspector) , m_contextGroupId(contextGroupId) , m_injectedScript(nullptr) - , m_handleScope(debugger->isolate()) - , m_tryCatch(debugger->isolate()) + , m_handleScope(inspector->isolate()) + , m_tryCatch(inspector->isolate()) , m_ignoreExceptionsAndMuteConsole(false) - , m_previousPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions) + , m_previousPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions) , m_userGesture(false) { } @@ -370,7 +369,7 @@ bool InjectedScript::Scope::initialize() { cleanup(); // TODO(dgozman): what if we reattach to the same context group during evaluate? Introduce a session id? - V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId); + V8InspectorSessionImpl* session = m_inspector->sessionForContextGroup(m_contextGroupId); if (!session) { *m_errorString = "Internal error"; return false; @@ -394,17 +393,18 @@ void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() { DCHECK(!m_ignoreExceptionsAndMuteConsole); m_ignoreExceptionsAndMuteConsole = true; - m_debugger->client()->muteWarningsAndDeprecations(m_contextGroupId); - m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions); + m_inspector->client()->muteMetrics(m_contextGroupId); + m_inspector->muteExceptions(m_contextGroupId); + m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8Debugger::DontPauseOnExceptions); } -V8DebuggerImpl::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptionsState(V8DebuggerImpl::PauseOnExceptionsState newState) +V8Debugger::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptionsState(V8Debugger::PauseOnExceptionsState newState) { - if (!m_debugger->enabled()) + if (!m_inspector->debugger()->enabled()) return newState; - V8DebuggerImpl::PauseOnExceptionsState presentState = m_debugger->getPauseOnExceptionsState(); + V8Debugger::PauseOnExceptionsState presentState = m_inspector->debugger()->getPauseOnExceptionsState(); if (presentState != newState) - m_debugger->setPauseOnExceptionsState(newState); + m_inspector->debugger()->setPauseOnExceptionsState(newState); return presentState; } @@ -412,7 +412,7 @@ void InjectedScript::Scope::pretendUserGesture() { DCHECK(!m_userGesture); m_userGesture = true; - m_debugger->client()->beginUserGesture(); + m_inspector->client()->beginUserGesture(); } void InjectedScript::Scope::cleanup() @@ -428,15 +428,16 @@ InjectedScript::Scope::~Scope() { if (m_ignoreExceptionsAndMuteConsole) { setPauseOnExceptionsState(m_previousPauseOnExceptionsState); - m_debugger->client()->unmuteWarningsAndDeprecations(m_contextGroupId); + m_inspector->client()->unmuteMetrics(m_contextGroupId); + m_inspector->unmuteExceptions(m_contextGroupId); } if (m_userGesture) - m_debugger->client()->endUserGesture(); + m_inspector->client()->endUserGesture(); cleanup(); } -InjectedScript::ContextScope::ContextScope(ErrorString* errorString, V8DebuggerImpl* debugger, int contextGroupId, int executionContextId) - : InjectedScript::Scope(errorString, debugger, contextGroupId) +InjectedScript::ContextScope::ContextScope(ErrorString* errorString, V8InspectorImpl* inspector, int contextGroupId, int executionContextId) + : InjectedScript::Scope(errorString, inspector, contextGroupId) , m_executionContextId(executionContextId) { } @@ -450,8 +451,8 @@ void InjectedScript::ContextScope::findInjectedScript(V8InspectorSessionImpl* se m_injectedScript = session->findInjectedScript(m_errorString, m_executionContextId); } -InjectedScript::ObjectScope::ObjectScope(ErrorString* errorString, V8DebuggerImpl* debugger, int contextGroupId, const String16& remoteObjectId) - : InjectedScript::Scope(errorString, debugger, contextGroupId) +InjectedScript::ObjectScope::ObjectScope(ErrorString* errorString, V8InspectorImpl* inspector, int contextGroupId, const String16& remoteObjectId) + : InjectedScript::Scope(errorString, inspector, contextGroupId) , m_remoteObjectId(remoteObjectId) { } @@ -474,8 +475,8 @@ void InjectedScript::ObjectScope::findInjectedScript(V8InspectorSessionImpl* ses m_injectedScript = injectedScript; } -InjectedScript::CallFrameScope::CallFrameScope(ErrorString* errorString, V8DebuggerImpl* debugger, int contextGroupId, const String16& remoteObjectId) - : InjectedScript::Scope(errorString, debugger, contextGroupId) +InjectedScript::CallFrameScope::CallFrameScope(ErrorString* errorString, V8InspectorImpl* inspector, int contextGroupId, const String16& remoteObjectId) + : InjectedScript::Scope(errorString, inspector, contextGroupId) , m_remoteCallFrameId(remoteObjectId) { } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h index ab847ee0412906..b65a857eb90fe6 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h @@ -36,7 +36,7 @@ #include "platform/v8_inspector/InjectedScriptNative.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/V8Console.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" #include "platform/v8_inspector/protocol/Runtime.h" #include @@ -45,6 +45,7 @@ namespace blink { class RemoteObjectId; class V8FunctionCall; +class V8InspectorImpl; class V8InspectorSessionImpl; namespace protocol { @@ -99,32 +100,32 @@ class InjectedScript final { const v8::TryCatch& tryCatch() const { return m_tryCatch; } protected: - Scope(ErrorString*, V8DebuggerImpl*, int contextGroupId); + Scope(ErrorString*, V8InspectorImpl*, int contextGroupId); ~Scope(); virtual void findInjectedScript(V8InspectorSessionImpl*) = 0; ErrorString* m_errorString; - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; int m_contextGroupId; InjectedScript* m_injectedScript; private: void cleanup(); - V8DebuggerImpl::PauseOnExceptionsState setPauseOnExceptionsState(V8DebuggerImpl::PauseOnExceptionsState); + V8Debugger::PauseOnExceptionsState setPauseOnExceptionsState(V8Debugger::PauseOnExceptionsState); v8::HandleScope m_handleScope; v8::TryCatch m_tryCatch; v8::Local m_context; std::unique_ptr m_commandLineAPIScope; bool m_ignoreExceptionsAndMuteConsole; - V8DebuggerImpl::PauseOnExceptionsState m_previousPauseOnExceptionsState; + V8Debugger::PauseOnExceptionsState m_previousPauseOnExceptionsState; bool m_userGesture; }; class ContextScope: public Scope { PROTOCOL_DISALLOW_COPY(ContextScope); public: - ContextScope(ErrorString*, V8DebuggerImpl*, int contextGroupId, int executionContextId); + ContextScope(ErrorString*, V8InspectorImpl*, int contextGroupId, int executionContextId); ~ContextScope(); private: void findInjectedScript(V8InspectorSessionImpl*) override; @@ -134,7 +135,7 @@ class InjectedScript final { class ObjectScope: public Scope { PROTOCOL_DISALLOW_COPY(ObjectScope); public: - ObjectScope(ErrorString*, V8DebuggerImpl*, int contextGroupId, const String16& remoteObjectId); + ObjectScope(ErrorString*, V8InspectorImpl*, int contextGroupId, const String16& remoteObjectId); ~ObjectScope(); const String16& objectGroupName() const { return m_objectGroupName; } v8::Local object() const { return m_object; } @@ -148,7 +149,7 @@ class InjectedScript final { class CallFrameScope: public Scope { PROTOCOL_DISALLOW_COPY(CallFrameScope); public: - CallFrameScope(ErrorString*, V8DebuggerImpl*, int contextGroupId, const String16& remoteCallFrameId); + CallFrameScope(ErrorString*, V8InspectorImpl*, int contextGroupId, const String16& remoteCallFrameId); ~CallFrameScope(); size_t frameOrdinal() const { return m_frameOrdinal; } private: diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js index d2b3b2725ee665..7e8b2cb41ba437 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js @@ -60,7 +60,7 @@ function push(array, var_args) */ function toString(obj) { - // We don't use String(obj) because String16 could be overridden. + // We don't use String(obj) because String could be overridden. // Also the ("" + obj) expression may throw. try { return "" + obj; @@ -115,7 +115,7 @@ function isArrayLike(obj) return false; try { if (typeof obj.splice === "function") { - if (!InjectedScriptHost.suppressWarningsAndCallFunction(Object.prototype.hasOwnProperty, obj, ["length"])) + if (!InjectedScriptHost.objectHasOwnProperty(/** @type {!Object} */ (obj), "length")) return false; var len = obj.length; return typeof len === "number" && isUInt32(len); @@ -170,12 +170,11 @@ domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true; function doesAttributeHaveObservableSideEffectOnGet(object, attribute) { for (var interfaceName in domAttributesWithObservableSideEffectOnGet) { - var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(function(object, interfaceName) { - return /* suppressBlacklist */ typeof inspectedGlobalObject[interfaceName] === "function" && object instanceof inspectedGlobalObject[interfaceName]; - }, null, [object, interfaceName]); - if (isInstance) { + var interfaceFunction = inspectedGlobalObject[interfaceName]; + // instanceof call looks safe after typeof check. + var isInstance = typeof interfaceFunction === "function" && /* suppressBlacklist */ object instanceof interfaceFunction; + if (isInstance) return attribute in domAttributesWithObservableSideEffectOnGet[interfaceName]; - } } return false; } @@ -200,18 +199,17 @@ InjectedScript.primitiveTypes = { } /** - * @type {!Map} + * @type {!Object} * @const */ -InjectedScript.closureTypes = new Map([ - ["local", "Local"], - ["closure", "Closure"], - ["catch", "Catch"], - ["block", "Block"], - ["script", "Script"], - ["with", "With Block"], - ["global", "Global"] -]); +InjectedScript.closureTypes = { __proto__: null }; +InjectedScript.closureTypes["local"] = "Local"; +InjectedScript.closureTypes["closure"] = "Closure"; +InjectedScript.closureTypes["catch"] = "Catch"; +InjectedScript.closureTypes["block"] = "Block"; +InjectedScript.closureTypes["script"] = "Script"; +InjectedScript.closureTypes["with"] = "With Block"; +InjectedScript.closureTypes["global"] = "Global"; InjectedScript.prototype = { /** @@ -369,6 +367,21 @@ InjectedScript.prototype = { return descriptors; }, + /** + * @param {!Object} object + * @return {?Object} + */ + _objectPrototype: function(object) + { + if (InjectedScriptHost.subtype(object) === "proxy") + return null; + try { + return Object.getPrototypeOf(object); + } catch (e) { + return null; + } + }, + /** * @param {!Object} object * @param {boolean=} ownProperties @@ -397,12 +410,12 @@ InjectedScript.prototype = { try { propertyProcessed[property] = true; - var descriptor = nullifyObjectProto(InjectedScriptHost.suppressWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property])); + var descriptor = nullifyObjectProto(Object.getOwnPropertyDescriptor(o, property)); if (descriptor) { if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor)) continue; if ("get" in descriptor && "set" in descriptor && name != "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object, descriptor.get) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) { - descriptor.value = InjectedScriptHost.suppressWarningsAndCallFunction(function(attribute) { return this[attribute]; }, object, [property]); + descriptor.value = object[property]; descriptor.isOwn = true; delete descriptor.get; delete descriptor.set; @@ -441,8 +454,8 @@ InjectedScript.prototype = { if (propertyNamesOnly) { for (var i = 0; i < propertyNamesOnly.length; ++i) { var name = propertyNamesOnly[i]; - for (var o = object; this._isDefined(o); o = InjectedScriptHost.prototype(o)) { - if (InjectedScriptHost.suppressWarningsAndCallFunction(Object.prototype.hasOwnProperty, o, [name])) { + for (var o = object; this._isDefined(o); o = this._objectPrototype(o)) { + if (InjectedScriptHost.objectHasOwnProperty(o, name)) { for (var descriptor of process(o, [name])) yield descriptor; break; @@ -465,11 +478,11 @@ InjectedScript.prototype = { var skipGetOwnPropertyNames; try { - skipGetOwnPropertyNames = InjectedScriptHost.isTypedArray(object) && object.length > 500000; + skipGetOwnPropertyNames = InjectedScriptHost.subtype(object) === "typedarray" && object.length > 500000; } catch (e) { } - for (var o = object; this._isDefined(o); o = InjectedScriptHost.prototype(o)) { + for (var o = object; this._isDefined(o); o = this._objectPrototype(o)) { if (InjectedScriptHost.subtype(o) === "proxy") continue; if (skipGetOwnPropertyNames && o === object) { @@ -488,7 +501,7 @@ InjectedScript.prototype = { yield descriptor; } if (ownProperties) { - var proto = InjectedScriptHost.prototype(o); + var proto = this._objectPrototype(o); if (proto && !accessorPropertiesOnly) yield { name: "__proto__", value: proto, writable: true, configurable: true, enumerable: false, isOwn: true, __proto__: null }; break; @@ -613,7 +626,7 @@ InjectedScript.prototype = { return "Proxy"; var className = InjectedScriptHost.internalConstructorName(obj); - if (subtype === "array") { + if (subtype === "array" || subtype === "typedarray") { if (typeof obj.length === "number") className += "[" + obj.length + "]"; return className; @@ -624,7 +637,8 @@ InjectedScript.prototype = { if (isSymbol(obj)) { try { - return /** @type {string} */ (InjectedScriptHost.suppressWarningsAndCallFunction(Symbol.prototype.toString, obj)) || "Symbol"; + // It isn't safe, because Symbol.prototype.toString can be overriden. + return /* suppressBlacklist */ obj.toString() || "Symbol"; } catch (e) { return "Symbol"; } @@ -655,7 +669,7 @@ InjectedScript.prototype = { return "Scopes[" + obj.length + "]"; if (subtype === "internal#scope") - return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (obj.name ? " (" + obj.name + ")" : ""); + return (InjectedScript.closureTypes[obj.type] || "Unknown") + (obj.name ? " (" + obj.name + ")" : ""); return className; }, @@ -718,13 +732,13 @@ InjectedScript.RemoteObject = function(object, objectGroupName, doNotBind, force // Provide user-friendly number values. if (this.type === "number") { this.description = toStringDescription(object); - // Override "value" property for values that can not be JSON-stringified. switch (this.description) { case "NaN": case "Infinity": case "-Infinity": case "-0": - this.value = this.description; + delete this.value; + this.unserializableValue = this.description; break; } } @@ -780,7 +794,8 @@ InjectedScript.RemoteObject.prototype = { */ function logError(error) { - Promise.resolve().then(inspectedGlobalObject.console.error.bind(inspectedGlobalObject.console, "Custom Formatter Failed: " + error.message)); + // We use user code to generate custom output for object, we can use user code for reporting error too. + Promise.resolve().then(/* suppressBlacklist */ inspectedGlobalObject.console.error.bind(inspectedGlobalObject.console, "Custom Formatter Failed: " + error.message)); } /** @@ -791,7 +806,7 @@ InjectedScript.RemoteObject.prototype = { */ function wrap(object, customObjectConfig) { - return InjectedScriptHost.suppressWarningsAndCallFunction(injectedScript._wrapObject, injectedScript, [ object, objectGroupName, false, false, null, false, false, customObjectConfig ]); + return injectedScript._wrapObject(object, objectGroupName, false, false, null, false, false, customObjectConfig); } try { @@ -915,7 +930,7 @@ InjectedScript.RemoteObject.prototype = { continue; // Ignore length property of array. - if (this.subtype === "array" && name === "length") + if ((this.subtype === "array" || this.subtype === "typedarray") && name === "length") continue; // Ignore size property of map, set. diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp index 5b52e015a54363..16e0f02732265b 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp @@ -6,10 +6,10 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/V8Console.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8ContextInfo.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { @@ -20,7 +20,7 @@ void InspectedContext::weakCallback(const v8::WeakCallbackInfo context->m_context.Reset(); data.SetSecondPassCallback(&InspectedContext::weakCallback); } else { - context->m_debugger->discardInspectedContext(context->m_contextGroupId, context->m_contextId); + context->m_inspector->discardInspectedContext(context->m_contextGroupId, context->m_contextId); } } @@ -29,20 +29,19 @@ void InspectedContext::consoleWeakCallback(const v8::WeakCallbackInfom_console.Reset(); } -InspectedContext::InspectedContext(V8DebuggerImpl* debugger, const V8ContextInfo& info, int contextId) - : m_debugger(debugger) +InspectedContext::InspectedContext(V8InspectorImpl* inspector, const V8ContextInfo& info, int contextId) + : m_inspector(inspector) , m_context(info.context->GetIsolate(), info.context) , m_contextId(contextId) , m_contextGroupId(info.contextGroupId) - , m_isDefault(info.isDefault) , m_origin(info.origin) , m_humanReadableName(info.humanReadableName) - , m_frameId(info.frameId) + , m_auxData(info.auxData) , m_reported(false) { m_context.SetWeak(this, &InspectedContext::weakCallback, v8::WeakCallbackType::kParameter); - v8::Isolate* isolate = m_debugger->isolate(); + v8::Isolate* isolate = m_inspector->isolate(); v8::Local global = info.context->Global(); v8::Local console = V8Console::createConsole(this, info.hasMemoryOnConsole); if (!global->Set(info.context, toV8StringInternalized(isolate, "console"), console).FromMaybe(false)) @@ -66,17 +65,12 @@ v8::Local InspectedContext::context() const v8::Isolate* InspectedContext::isolate() const { - return m_debugger->isolate(); + return m_inspector->isolate(); } void InspectedContext::createInjectedScript() { DCHECK(!m_injectedScript); - v8::HandleScope handles(isolate()); - v8::Local localContext = context(); - v8::Local callingContext = isolate()->GetCallingContext(); - if (!callingContext.IsEmpty() && !m_debugger->client()->callingContextCanAccessContext(callingContext, localContext)) - return; m_injectedScript = InjectedScript::create(this); } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h index ecff5e4012f008..421d3dfe03a419 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h @@ -15,7 +15,7 @@ namespace blink { class InjectedScript; class InjectedScriptHost; class V8ContextInfo; -class V8DebuggerImpl; +class V8InspectorImpl; class InspectedContext { PROTOCOL_DISALLOW_COPY(InspectedContext); @@ -25,35 +25,33 @@ class InspectedContext { v8::Local context() const; int contextId() const { return m_contextId; } int contextGroupId() const { return m_contextGroupId; } - bool isDefault() const { return m_isDefault; } String16 origin() const { return m_origin; } String16 humanReadableName() const { return m_humanReadableName; } - String16 frameId() const { return m_frameId; } + String16 auxData() const { return m_auxData; } bool isReported() const { return m_reported; } void setReported(bool reported) { m_reported = reported; } v8::Isolate* isolate() const; - V8DebuggerImpl* debugger() const { return m_debugger; } + V8InspectorImpl* inspector() const { return m_inspector; } InjectedScript* getInjectedScript() { return m_injectedScript.get(); } void createInjectedScript(); void discardInjectedScript(); private: - friend class V8DebuggerImpl; - InspectedContext(V8DebuggerImpl*, const V8ContextInfo&, int contextId); + friend class V8InspectorImpl; + InspectedContext(V8InspectorImpl*, const V8ContextInfo&, int contextId); static void weakCallback(const v8::WeakCallbackInfo&); static void consoleWeakCallback(const v8::WeakCallbackInfo&); - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; v8::Global m_context; int m_contextId; int m_contextGroupId; - bool m_isDefault; const String16 m_origin; const String16 m_humanReadableName; - const String16 m_frameId; + const String16 m_auxData; bool m_reported; std::unique_ptr m_injectedScript; v8::Global m_console; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h index 0f5b12cbb6cb07..d623da1a616f39 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h @@ -22,7 +22,11 @@ class V8_EXPORT MicrotasksScope { }; } // namespace v8 - +#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \ + v8::Function::New((context), (callback), (data), (length)) +#else +#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \ + v8::Function::New((context), (callback), (data), (length), v8::ConstructorBehavior::kThrow) #endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1) #endif // V8Compat_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp index f7e142deeadbf3..1bd738a8660aea 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp @@ -11,13 +11,13 @@ #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/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8ProfilerAgentImpl.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" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { @@ -36,7 +36,7 @@ class ConsoleHelper { , m_isolate(info.GetIsolate()) , m_context(info.GetIsolate()->GetCurrentContext()) , m_inspectedContext(nullptr) - , m_debuggerClient(nullptr) + , m_inspectorClient(nullptr) { } @@ -65,15 +65,15 @@ class ConsoleHelper { return m_inspectedContext; } - V8DebuggerClient* ensureDebuggerClient() + V8InspectorClient* ensureDebuggerClient() { - if (m_debuggerClient) - return m_debuggerClient; + if (m_inspectorClient) + return m_inspectorClient; InspectedContext* inspectedContext = ensureInspectedContext(); if (!inspectedContext) return nullptr; - m_debuggerClient = inspectedContext->debugger()->client(); - return m_debuggerClient; + m_inspectorClient = inspectedContext->inspector()->client(); + return m_inspectorClient; } void reportCall(ConsoleAPIType type) @@ -107,9 +107,9 @@ class ConsoleHelper { 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)); + V8InspectorImpl* inspector = inspectedContext->inspector(); + std::unique_ptr message = V8ConsoleMessage::createForConsoleAPI(inspector->client()->currentTimeMS(), type, arguments, inspector->debugger()->captureStackTrace(false), inspectedContext); + inspector->ensureConsoleMessageStorage(inspectedContext->contextGroupId())->addMessage(std::move(message)); } void reportDeprecatedCall(const char* id, const String16& message) @@ -233,7 +233,7 @@ class ConsoleHelper { InspectedContext* inspectedContext = ensureInspectedContext(); if (!inspectedContext) return nullptr; - return inspectedContext->debugger()->sessionForContextGroup(inspectedContext->contextGroupId()); + return inspectedContext->inspector()->sessionForContextGroup(inspectedContext->contextGroupId()); } private: @@ -242,7 +242,7 @@ class ConsoleHelper { v8::Local m_context; v8::Local m_console; InspectedContext* m_inspectedContext; - V8DebuggerClient* m_debuggerClient; + V8InspectorClient* m_inspectorClient; bool checkAndSetPrivateFlagOnConsole(const char* name, bool defaultValue) { @@ -271,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, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) + if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, console, 0).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, 0, v8::ConstructorBehavior::kThrow).ToLocal(&toStringFunction)) + if (V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, returnDataCallback, returnValue, 0).ToLocal(&toStringFunction)) func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction); } if (!console->Set(context, funcName, func).FromMaybe(false)) @@ -413,7 +413,7 @@ void V8Console::profileEndCallback(const v8::FunctionCallbackInfo& in static void timeFunction(const v8::FunctionCallbackInfo& info, bool timelinePrefix) { ConsoleHelper helper(info); - if (V8DebuggerClient* client = helper.ensureDebuggerClient()) { + if (V8InspectorClient* client = helper.ensureDebuggerClient()) { String16 protocolTitle = helper.firstArgToString("default"); if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; @@ -429,7 +429,7 @@ static void timeFunction(const v8::FunctionCallbackInfo& info, bool t static void timeEndFunction(const v8::FunctionCallbackInfo& info, bool timelinePrefix) { ConsoleHelper helper(info); - if (V8DebuggerClient* client = helper.ensureDebuggerClient()) { + if (V8InspectorClient* client = helper.ensureDebuggerClient()) { String16 protocolTitle = helper.firstArgToString("default"); if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; @@ -469,13 +469,13 @@ void V8Console::timeEndCallback(const v8::FunctionCallbackInfo& info) void V8Console::timeStampCallback(const v8::FunctionCallbackInfo& info) { ConsoleHelper helper(info); - if (V8DebuggerClient* client = helper.ensureDebuggerClient()) + if (V8InspectorClient* client = helper.ensureDebuggerClient()) client->consoleTimeStamp(helper.firstArgToString(String16())); } void V8Console::memoryGetterCallback(const v8::FunctionCallbackInfo& info) { - if (V8DebuggerClient* client = ConsoleHelper(info).ensureDebuggerClient()) { + if (V8InspectorClient* client = ConsoleHelper(info).ensureDebuggerClient()) { v8::Local memoryValue; if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrentContext()).ToLocal(&memoryValue)) return; @@ -656,6 +656,7 @@ void V8Console::inspectedObject(const v8::FunctionCallbackInfo& info, v8::Local V8Console::createConsole(InspectedContext* inspectedContext, bool hasMemoryAttribute) { v8::Local context = inspectedContext->context(); + v8::Context::Scope contextScope(context); v8::Isolate* isolate = context->GetIsolate(); v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); @@ -689,7 +690,7 @@ v8::Local V8Console::createConsole(InspectedContext* inspectedContex DCHECK(success); if (hasMemoryAttribute) - 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->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memoryGetterCallback, console, 0).ToLocalChecked(), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memorySetterCallback, v8::Local(), 0).ToLocalChecked(), static_cast(v8::None), v8::DEFAULT); console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext)); return console; @@ -731,7 +732,7 @@ v8::Local V8Console::createCommandLineAPI(InspectedContext* inspecte createBoundFunctionProperty(context, commandLineAPI, "$3", V8Console::inspectedObject3); createBoundFunctionProperty(context, commandLineAPI, "$4", V8Console::inspectedObject4); - inspectedContext->debugger()->client()->installAdditionalCommandLineAPI(context, commandLineAPI); + inspectedContext->inspector()->client()->installAdditionalCommandLineAPI(context, commandLineAPI); commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext)); return commandLineAPI; 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 index ab4017532f4bd8..0292dbb4ca6ba6 100644 --- 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 @@ -5,7 +5,7 @@ #include "platform/v8_inspector/V8ConsoleAgentImpl.h" #include "platform/v8_inspector/V8ConsoleMessage.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" @@ -33,7 +33,7 @@ void V8ConsoleAgentImpl::enable(ErrorString* errorString) return; m_state->setBoolean(ConsoleAgentState::consoleEnabled, true); m_enabled = true; - m_session->debugger()->enableStackCapturingIfNeeded(); + m_session->inspector()->enableStackCapturingIfNeeded(); reportAllMessages(); } @@ -41,7 +41,7 @@ void V8ConsoleAgentImpl::disable(ErrorString* errorString) { if (!m_enabled) return; - m_session->debugger()->disableStackCapturingIfNeeded(); + m_session->inspector()->disableStackCapturingIfNeeded(); m_state->setBoolean(ConsoleAgentState::consoleEnabled, false); m_enabled = false; } @@ -71,7 +71,7 @@ bool V8ConsoleAgentImpl::enabled() void V8ConsoleAgentImpl::reportAllMessages() { - V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + V8ConsoleMessageStorage* storage = m_session->inspector()->ensureConsoleMessageStorage(m_session->contextGroupId()); for (const auto& message : storage->messages()) { if (message->origin() == V8MessageOrigin::kConsole) reportMessage(message.get(), false); 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 index 42fe95bdfcd890..84bcc3d6e54df6 100644 --- 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 @@ -6,12 +6,12 @@ #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/V8ConsoleAgentImpl.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.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" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { @@ -191,7 +191,7 @@ V8ConsoleMessage::~V8ConsoleMessage() { } -void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) { m_url = url; m_lineNumber = lineNumber; @@ -219,7 +219,7 @@ std::unique_ptr> V8ConsoleMessa { if (!m_arguments.size() || !m_contextId) return nullptr; - InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + InspectedContext* inspectedContext = session->inspector()->getContext(session->contextGroupId(), m_contextId); if (!inspectedContext) return nullptr; @@ -252,9 +252,10 @@ std::unique_ptr> V8ConsoleMessa void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V8InspectorSessionImpl* session, bool generatePreview) const { if (m_origin == V8MessageOrigin::kException) { + std::unique_ptr exception = wrapException(session, generatePreview); // TODO(dgozman): unify with InjectedScript::createExceptionDetails. std::unique_ptr details = protocol::Runtime::ExceptionDetails::create() - .setText(m_message) + .setText(exception ? m_message : m_detailedMessage) .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String16()) @@ -262,9 +263,7 @@ void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V if (!m_url.isEmpty()) details->setUrl(m_url); if (m_stackTrace) - details->setStackTrace(m_stackTrace->buildInspectorObject()); - - std::unique_ptr exception = wrapException(session, generatePreview); + details->setStackTrace(m_stackTrace->buildInspectorObjectImpl()); if (exception) frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(details), std::move(exception), m_contextId); @@ -286,7 +285,7 @@ void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V arguments->addItem(std::move(messageArg)); } } - frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(arguments), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr); + frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(arguments), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObjectImpl() : nullptr); return; } NOTREACHED(); @@ -297,7 +296,7 @@ std::unique_ptr V8ConsoleMessage::wrapException if (!m_arguments.size() || !m_contextId) return nullptr; DCHECK_EQ(1u, m_arguments.size()); - InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + InspectedContext* inspectedContext = session->inspector()->getContext(session->contextGroupId(), m_contextId); if (!inspectedContext) return nullptr; @@ -318,7 +317,7 @@ ConsoleAPIType V8ConsoleMessage::type() const } // static -std::unique_ptr V8ConsoleMessage::createForConsoleAPI(double timestamp, ConsoleAPIType type, const std::vector>& arguments, std::unique_ptr stackTrace, InspectedContext* context) +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()) { @@ -334,31 +333,34 @@ std::unique_ptr V8ConsoleMessage::createForConsoleAPI(double t if (arguments.size()) message->m_message = V8ValueStringBuilder::toString(arguments[0], context->isolate()); - MessageLevel level = LogMessageLevel; + V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog; 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()); + clientType = V8ConsoleAPIType::kDebug; + else if (type == ConsoleAPIType::kError || type == ConsoleAPIType::kAssert) + clientType = V8ConsoleAPIType::kError; + else if (type == ConsoleAPIType::kWarning) + clientType = V8ConsoleAPIType::kWarning; + else if (type == ConsoleAPIType::kInfo) + clientType = V8ConsoleAPIType::kInfo; + else if (type == ConsoleAPIType::kClear) + clientType = V8ConsoleAPIType::kClear; + context->inspector()->client()->consoleAPIMessage(context->contextGroupId(), clientType, 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 V8ConsoleMessage::createForException(double timestamp, const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId, v8::Isolate* isolate, const String16& message, 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; + std::unique_ptr consoleMessage = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kException, timestamp, message)); + consoleMessage->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId); + consoleMessage->m_exceptionId = exceptionId; + consoleMessage->m_detailedMessage = detailedMessage; if (contextId && !exception.IsEmpty()) { - message->m_contextId = contextId; - message->m_arguments.push_back(wrapUnique(new v8::Global(isolate, exception))); + consoleMessage->m_contextId = contextId; + consoleMessage->m_arguments.push_back(wrapUnique(new v8::Global(isolate, exception))); } - return message; + return consoleMessage; } // static @@ -382,8 +384,8 @@ void V8ConsoleMessage::contextDestroyed(int contextId) // ------------------------ V8ConsoleMessageStorage ---------------------------- -V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8DebuggerImpl* debugger, int contextGroupId) - : m_debugger(debugger) +V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8InspectorImpl* inspector, int contextGroupId) + : m_inspector(inspector) , m_contextGroupId(contextGroupId) , m_expiredCount(0) { @@ -392,17 +394,14 @@ V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8DebuggerImpl* debugger, int c V8ConsoleMessageStorage::~V8ConsoleMessageStorage() { clear(); - notifyClear(); } void V8ConsoleMessageStorage::addMessage(std::unique_ptr message) { - if (message->type() == ConsoleAPIType::kClear) { + if (message->type() == ConsoleAPIType::kClear) clear(); - notifyClear(); - } - V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId); + V8InspectorSessionImpl* session = m_inspector->sessionForContextGroup(m_contextGroupId); if (session) { if (message->origin() == V8MessageOrigin::kConsole) session->consoleAgent()->messageAdded(message.get()); @@ -421,7 +420,7 @@ void V8ConsoleMessageStorage::clear() { m_messages.clear(); m_expiredCount = 0; - if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId)) + if (V8InspectorSessionImpl* session = m_inspector->sessionForContextGroup(m_contextGroupId)) session->releaseObjectGroup("console"); } @@ -431,10 +430,4 @@ void V8ConsoleMessageStorage::contextDestroyed(int contextId) 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 index 923a84e9269080..9c26f5d9e8f3ea 100644 --- 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 @@ -9,17 +9,15 @@ #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 V8InspectorImpl; class V8InspectorSessionImpl; -class V8StackTrace; +class V8StackTraceImpl; enum class V8MessageOrigin { kConsole, kException, kRevokedException }; @@ -33,18 +31,19 @@ class V8ConsoleMessage { double timestamp, ConsoleAPIType, const std::vector>& arguments, - std::unique_ptr, + std::unique_ptr, InspectedContext*); static std::unique_ptr createForException( double timestamp, - const String16& message, + const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, - std::unique_ptr, + std::unique_ptr, int scriptId, v8::Isolate*, + const String16& message, int contextId, v8::Local exception, unsigned exceptionId); @@ -66,7 +65,7 @@ class V8ConsoleMessage { 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); + void setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId); V8MessageOrigin m_origin; double m_timestamp; @@ -74,18 +73,19 @@ class V8ConsoleMessage { String16 m_url; unsigned m_lineNumber; unsigned m_columnNumber; - std::unique_ptr m_stackTrace; + std::unique_ptr m_stackTrace; int m_scriptId; int m_contextId; ConsoleAPIType m_type; unsigned m_exceptionId; unsigned m_revokedExceptionId; Arguments m_arguments; + String16 m_detailedMessage; }; class V8ConsoleMessageStorage { public: - V8ConsoleMessageStorage(V8DebuggerImpl*, int contextGroupId); + V8ConsoleMessageStorage(V8InspectorImpl*, int contextGroupId); ~V8ConsoleMessageStorage(); int contextGroupId() { return m_contextGroupId; } @@ -97,9 +97,7 @@ class V8ConsoleMessageStorage { void clear(); private: - void notifyClear(); - - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; int m_contextGroupId; int m_expiredCount; std::deque> m_messages; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Debugger.cpp similarity index 53% rename from deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Debugger.cpp index 4d84b32cece21b..a7ebd019f94903 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Debugger.cpp @@ -1,59 +1,24 @@ -/* - * Copyright (c) 2010-2011 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: - * - * * 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. - */ - -#include "platform/v8_inspector/V8DebuggerImpl.h" - -#include "platform/inspector_protocol/Values.h" -#include "platform/v8_inspector/Atomics.h" +// 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/V8Debugger.h" + #include "platform/v8_inspector/DebuggerScript.h" -#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/V8InspectorImpl.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" -#include "platform/v8_inspector/public/V8DebuggerClient.h" -#include +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { 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"; @@ -67,47 +32,46 @@ inline v8::Local v8Boolean(bool value, v8::Isolate* isolate) static bool inLiveEditScope = false; -v8::MaybeLocal V8DebuggerImpl::callDebuggerMethod(const char* functionName, int argc, v8::Local argv[]) +v8::MaybeLocal V8Debugger::callDebuggerMethod(const char* functionName, int argc, v8::Local argv[]) { v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local debuggerScript = m_debuggerScript.Get(m_isolate); - v8::Local function = v8::Local::Cast(debuggerScript->Get(v8InternalizedString(functionName))); + v8::Local function = v8::Local::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, functionName))); DCHECK(m_isolate->InContext()); return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv); } -std::unique_ptr V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient* client) -{ - return wrapUnique(new V8DebuggerImpl(isolate, client)); -} - -V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) +V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) : m_isolate(isolate) - , m_client(client) - , m_capturingStackTracesCount(0) - , m_lastExceptionId(0) - , m_enabledAgentsCount(0) + , m_inspector(inspector) + , m_lastContextId(0) + , m_enableCount(0) , m_breakpointsActivated(true) , m_runningNestedMessageLoop(false) + , m_ignoreScriptParsedEventsCounter(0) , m_maxAsyncCallStackDepth(0) { } -V8DebuggerImpl::~V8DebuggerImpl() +V8Debugger::~V8Debugger() { } -void V8DebuggerImpl::enable() +void V8Debugger::enable() { + if (m_enableCount++) + return; DCHECK(!enabled()); v8::HandleScope scope(m_isolate); - v8::Debug::SetDebugEventListener(m_isolate, &V8DebuggerImpl::v8DebugEventCallback, v8::External::New(m_isolate, this)); + v8::Debug::SetDebugEventListener(m_isolate, &V8Debugger::v8DebugEventCallback, v8::External::New(m_isolate, this)); m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext(m_isolate)); compileDebuggerScript(); } -void V8DebuggerImpl::disable() +void V8Debugger::disable() { + if (--m_enableCount) + return; DCHECK(enabled()); clearBreakpoints(); m_debuggerScript.Reset(); @@ -116,13 +80,13 @@ void V8DebuggerImpl::disable() v8::Debug::SetDebugEventListener(m_isolate, nullptr); } -bool V8DebuggerImpl::enabled() const +bool V8Debugger::enabled() const { return !m_debuggerScript.IsEmpty(); } // static -int V8DebuggerImpl::contextId(v8::Local context) +int V8Debugger::contextId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -140,7 +104,7 @@ int V8DebuggerImpl::contextId(v8::Local context) } // static -int V8DebuggerImpl::getGroupId(v8::Local context) +int V8Debugger::getGroupId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -154,43 +118,13 @@ int V8DebuggerImpl::getGroupId(v8::Local context) return dataString.substring(0, commaPos).toInt(); } -void V8DebuggerImpl::debuggerAgentEnabled() -{ - if (!m_enabledAgentsCount++) - enable(); -} - -void V8DebuggerImpl::debuggerAgentDisabled() -{ - if (!--m_enabledAgentsCount) - disable(); -} - -V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId) -{ - if (!contextGroupId) - 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) -{ - return findEnabledDebuggerAgent(getGroupId(context)); -} - -void V8DebuggerImpl::getCompiledScripts(int contextGroupId, std::vector>& result) +void V8Debugger::getCompiledScripts(int contextGroupId, std::vector>& result) { v8::HandleScope scope(m_isolate); v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local debuggerScript = m_debuggerScript.Get(m_isolate); DCHECK(!debuggerScript->IsUndefined()); - v8::Local getScriptsFunction = v8::Local::Cast(debuggerScript->Get(v8InternalizedString("getScripts"))); + v8::Local getScriptsFunction = v8::Local::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts"))); v8::Local argv[] = { v8::Integer::New(m_isolate, contextGroupId) }; v8::Local value; if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, PROTOCOL_ARRAY_LENGTH(argv), argv).ToLocal(&value)) @@ -204,49 +138,49 @@ void V8DebuggerImpl::getCompiledScripts(int contextGroupId, std::vector info = v8::Object::New(m_isolate); - info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID)); - info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber)); - info->Set(v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber)); - info->Set(v8InternalizedString("interstatementLocation"), v8Boolean(interstatementLocation, m_isolate)); - info->Set(v8InternalizedString("condition"), toV8String(m_isolate, scriptBreakpoint.condition)); + info->Set(toV8StringInternalized(m_isolate, "sourceID"), toV8String(m_isolate, sourceID)); + info->Set(toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber)); + info->Set(toV8StringInternalized(m_isolate, "columnNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber)); + info->Set(toV8StringInternalized(m_isolate, "interstatementLocation"), v8Boolean(interstatementLocation, m_isolate)); + info->Set(toV8StringInternalized(m_isolate, "condition"), toV8String(m_isolate, scriptBreakpoint.condition)); - v8::Local setBreakpointFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpoint"))); + v8::Local setBreakpointFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "setBreakpoint"))); v8::Local breakpointId = v8::Debug::Call(debuggerContext(), setBreakpointFunction, info).ToLocalChecked(); if (!breakpointId->IsString()) return ""; - *actualLineNumber = info->Get(v8InternalizedString("lineNumber"))->Int32Value(); - *actualColumnNumber = info->Get(v8InternalizedString("columnNumber"))->Int32Value(); + *actualLineNumber = info->Get(toV8StringInternalized(m_isolate, "lineNumber"))->Int32Value(); + *actualColumnNumber = info->Get(toV8StringInternalized(m_isolate, "columnNumber"))->Int32Value(); return toProtocolString(breakpointId.As()); } -void V8DebuggerImpl::removeBreakpoint(const String16& breakpointId) +void V8Debugger::removeBreakpoint(const String16& breakpointId) { v8::HandleScope scope(m_isolate); v8::Context::Scope contextScope(debuggerContext()); v8::Local info = v8::Object::New(m_isolate); - info->Set(v8InternalizedString("breakpointId"), toV8String(m_isolate, breakpointId)); + info->Set(toV8StringInternalized(m_isolate, "breakpointId"), toV8String(m_isolate, breakpointId)); - v8::Local removeBreakpointFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("removeBreakpoint"))); + v8::Local removeBreakpointFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "removeBreakpoint"))); v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info).ToLocalChecked(); } -void V8DebuggerImpl::clearBreakpoints() +void V8Debugger::clearBreakpoints() { v8::HandleScope scope(m_isolate); v8::Context::Scope contextScope(debuggerContext()); - v8::Local clearBreakpoints = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("clearBreakpoints"))); + v8::Local clearBreakpoints = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "clearBreakpoints"))); v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked(); } -void V8DebuggerImpl::setBreakpointsActivated(bool activated) +void V8Debugger::setBreakpointsActivated(bool activated) { if (!enabled()) { NOTREACHED(); @@ -256,14 +190,14 @@ void V8DebuggerImpl::setBreakpointsActivated(bool activated) v8::Context::Scope contextScope(debuggerContext()); v8::Local info = v8::Object::New(m_isolate); - info->Set(v8InternalizedString("enabled"), v8::Boolean::New(m_isolate, activated)); - v8::Local setBreakpointsActivated = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpointsActivated"))); + info->Set(toV8StringInternalized(m_isolate, "enabled"), v8::Boolean::New(m_isolate, activated)); + v8::Local setBreakpointsActivated = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "setBreakpointsActivated"))); v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info).ToLocalChecked(); m_breakpointsActivated = activated; } -V8DebuggerImpl::PauseOnExceptionsState V8DebuggerImpl::getPauseOnExceptionsState() +V8Debugger::PauseOnExceptionsState V8Debugger::getPauseOnExceptionsState() { DCHECK(enabled()); v8::HandleScope scope(m_isolate); @@ -271,10 +205,10 @@ V8DebuggerImpl::PauseOnExceptionsState V8DebuggerImpl::getPauseOnExceptionsState v8::Local argv[] = { v8::Undefined(m_isolate) }; v8::Local result = callDebuggerMethod("pauseOnExceptionsState", 0, argv).ToLocalChecked(); - return static_cast(result->Int32Value()); + return static_cast(result->Int32Value()); } -void V8DebuggerImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) +void V8Debugger::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) { DCHECK(enabled()); v8::HandleScope scope(m_isolate); @@ -284,7 +218,7 @@ void V8DebuggerImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExc callDebuggerMethod("setPauseOnExceptionsState", 1, argv); } -void V8DebuggerImpl::setPauseOnNextStatement(bool pause) +void V8Debugger::setPauseOnNextStatement(bool pause) { if (m_runningNestedMessageLoop) return; @@ -294,14 +228,14 @@ void V8DebuggerImpl::setPauseOnNextStatement(bool pause) v8::Debug::CancelDebugBreak(m_isolate); } -bool V8DebuggerImpl::canBreakProgram() +bool V8Debugger::canBreakProgram() { if (!m_breakpointsActivated) return false; return m_isolate->InContext(); } -void V8DebuggerImpl::breakProgram() +void V8Debugger::breakProgram() { if (isPaused()) { DCHECK(!m_runningNestedMessageLoop); @@ -316,20 +250,20 @@ 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), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction)) + if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(m_isolate->GetCurrentContext(), &V8Debugger::breakProgramCallback, v8::External::New(m_isolate, this), 0).ToLocal(&breakFunction)) return; v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked(); } -void V8DebuggerImpl::continueProgram() +void V8Debugger::continueProgram() { if (isPaused()) - m_client->quitMessageLoopOnPause(); + m_inspector->client()->quitMessageLoopOnPause(); m_pausedContext.Clear(); m_executionState.Clear(); } -void V8DebuggerImpl::stepIntoStatement() +void V8Debugger::stepIntoStatement() { DCHECK(isPaused()); DCHECK(!m_executionState.IsEmpty()); @@ -339,7 +273,7 @@ void V8DebuggerImpl::stepIntoStatement() continueProgram(); } -void V8DebuggerImpl::stepOverStatement() +void V8Debugger::stepOverStatement() { DCHECK(isPaused()); DCHECK(!m_executionState.IsEmpty()); @@ -349,7 +283,7 @@ void V8DebuggerImpl::stepOverStatement() continueProgram(); } -void V8DebuggerImpl::stepOutOfFunction() +void V8Debugger::stepOutOfFunction() { DCHECK(isPaused()); DCHECK(!m_executionState.IsEmpty()); @@ -359,7 +293,7 @@ void V8DebuggerImpl::stepOutOfFunction() continueProgram(); } -void V8DebuggerImpl::clearStepping() +void V8Debugger::clearStepping() { DCHECK(enabled()); v8::HandleScope scope(m_isolate); @@ -369,7 +303,7 @@ void V8DebuggerImpl::clearStepping() callDebuggerMethod("clearStepping", 0, argv); } -bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString* error, Maybe* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) +bool V8Debugger::setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString* error, Maybe* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) { class EnableLiveEditScope { public: @@ -441,13 +375,13 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::LocalInContext()) return JavaScriptCallFrames(); v8::Local currentCallFramesV8; if (m_executionState.IsEmpty()) { - v8::Local currentCallFramesFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallFrames"))); + v8::Local currentCallFramesFunction = v8::Local::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "currentCallFrames"))); currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFramesFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked(); } else { v8::Local argv[] = { m_executionState, v8::Integer::New(m_isolate, limit) }; @@ -470,29 +404,31 @@ JavaScriptCallFrames V8DebuggerImpl::currentCallFrames(int limit) return callFrames; } -static V8DebuggerImpl* toV8DebuggerImpl(v8::Local data) +static V8Debugger* toV8Debugger(v8::Local data) { void* p = v8::Local::Cast(data)->Value(); - return static_cast(p); + return static_cast(p); } -void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo& info) +void V8Debugger::breakProgramCallback(const v8::FunctionCallbackInfo& info) { DCHECK_EQ(info.Length(), 2); - V8DebuggerImpl* thisPtr = toV8DebuggerImpl(info.Data()); + V8Debugger* thisPtr = toV8Debugger(info.Data()); + if (!thisPtr->enabled()) + return; v8::Local pausedContext = thisPtr->m_isolate->GetCurrentContext(); v8::Local exception; v8::Local hitBreakpoints; thisPtr->handleProgramBreak(pausedContext, v8::Local::Cast(info[0]), exception, hitBreakpoints); } -void V8DebuggerImpl::handleProgramBreak(v8::Local pausedContext, v8::Local executionState, v8::Local exception, v8::Local hitBreakpointNumbers, bool isPromiseRejection) +void V8Debugger::handleProgramBreak(v8::Local pausedContext, v8::Local executionState, v8::Local exception, v8::Local hitBreakpointNumbers, bool isPromiseRejection) { // Don't allow nested breaks. if (m_runningNestedMessageLoop) return; - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(pausedContext); + V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); if (!agent) return; @@ -513,9 +449,9 @@ void V8DebuggerImpl::handleProgramBreak(v8::Local pausedContext, v8 m_runningNestedMessageLoop = true; int groupId = getGroupId(pausedContext); DCHECK(groupId); - m_client->runMessageLoopOnPause(groupId); + m_inspector->client()->runMessageLoopOnPause(groupId); // The agent may have been removed in the nested loop. - agent = findEnabledDebuggerAgent(pausedContext); + agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); if (agent) agent->didContinue(); m_runningNestedMessageLoop = false; @@ -535,21 +471,21 @@ void V8DebuggerImpl::handleProgramBreak(v8::Local pausedContext, v8 } } -void V8DebuggerImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails) +void V8Debugger::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails) { - V8DebuggerImpl* thisPtr = toV8DebuggerImpl(eventDetails.GetCallbackData()); + V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); thisPtr->handleV8DebugEvent(eventDetails); } -v8::Local V8DebuggerImpl::callInternalGetterFunction(v8::Local object, const char* functionName) +v8::Local V8Debugger::callInternalGetterFunction(v8::Local object, const char* functionName) { v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); - v8::Local getterValue = object->Get(v8InternalizedString(functionName)); + v8::Local getterValue = object->Get(toV8StringInternalized(m_isolate, functionName)); DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction()); return v8::Local::Cast(getterValue)->Call(m_isolate->GetCurrentContext(), object, 0, 0).ToLocalChecked(); } -void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails) +void V8Debugger::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails) { if (!enabled()) return; @@ -566,10 +502,10 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta return; } - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext); + V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(eventContext)); if (agent) { v8::HandleScope scope(m_isolate); - if (event == v8::AfterCompile || event == v8::CompileError) { + if (m_ignoreScriptParsedEventsCounter == 0 && (event == v8::AfterCompile || event == v8::CompileError)) { v8::Context::Scope contextScope(debuggerContext()); v8::Local argv[] = { eventDetails.GetEventData() }; v8::Local value = callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked(); @@ -591,7 +527,7 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta } } -void V8DebuggerImpl::handleV8AsyncTaskEvent(v8::Local context, v8::Local executionState, v8::Local eventData) +void V8Debugger::handleV8AsyncTaskEvent(v8::Local context, v8::Local executionState, v8::Local eventData) { if (!m_maxAsyncCallStackDepth) return; @@ -611,14 +547,14 @@ void V8DebuggerImpl::handleV8AsyncTaskEvent(v8::Local context, v8:: NOTREACHED(); } -V8StackTraceImpl* V8DebuggerImpl::currentAsyncCallChain() +V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { if (!m_currentStacks.size()) return nullptr; return m_currentStacks.back().get(); } -void V8DebuggerImpl::compileDebuggerScript() +void V8Debugger::compileDebuggerScript() { if (!m_debuggerScript.IsEmpty()) { NOTREACHED(); @@ -630,24 +566,21 @@ void V8DebuggerImpl::compileDebuggerScript() v8::Local scriptValue = v8::String::NewFromUtf8(m_isolate, DebuggerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLocalChecked(); v8::Local value; - if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&value)) + if (!m_inspector->compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&value)) { + NOTREACHED(); return; + } DCHECK(value->IsObject()); m_debuggerScript.Reset(m_isolate, value.As()); } -v8::Local V8DebuggerImpl::debuggerContext() const +v8::Local V8Debugger::debuggerContext() const { DCHECK(!m_debuggerContext.IsEmpty()); return m_debuggerContext.Get(m_isolate); } -v8::Local V8DebuggerImpl::v8InternalizedString(const char* str) const -{ - return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternalized).ToLocalChecked(); -} - -v8::MaybeLocal V8DebuggerImpl::functionScopes(v8::Local function) +v8::MaybeLocal V8Debugger::functionScopes(v8::Local function) { if (!enabled()) { NOTREACHED(); @@ -668,7 +601,7 @@ v8::MaybeLocal V8DebuggerImpl::functionScopes(v8::Local return scopes; } -v8::MaybeLocal V8DebuggerImpl::internalProperties(v8::Local context, v8::Local value) +v8::MaybeLocal V8Debugger::internalProperties(v8::Local context, v8::Local value) { v8::Local properties; if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) @@ -677,11 +610,11 @@ v8::MaybeLocal V8DebuggerImpl::internalProperties(v8::Local function = value.As(); v8::Local location = functionLocation(context, function); if (location->IsObject()) { - properties->Set(properties->Length(), v8InternalizedString("[[FunctionLocation]]")); + properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[FunctionLocation]]")); properties->Set(properties->Length(), location); } if (function->IsGeneratorFunction()) { - properties->Set(properties->Length(), v8InternalizedString("[[IsGenerator]]")); + properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[IsGenerator]]")); properties->Set(properties->Length(), v8::True(m_isolate)); } } @@ -690,14 +623,14 @@ v8::MaybeLocal V8DebuggerImpl::internalProperties(v8::LocalIsMap() || 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(), toV8StringInternalized(m_isolate, "[[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(), toV8StringInternalized(m_isolate, "[[GeneratorLocation]]")); properties->Set(properties->Length(), location); } } @@ -706,14 +639,14 @@ v8::MaybeLocal V8DebuggerImpl::internalProperties(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(), toV8StringInternalized(m_isolate, "[[Scopes]]")); properties->Set(properties->Length(), scopes); } } return properties; } -v8::Local V8DebuggerImpl::collectionEntries(v8::Local context, v8::Local object) +v8::Local V8Debugger::collectionEntries(v8::Local context, v8::Local object) { if (!enabled()) { NOTREACHED(); @@ -731,7 +664,7 @@ v8::Local V8DebuggerImpl::collectionEntries(v8::Local co return entries; } -v8::Local V8DebuggerImpl::generatorObjectLocation(v8::Local object) +v8::Local V8Debugger::generatorObjectLocation(v8::Local object) { if (!enabled()) { NOTREACHED(); @@ -747,7 +680,7 @@ v8::Local V8DebuggerImpl::generatorObjectLocation(v8::Local V8DebuggerImpl::functionLocation(v8::Local context, v8::Local function) +v8::Local V8Debugger::functionLocation(v8::Local context, v8::Local function) { int scriptId = function->ScriptId(); if (scriptId == v8::UnboundScript::kNoScriptId) @@ -757,193 +690,39 @@ v8::Local V8DebuggerImpl::functionLocation(v8::Local con 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)) + if (!location->Set(context, toV8StringInternalized(m_isolate, "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)) + if (!location->Set(context, toV8StringInternalized(m_isolate, "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)) + if (!location->Set(context, toV8StringInternalized(m_isolate, "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() +bool V8Debugger::isPaused() { return !m_pausedContext.IsEmpty(); } -v8::MaybeLocal V8DebuggerImpl::runCompiledScript(v8::Local context, v8::Local script) -{ - // TODO(dgozman): get rid of this check. - if (!m_client->isExecutionAllowed()) - return v8::MaybeLocal(); - - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); - int groupId = getGroupId(context); - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId)) - agent->willExecuteScript(script->GetUnboundScript()->GetId()); - v8::MaybeLocal result = script->Run(context); - // Get agent from the map again, since it could have detached during script execution. - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId)) - agent->didExecuteScript(); - return result; -} - -v8::MaybeLocal V8DebuggerImpl::callFunction(v8::Local function, v8::Local context, v8::Local receiver, int argc, v8::Local info[]) -{ - // TODO(dgozman): get rid of this check. - if (!m_client->isExecutionAllowed()) - return v8::MaybeLocal(); - - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); - int groupId = getGroupId(context); - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId)) - agent->willExecuteScript(function->ScriptId()); - v8::MaybeLocal result = function->Call(context, receiver, argc, info); - // Get agent from the map again, since it could have detached during script execution. - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId)) - agent->didExecuteScript(); - return result; -} - -v8::MaybeLocal V8DebuggerImpl::compileAndRunInternalScript(v8::Local context, v8::Local source) -{ - v8::Local script = compileInternalScript(context, source, String()); - if (script.IsEmpty()) - return v8::MaybeLocal(); - v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); - return script->Run(context); -} - -v8::Local V8DebuggerImpl::compileInternalScript(v8::Local context, v8::Local code, const String16& fileName) -{ - // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at - // 1, whereas v8 starts at 0. - v8::ScriptOrigin origin( - toV8String(m_isolate, fileName), - v8::Integer::New(m_isolate, 0), - v8::Integer::New(m_isolate, 0), - v8::False(m_isolate), // sharable - v8::Local(), - v8::True(m_isolate), // internal - toV8String(m_isolate, String16()), // sourceMap - v8::True(m_isolate)); // opaqueresource - v8::ScriptCompiler::Source source(code, origin); - v8::Local script; - if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) - return v8::Local(); - return script; -} - -void V8DebuggerImpl::enableStackCapturingIfNeeded() -{ - if (!m_capturingStackTracesCount) - V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, true); - ++m_capturingStackTracesCount; -} - -void V8DebuggerImpl::disableStackCapturingIfNeeded() -{ - if (!(--m_capturingStackTracesCount)) - V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, false); -} - -V8ConsoleMessageStorage* V8DebuggerImpl::ensureConsoleMessageStorage(int contextGroupId) -{ - ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); - if (storageIt == m_consoleStorageMap.end()) - storageIt = m_consoleStorageMap.insert(std::make_pair(contextGroupId, wrapUnique(new V8ConsoleMessageStorage(this, contextGroupId)))).first; - return storageIt->second.get(); -} - -std::unique_ptr V8DebuggerImpl::createStackTrace(v8::Local stackTrace) +std::unique_ptr V8Debugger::createStackTrace(v8::Local stackTrace) { 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.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.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) +int V8Debugger::markContext(const V8ContextInfo& info) { DCHECK(info.context->GetIsolate() == m_isolate); - // TODO(dgozman): make s_lastContextId non-static. - int contextId = atomicIncrement(&s_lastContextId); - String16 debugData = String16::fromInteger(info.contextGroupId) + "," + String16::fromInteger(contextId) + "," + (info.isDefault ? "default" : "nondefault"); - v8::HandleScope scope(m_isolate); + int contextId = ++m_lastContextId; + String16 debugData = String16::fromInteger(info.contextGroupId) + "," + String16::fromInteger(contextId) + "," + info.auxData; v8::Context::Scope contextScope(info.context); info.context->SetEmbedderData(static_cast(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); - - 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; - - const auto& contextById = contextIt->second; - - 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); + return contextId; } -void V8DebuggerImpl::contextDestroyed(v8::Local context) -{ - int contextId = V8DebuggerImpl::contextId(context); - int contextGroupId = getGroupId(context); - - ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); - if (storageIt != m_consoleStorageMap.end()) - storageIt->second->contextDestroyed(contextId); - - InspectedContext* inspectedContext = getContext(contextGroupId, contextId); - if (!inspectedContext) - return; - - 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) -{ - 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) +void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) { if (depth <= 0) m_maxAsyncCallStackDepthMap.erase(agent); @@ -958,18 +737,12 @@ void V8DebuggerImpl::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int dept 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) +void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) { if (!m_maxAsyncCallStackDepth) return; @@ -983,7 +756,7 @@ void V8DebuggerImpl::asyncTaskScheduled(const String16& taskName, void* task, bo } } -void V8DebuggerImpl::asyncTaskCanceled(void* task) +void V8Debugger::asyncTaskCanceled(void* task) { if (!m_maxAsyncCallStackDepth) return; @@ -991,12 +764,10 @@ void V8DebuggerImpl::asyncTaskCanceled(void* task) m_recurringTasks.erase(task); } -void V8DebuggerImpl::asyncTaskStarted(void* task) +void V8Debugger::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: @@ -1012,7 +783,7 @@ void V8DebuggerImpl::asyncTaskStarted(void* task) m_currentStacks.push_back(std::move(stack)); } -void V8DebuggerImpl::asyncTaskFinished(void* task) +void V8Debugger::asyncTaskFinished(void* task) { if (!m_maxAsyncCallStackDepth) return; @@ -1028,7 +799,7 @@ void V8DebuggerImpl::asyncTaskFinished(void* task) m_asyncTaskStacks.erase(task); } -void V8DebuggerImpl::allAsyncTasksCanceled() +void V8Debugger::allAsyncTasksCanceled() { m_asyncTaskStacks.clear(); m_recurringTasks.clear(); @@ -1036,71 +807,18 @@ void V8DebuggerImpl::allAsyncTasksCanceled() m_currentTasks.clear(); } -void V8DebuggerImpl::willExecuteScript(v8::Local context, int scriptId) -{ - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(context)) - agent->willExecuteScript(scriptId); -} - -void V8DebuggerImpl::didExecuteScript(v8::Local context) -{ - if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(context)) - agent->didExecuteScript(); -} - -void V8DebuggerImpl::idleStarted() -{ - m_isolate->GetCpuProfiler()->SetIdle(true); -} - -void V8DebuggerImpl::idleFinished() -{ - m_isolate->GetCpuProfiler()->SetIdle(false); -} - -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) +void V8Debugger::muteScriptParsedEvents() { - 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)); + ++m_ignoreScriptParsedEventsCounter; } -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) +void V8Debugger::unmuteScriptParsedEvents() { - 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)); + --m_ignoreScriptParsedEventsCounter; + DCHECK_GE(m_ignoreScriptParsedEventsCounter, 0); } -std::unique_ptr V8DebuggerImpl::captureStackTrace(bool fullStack) +std::unique_ptr V8Debugger::captureStackTrace(bool fullStack) { if (!m_isolate->InContext()) return nullptr; @@ -1111,41 +829,10 @@ std::unique_ptr V8DebuggerImpl::captureStackTrace(bool fullStack) 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()) + if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; return V8StackTraceImpl::capture(this, contextGroupId, stackSize); } -v8::Local V8DebuggerImpl::regexContext() -{ - if (m_regexContext.IsEmpty()) - m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); - return m_regexContext.Get(m_isolate); -} - -void V8DebuggerImpl::discardInspectedContext(int contextGroupId, int contextId) -{ - if (!getContext(contextGroupId, contextId)) - return; - m_contexts[contextGroupId]->erase(contextId); - if (m_contexts[contextGroupId]->empty()) - m_contexts.erase(contextGroupId); -} - -const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGroupId) -{ - ContextsByGroupMap::iterator iter = m_contexts.find(contextGroupId); - return iter == m_contexts.end() ? nullptr : iter->second.get(); -} - -V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupId) -{ - 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/third_party/v8_inspector/platform/v8_inspector/V8Debugger.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Debugger.h new file mode 100644 index 00000000000000..3ec68a8708bee4 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Debugger.h @@ -0,0 +1,131 @@ +// 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 V8Debugger_h +#define V8Debugger_h + +#include "platform/inspector_protocol/Allocator.h" +#include "platform/inspector_protocol/Maybe.h" +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/JavaScriptCallFrame.h" +#include "platform/v8_inspector/V8DebuggerScript.h" +#include "platform/v8_inspector/protocol/Runtime.h" +#include "platform/v8_inspector/public/V8ContextInfo.h" + +#include +#include +#include + +namespace blink { + +struct ScriptBreakpoint; +class V8DebuggerAgentImpl; +class V8InspectorImpl; +class V8StackTraceImpl; + +class V8Debugger { + PROTOCOL_DISALLOW_COPY(V8Debugger); +public: + V8Debugger(v8::Isolate*, V8InspectorImpl*); + ~V8Debugger(); + + static int contextId(v8::Local); + static int getGroupId(v8::Local); + int markContext(const V8ContextInfo&); + + bool enabled() const; + + String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation); + void removeBreakpoint(const String16& breakpointId); + void setBreakpointsActivated(bool); + bool breakpointsActivated() const { return m_breakpointsActivated; } + + enum PauseOnExceptionsState { + DontPauseOnExceptions, + PauseOnAllExceptions, + PauseOnUncaughtExceptions + }; + PauseOnExceptionsState getPauseOnExceptionsState(); + void setPauseOnExceptionsState(PauseOnExceptionsState); + void setPauseOnNextStatement(bool); + bool canBreakProgram(); + void breakProgram(); + void continueProgram(); + void stepIntoStatement(); + void stepOverStatement(); + void stepOutOfFunction(); + void clearStepping(); + + bool setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString*, protocol::Maybe*, JavaScriptCallFrames* newCallFrames, protocol::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, std::vector>&); + void enable(); + void disable(); + + bool isPaused(); + v8::Local pausedContext() { return m_pausedContext; } + + int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } + V8StackTraceImpl* currentAsyncCallChain(); + void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int); + std::unique_ptr createStackTrace(v8::Local); + std::unique_ptr captureStackTrace(bool fullStack); + + v8::MaybeLocal functionScopes(v8::Local); + v8::MaybeLocal internalProperties(v8::Local, v8::Local); + + void asyncTaskScheduled(const String16& taskName, void* task, bool recurring); + void asyncTaskCanceled(void* task); + void asyncTaskStarted(void* task); + void asyncTaskFinished(void* task); + void allAsyncTasksCanceled(); + + void muteScriptParsedEvents(); + void unmuteScriptParsedEvents(); + +private: + void compileDebuggerScript(); + v8::MaybeLocal callDebuggerMethod(const char* functionName, int argc, v8::Local argv[]); + v8::Local debuggerContext() const; + void clearBreakpoints(); + + 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&); + v8::Local callInternalGetterFunction(v8::Local, const char* functionName); + void handleV8DebugEvent(const v8::Debug::EventDetails&); + void handleV8AsyncTaskEvent(v8::Local, v8::Local executionState, v8::Local eventData); + + v8::Local collectionEntries(v8::Local, v8::Local); + v8::Local generatorObjectLocation(v8::Local); + v8::Local functionLocation(v8::Local, v8::Local); + + v8::Isolate* m_isolate; + V8InspectorImpl* m_inspector; + int m_lastContextId; + int m_enableCount; + bool m_breakpointsActivated; + v8::Global m_debuggerScript; + v8::Global m_debuggerContext; + v8::Local m_executionState; + v8::Local m_pausedContext; + bool m_runningNestedMessageLoop; + int m_ignoreScriptParsedEventsCounter; + + 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 + +#endif // V8Debugger_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp index 2b232efc2e714b..584c0164e0339a 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp @@ -4,6 +4,7 @@ #include "platform/v8_inspector/V8DebuggerAgentImpl.h" +#include "platform/inspector_protocol/Parser.h" #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/Values.h" #include "platform/v8_inspector/InjectedScript.h" @@ -11,14 +12,15 @@ #include "platform/v8_inspector/JavaScriptCallFrame.h" #include "platform/v8_inspector/RemoteObjectId.h" #include "platform/v8_inspector/ScriptBreakpoint.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8DebuggerScript.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8Regex.h" #include "platform/v8_inspector/V8RuntimeAgentImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#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/V8InspectorClient.h" #include @@ -51,6 +53,7 @@ static const char skipAllPauses[] = "skipAllPauses"; } // namespace DebuggerAgentState; static const int maxSkipStepFrameCount = 128; +static const char backtraceObjectGroup[] = "backtrace"; static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) { @@ -93,12 +96,13 @@ static std::unique_ptr buildProtocolLocation(const } V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) - : m_debugger(session->debugger()) + : m_inspector(session->inspector()) + , m_debugger(m_inspector->debugger()) , m_session(session) , m_enabled(false) , m_state(state) , m_frontend(frontendChannel) - , m_isolate(m_debugger->isolate()) + , m_isolate(m_inspector->isolate()) , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) , m_scheduledDebuggerStep(NoStep) , m_skipNextDebuggerStepOut(false) @@ -127,19 +131,19 @@ bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) void V8DebuggerAgentImpl::enable() { - // debugger().addListener may result in reporting all parsed scripts to + // m_inspector->addListener may result in reporting all parsed scripts to // the agent so it should already be in enabled state by then. m_enabled = true; m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); - debugger().debuggerAgentEnabled(); + m_debugger->enable(); std::vector> compiledScripts; - debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts); + m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts); for (size_t i = 0; i < compiledScripts.size(); i++) didParseSource(std::move(compiledScripts[i]), true); // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends - debugger().setBreakpointsActivated(true); + m_debugger->setBreakpointsActivated(true); } bool V8DebuggerAgentImpl::enabled() @@ -152,7 +156,7 @@ void V8DebuggerAgentImpl::enable(ErrorString* errorString) if (enabled()) return; - if (!m_session->client()->canExecuteScripts()) { + if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) { *errorString = "Script execution is prohibited"; return; } @@ -166,12 +170,12 @@ void V8DebuggerAgentImpl::disable(ErrorString*) return; m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::DictionaryValue::create()); - m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImpl::DontPauseOnExceptions); + m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8Debugger::DontPauseOnExceptions); m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); if (!m_pausedContext.IsEmpty()) - debugger().continueProgram(); - debugger().debuggerAgentDisabled(); + m_debugger->continueProgram(); + m_debugger->disable(); m_pausedContext.Reset(); JavaScriptCallFrames emptyCallFrames; m_pausedCallFrames.swap(emptyCallFrames); @@ -200,13 +204,13 @@ void V8DebuggerAgentImpl::restore() DCHECK(!m_enabled); if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) return; - if (!m_session->client()->canExecuteScripts()) + if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) return; enable(); ErrorString error; - int pauseState = V8DebuggerImpl::DontPauseOnExceptions; + int pauseState = V8Debugger::DontPauseOnExceptions; m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); setPauseOnExceptionsImpl(&error, pauseState); DCHECK(error.isEmpty()); @@ -228,7 +232,7 @@ void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac { if (!checkEnabled(errorString)) return; - debugger().setBreakpointsActivated(active); + m_debugger->setBreakpointsActivated(active); } void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) @@ -248,10 +252,10 @@ static std::unique_ptr buildObjectForBreakpointCookie return breakpointObject; } -static bool matches(V8DebuggerImpl* debugger, const String16& url, const String16& pattern, bool isRegex) +static bool matches(V8InspectorImpl* inspector, const String16& url, const String16& pattern, bool isRegex) { if (isRegex) { - V8Regex regex(debugger, pattern, true); + V8Regex regex(inspector, pattern, true); return regex.match(url) != -1; } return url == pattern; @@ -300,7 +304,7 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); for (const auto& script : m_scripts) { - if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) + if (!matches(m_inspector, script.second->sourceURL(), url, isRegex)) continue; std::unique_ptr location = resolveBreakpoint(breakpointId, script.first, breakpoint, UserBreakpointSource); if (location) @@ -366,7 +370,7 @@ void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) for (size_t i = 0; i < ids.size(); ++i) { const String16& debuggerBreakpointId = ids[i]; - debugger().removeBreakpoint(debuggerBreakpointId); + m_debugger->removeBreakpoint(debuggerBreakpointId); m_serverBreakpoints.erase(debuggerBreakpointId); } m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); @@ -379,7 +383,7 @@ void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, if (!checkEnabled(errorString)) return; if (!m_continueToLocationBreakpointId.isEmpty()) { - debugger().removeBreakpoint(m_continueToLocationBreakpointId); + m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); m_continueToLocationBreakpointId = ""; } @@ -391,7 +395,7 @@ void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, return; ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); - m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakpoint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); + m_continueToLocationBreakpointId = m_debugger->setBreakpoint(scriptId, breakpoint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); resume(errorString); } @@ -399,7 +403,7 @@ void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr { if (!assertPaused(errorString)) return; - JavaScriptCallFrames frames = debugger().currentCallFrames(); + JavaScriptCallFrames frames = m_debugger->currentCallFrames(); m_pausedCallFrames.swap(frames); *callFrames = currentCallFrames(errorString); if (!*callFrames) @@ -410,7 +414,7 @@ void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() { DCHECK(enabled()); - JavaScriptCallFrames callFrames = debugger().currentCallFrames(); + JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(); for (size_t index = 0; index < callFrames.size(); ++index) { if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) return false; @@ -498,7 +502,7 @@ std::unique_ptr V8DebuggerAgentImpl::resolveBreakp int actualLineNumber; int actualColumnNumber; - String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoint, &actualLineNumber, &actualColumnNumber, false); + String16 debuggerBreakpointId = m_debugger->setBreakpoint(scriptId, breakpoint, &actualLineNumber, &actualColumnNumber, false); if (debuggerBreakpointId.isEmpty()) return nullptr; @@ -516,10 +520,15 @@ void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc { v8::HandleScope handles(m_isolate); ScriptsMap::iterator it = m_scripts.find(scriptId); - if (it != m_scripts.end()) - *results = V8ContentSearchUtil::searchInTextByLines(m_session, toProtocolString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); - else + if (it == m_scripts.end()) { *error = String16("No script for id: " + scriptId); + return; + } + + std::vector> matches = searchInTextByLinesImpl(m_session, toProtocolString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); + *results = protocol::Array::create(); + for (size_t i = 0; i < matches.size(); ++i) + (*results)->addItem(std::move(matches[i])); } void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, @@ -536,7 +545,7 @@ void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, 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)) + if (!m_debugger->setScriptSource(scriptId, newSource, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) return; ScriptsMap::iterator it = m_scripts.find(scriptId); @@ -557,7 +566,7 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, { if (!assertPaused(errorString)) return; - InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->contextGroupId(), callFrameId); + InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->contextGroupId(), callFrameId); if (!scope.initialize()) return; if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { @@ -571,7 +580,7 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, *errorString = "Internal error"; return; } - JavaScriptCallFrames frames = debugger().currentCallFrames(); + JavaScriptCallFrames frames = m_debugger->currentCallFrames(); m_pausedCallFrames.swap(frames); *newCallFrames = currentCallFrames(errorString); @@ -595,48 +604,48 @@ void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) { - if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || debugger().isPaused() || !debugger().breakpointsActivated()) + if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || m_debugger->isPaused() || !m_debugger->breakpointsActivated()) return; m_breakReason = breakReason; m_breakAuxData = std::move(data); m_pausingOnNativeEvent = true; m_skipNextDebuggerStepOut = false; - debugger().setPauseOnNextStatement(true); + m_debugger->setPauseOnNextStatement(true); } void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() { DCHECK(enabled()); - if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || debugger().isPaused()) + if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || m_debugger->isPaused()) return; clearBreakDetails(); m_pausingOnNativeEvent = false; m_skippedStepFrameCount = 0; m_recursionLevelForStepFrame = 0; - debugger().setPauseOnNextStatement(true); + m_debugger->setPauseOnNextStatement(true); } void V8DebuggerAgentImpl::cancelPauseOnNextStatement() { - if (m_javaScriptPauseScheduled || debugger().isPaused()) + if (m_javaScriptPauseScheduled || m_debugger->isPaused()) return; clearBreakDetails(); m_pausingOnNativeEvent = false; - debugger().setPauseOnNextStatement(false); + m_debugger->setPauseOnNextStatement(false); } void V8DebuggerAgentImpl::pause(ErrorString* errorString) { if (!checkEnabled(errorString)) return; - if (m_javaScriptPauseScheduled || debugger().isPaused()) + if (m_javaScriptPauseScheduled || m_debugger->isPaused()) return; clearBreakDetails(); m_javaScriptPauseScheduled = true; m_scheduledDebuggerStep = NoStep; m_skippedStepFrameCount = 0; m_steppingFromFramework = false; - debugger().setPauseOnNextStatement(true); + m_debugger->setPauseOnNextStatement(true); } void V8DebuggerAgentImpl::resume(ErrorString* errorString) @@ -645,8 +654,8 @@ void V8DebuggerAgentImpl::resume(ErrorString* errorString) return; m_scheduledDebuggerStep = NoStep; m_steppingFromFramework = false; - m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); - debugger().continueProgram(); + m_session->releaseObjectGroup(backtraceObjectGroup); + m_debugger->continueProgram(); } void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) @@ -661,8 +670,8 @@ void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) } m_scheduledDebuggerStep = StepOver; m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); - m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); - debugger().stepOverStatement(); + m_session->releaseObjectGroup(backtraceObjectGroup); + m_debugger->stepOverStatement(); } void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) @@ -671,8 +680,8 @@ void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) return; m_scheduledDebuggerStep = StepInto; m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); - m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); - debugger().stepIntoStatement(); + m_session->releaseObjectGroup(backtraceObjectGroup); + m_debugger->stepIntoStatement(); } void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) @@ -683,21 +692,21 @@ void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) m_skipNextDebuggerStepOut = false; m_recursionLevelForStepOut = 1; m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); - m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); - debugger().stepOutOfFunction(); + m_session->releaseObjectGroup(backtraceObjectGroup); + m_debugger->stepOutOfFunction(); } void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const String16& stringPauseState) { if (!checkEnabled(errorString)) return; - V8DebuggerImpl::PauseOnExceptionsState pauseState; + V8Debugger::PauseOnExceptionsState pauseState; if (stringPauseState == "none") { - pauseState = V8DebuggerImpl::DontPauseOnExceptions; + pauseState = V8Debugger::DontPauseOnExceptions; } else if (stringPauseState == "all") { - pauseState = V8DebuggerImpl::PauseOnAllExceptions; + pauseState = V8Debugger::PauseOnAllExceptions; } else if (stringPauseState == "uncaught") { - pauseState = V8DebuggerImpl::PauseOnUncaughtExceptions; + pauseState = V8Debugger::PauseOnUncaughtExceptions; } else { *errorString = "Unknown pause on exceptions mode: " + stringPauseState; return; @@ -707,8 +716,8 @@ void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int pauseState) { - debugger().setPauseOnExceptionsState(static_cast(pauseState)); - if (debugger().getPauseOnExceptionsState() != pauseState) + m_debugger->setPauseOnExceptionsState(static_cast(pauseState)); + if (m_debugger->getPauseOnExceptionsState() != pauseState) *errorString = "Internal error. Could not change pause on exceptions state"; else m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); @@ -728,7 +737,7 @@ void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, { if (!assertPaused(errorString)) return; - InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->contextGroupId(), callFrameId); + InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->contextGroupId(), callFrameId); if (!scope.initialize()) return; if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { @@ -767,7 +776,7 @@ void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, return; if (!assertPaused(errorString)) return; - InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->contextGroupId(), callFrameId); + InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->contextGroupId(), callFrameId); if (!scope.initialize()) return; @@ -818,7 +827,7 @@ void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const String16& pattern) { - std::unique_ptr regex(new V8Regex(m_debugger, pattern, true /** caseSensitive */, false /** multiline */)); + std::unique_ptr regex(new V8Regex(m_inspector, pattern, true /** caseSensitive */, false /** multiline */)); if (!regex->isValid()) { *errorString = "Pattern parser error: " + regex->errorMessage(); return false; @@ -873,9 +882,6 @@ void V8DebuggerAgentImpl::willExecuteScript(int scriptId) // Fast return. if (m_scheduledDebuggerStep != StepInto) return; - // Skip unknown scripts (e.g. InjectedScript). - if (m_scripts.find(String16::fromInteger(scriptId)) == m_scripts.end()) - return; schedulePauseOnNextStatementIfSteppingInto(); } @@ -886,9 +892,9 @@ void V8DebuggerAgentImpl::didExecuteScript() void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) { - if (m_javaScriptPauseScheduled && !m_skipAllPauses && !debugger().isPaused()) { + if (m_javaScriptPauseScheduled && !m_skipAllPauses && !m_debugger->isPaused()) { // Do not ever loose user's pause request until we have actually paused. - debugger().setPauseOnNextStatement(true); + m_debugger->setPauseOnNextStatement(true); } if (m_scheduledDebuggerStep == StepOut) { m_recursionLevelForStepOut += step; @@ -910,7 +916,7 @@ void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) // from the old StepFrame. m_skippedStepFrameCount = 0; if (m_scheduledDebuggerStep == NoStep) - debugger().clearStepping(); + m_debugger->clearStepping(); else if (m_scheduledDebuggerStep == StepOut) m_skipNextDebuggerStepOut = true; } @@ -947,12 +953,12 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt 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)) + if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), backtraceObjectGroup)) return Array::create(); - if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), 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)) + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), backtraceObjectGroup)) return Array::create(); } } else { @@ -992,17 +998,19 @@ void V8DebuggerAgentImpl::didParseSource(std::unique_ptr scrip String16 scriptSource = toProtocolString(script->source(m_isolate)); bool isDeprecatedSourceURL = false; if (!success) - script->setSourceURL(V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL)); + script->setSourceURL(findSourceURL(scriptSource, false, &isDeprecatedSourceURL)); else if (script->hasSourceURL()) - V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL); + findSourceURL(scriptSource, false, &isDeprecatedSourceURL); bool isDeprecatedSourceMappingURL = false; if (!success) - script->setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL)); + script->setSourceMappingURL(findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL)); else if (!script->sourceMappingURL().isEmpty()) - V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL); + findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL); - bool isContentScript = script->isContentScript(); + std::unique_ptr executionContextAuxData; + if (!script->executionContextAuxData().isEmpty()) + executionContextAuxData = protocol::DictionaryValue::cast(parseJSON(script->executionContextAuxData())); bool isInternalScript = script->isInternalScript(); bool isLiveEdit = script->isLiveEdit(); bool hasSourceURL = script->hasSourceURL(); @@ -1011,15 +1019,15 @@ void V8DebuggerAgentImpl::didParseSource(std::unique_ptr scrip bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceMappingURL; const Maybe& sourceMapURLParam = script->sourceMappingURL(); - const bool* isContentScriptParam = isContentScript ? &isContentScript : nullptr; + const Maybe& executionContextAuxDataParam(std::move(executionContextAuxData)); 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 (success) - m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); + m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), executionContextAuxDataParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); else - m_frontend.scriptFailedToParse(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->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(), executionContextAuxDataParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); m_scripts[scriptId] = std::move(script); @@ -1037,7 +1045,7 @@ void V8DebuggerAgentImpl::didParseSource(std::unique_ptr scrip breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); String16 url; breakpointObject->getString(DebuggerAgentState::url, &url); - if (!matches(m_debugger, scriptURL, url, isRegex)) + if (!matches(m_inspector, scriptURL, url, isRegex)) continue; ScriptBreakpoint breakpoint; breakpointObject->getInteger(DebuggerAgentState::lineNumber, &breakpoint.lineNumber); @@ -1051,9 +1059,16 @@ void V8DebuggerAgentImpl::didParseSource(std::unique_ptr scrip V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local context, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection) { - JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); + JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(1); JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()->get() : nullptr; + // Skip pause in internal scripts (e.g. InjectedScriptSource.js). + if (topCallFrame) { + ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFrame->sourceID())); + if (it != m_scripts.end() && it->second->isInternalScript()) + return RequestStepFrame; + } + V8DebuggerAgentImpl::SkipPauseRequest result; if (m_skipAllPauses) result = RequestContinue; @@ -1074,18 +1089,18 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::LocalcurrentCallFrames(); m_pausedCallFrames.swap(frames); m_pausedContext.Reset(m_isolate, context); v8::HandleScope handles(m_isolate); if (!exception.IsEmpty()) { ErrorString ignored; - InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8DebuggerImpl::contextId(context)); + InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context)); if (injectedScript) { m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; ErrorString errorString; - auto obj = injectedScript->wrapObject(&errorString, exception, V8InspectorSession::backtraceObjectGroup); + auto obj = injectedScript->wrapObject(&errorString, exception, backtraceObjectGroup); m_breakAuxData = obj ? obj->serialize() : nullptr; // m_breakAuxData might be null after this. } @@ -1115,7 +1130,7 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::LocalremoveBreakpoint(m_continueToLocationBreakpointId); m_continueToLocationBreakpointId = ""; } return result; @@ -1132,19 +1147,19 @@ void V8DebuggerAgentImpl::didContinue() void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_ptr data) { - if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrentCallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated()) + if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrentCallStackEmptyOrBlackboxed() || !m_debugger->breakpointsActivated()) return; m_breakReason = breakReason; m_breakAuxData = std::move(data); m_scheduledDebuggerStep = NoStep; m_steppingFromFramework = false; m_pausingOnNativeEvent = false; - debugger().breakProgram(); + m_debugger->breakProgram(); } void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, std::unique_ptr data) { - if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl::DontPauseOnExceptions) + if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8Debugger::DontPauseOnExceptions) return; breakProgram(breakReason, std::move(data)); } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h index b6aea619e10318..e777f3b2cd8af4 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h @@ -7,15 +7,19 @@ #include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/JavaScriptCallFrame.h" #include "platform/v8_inspector/protocol/Debugger.h" #include namespace blink { +struct ScriptBreakpoint; class JavaScriptCallFrame; class PromiseTracker; +class V8Debugger; +class V8DebuggerScript; +class V8InspectorImpl; class V8InspectorSessionImpl; class V8Regex; class V8StackTraceImpl; @@ -122,7 +126,6 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { std::unique_ptr> positions) override; bool enabled(); - V8DebuggerImpl& debugger() { return *m_debugger; } void setBreakpointAt(const String16& scriptId, int lineNumber, int columnNumber, BreakpointSource, const String16& condition = String16()); void removeBreakpointAt(const String16& scriptId, int lineNumber, int columnNumber, BreakpointSource); @@ -133,7 +136,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { void reset(); - // Interface for V8DebuggerImpl + // Interface for V8InspectorImpl SkipPauseRequest didPause(v8::Local, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection); void didContinue(); void didParseSource(std::unique_ptr, bool success); @@ -184,7 +187,8 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { StepOut }; - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; + V8Debugger* m_debugger; V8InspectorSessionImpl* m_session; bool m_enabled; protocol::DictionaryValue* m_state; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h deleted file mode 100644 index 0be86bfb28ae52..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2010, 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: - * - * * 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. - */ - -#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" -#include "platform/v8_inspector/V8DebuggerScript.h" -#include "platform/v8_inspector/protocol/Debugger.h" -#include "platform/v8_inspector/public/V8Debugger.h" - -#include -#include -#include - -#include - -namespace blink { - -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); -public: - 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); - void removeBreakpoint(const String16& breakpointId); - void setBreakpointsActivated(bool); - bool breakpointsActivated() const { return m_breakpointsActivated; } - - enum PauseOnExceptionsState { - DontPauseOnExceptions, - PauseOnAllExceptions, - PauseOnUncaughtExceptions - }; - PauseOnExceptionsState getPauseOnExceptionsState(); - void setPauseOnExceptionsState(PauseOnExceptionsState); - void setPauseOnNextStatement(bool); - bool canBreakProgram(); - void breakProgram(); - void continueProgram(); - void stepIntoStatement(); - void stepOverStatement(); - void stepOutOfFunction(); - void clearStepping(); - - 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, std::vector>&); - void debuggerAgentEnabled(); - void debuggerAgentDisabled(); - - 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::MaybeLocal internalProperties(v8::Local, v8::Local); - - v8::Isolate* isolate() const { return m_isolate; } - V8DebuggerClient* client() { return m_client; } - - v8::MaybeLocal runCompiledScript(v8::Local, v8::Local); - v8::MaybeLocal callFunction(v8::Local, v8::Local, v8::Local receiver, int argc, v8::Local info[]); - v8::MaybeLocal compileAndRunInternalScript(v8::Local, v8::Local); - 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; - void contextDestroyed(v8::Local) override; - void resetContextGroup(int contextGroupId) override; - void willExecuteScript(v8::Local, int scriptId) override; - 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(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(); - void disable(); - V8DebuggerAgentImpl* findEnabledDebuggerAgent(int contextGroupId); - V8DebuggerAgentImpl* findEnabledDebuggerAgent(v8::Local); - - void compileDebuggerScript(); - v8::MaybeLocal callDebuggerMethod(const char* functionName, int argc, v8::Local argv[]); - v8::Local debuggerContext() const; - void clearBreakpoints(); - - 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&); - v8::Local callInternalGetterFunction(v8::Local, const char* functionName); - void handleV8DebugEvent(const v8::Debug::EventDetails&); - - v8::Local v8InternalizedString(const char*) const; - - 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; - 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; - v8::Global m_debuggerContext; - v8::Local m_executionState; - 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 - - -#endif // V8DebuggerImpl_h 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 index 91a060b954e023..edb2fcdc7d333d 100644 --- 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 @@ -78,7 +78,7 @@ V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, v8::Local o 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_executionContextAuxData = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "executionContextAuxData"))); m_isInternalScript = object->Get(toV8StringInternalized(isolate, "isInternalScript"))->ToBoolean(isolate)->Value(); m_executionContextId = object->Get(toV8StringInternalized(isolate, "executionContextId"))->ToInteger(isolate)->Value(); m_isLiveEdit = isLiveEdit; @@ -92,7 +92,7 @@ V8DebuggerScript::~V8DebuggerScript() { } -String16 V8DebuggerScript::sourceURL() const +const String16& V8DebuggerScript::sourceURL() const { return m_sourceURL.isEmpty() ? m_url : m_sourceURL; } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h index 60d93d81986493..d3e9d8d02d5faa 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h @@ -42,19 +42,19 @@ class V8DebuggerScript { V8DebuggerScript(v8::Isolate*, v8::Local, bool isLiveEdit); ~V8DebuggerScript(); - String16 scriptId() const { return m_id; } - String16 url() const { return m_url; } + const String16& scriptId() const { return m_id; } + const String16& url() const { return m_url; } bool hasSourceURL() const { return !m_sourceURL.isEmpty(); } - String16 sourceURL() const; - String16 sourceMappingURL() const { return m_sourceMappingURL; } + const String16& sourceURL() const; + const String16& sourceMappingURL() const { return m_sourceMappingURL; } v8::Local source(v8::Isolate*) const; - String16 hash() const { return m_hash; } + const String16& hash() const { return m_hash; } int startLine() const { return m_startLine; } int startColumn() const { return m_startColumn; } int endLine() const { return m_endLine; } int endColumn() const { return m_endColumn; } int executionContextId() const { return m_executionContextId; } - bool isContentScript() const { return m_isContentScript; } + const String16& executionContextAuxData() const { return m_executionContextAuxData; } bool isInternalScript() const { return m_isInternalScript; } bool isLiveEdit() const { return m_isLiveEdit; } @@ -74,7 +74,7 @@ class V8DebuggerScript { int m_endLine; int m_endColumn; int m_executionContextId; - bool m_isContentScript; + String16 m_executionContextAuxData; bool m_isInternalScript; bool m_isLiveEdit; }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp index 73edc7260f0719..bed316ef35ddd5 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp @@ -32,16 +32,17 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/v8_inspector/V8Compat.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" #include namespace blink { -V8FunctionCall::V8FunctionCall(V8DebuggerImpl* debugger, v8::Local context, v8::Local value, const String16& name) - : m_debugger(debugger) +V8FunctionCall::V8FunctionCall(V8InspectorImpl* inspector, v8::Local context, v8::Local value, const String16& name) + : m_inspector(inspector) , m_context(context) , m_name(toV8String(context->GetIsolate(), name)) , m_value(value) @@ -68,11 +69,6 @@ void V8FunctionCall::appendArgument(bool argument) m_arguments.push_back(argument ? v8::True(m_context->GetIsolate()) : v8::False(m_context->GetIsolate())); } -void V8FunctionCall::appendUndefinedArgument() -{ - m_arguments.push_back(v8::Undefined(m_context->GetIsolate())); -} - v8::Local V8FunctionCall::call(bool& hadException, bool reportExceptions) { v8::TryCatch tryCatch(m_context->GetIsolate()); @@ -85,10 +81,6 @@ v8::Local V8FunctionCall::call(bool& hadException, bool reportExcepti v8::Local V8FunctionCall::callWithoutExceptionHandling() { - // TODO(dgozman): get rid of this check. - if (!m_debugger->client()->isExecutionAllowed()) - return v8::Local(); - v8::Local thisObject = v8::Local::Cast(m_value); v8::Local value; if (!thisObject->Get(m_context, m_name).ToLocal(&value)) @@ -103,23 +95,22 @@ v8::Local V8FunctionCall::callWithoutExceptionHandling() DCHECK(!info[i].IsEmpty()); } + int contextGroupId = V8Debugger::getGroupId(m_context); + if (contextGroupId) { + m_inspector->client()->muteMetrics(contextGroupId); + m_inspector->muteExceptions(contextGroupId); + } v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); + v8::MaybeLocal maybeResult = function->Call(m_context, thisObject, m_arguments.size(), info.get()); + if (contextGroupId) { + m_inspector->client()->unmuteMetrics(contextGroupId); + m_inspector->unmuteExceptions(contextGroupId); + } + v8::Local result; - if (!function->Call(m_context, thisObject, m_arguments.size(), info.get()).ToLocal(&result)) + if (!maybeResult.ToLocal(&result)) return v8::Local(); return result; } -v8::Local V8FunctionCall::function() -{ - v8::TryCatch tryCatch(m_context->GetIsolate()); - v8::Local thisObject = v8::Local::Cast(m_value); - v8::Local value; - if (!thisObject->Get(m_context, m_name).ToLocal(&value)) - return v8::Local(); - - DCHECK(value->IsFunction()); - return v8::Local::Cast(value); -} - } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h index 0b9d4e2a5096f1..acb5b5c3417243 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h @@ -37,25 +37,22 @@ namespace blink { -class V8DebuggerImpl; +class V8InspectorImpl; class V8FunctionCall { public: - V8FunctionCall(V8DebuggerImpl*, v8::Local, v8::Local, const String16& name); + V8FunctionCall(V8InspectorImpl*, v8::Local, v8::Local, const String16& name); void appendArgument(v8::Local); void appendArgument(const String16&); void appendArgument(int); void appendArgument(bool); - void appendUndefinedArgument(); v8::Local call(bool& hadException, bool reportExceptions = true); - v8::Local function(); v8::Local callWithoutExceptionHandling(); - v8::Local context() { return m_context; } protected: - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; v8::Local m_context; std::vector> m_arguments; v8::Local m_name; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp index 240dc3d27492e9..d256fe1cc29efa 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp @@ -5,10 +5,11 @@ #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" #include "platform/v8_inspector/InjectedScript.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" #include #include @@ -50,14 +51,10 @@ class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolv const char* GetName(v8::Local object) override { - int contextId = V8DebuggerImpl::contextId(object->CreationContext()); - if (!contextId) + InspectedContext* context = m_session->inspector()->getContext(m_session->contextGroupId(), V8Debugger::contextId(object->CreationContext())); + if (!context) return ""; - ErrorString errorString; - InjectedScript* injectedScript = m_session->findInjectedScript(&errorString, contextId); - if (!injectedScript) - return ""; - String16 name = injectedScript->context()->origin(); + String16 name = context->origin(); size_t length = name.length(); if (m_offset + length + 1 >= m_strings.size()) return ""; @@ -149,7 +146,7 @@ class HeapStatsStream final : public v8::OutputStream { V8HeapProfilerAgentImpl::V8HeapProfilerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) : m_session(session) - , m_isolate(session->debugger()->isolate()) + , m_isolate(session->inspector()->isolate()) , m_frontend(frontendChannel) , m_state(state) , m_hasTimer(false) @@ -253,7 +250,7 @@ void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const return; } - if (!m_session->debugger()->client()->isInspectableHeapObject(heapObject)) { + if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) { *error = "Object is not available"; return; } @@ -279,7 +276,7 @@ void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, c return; } - if (!m_session->debugger()->client()->isInspectableHeapObject(heapObject)) { + if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) { *errorString = "Object is not available"; return; } @@ -290,8 +287,10 @@ void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, c void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const String16& objectId, String16* heapSnapshotObjectId) { v8::HandleScope handles(m_isolate); - v8::Local value = m_session->findObject(errorString, objectId); - if (value.IsEmpty() || value->IsUndefined()) + v8::Local value; + v8::Local context; + String16 objectGroup; + if (!m_session->unwrapObject(errorString, objectId, &value, &context, &objectGroup) || value->IsUndefined()) return; v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); @@ -302,7 +301,7 @@ void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() { HeapStatsStream stream(&m_frontend); v8::SnapshotObjectId lastSeenObjectId = m_isolate->GetHeapProfiler()->GetHeapStats(&stream); - m_frontend.lastSeenObjectId(lastSeenObjectId, m_session->debugger()->client()->currentTimeMS()); + m_frontend.lastSeenObjectId(lastSeenObjectId, m_session->inspector()->client()->currentTimeMS()); } // static @@ -316,14 +315,14 @@ void V8HeapProfilerAgentImpl::startTrackingHeapObjectsInternal(bool trackAllocat m_isolate->GetHeapProfiler()->StartTrackingHeapObjects(trackAllocations); if (!m_hasTimer) { m_hasTimer = true; - m_session->debugger()->client()->startRepeatingTimer(0.05, &V8HeapProfilerAgentImpl::onTimer, reinterpret_cast(this)); + m_session->inspector()->client()->startRepeatingTimer(0.05, &V8HeapProfilerAgentImpl::onTimer, reinterpret_cast(this)); } } void V8HeapProfilerAgentImpl::stopTrackingHeapObjectsInternal() { if (m_hasTimer) { - m_session->debugger()->client()->cancelTimer(reinterpret_cast(this)); + m_session->inspector()->client()->cancelTimer(reinterpret_cast(this)); m_hasTimer = false; } m_isolate->GetHeapProfiler()->StopTrackingHeapObjects(); diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp index afa5138f6ec245..6f9a2a05cecc8f 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp @@ -7,10 +7,11 @@ #include "platform/inspector_protocol/String16.h" #include "platform/v8_inspector/InjectedScriptNative.h" #include "platform/v8_inspector/V8Compat.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InternalValueType.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { @@ -20,38 +21,36 @@ 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, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) + if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, external, 0).ToLocal(&func)) return; func->SetName(funcName); if (!obj->Set(context, funcName, func).FromMaybe(false)) return; } -V8DebuggerImpl* unwrapDebugger(const v8::FunctionCallbackInfo& info) +V8InspectorImpl* unwrapInspector(const v8::FunctionCallbackInfo& info) { DCHECK(!info.Data().IsEmpty()); DCHECK(info.Data()->IsExternal()); - V8DebuggerImpl* debugger = static_cast(info.Data().As()->Value()); - DCHECK(debugger); - return debugger; + V8InspectorImpl* inspector = static_cast(info.Data().As()->Value()); + DCHECK(inspector); + return inspector; } } // namespace -v8::Local V8InjectedScriptHost::create(v8::Local context, V8DebuggerImpl* debugger) +v8::Local V8InjectedScriptHost::create(v8::Local context, V8InspectorImpl* inspector) { - v8::Isolate* isolate = debugger->isolate(); + v8::Isolate* isolate = inspector->isolate(); v8::Local injectedScriptHost = v8::Object::New(isolate); - v8::Local debuggerExternal = v8::External::New(isolate, debugger); + v8::Local debuggerExternal = v8::External::New(isolate, inspector); setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); - setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedScriptHost::isTypedArrayCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScriptHost::subtypeCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); - setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerExternal); + setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", V8InjectedScriptHost::objectHasOwnPropertyCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHost::bindCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8InjectedScriptHost::proxyTargetValueCallback, debuggerExternal); - setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScriptHost::prototypeCallback, debuggerExternal); return injectedScriptHost; } @@ -73,15 +72,7 @@ void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac // Check that function is user-defined. if (info[1].As()->ScriptId() != v8::UnboundScript::kNoScriptId) return; - info.GetReturnValue().Set(unwrapDebugger(info)->client()->formatAccessorsAsProperties(info[0])); -} - -void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo& info) -{ - if (info.Length() < 1) - return; - - info.GetReturnValue().Set(info[0]->IsTypedArray()); + info.GetReturnValue().Set(unwrapInspector(info)->client()->formatAccessorsAsProperties(info[0])); } void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo& info) @@ -98,10 +89,14 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfoIsArray() || value->IsTypedArray() || value->IsArgumentsObject()) { + if (value->IsArray() || value->IsArgumentsObject()) { info.GetReturnValue().Set(toV8StringInternalized(isolate, "array")); return; } + if (value->IsTypedArray()) { + info.GetReturnValue().Set(toV8StringInternalized(isolate, "typedarray")); + return; + } if (value->IsDate()) { info.GetReturnValue().Set(toV8StringInternalized(isolate, "date")); return; @@ -134,7 +129,11 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfoclient()->valueSubtype(value); + if (value->IsPromise()) { + info.GetReturnValue().Set(toV8StringInternalized(isolate, "promise")); + return; + } + String16 subtype = unwrapInspector(info)->client()->valueSubtype(value); if (!subtype.isEmpty()) { info.GetReturnValue().Set(toV8String(isolate, subtype)); return; @@ -146,51 +145,16 @@ void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb if (info.Length() < 1) return; v8::Local properties; - if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentContext(), info[0]).ToLocal(&properties)) + if (unwrapInspector(info)->debugger()->internalProperties(info.GetIsolate()->GetCurrentContext(), info[0]).ToLocal(&properties)) info.GetReturnValue().Set(properties); } -void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo& info) +void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallbackInfo& info) { - if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { - NOTREACHED(); + if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString()) return; - } - if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { - NOTREACHED(); - return; - } - - v8::Isolate* isolate = info.GetIsolate(); - v8::Local context = isolate->GetCurrentContext(); - - v8::Local function = info[0].As(); - v8::Local receiver = info[1]; - std::unique_ptr[]> argv = nullptr; - size_t argc = 0; - - if (info.Length() > 2 && info[2]->IsArray()) { - v8::Local arguments = info[2].As(); - argc = arguments->Length(); - argv.reset(new v8::Local[argc]); - for (size_t i = 0; i < argc; ++i) { - if (!arguments->Get(context, i).ToLocal(&argv[i])) - return; - } - } - - 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); - - if (contextGroupId) - debugger->client()->unmuteWarningsAndDeprecations(contextGroupId); + bool result = info[0].As()->HasOwnProperty(info.GetIsolate()->GetCurrentContext(), v8::Local::Cast(info[1])).FromMaybe(false); + info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result)); } void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo& info) @@ -219,10 +183,4 @@ void V8InjectedScriptHost::proxyTargetValueCallback(const v8::FunctionCallbackIn info.GetReturnValue().Set(target); } -void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo& info) -{ - DCHECK(info.Length() > 0 && info[0]->IsObject()); - info.GetReturnValue().Set(info[0].As()->GetPrototype()); -} - } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h index bf49fa71f40cea..496b5a77f801f0 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h @@ -9,7 +9,7 @@ namespace blink { -class V8DebuggerImpl; +class V8InspectorImpl; // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by the inspector, // a reference to the InjectedScriptHost may be leaked to the page being inspected. Thus, the @@ -19,18 +19,16 @@ class V8DebuggerImpl; class V8InjectedScriptHost { public: // 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*); + // is destroyed before inspector. + static v8::Local create(v8::Local, V8InspectorImpl*); 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 getInternalPropertiesCallback(const v8::FunctionCallbackInfo&); - static void suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo&); + static void objectHasOwnPropertyCallback(const v8::FunctionCallbackInfo&); static void bindCallback(const v8::FunctionCallbackInfo&); static void proxyTargetValueCallback(const v8::FunctionCallbackInfo&); - static void prototypeCallback(const v8::FunctionCallbackInfo&); }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.cpp new file mode 100644 index 00000000000000..caac2020602009 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.cpp @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2010-2011 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: + * + * * 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. + */ + +#include "platform/v8_inspector/V8InspectorImpl.h" + +#include "platform/v8_inspector/InspectedContext.h" +#include "platform/v8_inspector/V8Compat.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8DebuggerAgentImpl.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/V8InspectorClient.h" +#include + +namespace blink { + +std::unique_ptr V8Inspector::create(v8::Isolate* isolate, V8InspectorClient* client) +{ + return wrapUnique(new V8InspectorImpl(isolate, client)); +} + +V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, V8InspectorClient* client) + : m_isolate(isolate) + , m_client(client) + , m_debugger(new V8Debugger(isolate, this)) + , m_capturingStackTracesCount(0) + , m_lastExceptionId(0) +{ +} + +V8InspectorImpl::~V8InspectorImpl() +{ +} + +V8DebuggerAgentImpl* V8InspectorImpl::enabledDebuggerAgentForGroup(int contextGroupId) +{ + V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); + V8DebuggerAgentImpl* agent = session ? session->debuggerAgent() : nullptr; + return agent && agent->enabled() ? agent : nullptr; +} + +V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup(int contextGroupId) +{ + V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); + V8RuntimeAgentImpl* agent = session ? session->runtimeAgent() : nullptr; + return agent && agent->enabled() ? agent : nullptr; +} + +v8::MaybeLocal V8InspectorImpl::runCompiledScript(v8::Local context, v8::Local script) +{ + v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); + int groupId = V8Debugger::getGroupId(context); + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) + agent->willExecuteScript(script->GetUnboundScript()->GetId()); + v8::MaybeLocal result = script->Run(context); + // Get agent from the map again, since it could have detached during script execution. + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) + agent->didExecuteScript(); + return result; +} + +v8::MaybeLocal V8InspectorImpl::callFunction(v8::Local function, v8::Local context, v8::Local receiver, int argc, v8::Local info[]) +{ + v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks); + int groupId = V8Debugger::getGroupId(context); + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) + agent->willExecuteScript(function->ScriptId()); + v8::MaybeLocal result = function->Call(context, receiver, argc, info); + // Get agent from the map again, since it could have detached during script execution. + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) + agent->didExecuteScript(); + return result; +} + +v8::MaybeLocal V8InspectorImpl::compileAndRunInternalScript(v8::Local context, v8::Local source) +{ + v8::Local script = compileScript(context, source, String(), true); + if (script.IsEmpty()) + return v8::MaybeLocal(); + v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); + return script->Run(context); +} + +v8::Local V8InspectorImpl::compileScript(v8::Local context, v8::Local code, const String16& fileName, bool markAsInternal) +{ + v8::ScriptOrigin origin( + toV8String(m_isolate, fileName), + v8::Integer::New(m_isolate, 0), + v8::Integer::New(m_isolate, 0), + v8::False(m_isolate), // sharable + v8::Local(), + v8::Boolean::New(m_isolate, markAsInternal), // internal + toV8String(m_isolate, String16()), // sourceMap + v8::True(m_isolate)); // opaqueresource + v8::ScriptCompiler::Source source(code, origin); + v8::Local script; + if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) + return v8::Local(); + return script; +} + +void V8InspectorImpl::enableStackCapturingIfNeeded() +{ + if (!m_capturingStackTracesCount) + V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, true); + ++m_capturingStackTracesCount; +} + +void V8InspectorImpl::disableStackCapturingIfNeeded() +{ + if (!(--m_capturingStackTracesCount)) + V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, false); +} + +void V8InspectorImpl::muteExceptions(int contextGroupId) +{ + m_muteExceptionsMap[contextGroupId]++; +} + +void V8InspectorImpl::unmuteExceptions(int contextGroupId) +{ + m_muteExceptionsMap[contextGroupId]--; +} + +V8ConsoleMessageStorage* V8InspectorImpl::ensureConsoleMessageStorage(int contextGroupId) +{ + ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); + if (storageIt == m_consoleStorageMap.end()) + storageIt = m_consoleStorageMap.insert(std::make_pair(contextGroupId, wrapUnique(new V8ConsoleMessageStorage(this, contextGroupId)))).first; + return storageIt->second.get(); +} + +std::unique_ptr V8InspectorImpl::createStackTrace(v8::Local stackTrace) +{ + return m_debugger->createStackTrace(stackTrace); +} + +std::unique_ptr V8InspectorImpl::connect(int contextGroupId, protocol::FrontendChannel* channel, const String16* state) +{ + DCHECK(m_sessions.find(contextGroupId) == m_sessions.cend()); + std::unique_ptr session = V8InspectorSessionImpl::create(this, contextGroupId, channel, state); + m_sessions[contextGroupId] = session.get(); + return std::move(session); +} + +void V8InspectorImpl::disconnect(V8InspectorSessionImpl* session) +{ + DCHECK(m_sessions.find(session->contextGroupId()) != m_sessions.end()); + m_sessions.erase(session->contextGroupId()); +} + +InspectedContext* V8InspectorImpl::getContext(int groupId, int contextId) const +{ + if (!groupId || !contextId) + return nullptr; + + 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 V8InspectorImpl::contextCreated(const V8ContextInfo& info) +{ + int contextId = m_debugger->markContext(info); + + 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; + + const auto& contextById = contextIt->second; + + 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 V8InspectorImpl::contextDestroyed(v8::Local context) +{ + int contextId = V8Debugger::contextId(context); + int contextGroupId = V8Debugger::getGroupId(context); + + ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); + if (storageIt != m_consoleStorageMap.end()) + storageIt->second->contextDestroyed(contextId); + + InspectedContext* inspectedContext = getContext(contextGroupId, contextId); + if (!inspectedContext) + return; + + SessionMap::iterator iter = m_sessions.find(contextGroupId); + if (iter != m_sessions.end()) + iter->second->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext); + discardInspectedContext(contextGroupId, contextId); +} + +void V8InspectorImpl::resetContextGroup(int contextGroupId) +{ + m_consoleStorageMap.erase(contextGroupId); + m_muteExceptionsMap.erase(contextGroupId); + SessionMap::iterator session = m_sessions.find(contextGroupId); + if (session != m_sessions.end()) + session->second->reset(); + m_contexts.erase(contextGroupId); +} + +void V8InspectorImpl::willExecuteScript(v8::Local context, int scriptId) +{ + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(V8Debugger::getGroupId(context))) + agent->willExecuteScript(scriptId); +} + +void V8InspectorImpl::didExecuteScript(v8::Local context) +{ + if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(V8Debugger::getGroupId(context))) + agent->didExecuteScript(); +} + +void V8InspectorImpl::idleStarted() +{ + m_isolate->GetCpuProfiler()->SetIdle(true); +} + +void V8InspectorImpl::idleFinished() +{ + m_isolate->GetCpuProfiler()->SetIdle(false); +} + +unsigned V8InspectorImpl::exceptionThrown(v8::Local context, const String16& message, v8::Local exception, const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + int contextGroupId = V8Debugger::getGroupId(context); + if (!contextGroupId || m_muteExceptionsMap[contextGroupId]) + return 0; + std::unique_ptr stackTraceImpl = wrapUnique(static_cast(stackTrace.release())); + unsigned exceptionId = ++m_lastExceptionId; + std::unique_ptr consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), detailedMessage, url, lineNumber, columnNumber, std::move(stackTraceImpl), scriptId, m_isolate, message, V8Debugger::contextId(context), exception, exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); + return exceptionId; +} + +void V8InspectorImpl::exceptionRevoked(v8::Local context, unsigned exceptionId, const String16& message) +{ + int contextGroupId = V8Debugger::getGroupId(context); + if (!contextGroupId) + return; + + std::unique_ptr consoleMessage = V8ConsoleMessage::createForRevokedException(m_client->currentTimeMS(), message, exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); +} + +std::unique_ptr V8InspectorImpl::captureStackTrace(bool fullStack) +{ + return m_debugger->captureStackTrace(fullStack); +} + +void V8InspectorImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) +{ + m_debugger->asyncTaskScheduled(taskName, task, recurring); +} + +void V8InspectorImpl::asyncTaskCanceled(void* task) +{ + m_debugger->asyncTaskCanceled(task); +} + +void V8InspectorImpl::asyncTaskStarted(void* task) +{ + m_debugger->asyncTaskStarted(task); +} + +void V8InspectorImpl::asyncTaskFinished(void* task) +{ + m_debugger->asyncTaskFinished(task); +} + +void V8InspectorImpl::allAsyncTasksCanceled() +{ + m_debugger->allAsyncTasksCanceled(); +} + +v8::Local V8InspectorImpl::regexContext() +{ + if (m_regexContext.IsEmpty()) + m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); + return m_regexContext.Get(m_isolate); +} + +void V8InspectorImpl::discardInspectedContext(int contextGroupId, int contextId) +{ + if (!getContext(contextGroupId, contextId)) + return; + m_contexts[contextGroupId]->erase(contextId); + if (m_contexts[contextGroupId]->empty()) + m_contexts.erase(contextGroupId); +} + +const V8InspectorImpl::ContextByIdMap* V8InspectorImpl::contextGroup(int contextGroupId) +{ + ContextsByGroupMap::iterator iter = m_contexts.find(contextGroupId); + return iter == m_contexts.end() ? nullptr : iter->second.get(); +} + +V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup(int contextGroupId) +{ + 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/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.h new file mode 100644 index 00000000000000..e4dad93d9c6356 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorImpl.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2010, 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: + * + * * 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. + */ + +#ifndef V8InspectorImpl_h +#define V8InspectorImpl_h + +#include "platform/inspector_protocol/Allocator.h" +#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/public/V8Inspector.h" + +#include +#include +#include + +namespace blink { + +class InspectedContext; +class V8ConsoleMessageStorage; +class V8Debugger; +class V8DebuggerAgentImpl; +class V8InspectorSessionImpl; +class V8RuntimeAgentImpl; +class V8StackTraceImpl; + +class V8InspectorImpl : public V8Inspector { + PROTOCOL_DISALLOW_COPY(V8InspectorImpl); +public: + V8InspectorImpl(v8::Isolate*, V8InspectorClient*); + ~V8InspectorImpl() override; + + v8::Isolate* isolate() const { return m_isolate; } + V8InspectorClient* client() { return m_client; } + V8Debugger* debugger() { return m_debugger.get(); } + + v8::MaybeLocal runCompiledScript(v8::Local, v8::Local); + v8::MaybeLocal callFunction(v8::Local, v8::Local, v8::Local receiver, int argc, v8::Local info[]); + v8::MaybeLocal compileAndRunInternalScript(v8::Local, v8::Local); + v8::Local compileScript(v8::Local, v8::Local, const String16& fileName, bool markAsInternal); + v8::Local regexContext(); + + // V8Inspector implementation. + std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, const String16* state) override; + void contextCreated(const V8ContextInfo&) override; + void contextDestroyed(v8::Local) override; + void resetContextGroup(int contextGroupId) override; + void willExecuteScript(v8::Local, int scriptId) override; + void didExecuteScript(v8::Local) override; + void idleStarted() override; + void idleFinished() override; + unsigned exceptionThrown(v8::Local, const String16& message, v8::Local exception, const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) override; + void exceptionRevoked(v8::Local, unsigned exceptionId, const String16& message) override; + std::unique_ptr createStackTrace(v8::Local) 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; + + void enableStackCapturingIfNeeded(); + void disableStackCapturingIfNeeded(); + void muteExceptions(int contextGroupId); + void unmuteExceptions(int contextGroupId); + V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId); + 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; + V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId); + V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId); + +private: + v8::Isolate* m_isolate; + V8InspectorClient* m_client; + std::unique_ptr m_debugger; + v8::Global m_regexContext; + int m_capturingStackTracesCount; + unsigned m_lastExceptionId; + + using MuteExceptionsMap = protocol::HashMap; + MuteExceptionsMap m_muteExceptionsMap; + + using ContextsByGroupMap = protocol::HashMap>; + ContextsByGroupMap m_contexts; + + using SessionMap = protocol::HashMap; + SessionMap m_sessions; + + using ConsoleStorageMap = protocol::HashMap>; + ConsoleStorageMap m_consoleStorageMap; +}; + +} // namespace blink + + +#endif // V8InspectorImpl_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp index 88aac8c894d41a..814b7f91ea52c4 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp @@ -9,33 +9,36 @@ #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" #include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8Debugger.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8ProfilerAgentImpl.h" #include "platform/v8_inspector/V8RuntimeAgentImpl.h" +#include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8ContextInfo.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { -const char V8InspectorSession::backtraceObjectGroup[] = "backtrace"; - // static -bool V8InspectorSession::isV8ProtocolMethod(const String16& method) +bool V8InspectorSession::canDispatchMethod(const String16& method) { - return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.") || method.startWith("Console."); + return method.startWith(protocol::Runtime::Metainfo::commandPrefix) + || method.startWith(protocol::Debugger::Metainfo::commandPrefix) + || method.startWith(protocol::Profiler::Metainfo::commandPrefix) + || method.startWith(protocol::HeapProfiler::Metainfo::commandPrefix) + || method.startWith(protocol::Console::Metainfo::commandPrefix); } -std::unique_ptr V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state) +std::unique_ptr V8InspectorSessionImpl::create(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const String16* state) { - return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, channel, client, state)); + return wrapUnique(new V8InspectorSessionImpl(inspector, contextGroupId, channel, state)); } -V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* savedState) +V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const String16* savedState) : m_contextGroupId(contextGroupId) - , m_debugger(debugger) - , m_client(client) + , m_inspector(inspector) , m_customObjectFormatterEnabled(false) , m_dispatcher(channel) , m_state(nullptr) @@ -89,7 +92,7 @@ V8InspectorSessionImpl::~V8InspectorSessionImpl() m_runtimeAgent->disable(&errorString); discardInjectedScripts(); - m_debugger->disconnect(this); + m_inspector->disconnect(this); } protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& name) @@ -113,7 +116,7 @@ void V8InspectorSessionImpl::reset() void V8InspectorSessionImpl::discardInjectedScripts() { m_inspectedObjects.clear(); - const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); + const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) return; @@ -122,7 +125,7 @@ void V8InspectorSessionImpl::discardInjectedScripts() for (auto& idContext : *contexts) keys.push_back(idContext.first); for (auto& key : keys) { - contexts = m_debugger->contextGroup(m_contextGroupId); + contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) continue; auto contextIt = contexts->find(key); @@ -138,8 +141,13 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr return nullptr; } - const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); - auto contextsIt = contexts ? contexts->find(contextId) : contexts->end(); + const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId); + if (!contexts) { + *errorString = "Cannot find context with specified id"; + return nullptr; + } + + auto contextsIt = contexts->find(contextId); if (contextsIt == contexts->end()) { *errorString = "Cannot find context with specified id"; return nullptr; @@ -165,7 +173,7 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) { - const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); + const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) return; @@ -173,7 +181,7 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) for (auto& idContext : *contexts) keys.push_back(idContext.first); for (auto& key : keys) { - contexts = m_debugger->contextGroup(m_contextGroupId); + contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) continue; auto contextsIt = contexts->find(key); @@ -185,29 +193,30 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) } } -v8::Local V8InspectorSessionImpl::findObject(ErrorString* errorString, const String16& objectId, v8::Local* context, String16* groupName) +bool V8InspectorSessionImpl::unwrapObject(ErrorString* errorString, const String16& objectId, v8::Local* object, v8::Local* context, String16* objectGroup) { std::unique_ptr remoteId = RemoteObjectId::parse(errorString, objectId); if (!remoteId) - return v8::Local(); + return false; InjectedScript* injectedScript = findInjectedScript(errorString, remoteId.get()); if (!injectedScript) - return v8::Local(); - v8::Local objectValue; - injectedScript->findObject(errorString, *remoteId, &objectValue); - if (objectValue.IsEmpty()) - return v8::Local(); - if (context) - *context = injectedScript->context()->context(); - if (groupName) - *groupName = injectedScript->objectGroupName(*remoteId); - return objectValue; + return false; + if (!injectedScript->findObject(errorString, *remoteId, object)) + return false; + *context = injectedScript->context()->context(); + *objectGroup = injectedScript->objectGroupName(*remoteId); + return true; +} + +std::unique_ptr V8InspectorSessionImpl::wrapObject(v8::Local context, v8::Local value, const String16& groupName) +{ + return wrapObject(context, value, groupName, false); } std::unique_ptr V8InspectorSessionImpl::wrapObject(v8::Local context, v8::Local value, const String16& groupName, bool generatePreview) { ErrorString errorString; - InjectedScript* injectedScript = findInjectedScript(&errorString, V8DebuggerImpl::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapObject(&errorString, value, groupName, false, generatePreview); @@ -216,7 +225,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, V8DebuggerImpl::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapTable(table, columns); @@ -225,7 +234,7 @@ std::unique_ptr V8InspectorSessionImpl::wrapTab void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled) { m_customObjectFormatterEnabled = enabled; - const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); + const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) return; for (auto& idContext : *contexts) { @@ -237,7 +246,7 @@ void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled) void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) { - const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); + const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_contextGroupId); if (!contexts) return; for (auto& idContext : *contexts) @@ -268,9 +277,9 @@ V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigne return m_inspectedObjects[num].get(); } -void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) +void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails) { - m_debuggerAgent->schedulePauseOnNextStatement(breakReason, std::move(data)); + m_debuggerAgent->schedulePauseOnNextStatement(breakReason, protocol::DictionaryValue::cast(parseJSON(breakDetails))); } void V8InspectorSessionImpl::cancelPauseOnNextStatement() @@ -278,9 +287,9 @@ void V8InspectorSessionImpl::cancelPauseOnNextStatement() m_debuggerAgent->cancelPauseOnNextStatement(); } -void V8InspectorSessionImpl::breakProgram(const String16& breakReason, std::unique_ptr data) +void V8InspectorSessionImpl::breakProgram(const String16& breakReason, const String16& breakDetails) { - m_debuggerAgent->breakProgram(breakReason, std::move(data)); + m_debuggerAgent->breakProgram(breakReason, protocol::DictionaryValue::cast(parseJSON(breakDetails))); } void V8InspectorSessionImpl::setSkipAllPauses(bool skip) @@ -301,4 +310,13 @@ void V8InspectorSessionImpl::stepOver() m_debuggerAgent->stepOver(&errorString); } +std::unique_ptr> V8InspectorSessionImpl::searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex) +{ + std::vector> matches = searchInTextByLinesImpl(this, text, query, caseSensitive, isRegex); + std::unique_ptr> result = protocol::Array::create(); + for (size_t i = 0; i < matches.size(); ++i) + result->addItem(std::move(matches[i])); + return result; +} + } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h index 21753dac21b98a..d5ee2ef75f8019 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h @@ -11,7 +11,6 @@ #include "platform/inspector_protocol/String16.h" #include "platform/v8_inspector/protocol/Runtime.h" #include "platform/v8_inspector/public/V8InspectorSession.h" -#include "platform/v8_inspector/public/V8InspectorSessionClient.h" #include @@ -23,7 +22,7 @@ class InjectedScript; class RemoteObjectIdBase; class V8ConsoleAgentImpl; class V8DebuggerAgentImpl; -class V8DebuggerImpl; +class V8InspectorImpl; class V8HeapProfilerAgentImpl; class V8ProfilerAgentImpl; class V8RuntimeAgentImpl; @@ -31,11 +30,10 @@ class V8RuntimeAgentImpl; class V8InspectorSessionImpl : public V8InspectorSession { PROTOCOL_DISALLOW_COPY(V8InspectorSessionImpl); public: - static std::unique_ptr create(V8DebuggerImpl*, int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state); + static std::unique_ptr create(V8InspectorImpl*, int contextGroupId, protocol::FrontendChannel*, const String16* state); ~V8InspectorSessionImpl(); - V8DebuggerImpl* debugger() const { return m_debugger; } - V8InspectorSessionClient* client() const { return m_client; } + V8InspectorImpl* inspector() const { return m_inspector; } V8ConsoleAgentImpl* consoleAgent() { return m_consoleAgent.get(); } V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); } V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); } @@ -48,32 +46,33 @@ class V8InspectorSessionImpl : public V8InspectorSession { void discardInjectedScripts(); void reportAllContexts(V8RuntimeAgentImpl*); void setCustomObjectFormatterEnabled(bool); + std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview); + std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns); // V8InspectorSession implementation. void dispatchProtocolMessage(const String16& message) override; String16 stateJSON() override; void addInspectedObject(std::unique_ptr) override; - void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) override; + void schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails) override; void cancelPauseOnNextStatement() override; - void breakProgram(const String16& breakReason, std::unique_ptr data) override; + void breakProgram(const String16& breakReason, const String16& breakDetails) override; void setSkipAllPauses(bool) override; void resume() override; void stepOver() override; + std::unique_ptr> searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex) 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) override; - std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns); + bool unwrapObject(ErrorString*, const String16& objectId, v8::Local*, v8::Local*, String16* objectGroup) override; + std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName) override; V8InspectorSession::Inspectable* inspectedObject(unsigned num); static const unsigned kInspectedObjectBufferSize = 5; private: - V8InspectorSessionImpl(V8DebuggerImpl*, int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state); + V8InspectorSessionImpl(V8InspectorImpl*, int contextGroupId, protocol::FrontendChannel*, const String16* state); protocol::DictionaryValue* agentState(const String16& name); int m_contextGroupId; - V8DebuggerImpl* m_debugger; - V8InspectorSessionClient* m_client; + V8InspectorImpl* m_inspector; bool m_customObjectFormatterEnabled; protocol::UberDispatcher m_dispatcher; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp index 0761f87e0d7a26..57712a9c107439 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp @@ -5,7 +5,7 @@ #include "platform/v8_inspector/V8ProfilerAgentImpl.h" #include "platform/v8_inspector/Atomics.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -13,6 +13,9 @@ #include +#define ENSURE_V8_VERSION(major, minor) \ + (V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= (major) * 1000 + (minor)) + namespace blink { namespace ProfilerAgentState { @@ -102,9 +105,9 @@ std::unique_ptr createCPUProfile(v8::Isolate* is return profile; } -std::unique_ptr currentDebugLocation(V8DebuggerImpl* debugger) +std::unique_ptr currentDebugLocation(V8InspectorImpl* inspector) { - std::unique_ptr callStack = debugger->captureStackTrace(1); + std::unique_ptr callStack = inspector->captureStackTrace(1); std::unique_ptr location = protocol::Debugger::Location::create() .setScriptId(callStack->topScriptId()) .setLineNumber(callStack->topLineNumber()).build(); @@ -127,7 +130,8 @@ class V8ProfilerAgentImpl::ProfileDescriptor { V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) : m_session(session) - , m_isolate(m_session->debugger()->isolate()) + , m_isolate(m_session->inspector()->isolate()) + , m_profiler(nullptr) , m_state(state) , m_frontend(frontendChannel) , m_enabled(false) @@ -137,6 +141,10 @@ V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc V8ProfilerAgentImpl::~V8ProfilerAgentImpl() { +#if ENSURE_V8_VERSION(5, 4) + if (m_profiler) + m_profiler->Dispose(); +#endif } void V8ProfilerAgentImpl::consoleProfile(const String16& title) @@ -146,7 +154,7 @@ void V8ProfilerAgentImpl::consoleProfile(const String16& title) String16 id = nextProfileId(); m_startedProfiles.push_back(ProfileDescriptor(id, title)); startProfiling(id); - m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title); + m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->inspector()), title); } void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) @@ -177,7 +185,7 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) std::unique_ptr profile = stopProfiling(id, true); if (!profile) return; - std::unique_ptr location = currentDebugLocation(m_session->debugger()); + std::unique_ptr location = currentDebugLocation(m_session->inspector()); m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle); } @@ -186,6 +194,10 @@ void V8ProfilerAgentImpl::enable(ErrorString*) if (m_enabled) return; m_enabled = true; +#if ENSURE_V8_VERSION(5, 4) + DCHECK(!m_profiler); + m_profiler = v8::CpuProfiler::New(m_isolate); +#endif m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); } @@ -197,6 +209,10 @@ void V8ProfilerAgentImpl::disable(ErrorString* errorString) stopProfiling(m_startedProfiles[i - 1].m_id, false); m_startedProfiles.clear(); stop(nullptr, nullptr); +#if ENSURE_V8_VERSION(5, 4) + m_profiler->Dispose(); + m_profiler = nullptr; +#endif m_enabled = false; m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); } @@ -208,7 +224,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) return; } m_state->setInteger(ProfilerAgentState::samplingInterval, interval); - m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); + profiler()->SetSamplingInterval(interval); } void V8ProfilerAgentImpl::restore() @@ -217,10 +233,14 @@ void V8ProfilerAgentImpl::restore() if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) return; m_enabled = true; +#if ENSURE_V8_VERSION(5, 4) + DCHECK(!m_profiler); + m_profiler = v8::CpuProfiler::New(m_isolate); +#endif int interval = 0; m_state->getInteger(ProfilerAgentState::samplingInterval, &interval); if (interval) - m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); + profiler()->SetSamplingInterval(interval); if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, false)) { ErrorString error; start(&error); @@ -239,7 +259,6 @@ void V8ProfilerAgentImpl::start(ErrorString* error) m_frontendInitiatedProfileId = nextProfileId(); startProfiling(m_frontendInitiatedProfileId); m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true); - m_session->client()->profilingStarted(); } void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr* profile) @@ -258,7 +277,6 @@ void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptrsetBoolean(ProfilerAgentState::userInitiatedProfiling, false); - m_session->client()->profilingStopped(); } String16 V8ProfilerAgentImpl::nextProfileId() @@ -269,13 +287,13 @@ String16 V8ProfilerAgentImpl::nextProfileId() void V8ProfilerAgentImpl::startProfiling(const String16& title) { v8::HandleScope handleScope(m_isolate); - m_isolate->GetCpuProfiler()->StartProfiling(toV8String(m_isolate, title), true); + profiler()->StartProfiling(toV8String(m_isolate, title), true); } std::unique_ptr V8ProfilerAgentImpl::stopProfiling(const String16& title, bool serialize) { v8::HandleScope handleScope(m_isolate); - v8::CpuProfile* profile = m_isolate->GetCpuProfiler()->StopProfiling(toV8String(m_isolate, title)); + v8::CpuProfile* profile = profiler()->StopProfiling(toV8String(m_isolate, title)); if (!profile) return nullptr; std::unique_ptr result; @@ -290,4 +308,13 @@ bool V8ProfilerAgentImpl::isRecording() const return m_recordingCPUProfile || !m_startedProfiles.empty(); } +v8::CpuProfiler* V8ProfilerAgentImpl::profiler() +{ +#if ENSURE_V8_VERSION(5, 4) + return m_profiler; +#else + return m_isolate->GetCpuProfiler(); +#endif +} + } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h index 03b8f703ae1215..4bbe00be679f9e 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h @@ -12,6 +12,7 @@ #include namespace v8 { +class CpuProfiler; class Isolate; } @@ -39,6 +40,7 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { private: String16 nextProfileId(); + v8::CpuProfiler* profiler(); void startProfiling(const String16& title); std::unique_ptr stopProfiling(const String16& title, bool serialize); @@ -47,6 +49,7 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { V8InspectorSessionImpl* m_session; v8::Isolate* m_isolate; + v8::CpuProfiler* m_profiler; protocol::DictionaryValue* m_state; protocol::Profiler::Frontend m_frontend; bool m_enabled; @@ -58,5 +61,4 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { } // namespace blink - #endif // !defined(V8ProfilerAgentImpl_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp index 304b715f797b51..96cd350d814317 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp @@ -5,20 +5,20 @@ #include "platform/v8_inspector/V8Regex.h" #include "platform/v8_inspector/V8Compat.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" #include namespace blink { -V8Regex::V8Regex(V8DebuggerImpl* debugger, const String16& pattern, bool caseSensitive, bool multiline) - : m_debugger(debugger) +V8Regex::V8Regex(V8InspectorImpl* inspector, const String16& pattern, bool caseSensitive, bool multiline) + : m_inspector(inspector) { - v8::Isolate* isolate = m_debugger->isolate(); + v8::Isolate* isolate = m_inspector->isolate(); v8::HandleScope handleScope(isolate); - v8::Local context = m_debugger->regexContext(); + v8::Local context = m_inspector->regexContext(); v8::Context::Scope contextScope(context); v8::TryCatch tryCatch(isolate); @@ -49,9 +49,9 @@ int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons if (string.length() > INT_MAX) return -1; - v8::Isolate* isolate = m_debugger->isolate(); + v8::Isolate* isolate = m_inspector->isolate(); v8::HandleScope handleScope(isolate); - v8::Local context = m_debugger->regexContext(); + v8::Local context = m_inspector->regexContext(); v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::TryCatch tryCatch(isolate); diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h index 983717d971a0bc..e4900e2d5407be 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h @@ -11,7 +11,7 @@ namespace blink { -class V8DebuggerImpl; +class V8InspectorImpl; enum MultilineMode { MultilineDisabled, @@ -21,13 +21,13 @@ enum MultilineMode { class V8Regex { PROTOCOL_DISALLOW_COPY(V8Regex); public: - V8Regex(V8DebuggerImpl*, const String16&, bool caseSensitive, bool multiline = false); + V8Regex(V8InspectorImpl*, const String16&, bool caseSensitive, bool multiline = false); int match(const String16&, int startFrom = 0, int* matchLength = 0) const; bool isValid() const { return !m_regex.IsEmpty(); } const String16& errorMessage() const { return m_errorMessage; } private: - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; v8::Global m_regex; String16 m_errorMessage; }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp index c9a235ae29e5fd..79d8cc9ce001ab 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp @@ -30,15 +30,20 @@ #include "platform/v8_inspector/V8RuntimeAgentImpl.h" +#include "platform/inspector_protocol/Parser.h" #include "platform/inspector_protocol/Values.h" #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" +#include "platform/v8_inspector/V8Compat.h" #include "platform/v8_inspector/V8ConsoleMessage.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" +#include "platform/v8_inspector/V8DebuggerAgentImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" namespace blink { @@ -57,11 +62,165 @@ static bool hasInternalError(ErrorString* errorString, bool hasError) return hasError; } +namespace { + +template +class ProtocolPromiseHandler { +public: + static void add(V8InspectorImpl* inspector, v8::Local context, v8::MaybeLocal value, const String16& notPromiseError, int contextGroupId, int executionContextId, const String16& objectGroup, bool returnByValue, bool generatePreview, std::unique_ptr callback) + { + if (value.IsEmpty()) { + callback->sendFailure("Internal error"); + return; + } + if (!value.ToLocalChecked()->IsPromise()) { + callback->sendFailure(notPromiseError); + return; + } + v8::Local promise = v8::Local::Cast(value.ToLocalChecked()); + Callback* rawCallback = callback.get(); + ProtocolPromiseHandler* handler = new ProtocolPromiseHandler(inspector, contextGroupId, executionContextId, objectGroup, returnByValue, generatePreview, std::move(callback)); + v8::Local wrapper = handler->m_wrapper.Get(inspector->isolate()); + + v8::Local thenCallbackFunction = V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, thenCallback, wrapper, 0).ToLocalChecked(); + if (promise->Then(context, thenCallbackFunction).IsEmpty()) { + rawCallback->sendFailure("Internal error"); + return; + } + v8::Local catchCallbackFunction = V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, catchCallback, wrapper, 0).ToLocalChecked(); + if (promise->Catch(context, catchCallbackFunction).IsEmpty()) { + rawCallback->sendFailure("Internal error"); + return; + } + } +private: + static void thenCallback(const v8::FunctionCallbackInfo& info) + { + ProtocolPromiseHandler* handler = static_cast*>(info.Data().As()->Value()); + DCHECK(handler); + v8::Local value = info.Length() > 0 ? info[0] : v8::Local::Cast(v8::Undefined(info.GetIsolate())); + handler->m_callback->sendSuccess(handler->wrapObject(value), Maybe(), Maybe()); + } + + static void catchCallback(const v8::FunctionCallbackInfo& info) + { + ProtocolPromiseHandler* handler = static_cast*>(info.Data().As()->Value()); + DCHECK(handler); + v8::Local value = info.Length() > 0 ? info[0] : v8::Local::Cast(v8::Undefined(info.GetIsolate())); + + std::unique_ptr exceptionDetails; + std::unique_ptr stack = handler->m_inspector->debugger()->captureStackTrace(true); + if (stack) { + exceptionDetails = protocol::Runtime::ExceptionDetails::create() + .setText("Promise was rejected") + .setLineNumber(!stack->isEmpty() ? stack->topLineNumber() : 0) + .setColumnNumber(!stack->isEmpty() ? stack->topColumnNumber() : 0) + .setScriptId(!stack->isEmpty() ? stack->topScriptId() : String16()) + .setStackTrace(stack->buildInspectorObjectImpl()) + .build(); + } + handler->m_callback->sendSuccess(handler->wrapObject(value), true, std::move(exceptionDetails)); + } + + ProtocolPromiseHandler(V8InspectorImpl* inspector, int contextGroupId, int executionContextId, const String16& objectGroup, bool returnByValue, bool generatePreview, std::unique_ptr callback) + : m_inspector(inspector) + , m_contextGroupId(contextGroupId) + , m_executionContextId(executionContextId) + , m_objectGroup(objectGroup) + , m_returnByValue(returnByValue) + , m_generatePreview(generatePreview) + , m_callback(std::move(callback)) + , m_wrapper(inspector->isolate(), v8::External::New(inspector->isolate(), this)) + { + m_wrapper.SetWeak(this, cleanup, v8::WeakCallbackType::kParameter); + } + + static void cleanup(const v8::WeakCallbackInfo>& data) + { + if (!data.GetParameter()->m_wrapper.IsEmpty()) { + data.GetParameter()->m_wrapper.Reset(); + data.SetSecondPassCallback(cleanup); + } else { + data.GetParameter()->m_callback->sendFailure("Promise was collected"); + delete data.GetParameter(); + } + } + + std::unique_ptr wrapObject(v8::Local value) + { + ErrorString errorString; + InjectedScript::ContextScope scope(&errorString, m_inspector, m_contextGroupId, m_executionContextId); + if (!scope.initialize()) { + m_callback->sendFailure(errorString); + return nullptr; + } + std::unique_ptr wrappedValue = scope.injectedScript()->wrapObject(&errorString, value, m_objectGroup, m_returnByValue, m_generatePreview); + if (!wrappedValue) { + m_callback->sendFailure(errorString); + return nullptr; + } + return wrappedValue; + } + + V8InspectorImpl* m_inspector; + int m_contextGroupId; + int m_executionContextId; + String16 m_objectGroup; + bool m_returnByValue; + bool m_generatePreview; + std::unique_ptr m_callback; + v8::Global m_wrapper; +}; + +template +bool wrapEvaluateResultAsync(InjectedScript* injectedScript, v8::MaybeLocal maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGroup, bool returnByValue, bool generatePreview, Callback* callback) +{ + std::unique_ptr result; + Maybe wasThrown; + Maybe exceptionDetails; + + ErrorString errorString; + injectedScript->wrapEvaluateResult(&errorString, + maybeResultValue, + tryCatch, + objectGroup, + returnByValue, + generatePreview, + &result, + &wasThrown, + &exceptionDetails); + if (errorString.isEmpty()) { + callback->sendSuccess(std::move(result), wasThrown, exceptionDetails); + return true; + } + callback->sendFailure(errorString); + return false; +} + +int ensureContext(ErrorString* errorString, V8InspectorImpl* inspector, int contextGroupId, const Maybe& executionContextId) +{ + int contextId; + if (executionContextId.isJust()) { + contextId = executionContextId.fromJust(); + } else { + v8::HandleScope handles(inspector->isolate()); + v8::Local defaultContext = inspector->client()->ensureDefaultContextInGroup(contextGroupId); + if (defaultContext.IsEmpty()) { + *errorString = "Cannot find default execution context"; + return 0; + } + contextId = V8Debugger::contextId(defaultContext); + } + return contextId; +} + +} // namespace + V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* FrontendChannel, protocol::DictionaryValue* state) : m_session(session) , m_state(state) , m_frontend(FrontendChannel) - , m_debugger(session->debugger()) + , m_inspector(session->inspector()) , m_enabled(false) { } @@ -71,7 +230,6 @@ V8RuntimeAgentImpl::~V8RuntimeAgentImpl() } void V8RuntimeAgentImpl::evaluate( - ErrorString* errorString, const String16& expression, const Maybe& objectGroup, const Maybe& includeCommandLineAPI, @@ -80,34 +238,31 @@ void V8RuntimeAgentImpl::evaluate( const Maybe& returnByValue, const Maybe& generatePreview, const Maybe& userGesture, - std::unique_ptr* result, - Maybe* wasThrown, - Maybe* exceptionDetails) + const Maybe& awaitPromise, + std::unique_ptr callback) { - int contextId; - if (executionContextId.isJust()) { - contextId = executionContextId.fromJust(); - } else { - 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); + ErrorString errorString; + int contextId = ensureContext(&errorString, m_inspector, m_session->contextGroupId(), executionContextId); + if (!errorString.isEmpty()) { + callback->sendFailure(errorString); + return; } - InjectedScript::ContextScope scope(errorString, m_debugger, m_session->contextGroupId(), contextId); - if (!scope.initialize()) + InjectedScript::ContextScope scope(&errorString, m_inspector, m_session->contextGroupId(), contextId); + if (!scope.initialize()) { + callback->sendFailure(errorString); return; + } if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); if (userGesture.fromMaybe(false)) scope.pretendUserGesture(); - if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()) + if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()) { + callback->sendFailure(errorString); return; + } bool evalIsDisabled = !scope.context()->IsCodeGenerationFromStringsAllowed(); // Temporarily enable allow evals for inspector. @@ -115,28 +270,62 @@ void V8RuntimeAgentImpl::evaluate( scope.context()->AllowCodeGenerationFromStrings(true); v8::MaybeLocal maybeResultValue; - v8::Local script = m_debugger->compileInternalScript(scope.context(), toV8String(m_debugger->isolate(), expression), String16()); + v8::Local script = m_inspector->compileScript(scope.context(), toV8String(m_inspector->isolate(), expression), String16(), false); if (!script.IsEmpty()) - maybeResultValue = m_debugger->runCompiledScript(scope.context(), script); + maybeResultValue = m_inspector->runCompiledScript(scope.context(), script); if (evalIsDisabled) scope.context()->AllowCodeGenerationFromStrings(false); // Re-initialize after running client's code, as it could have destroyed context or session. - if (!scope.initialize()) + if (!scope.initialize()) { + callback->sendFailure(errorString); return; - scope.injectedScript()->wrapEvaluateResult(errorString, + } + + if (!awaitPromise.fromMaybe(false) || scope.tryCatch().HasCaught()) { + wrapEvaluateResultAsync(scope.injectedScript(), maybeResultValue, scope.tryCatch(), objectGroup.fromMaybe(""), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), callback.get()); + return; + } + ProtocolPromiseHandler::add( + m_inspector, + scope.context(), maybeResultValue, - scope.tryCatch(), + "Result of the evaluation is not a promise", + m_session->contextGroupId(), + scope.injectedScript()->context()->contextId(), objectGroup.fromMaybe(""), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), - result, - wasThrown, - exceptionDetails); + std::move(callback)); +} + +void V8RuntimeAgentImpl::awaitPromise( + const String16& promiseObjectId, + const Maybe& returnByValue, + const Maybe& generatePreview, + std::unique_ptr callback) +{ + ErrorString errorString; + InjectedScript::ObjectScope scope(&errorString, m_inspector, m_session->contextGroupId(), promiseObjectId); + if (!scope.initialize()) { + callback->sendFailure(errorString); + return; + } + ProtocolPromiseHandler::add( + m_inspector, + scope.context(), + scope.object(), + "Could not find promise with given id", + m_session->contextGroupId(), + scope.injectedScript()->context()->contextId(), + scope.objectGroupName(), + returnByValue.fromMaybe(false), + generatePreview.fromMaybe(false), + std::move(callback)); } -void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, +void V8RuntimeAgentImpl::callFunctionOn( const String16& objectId, const String16& expression, const Maybe>& optionalArguments, @@ -144,12 +333,15 @@ void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, const Maybe& returnByValue, const Maybe& generatePreview, const Maybe& userGesture, - std::unique_ptr* result, - Maybe* wasThrown) + const Maybe& awaitPromise, + std::unique_ptr callback) { - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); - if (!scope.initialize()) + ErrorString errorString; + InjectedScript::ObjectScope scope(&errorString, m_inspector, m_session->contextGroupId(), objectId); + if (!scope.initialize()) { + callback->sendFailure(errorString); return; + } std::unique_ptr[]> argv = nullptr; int argc = 0; @@ -159,8 +351,10 @@ void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, argv.reset(new v8::Local[argc]); for (int i = 0; i < argc; ++i) { v8::Local argumentValue; - if (!scope.injectedScript()->resolveCallArgument(errorString, arguments->get(i)).ToLocal(&argumentValue)) + if (!scope.injectedScript()->resolveCallArgument(&errorString, arguments->get(i)).ToLocal(&argumentValue)) { + callback->sendFailure(errorString); return; + } argv[i] = argumentValue; } } @@ -170,28 +364,47 @@ void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, if (userGesture.fromMaybe(false)) scope.pretendUserGesture(); - v8::MaybeLocal maybeFunctionValue = m_debugger->compileAndRunInternalScript(scope.context(), toV8String(m_debugger->isolate(), "(" + expression + ")")); + v8::MaybeLocal maybeFunctionValue = m_inspector->compileAndRunInternalScript(scope.context(), toV8String(m_inspector->isolate(), "(" + expression + ")")); // Re-initialize after running client's code, as it could have destroyed context or session. - if (!scope.initialize()) + if (!scope.initialize()) { + callback->sendFailure(errorString); return; + } if (scope.tryCatch().HasCaught()) { - scope.injectedScript()->wrapEvaluateResult(errorString, maybeFunctionValue, scope.tryCatch(), scope.objectGroupName(), false, false, result, wasThrown, nullptr); + wrapEvaluateResultAsync(scope.injectedScript(), maybeFunctionValue, scope.tryCatch(), scope.objectGroupName(), false, false, callback.get()); return; } v8::Local functionValue; if (!maybeFunctionValue.ToLocal(&functionValue) || !functionValue->IsFunction()) { - *errorString = "Given expression does not evaluate to a function"; + callback->sendFailure("Given expression does not evaluate to a function"); return; } - v8::MaybeLocal maybeResultValue = m_debugger->callFunction(functionValue.As(), scope.context(), scope.object(), argc, argv.get()); + v8::MaybeLocal maybeResultValue = m_inspector->callFunction(functionValue.As(), scope.context(), scope.object(), argc, argv.get()); // Re-initialize after running client's code, as it could have destroyed context or session. - if (!scope.initialize()) + if (!scope.initialize()) { + callback->sendFailure(errorString); + return; + } + + if (!awaitPromise.fromMaybe(false) || scope.tryCatch().HasCaught()) { + wrapEvaluateResultAsync(scope.injectedScript(), maybeResultValue, scope.tryCatch(), scope.objectGroupName(), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), callback.get()); return; + } - scope.injectedScript()->wrapEvaluateResult(errorString, maybeResultValue, scope.tryCatch(), scope.objectGroupName(), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown, nullptr); + ProtocolPromiseHandler::add( + m_inspector, + scope.context(), + maybeResultValue, + "Result of the function call is not a promise", + m_session->contextGroupId(), + scope.injectedScript()->context()->contextId(), + scope.objectGroupName(), + returnByValue.fromMaybe(false), + generatePreview.fromMaybe(false), + std::move(callback)); } void V8RuntimeAgentImpl::getProperties( @@ -206,7 +419,7 @@ void V8RuntimeAgentImpl::getProperties( { using protocol::Runtime::InternalPropertyDescriptor; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); + InjectedScript::ObjectScope scope(errorString, m_inspector, m_session->contextGroupId(), objectId); if (!scope.initialize()) return; @@ -221,7 +434,7 @@ void V8RuntimeAgentImpl::getProperties( if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropertiesOnly.fromMaybe(false)) return; v8::Local propertiesArray; - if (hasInternalError(errorString, !m_debugger->internalProperties(scope.context(), scope.object()).ToLocal(&propertiesArray))) + if (hasInternalError(errorString, !m_inspector->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) { @@ -245,7 +458,7 @@ void V8RuntimeAgentImpl::getProperties( void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String16& objectId) { - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); + InjectedScript::ObjectScope scope(errorString, m_inspector, m_session->contextGroupId(), objectId); if (!scope.initialize()) return; scope.injectedScript()->releaseObject(objectId); @@ -258,7 +471,7 @@ void V8RuntimeAgentImpl::releaseObjectGroup(ErrorString*, const String16& object void V8RuntimeAgentImpl::run(ErrorString* errorString) { - m_session->client()->resumeStartup(); + m_inspector->client()->resumeStartup(m_session->contextGroupId()); } void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enabled) @@ -269,7 +482,7 @@ void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enab void V8RuntimeAgentImpl::discardConsoleEntries(ErrorString*) { - V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + V8ConsoleMessageStorage* storage = m_inspector->ensureConsoleMessageStorage(m_session->contextGroupId()); storage->clear(); } @@ -277,7 +490,7 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, const String16& expression, const String16& sourceURL, bool persistScript, - int executionContextId, + const Maybe& executionContextId, Maybe* scriptId, Maybe* exceptionDetails) { @@ -285,11 +498,18 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, *errorString = "Runtime agent is not enabled"; return; } - InjectedScript::ContextScope scope(errorString, m_debugger, m_session->contextGroupId(), executionContextId); + int contextId = ensureContext(errorString, m_inspector, m_session->contextGroupId(), executionContextId); + if (!errorString->isEmpty()) + return; + InjectedScript::ContextScope scope(errorString, m_inspector, m_session->contextGroupId(), contextId); if (!scope.initialize()) return; - v8::Local script = m_debugger->compileInternalScript(scope.context(), toV8String(m_debugger->isolate(), expression), sourceURL); + if (!persistScript) + m_inspector->debugger()->muteScriptParsedEvents(); + v8::Local script = m_inspector->compileScript(scope.context(), toV8String(m_inspector->isolate(), expression), sourceURL, false); + if (!persistScript) + m_inspector->debugger()->unmuteScriptParsedEvents(); if (script.IsEmpty()) { v8::Local message = scope.tryCatch().Message(); if (!message.IsEmpty()) @@ -303,55 +523,81 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, return; String16 scriptValueId = String16::fromInteger(script->GetUnboundScript()->GetId()); - std::unique_ptr> global(new v8::Global(m_debugger->isolate(), script)); + std::unique_ptr> global(new v8::Global(m_inspector->isolate(), script)); m_compiledScripts[scriptValueId] = std::move(global); *scriptId = scriptValueId; } -void V8RuntimeAgentImpl::runScript(ErrorString* errorString, +void V8RuntimeAgentImpl::runScript( const String16& scriptId, - int executionContextId, + const Maybe& executionContextId, const Maybe& objectGroup, const Maybe& doNotPauseOnExceptionsAndMuteConsole, const Maybe& includeCommandLineAPI, - std::unique_ptr* result, - Maybe* exceptionDetails) + const Maybe& returnByValue, + const Maybe& generatePreview, + const Maybe& awaitPromise, + std::unique_ptr callback) { if (!m_enabled) { - *errorString = "Runtime agent is not enabled"; + callback->sendFailure("Runtime agent is not enabled"); return; } auto it = m_compiledScripts.find(scriptId); if (it == m_compiledScripts.end()) { - *errorString = "Script execution failed"; + callback->sendFailure("No script with given id"); return; } - InjectedScript::ContextScope scope(errorString, m_debugger, m_session->contextGroupId(), executionContextId); - if (!scope.initialize()) + ErrorString errorString; + int contextId = ensureContext(&errorString, m_inspector, m_session->contextGroupId(), executionContextId); + if (!errorString.isEmpty()) { + callback->sendFailure(errorString); return; + } + + InjectedScript::ContextScope scope(&errorString, m_inspector, m_session->contextGroupId(), contextId); + if (!scope.initialize()) { + callback->sendFailure(errorString); + return; + } if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); std::unique_ptr> scriptWrapper = std::move(it->second); m_compiledScripts.erase(it); - v8::Local script = scriptWrapper->Get(m_debugger->isolate()); + v8::Local script = scriptWrapper->Get(m_inspector->isolate()); if (script.IsEmpty()) { - *errorString = "Script execution failed"; + callback->sendFailure("Script execution failed"); return; } if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()) return; - v8::MaybeLocal maybeResultValue = m_debugger->runCompiledScript(scope.context(), script); + v8::MaybeLocal maybeResultValue = m_inspector->runCompiledScript(scope.context(), script); // Re-initialize after running client's code, as it could have destroyed context or session. if (!scope.initialize()) return; - scope.injectedScript()->wrapEvaluateResult(errorString, maybeResultValue, scope.tryCatch(), objectGroup.fromMaybe(""), false, false, result, nullptr, exceptionDetails); + + if (!awaitPromise.fromMaybe(false) || scope.tryCatch().HasCaught()) { + wrapEvaluateResultAsync(scope.injectedScript(), maybeResultValue, scope.tryCatch(), objectGroup.fromMaybe(""), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), callback.get()); + return; + } + ProtocolPromiseHandler::add( + m_inspector, + scope.context(), + maybeResultValue.ToLocalChecked(), + "Result of the script execution is not a promise", + m_session->contextGroupId(), + scope.injectedScript()->context()->contextId(), + objectGroup.fromMaybe(""), + returnByValue.fromMaybe(false), + generatePreview.fromMaybe(false), + std::move(callback)); } void V8RuntimeAgentImpl::restore() @@ -369,12 +615,12 @@ void V8RuntimeAgentImpl::enable(ErrorString* errorString) { if (m_enabled) return; - m_session->client()->runtimeEnabled(); + m_inspector->client()->beginEnsureAllContextsInGroup(m_session->contextGroupId()); m_enabled = true; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, true); - m_session->debugger()->enableStackCapturingIfNeeded(); + m_inspector->enableStackCapturingIfNeeded(); m_session->reportAllContexts(this); - V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + V8ConsoleMessageStorage* storage = m_inspector->ensureConsoleMessageStorage(m_session->contextGroupId()); for (const auto& message : storage->messages()) reportMessage(message.get(), false); } @@ -385,17 +631,17 @@ void V8RuntimeAgentImpl::disable(ErrorString* errorString) return; m_enabled = false; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); - m_session->debugger()->disableStackCapturingIfNeeded(); + m_inspector->disableStackCapturingIfNeeded(); m_session->discardInjectedScripts(); reset(); - m_session->client()->runtimeDisabled(); + m_inspector->client()->endEnsureAllContextsInGroup(m_session->contextGroupId()); } void V8RuntimeAgentImpl::reset() { m_compiledScripts.clear(); if (m_enabled) { - if (const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_session->contextGroupId())) { + if (const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup(m_session->contextGroupId())) { for (auto& idContext : *contexts) idContext.second->setReported(false); } @@ -410,10 +656,10 @@ void V8RuntimeAgentImpl::reportExecutionContextCreated(InspectedContext* context context->setReported(true); std::unique_ptr description = protocol::Runtime::ExecutionContextDescription::create() .setId(context->contextId()) - .setIsDefault(context->isDefault()) .setName(context->humanReadableName()) - .setOrigin(context->origin()) - .setFrameId(context->frameId()).build(); + .setOrigin(context->origin()).build(); + if (!context->auxData().isEmpty()) + description->setAuxData(protocol::DictionaryValue::cast(parseJSON(context->auxData()))); m_frontend.executionContextCreated(std::move(description)); } diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h index 7b33379a0c29c0..8594ce8e2d52af 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h @@ -43,7 +43,7 @@ class InjectedScript; class InspectedContext; class RemoteObjectIdBase; class V8ConsoleMessage; -class V8DebuggerImpl; +class V8InspectorImpl; class V8InspectorSessionImpl; namespace protocol { @@ -62,7 +62,7 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { // Part of the protocol. void enable(ErrorString*) override; void disable(ErrorString*) override; - void evaluate(ErrorString*, + void evaluate( const String16& expression, const Maybe& objectGroup, const Maybe& includeCommandLineAPI, @@ -71,10 +71,14 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { const Maybe& returnByValue, const Maybe& generatePreview, const Maybe& userGesture, - std::unique_ptr* result, - Maybe* wasThrown, - Maybe*) override; - void callFunctionOn(ErrorString*, + const Maybe& awaitPromise, + std::unique_ptr) override; + void awaitPromise( + const String16& promiseObjectId, + const Maybe& returnByValue, + const Maybe& generatePreview, + std::unique_ptr) override; + void callFunctionOn( const String16& objectId, const String16& expression, const Maybe>& optionalArguments, @@ -82,8 +86,8 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { const Maybe& returnByValue, const Maybe& generatePreview, const Maybe& userGesture, - std::unique_ptr* result, - Maybe* wasThrown) override; + const Maybe& awaitPromise, + std::unique_ptr) override; void releaseObject(ErrorString*, const String16& objectId) override; void getProperties(ErrorString*, const String16& objectId, @@ -101,17 +105,19 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { const String16& expression, const String16& sourceURL, bool persistScript, - int executionContextId, + const Maybe& executionContextId, Maybe*, Maybe*) override; - void runScript(ErrorString*, + void runScript( const String16&, - int executionContextId, + const Maybe& executionContextId, const Maybe& objectGroup, const Maybe& doNotPauseOnExceptionsAndMuteConsole, const Maybe& includeCommandLineAPI, - std::unique_ptr* result, - Maybe*) override; + const Maybe& returnByValue, + const Maybe& generatePreview, + const Maybe& awaitPromise, + std::unique_ptr) override; void reset(); void reportExecutionContextCreated(InspectedContext*); @@ -126,7 +132,7 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { V8InspectorSessionImpl* m_session; protocol::DictionaryValue* m_state; protocol::Runtime::Frontend m_frontend; - V8DebuggerImpl* m_debugger; + V8InspectorImpl* m_inspector; bool m_enabled; protocol::HashMap>> m_compiledScripts; }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp index 343234c02278cc..0a8e6e1e489336 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp @@ -6,7 +6,7 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8Debugger.h" #include "platform/v8_inspector/V8StringUtil.h" #include @@ -93,7 +93,7 @@ std::unique_ptr V8StackTraceImpl::Frame::buildInsp .build(); } -V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const +V8StackTraceImpl::Frame V8StackTraceImpl::Frame::clone() const { return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scriptName.isolatedCopy(), m_lineNumber, m_columnNumber); } @@ -105,7 +105,7 @@ void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(v8::Isolate* is } // static -std::unique_ptr V8StackTraceImpl::create(V8DebuggerImpl* debugger, int contextGroupId, v8::Local stackTrace, size_t maxStackSize, const String16& description) +std::unique_ptr V8StackTraceImpl::create(V8Debugger* debugger, int contextGroupId, v8::Local stackTrace, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); @@ -147,7 +147,7 @@ std::unique_ptr V8StackTraceImpl::create(V8DebuggerImpl* debug return result; } -std::unique_ptr V8StackTraceImpl::capture(V8DebuggerImpl* debugger, int contextGroupId, size_t maxStackSize, const String16& description) +std::unique_ptr V8StackTraceImpl::capture(V8Debugger* debugger, int contextGroupId, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); @@ -161,28 +161,18 @@ std::unique_ptr V8StackTraceImpl::capture(V8DebuggerImpl* debu return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, maxStackSize, description); } -std::unique_ptr V8StackTraceImpl::clone() -{ - return cloneImpl(); -} - std::unique_ptr V8StackTraceImpl::cloneImpl() { 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() -{ - return isolatedCopyImpl(); -} - -std::unique_ptr V8StackTraceImpl::isolatedCopyImpl() +std::unique_ptr V8StackTraceImpl::clone() { std::vector frames; for (size_t i = 0; i < m_frames.size(); i++) - frames.push_back(m_frames.at(i).isolatedCopy()); - return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); + frames.push_back(m_frames.at(i).clone()); + return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isolatedCopy(), frames, nullptr)); } V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, const String16& description, std::vector& frames, std::unique_ptr parent) @@ -227,7 +217,7 @@ String16 V8StackTraceImpl::topScriptId() const return m_frames[0].m_scriptId; } -std::unique_ptr V8StackTraceImpl::buildInspectorObject() const +std::unique_ptr V8StackTraceImpl::buildInspectorObjectImpl() const { std::unique_ptr> frames = protocol::Array::create(); for (size_t i = 0; i < m_frames.size(); i++) @@ -238,18 +228,23 @@ std::unique_ptr V8StackTraceImpl::buildInspectorO if (!m_description.isEmpty()) stackTrace->setDescription(m_description); if (m_parent) - stackTrace->setParent(m_parent->buildInspectorObject()); + stackTrace->setParent(m_parent->buildInspectorObjectImpl()); return stackTrace; } -std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8DebuggerImpl* debugger) const +std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8Debugger* debugger) const { v8::HandleScope handleScope(v8::Isolate::GetCurrent()); // Next call collapses possible empty stack and ensures maxAsyncCallChainDepth. 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(); + return fullChain->m_parent->buildInspectorObjectImpl(); +} + +std::unique_ptr V8StackTraceImpl::buildInspectorObject() const +{ + return buildInspectorObjectImpl(); } String16 V8StackTraceImpl::toString() const diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h index 63b59e8d9009b3..9d9a4892f1d2a7 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h @@ -5,7 +5,9 @@ #ifndef V8StackTraceImpl_h #define V8StackTraceImpl_h +#include "platform/inspector_protocol/Allocator.h" #include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/protocol/Runtime.h" #include "platform/v8_inspector/public/V8StackTrace.h" #include @@ -13,7 +15,7 @@ namespace blink { class TracedValue; -class V8DebuggerImpl; +class V8Debugger; // Note: async stack trace may have empty top stack with non-empty tail to indicate // that current native-only state had some async story. @@ -34,7 +36,7 @@ class V8StackTraceImpl final : public V8StackTrace { const String16& sourceURL() const { return m_scriptName; } int lineNumber() const { return m_lineNumber; } int columnNumber() const { return m_columnNumber; } - Frame isolatedCopy() const; + Frame clone() const; private: friend class V8StackTraceImpl; @@ -49,14 +51,14 @@ class V8StackTraceImpl final : public V8StackTrace { }; 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()); + static std::unique_ptr create(V8Debugger*, int contextGroupId, v8::Local, size_t maxStackSize, const String16& description = String16()); + static std::unique_ptr capture(V8Debugger*, int contextGroupId, size_t maxStackSize, const String16& description = String16()); + // This method drops the async chain. Use cloneImpl() instead. std::unique_ptr clone() override; std::unique_ptr cloneImpl(); - std::unique_ptr isolatedCopy() override; - std::unique_ptr isolatedCopyImpl(); - std::unique_ptr buildInspectorObjectForTail(V8DebuggerImpl*) const; + std::unique_ptr buildInspectorObjectForTail(V8Debugger*) const; + std::unique_ptr buildInspectorObjectImpl() const; ~V8StackTraceImpl() override; // V8StackTrace implementation. @@ -66,7 +68,7 @@ class V8StackTraceImpl final : public V8StackTrace { int topColumnNumber() const override; String16 topScriptId() const override; String16 topFunctionName() const override; - std::unique_ptr buildInspectorObject() const override; + std::unique_ptr buildInspectorObject() const override; String16 toString() const override; private: diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp index 4ba7898bc58162..037d91036cfde8 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp @@ -5,10 +5,9 @@ #include "platform/v8_inspector/V8StringUtil.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8Regex.h" -#include "platform/v8_inspector/public/V8ContentSearchUtil.h" namespace blink { @@ -144,10 +143,10 @@ std::unique_ptr buildObjectForSearchMatch(int l .build(); } -std::unique_ptr createSearchRegex(V8DebuggerImpl* debugger, const String16& query, bool caseSensitive, bool isRegex) +std::unique_ptr createSearchRegex(V8InspectorImpl* inspector, const String16& query, bool caseSensitive, bool isRegex) { String16 regexSource = isRegex ? query : createSearchRegexSource(query); - return wrapUnique(new V8Regex(debugger, regexSource, caseSensitive)); + return wrapUnique(new V8Regex(inspector, regexSource, caseSensitive)); } } // namespace @@ -166,6 +165,11 @@ v8::Local toV8StringInternalized(v8::Isolate* isolate, const String1 return v8::String::NewFromTwoByte(isolate, reinterpret_cast(string.characters16()), v8::NewStringType::kInternalized, string.length()).ToLocalChecked(); } +v8::Local toV8StringInternalized(v8::Isolate* isolate, const char* str) +{ + return v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInternalized).ToLocalChecked(); +} + String16 toProtocolString(v8::Local value) { if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) @@ -182,7 +186,16 @@ String16 toProtocolStringWithTypeCheck(v8::Local value) return toProtocolString(value.As()); } -namespace V8ContentSearchUtil { +std::vector> searchInTextByLinesImpl(V8InspectorSession* session, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex) +{ + std::unique_ptr regex = createSearchRegex(static_cast(session)->inspector(), query, caseSensitive, isRegex); + std::vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); + + std::vector> result; + for (const auto& match : matches) + result.push_back(buildObjectForSearchMatch(match.first, match.second)); + return result; +} String16 findSourceURL(const String16& content, bool multiline, bool* deprecated) { @@ -194,20 +207,6 @@ String16 findSourceMapURL(const String16& content, bool multiline, bool* depreca return findMagicComment(content, "sourceMappingURL", multiline, deprecated); } -std::unique_ptr> searchInTextByLines(V8InspectorSession* session, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex) -{ - std::unique_ptr> result = protocol::Array::create(); - std::unique_ptr regex = createSearchRegex(static_cast(session)->debugger(), query, caseSensitive, isRegex); - std::vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); - - for (const auto& match : matches) - result->addItem(buildObjectForSearchMatch(match.first, match.second)); - - return result; -} - -} // namespace V8ContentSearchUtil - std::unique_ptr toProtocolValue(v8::Local context, v8::Local value, int maxDepth) { if (value.IsEmpty()) { diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h index 2d42613d41614d..029ed5661a9e29 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h @@ -7,18 +7,26 @@ #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/Values.h" +#include "platform/v8_inspector/protocol/Debugger.h" #include namespace blink { +class V8InspectorSession; + 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&); +v8::Local toV8StringInternalized(v8::Isolate*, const char*); String16 toProtocolString(v8::Local); String16 toProtocolStringWithTypeCheck(v8::Local); +String16 findSourceURL(const String16& content, bool multiline, bool* deprecated = nullptr); +String16 findSourceMapURL(const String16& content, bool multiline, bool* deprecated = nullptr); +std::vector> searchInTextByLinesImpl(V8InspectorSession*, const String16& text, const String16& query, bool caseSensitive, bool isRegex); + } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js index cf2a0457c4c1b3..dddc709a57a471 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js @@ -29,7 +29,7 @@ var RawLocation; startColumn: number, endColumn: number, executionContextId: number, - isContentScript: boolean, + executionContextAuxData: string, isInternalScript: boolean }} */ var FormattedScript; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js index 5fba025caab2b8..03455614f32f1f 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js @@ -39,12 +39,11 @@ InjectedScriptHostClass.prototype.isTypedArray = function(obj) {} InjectedScriptHostClass.prototype.getInternalProperties = function(obj) {} /** - * @param {!Function} fn - * @param {*} receiver - * @param {!Array.<*>=} argv - * @return {*} + * @param {!Object} object + * @param {string} propertyName + * @return {boolean} */ -InjectedScriptHostClass.prototype.suppressWarningsAndCallFunction = function(fn, receiver, argv) {} +InjectedScriptHostClass.prototype.objectHasOwnProperty = function(object, propertyName) {} /** * @param {*} value @@ -59,12 +58,6 @@ InjectedScriptHostClass.prototype.bind = function(value, groupName) {} */ InjectedScriptHostClass.prototype.proxyTargetValue = function(object) {} -/** - * @param {!Object} object - * @return {Object|undefined} - */ -InjectedScriptHostClass.prototype.prototype = function(object) {} - /** @type {!InjectedScriptHostClass} */ var InjectedScriptHost; /** @type {!Window} */ diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json index 78548bc8402aeb..161cdb89e17f8c 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json @@ -14,25 +14,33 @@ "type": "string", "description": "Unique object identifier." }, + { + "id": "UnserializableValue", + "type": "string", + "enum": ["Infinity", "NaN", "-Infinity", "-0"], + "description": "Primitive value which cannot be JSON-stringified." + }, { "id": "RemoteObject", "type": "object", "description": "Mirror object referencing original JavaScript object.", + "exported": true, "properties": [ { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, - { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for object type values only." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error", "proxy", "promise", "typedarray"], "description": "Object subtype hint. Specified for object type values only." }, { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for object type values only." }, - { "name": "value", "type": "any", "optional": true, "description": "Remote object value in case of primitive values or JSON values (if it was requested), or description string if the value can not be JSON-stringified (like NaN, Infinity, -Infinity, -0)." }, + { "name": "value", "type": "any", "optional": true, "description": "Remote object value in case of primitive values or JSON values (if it was requested)." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "experimental": true, "description": "Primitive value which can not be JSON-stringified does not have value, but gets this property." }, { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." }, { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." }, - { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for object type values only.", "hidden": true }, - { "name": "customPreview", "$ref": "CustomPreview", "optional": true, "hidden": true} + { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for object type values only.", "experimental": true }, + { "name": "customPreview", "$ref": "CustomPreview", "optional": true, "experimental": true} ] }, { "id": "CustomPreview", "type": "object", - "hidden": true, + "experimental": true, "properties": [ { "name": "header", "type": "string"}, { "name": "hasBody", "type": "boolean"}, @@ -44,7 +52,7 @@ { "id": "ObjectPreview", "type": "object", - "hidden": true, + "experimental": true, "description": "Object containing abbreviated remote object value.", "properties": [ { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, @@ -58,7 +66,7 @@ { "id": "PropertyPreview", "type": "object", - "hidden": true, + "experimental": true, "properties": [ { "name": "name", "type": "string", "description": "Property name." }, { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type. Accessor means that the property itself is an accessor property." }, @@ -70,7 +78,7 @@ { "id": "EntryPreview", "type": "object", - "hidden": true, + "experimental": true, "properties": [ { "name": "key", "$ref": "ObjectPreview", "optional": true, "description": "Preview of the key. Specified for map-like collection entries." }, { "name": "value", "$ref": "ObjectPreview", "description": "Preview of the value." } @@ -89,8 +97,8 @@ { "name": "configurable", "type": "boolean", "description": "True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object." }, { "name": "enumerable", "type": "boolean", "description": "True if this property shows up during enumeration of the properties on the corresponding object." }, { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, - { "name": "isOwn", "optional": true, "type": "boolean", "description": "True if the property is owned for the object.", "hidden": true }, - { "name": "symbol", "$ref": "RemoteObject", "optional": true, "description": "Property symbol object, if the property is of the symbol type.", "hidden": true } + { "name": "isOwn", "optional": true, "type": "boolean", "description": "True if the property is owned for the object.", "experimental": true }, + { "name": "symbol", "$ref": "RemoteObject", "optional": true, "description": "Property symbol object, if the property is of the symbol type.", "experimental": true } ] }, { @@ -101,16 +109,16 @@ { "name": "name", "type": "string", "description": "Conventional property name." }, { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." } ], - "hidden": true + "experimental": true }, { "id": "CallArgument", "type": "object", - "description": "Represents function call argument. Either remote object id objectId or primitive value or neither of (for undefined) them should be specified.", + "description": "Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified.", "properties": [ - { "name": "value", "type": "any", "optional": true, "description": "Primitive value, or description string if the value can not be JSON-stringified (like NaN, Infinity, -Infinity, -0)." }, - { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." }, - { "name": "type", "optional": true, "hidden": true, "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." } + { "name": "value", "type": "any", "optional": true, "description": "Primitive value." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "experimental": true, "description": "Primitive value which can not be JSON-stringified." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." } ] }, { @@ -124,16 +132,15 @@ "description": "Description of an isolated world.", "properties": [ { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." }, - { "name": "isDefault", "type": "boolean", "description": "Whether context is the default page context (as opposite to e.g. context of content script).", "hidden": true }, - { "name": "origin", "type": "string", "description": "Execution context origin.", "hidden": true}, - { "name": "name", "type": "string", "description": "Human readable name describing given context.", "hidden": true}, - { "name": "frameId", "type": "string", "description": "Id of the owning frame. May be an empty string if the context is not associated with a frame." } + { "name": "origin", "type": "string", "description": "Execution context origin.", "experimental": true }, + { "name": "name", "type": "string", "description": "Human readable name describing given context.", "experimental": true }, + { "name": "auxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data.", "experimental": true } ] }, { "id": "ExceptionDetails", "type": "object", - "hidden": true, + "experimental": true, "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.", "properties": [ { "name": "text", "type": "string", "description": "Exception text." }, @@ -148,7 +155,7 @@ "id": "Timestamp", "type": "number", "description": "Number of milliseconds since epoch.", - "hidden": true + "experimental": true }, { "id": "CallFrame", @@ -166,47 +173,69 @@ "id": "StackTrace", "type": "object", "description": "Call frames for assertions or error messages.", + "exported": true, "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, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } + { "name": "parent", "$ref": "StackTrace", "optional": true, "experimental": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } ] } ], "commands": [ { "name": "evaluate", + "async": true, "parameters": [ { "name": "expression", "type": "string", "description": "Expression to evaluate." }, { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, - { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation.", "hidden": true }, - { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true }, - { "name": "contextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which isolated context to perform evaluation. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation.", "experimental": true }, + { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "experimental": true }, + { "name": "contextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, - { "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." }, - { "name": "userGesture", "type": "boolean", "optional": true, "hidden": true, "description": "Whether execution should be treated as initiated by user in the UI." } + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "experimental": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "experimental": true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } ], "returns": [ { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }, { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, - { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."} + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "experimental": true, "description": "Exception details."} ], "description": "Evaluates expression on global object." }, + { + "name": "awaitPromise", + "experimental": true, + "async": true, + "parameters": [ + { "name": "promiseObjectId", "$ref": "RemoteObjectId", "description": "Identifier of the promise." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Promise result. Will contain rejected value if promise was rejected." }, + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the promise was rejected." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details if stack strace is available."} + ], + "description": "Add handler to promise with given promise object id." + }, { "name": "callFunctionOn", + "async": true, "parameters": [ { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to call function on." }, { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." }, { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object." }, - { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether function call should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true }, + { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether function call should stop on exceptions and mute console. Overrides setPauseOnException state.", "experimental": true }, { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, - { "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." }, - { "name": "userGesture", "type": "boolean", "optional": true, "hidden": true, "description": "Whether execution should be treated as initiated by user in the UI." } + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "experimental": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "experimental": true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } ], "returns": [ { "name": "result", "$ref": "RemoteObject", "description": "Call result." }, - { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." } + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "experimental": true, "description": "Exception details."} ], "description": "Calls function with given declaration on the given object. Object group of the result is inherited from the target object." }, @@ -215,13 +244,13 @@ "parameters": [ { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." }, { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." }, - { "name": "accessorPropertiesOnly", "optional": true, "type": "boolean", "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.", "hidden": true }, - { "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the results." } + { "name": "accessorPropertiesOnly", "optional": true, "type": "boolean", "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.", "experimental": true }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the results." } ], "returns": [ { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor" }, "description": "Object properties." }, - { "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor" }, "description": "Internal object properties (only of the element itself).", "hidden": true }, - { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."} + { "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor" }, "description": "Internal object properties (only of the element itself).", "experimental": true }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "experimental": true, "description": "Exception details."} ], "description": "Returns properties of a given object. Object group of the result is inherited from the target object." }, @@ -241,7 +270,7 @@ }, { "name": "run", - "hidden": true, + "experimental": true, "description": "Tells inspected instance(worker or page) that it can run in case it was started paused." }, { @@ -250,12 +279,12 @@ }, { "name": "disable", - "hidden": true, + "experimental": true, "description": "Disables reporting of execution contexts creation." }, { "name": "discardConsoleEntries", - "hidden": true, + "experimental": true, "description": "Discards collected exceptions and console API calls." }, { @@ -266,16 +295,16 @@ "type": "boolean" } ], - "hidden": true + "experimental": true }, { "name": "compileScript", - "hidden": true, + "experimental": true, "parameters": [ { "name": "expression", "type": "string", "description": "Expression to compile." }, { "name": "sourceURL", "type": "string", "description": "Source url to be set for the script." }, { "name": "persistScript", "type": "boolean", "description": "Specifies whether the compiled script should be persisted." }, - { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter is used to specify one of those contexts." } + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." } ], "returns": [ { "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Id of the script." }, @@ -285,16 +314,21 @@ }, { "name": "runScript", - "hidden": true, + "experimental": true, + "async": true, "parameters": [ { "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to run." }, - { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter is used to specify one of those contexts." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether script run should stop on exceptions and mute console. Overrides setPauseOnException state." }, - { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." } + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." }, + { "name": "awaitPromise", "type": "boolean", "optional": true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } ], "returns": [ { "name": "result", "$ref": "RemoteObject", "description": "Run result." }, + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the execution." }, { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} ], "description": "Runs script with given id in a given context." @@ -329,7 +363,7 @@ { "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 + "experimental": true }, { "name": "exceptionRevoked", @@ -338,7 +372,7 @@ { "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 + "experimental": true }, { "name": "consoleAPICalled", @@ -350,7 +384,7 @@ { "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." }, { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "Stack trace captured when the call was made." } ], - "hidden": true + "experimental": true }, { "name": "inspectRequested", @@ -358,7 +392,7 @@ { "name": "object", "$ref": "RemoteObject" }, { "name": "hints", "type": "object" } ], - "hidden": true + "experimental": true } ] }, @@ -389,7 +423,7 @@ }, { "id": "ScriptPosition", - "hidden": true, + "experimental": true, "type": "object", "properties": [ { "name": "lineNumber", "type": "integer" }, @@ -403,11 +437,11 @@ "properties": [ { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier. This identifier is only valid while the virtual machine is paused." }, { "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." }, - { "name": "functionLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code." }, + { "name": "functionLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code." }, { "name": "location", "$ref": "Location", "description": "Location in the source code." }, { "name": "scopeChain", "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for this call frame." }, { "name": "this", "$ref": "Runtime.RemoteObject", "description": "this object for this call frame." }, - { "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "hidden": true, "description": "The value being returned, if the function is at return point." } + { "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "experimental": true, "description": "The value being returned, if the function is at return point." } ], "description": "JavaScript call frame. Array of call frames form the call stack." }, @@ -417,9 +451,9 @@ "properties": [ { "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "block", "script"], "description": "Scope type." }, { "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." }, - { "name": "name", "type": "string", "optional": true, "hidden": true }, - { "name": "startLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code where scope starts" }, - { "name": "endLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code where scope ends" } + { "name": "name", "type": "string", "optional": true, "experimental": true }, + { "name": "startLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code where scope starts" }, + { "name": "endLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code where scope ends" } ], "description": "Scope description." }, @@ -427,11 +461,12 @@ "id": "SearchMatch", "type": "object", "description": "Search match for resource.", + "exported": true, "properties": [ { "name": "lineNumber", "type": "number", "description": "Line number in resource content." }, { "name": "lineContent", "type": "string", "description": "Line with match content." } ], - "hidden": true + "experimental": true } ], "commands": [ @@ -452,7 +487,7 @@ }, { "name": "setSkipAllPauses", - "hidden": true, + "experimental": true, "parameters": [ { "name": "skipped", "type": "boolean", "description": "New value for skip pauses state." } ], @@ -496,7 +531,7 @@ "name": "continueToLocation", "parameters": [ { "name": "location", "$ref": "Location", "description": "Location to continue to." }, - { "name": "interstatementLocation", "type": "boolean", "optional": true, "hidden": true, "description": "Allows breakpoints at the intemediate positions inside statements." } + { "name": "interstatementLocation", "type": "boolean", "optional": true, "experimental": true, "description": "Allows breakpoints at the intemediate positions inside statements." } ], "description": "Continues execution until specific location is reached." }, @@ -545,12 +580,12 @@ "parameters": [ { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to edit." }, { "name": "scriptSource", "type": "string", "description": "New content of the script." }, - { "name": "preview", "type": "boolean", "optional": true, "description": " If true the change will not actually be applied. Preview mode may be used to get result description without actually modifying the code.", "hidden": true } + { "name": "preview", "type": "boolean", "optional": true, "description": " If true the change will not actually be applied. Preview mode may be used to get result description without actually modifying the code.", "experimental": true } ], "returns": [ { "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": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes.", "experimental": true }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "experimental": true }, { "name": "compileError", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Error data if any." } ], "description": "Edits JavaScript source live." @@ -564,7 +599,7 @@ { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "New stack trace." }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." } ], - "hidden": true, + "experimental": true, "description": "Restarts particular call frame from the beginning." }, { @@ -590,15 +625,15 @@ { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." }, { "name": "expression", "type": "string", "description": "Expression to evaluate." }, { "name": "objectGroup", "type": "string", "optional": true, "description": "String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup)." }, - { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false.", "hidden": true }, - { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false.", "experimental": true }, + { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "experimental": true }, { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, - { "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." } + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." } ], "returns": [ { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." }, { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, - { "name": "exceptionDetails", "$ref": "Runtime.ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."} + { "name": "exceptionDetails", "$ref": "Runtime.ExceptionDetails", "optional": true, "experimental": true, "description": "Exception details."} ], "description": "Evaluates expression on a given call frame." }, @@ -610,7 +645,7 @@ { "name": "newValue", "$ref": "Runtime.CallArgument", "description": "New variable value." }, { "name": "callFrameId", "$ref": "CallFrameId", "description": "Id of callframe that holds variable." } ], - "hidden": true, + "experimental": true, "description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually." }, { @@ -619,7 +654,7 @@ { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." } ], - "hidden": true, + "experimental": true, "description": "Returns call stack including variables changed since VM was paused. VM must be paused." }, { @@ -627,7 +662,7 @@ "parameters": [ { "name": "maxDepth", "type": "integer", "description": "Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default)." } ], - "hidden": true, + "experimental": true, "description": "Enables or disables async call stacks tracking." }, { @@ -635,7 +670,7 @@ "parameters": [ { "name": "patterns", "type": "array", "items": { "type": "string" }, "description": "Array of regexps that will be used to check script url for blackbox state." } ], - "hidden": true, + "experimental": true, "description": "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful." }, { @@ -644,7 +679,7 @@ { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script." }, { "name": "positions", "type": "array", "items": { "$ref": "ScriptPosition" } } ], - "hidden": true, + "experimental": true, "description": "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted." } ], @@ -658,14 +693,14 @@ { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, { "name": "endLine", "type": "integer", "description": "Last line of the script." }, { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, - { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "hidden": true }, - { "name": "hash", "type": "string", "hidden": true, "description": "Content hash of the script."}, - { "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." }, - { "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "hidden": true }, - { "name": "isLiveEdit", "type": "boolean", "optional": true, "description": "True, if this script is generated as a result of the live edit operation.", "hidden": true }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "experimental": true }, + { "name": "hash", "type": "string", "experimental": true, "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data.", "experimental": true }, + { "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "experimental": true }, + { "name": "isLiveEdit", "type": "boolean", "optional": true, "description": "True, if this script is generated as a result of the live edit operation.", "experimental": true }, { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, - { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "hidden": true }, - { "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "hidden": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."} + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "experimental": true }, + { "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "experimental": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."} ], "description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger." }, @@ -678,13 +713,13 @@ { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, { "name": "endLine", "type": "integer", "description": "Last line of the script." }, { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, - { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "hidden": true }, - { "name": "hash", "type": "string", "hidden": true, "description": "Content hash of the script."}, - { "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." }, - { "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "hidden": true }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "experimental": true }, + { "name": "hash", "type": "string", "experimental": true, "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data.", "experimental": true }, + { "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "experimental": true }, { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, - { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "hidden": true }, - { "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "hidden": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."} + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "experimental": true }, + { "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "experimental": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."} ], "description": "Fired when virtual machine fails to parse the script." }, @@ -700,10 +735,10 @@ "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", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." }, + { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason.", "exported": true }, { "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 } + { "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs", "experimental": true }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "experimental": true } ], "description": "Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria." }, @@ -759,7 +794,7 @@ "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 } + { "name": "timestamp", "$ref": "Runtime.Timestamp", "description": "Timestamp of most recent message in batch.", "experimental": true } ], "description": "Not issued.", "deprecated": true @@ -774,7 +809,7 @@ { "domain": "Profiler", "dependencies": ["Runtime", "Debugger"], - "hidden": true, + "experimental": true, "types": [ { "id": "CPUProfileNode", @@ -859,7 +894,7 @@ { "domain": "HeapProfiler", "dependencies": ["Runtime"], - "hidden": true, + "experimental": true, "types": [ { "id": "HeapSnapshotObjectId", diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/InspectorVersion.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/InspectorVersion.h new file mode 100644 index 00000000000000..aff7b1519fb8e7 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/InspectorVersion.h @@ -0,0 +1,6 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is automatically generated. Do not modify. +#define V8_INSPECTOR_REVISION "62cd277117e6f8ec53e31b1be58290a6f7ab42ef" 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 deleted file mode 100644 index 73c1878e9e3d84..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h +++ /dev/null @@ -1,20 +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 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/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h deleted file mode 100644 index a932b7a4664c92..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h +++ /dev/null @@ -1,26 +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 V8ContentSearchUtil_h -#define V8ContentSearchUtil_h - -#include "platform/inspector_protocol/Platform.h" -#include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/protocol/Debugger.h" - -namespace blink { - -class V8InspectorSession; - -namespace V8ContentSearchUtil { - -PLATFORM_EXPORT String16 findSourceURL(const String16& content, bool multiline, bool* deprecated = nullptr); -PLATFORM_EXPORT String16 findSourceMapURL(const String16& content, bool multiline, bool* deprecated = nullptr); -PLATFORM_EXPORT std::unique_ptr> searchInTextByLines(V8InspectorSession*, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex); - -} - -} - -#endif // !defined(V8ContentSearchUtil_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h index 0dc1de29da75e5..81a98e6c520198 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h @@ -13,14 +13,11 @@ namespace blink { class V8ContextInfo { public: - V8ContextInfo(v8::Local context, int contextGroupId, bool isDefault, const String16& origin, const String16& humanReadableName, const String16& frameId, bool hasMemoryOnConsole) + V8ContextInfo(v8::Local context, int contextGroupId, const String16& humanReadableName) : context(context) , contextGroupId(contextGroupId) - , isDefault(isDefault) - , origin(origin) , humanReadableName(humanReadableName) - , frameId(frameId) - , hasMemoryOnConsole(hasMemoryOnConsole) + , hasMemoryOnConsole(false) { } @@ -29,11 +26,9 @@ class V8ContextInfo { // V8DebuggerAgent to notify about events in the context. // |contextGroupId| must be non-0. int contextGroupId; - bool isDefault; - const String16 origin; - const String16 humanReadableName; - // TODO(dgozman): aux data? - const String16 frameId; + String16 humanReadableName; + String16 origin; + String16 auxData; bool hasMemoryOnConsole; }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h deleted file mode 100644 index da3dcacf555b15..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2015 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 V8Debugger_h -#define V8Debugger_h - -#include "platform/inspector_protocol/Platform.h" -#include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/public/V8ConsoleTypes.h" - -#include - -namespace blink { - -class V8ContextInfo; -class V8DebuggerClient; -class V8InspectorSession; -class V8InspectorSessionClient; -class V8StackTrace; - -namespace protocol { -class FrontendChannel; -} - -class PLATFORM_EXPORT V8Debugger { -public: - static std::unique_ptr create(v8::Isolate*, V8DebuggerClient*); - virtual ~V8Debugger() { } - - // Contexts instrumentation. - virtual void contextCreated(const V8ContextInfo&) = 0; - virtual void contextDestroyed(v8::Local) = 0; - virtual void resetContextGroup(int contextGroupId) = 0; - - // Various instrumentation. - virtual void willExecuteScript(v8::Local, int scriptId) = 0; - virtual void didExecuteScript(v8::Local) = 0; - virtual void idleStarted() = 0; - virtual void idleFinished() = 0; - - // Async 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(bool fullStack) = 0; -}; - -} // namespace blink - - -#endif // V8Debugger_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h deleted file mode 100644 index 3747f66707d051..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 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 V8DebuggerClient_h -#define V8DebuggerClient_h - -#include "platform/inspector_protocol/Platform.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(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; - virtual String16 valueSubtype(v8::Local) = 0; - virtual bool formatAccessorsAsProperties(v8::Local) = 0; - virtual bool isExecutionAllowed() = 0; - virtual double currentTimeMS() = 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 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; - - typedef void (*TimerCallback)(void*); - virtual void startRepeatingTimer(double, TimerCallback, void* data) = 0; - virtual void cancelTimer(void* data) = 0; -}; - -} // namespace blink - - -#endif // V8DebuggerClient_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp deleted file mode 100644 index f118dcacf3ce5a..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp +++ /dev/null @@ -1,74 +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. - - -#include "platform/v8_inspector/public/V8Inspector.h" - -#include "platform/inspector_protocol/DispatcherBase.h" -#include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/V8Debugger.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" - -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, "", - "NodeJS Main Context", "", false)); -} - -V8Inspector::~V8Inspector() -{ - disconnectFrontend(); -} - -bool V8Inspector::callingContextCanAccessContext(v8::Local calling, v8::Local target) -{ - return true; -} - -String16 V8Inspector::valueSubtype(v8::Local value) -{ - return String16(); -} - -bool V8Inspector::formatAccessorsAsProperties(v8::Local value) -{ - return false; -} - -void V8Inspector::connectFrontend(protocol::FrontendChannel* channel) -{ - m_session = m_debugger->connect(1, channel, this, &m_state); -} - -void V8Inspector::disconnectFrontend() -{ - m_session.reset(); -} - -void V8Inspector::dispatchMessageFromFrontend(const String16& message) -{ - if (m_session) - m_session->dispatchProtocolMessage(message); -} - -v8::Local V8Inspector::ensureDefaultContextInGroup(int) -{ - return m_context; -} - -bool V8Inspector::isExecutionAllowed() -{ - return true; -} - -bool V8Inspector::canExecuteScripts() -{ - return true; -} - -} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h index 4dbb797d50935f..a62f0c8b3a078d 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h @@ -1,4 +1,4 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. +// Copyright 2015 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. @@ -6,76 +6,55 @@ #define V8Inspector_h #include "platform/inspector_protocol/Platform.h" -#include "platform/v8_inspector/public/V8DebuggerClient.h" -#include "platform/v8_inspector/public/V8InspectorSession.h" -#include "platform/v8_inspector/public/V8InspectorSessionClient.h" +#include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/public/V8ContextInfo.h" #include namespace blink { +class V8InspectorClient; +class V8InspectorSession; +class V8StackTrace; + namespace protocol { -class Dispatcher; -class Frontend; class FrontendChannel; } -class V8Debugger; -class V8HeapProfilerAgent; -class V8ProfilerAgent; - -class V8Inspector : public V8DebuggerClient, V8InspectorSessionClient { +class PLATFORM_EXPORT V8Inspector { public: - V8Inspector(v8::Isolate*, v8::Local); - ~V8Inspector(); - - // Transport interface. - void connectFrontend(protocol::FrontendChannel*); - void disconnectFrontend(); - void dispatchMessageFromFrontend(const String16& message); - -private: - bool callingContextCanAccessContext(v8::Local calling, v8::Local target) override; - String16 valueSubtype(v8::Local) override; - bool formatAccessorsAsProperties(v8::Local) override; - void muteWarningsAndDeprecations(int) override { } - void unmuteWarningsAndDeprecations(int) override { } - double currentTimeMS() override { return 0; }; - - bool isExecutionAllowed() 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 installAdditionalCommandLineAPI(v8::Local, v8::Local) 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; + static std::unique_ptr create(v8::Isolate*, V8InspectorClient*); + virtual ~V8Inspector() { } + + // Contexts instrumentation. + virtual void contextCreated(const V8ContextInfo&) = 0; + virtual void contextDestroyed(v8::Local) = 0; + virtual void resetContextGroup(int contextGroupId) = 0; + + // Various instrumentation. + virtual void willExecuteScript(v8::Local, int scriptId) = 0; + virtual void didExecuteScript(v8::Local) = 0; + virtual void idleStarted() = 0; + virtual void idleFinished() = 0; + + // Async stack traces instrumentation. + virtual void asyncTaskScheduled(const 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; + + // Exceptions instrumentation. + virtual unsigned exceptionThrown(v8::Local, const String16& message, v8::Local exception, const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) = 0; + virtual void exceptionRevoked(v8::Local, unsigned exceptionId, const String16& message) = 0; + + // API methods. + virtual std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, const String16* state) = 0; + virtual std::unique_ptr createStackTrace(v8::Local) = 0; + virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; }; -} +} // namespace blink + #endif // V8Inspector_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorClient.h new file mode 100644 index 00000000000000..27495ae9884b0b --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorClient.h @@ -0,0 +1,60 @@ +// Copyright 2015 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 V8InspectorClient_h +#define V8InspectorClient_h + +#include "platform/inspector_protocol/Platform.h" +#include "platform/inspector_protocol/String16.h" + +#include + +namespace blink { + +class V8StackTrace; + +enum class V8ConsoleAPIType { kClear, kDebug, kLog, kInfo, kWarning, kError }; + +class PLATFORM_EXPORT V8InspectorClient { +public: + virtual ~V8InspectorClient() { } + + virtual void runMessageLoopOnPause(int contextGroupId) { } + virtual void quitMessageLoopOnPause() { } + virtual void resumeStartup(int contextGroupId) { } + + virtual void muteMetrics(int contextGroupId) { } + virtual void unmuteMetrics(int contextGroupId) { } + + virtual void beginUserGesture() { } + virtual void endUserGesture() { } + + virtual String16 valueSubtype(v8::Local) { return String16(); } + virtual bool formatAccessorsAsProperties(v8::Local) { return false; } + virtual bool isInspectableHeapObject(v8::Local) { return true; } + + virtual v8::Local ensureDefaultContextInGroup(int contextGroupId) { return v8::Local(); } + virtual void beginEnsureAllContextsInGroup(int contextGroupId) { } + virtual void endEnsureAllContextsInGroup(int contextGroupId) { } + + virtual void installAdditionalCommandLineAPI(v8::Local, v8::Local) { } + virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType, const String16& message, const String16& url, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) { } + virtual v8::MaybeLocal memoryInfo(v8::Isolate*, v8::Local) { return v8::MaybeLocal(); } + + virtual void consoleTime(const String16& title) { } + virtual void consoleTimeEnd(const String16& title) { } + virtual void consoleTimeStamp(const String16& title) { } + virtual double currentTimeMS() { return 0; } + typedef void (*TimerCallback)(void*); + virtual void startRepeatingTimer(double, TimerCallback, void* data) { } + virtual void cancelTimer(void* data) { } + + // TODO(dgozman): this was added to support service worker shadow page. We should not connect at all. + virtual bool canExecuteScripts(int contextGroupId) { return true; } +}; + +} // namespace blink + + +#endif // V8InspectorClient_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h index 2103467e44087b..365ab86432ba1f 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h @@ -5,8 +5,10 @@ #ifndef V8InspectorSession_h #define V8InspectorSession_h +#include "platform/inspector_protocol/Array.h" #include "platform/inspector_protocol/Platform.h" -#include "platform/v8_inspector/protocol/Runtime.h" +#include "platform/v8_inspector/public/protocol/Debugger.h" +#include "platform/v8_inspector/public/protocol/Runtime.h" #include @@ -25,23 +27,22 @@ class PLATFORM_EXPORT V8InspectorSession { virtual void addInspectedObject(std::unique_ptr) = 0; // Dispatching protocol messages. - // TODO(dgozman): generate this one. - static bool isV8ProtocolMethod(const String16& method); + static bool canDispatchMethod(const String16& method); virtual void dispatchProtocolMessage(const String16& message) = 0; virtual String16 stateJSON() = 0; // Debugger actions. - virtual void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) = 0; + virtual void schedulePauseOnNextStatement(const String16& breakReason, const String16& breakDetails) = 0; virtual void cancelPauseOnNextStatement() = 0; - virtual void breakProgram(const String16& breakReason, std::unique_ptr data) = 0; + virtual void breakProgram(const String16& breakReason, const String16& breakDetails) = 0; virtual void setSkipAllPauses(bool) = 0; virtual void resume() = 0; virtual void stepOver() = 0; + virtual std::unique_ptr> searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex) = 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 std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName) = 0; + virtual bool unwrapObject(ErrorString*, const String16& objectId, v8::Local*, v8::Local*, String16* objectGroup) = 0; virtual void releaseObjectGroup(const String16&) = 0; }; diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h deleted file mode 100644 index e9e7c33ea83fd2..00000000000000 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h +++ /dev/null @@ -1,29 +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 V8InspectorSessionClient_h -#define V8InspectorSessionClient_h - -#include "platform/inspector_protocol/Platform.h" - -#include - -namespace blink { - -class PLATFORM_EXPORT V8InspectorSessionClient { -public: - virtual ~V8InspectorSessionClient() { } - 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 - -#endif // V8InspectorSessionClient_h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h index beee1155f6e87f..1913554a20e141 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h @@ -7,13 +7,12 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/protocol/Runtime.h" +#include "platform/v8_inspector/public/protocol/Runtime.h" #include namespace blink { -// TODO(dgozman): migrate to V8SourceLocation. class V8StackTrace { public: virtual bool isEmpty() const = 0; @@ -24,10 +23,11 @@ class V8StackTrace { virtual String16 topFunctionName() const = 0; virtual ~V8StackTrace() { } - virtual std::unique_ptr buildInspectorObject() const = 0; + virtual std::unique_ptr buildInspectorObject() const = 0; virtual String16 toString() const = 0; + + // Safe to pass between threads, drops async chain. virtual std::unique_ptr clone() = 0; - virtual std::unique_ptr isolatedCopy() = 0; // Safe to pass between threads. }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp index 6de6017c6931af..ebfc91a66d4b19 100644 --- a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp @@ -79,6 +79,8 @@ # Source code templates. '../inspector_protocol/TypeBuilder_h.template', '../inspector_protocol/TypeBuilder_cpp.template', + '../inspector_protocol/Exported_h.template', + '../inspector_protocol/Imported_h.template', # Protocol definitions 'js_protocol.json', ], @@ -93,6 +95,8 @@ '<(blink_platform_output_dir)/v8_inspector/protocol/Profiler.h', '<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.cpp', '<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.h', + '<(blink_platform_output_dir)/v8_inspector/public/protocol/Runtime.h', + '<(blink_platform_output_dir)/v8_inspector/public/protocol/Debugger.h', ], 'action': [ 'python', @@ -102,6 +106,8 @@ '--export_macro', 'PLATFORM_EXPORT', '--output_dir', '<(blink_platform_output_dir)/v8_inspector/protocol', '--output_package', 'platform/v8_inspector/protocol', + '--exported_dir', '<(blink_platform_output_dir)/v8_inspector/public/protocol', + '--exported_package', 'platform/v8_inspector/public/protocol', ], 'message': 'Generating protocol backend sources from json definitions.', }, @@ -177,11 +183,9 @@ '../inspector_protocol/String16STL.h', '../inspector_protocol/Values.cpp', '../inspector_protocol/Values.h', - '../inspector_protocol/ValueConversions.cpp', '../inspector_protocol/ValueConversions.h', 'Atomics.h', - 'IgnoreExceptionsScope.h', 'InjectedScript.cpp', 'InjectedScript.h', 'InjectedScriptNative.cpp', @@ -200,10 +204,12 @@ 'V8ConsoleAgentImpl.h', 'V8ConsoleMessage.cpp', 'V8ConsoleMessage.h', + 'V8Debugger.cpp', + 'V8Debugger.h', 'V8DebuggerAgentImpl.cpp', 'V8DebuggerAgentImpl.h', - 'V8DebuggerImpl.cpp', - 'V8DebuggerImpl.h', + 'V8InspectorImpl.cpp', + 'V8InspectorImpl.h', 'V8DebuggerScript.cpp', 'V8DebuggerScript.h', 'V8FunctionCall.cpp', @@ -227,13 +233,10 @@ 'V8StringUtil.cpp', 'V8StringUtil.h', 'public/V8EventListenerInfo.h', - 'public/V8ContentSearchUtil.h', 'public/V8ContextInfo.h', - 'public/V8Debugger.h', - 'public/V8DebuggerClient.h', - 'public/V8HeapProfilerAgent.h', - 'public/V8Inspector.cpp', 'public/V8Inspector.h', + 'public/V8InspectorClient.h', + 'public/V8HeapProfilerAgent.h', 'public/V8InspectorSession.h', 'public/V8StackTrace.h', diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 5a870aa91ca0f4..6bcc195e77535c 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -9,7 +9,10 @@ #include "v8-platform.h" #include "util.h" +#include "platform/v8_inspector/public/InspectorVersion.h" #include "platform/v8_inspector/public/V8Inspector.h" +#include "platform/v8_inspector/public/V8InspectorClient.h" +#include "platform/v8_inspector/public/V8InspectorSession.h" #include "platform/inspector_protocol/FrontendChannel.h" #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/Values.h" @@ -36,7 +39,7 @@ const char TAG_CONNECT[] = "#connect"; const char TAG_DISCONNECT[] = "#disconnect"; const char DEVTOOLS_PATH[] = "/node"; -const char DEVTOOLS_HASH[] = "851972d6da7463c353d712d2cb6c1ec23fa6c4fe"; +const char DEVTOOLS_HASH[] = V8_INSPECTOR_REVISION; void PrintDebuggerReadyMessage(int port) { fprintf(stderr, "Debugger listening on port %d.\n" @@ -156,6 +159,8 @@ bool RespondToGet(inspector_socket_t* socket, const std::string& path, namespace inspector { +class V8NodeInspector; + class AgentImpl { public: explicit AgentImpl(node::Environment* env); @@ -211,7 +216,7 @@ class AgentImpl { uv_async_t* data_written_; uv_async_t io_thread_req_; inspector_socket_t* client_socket_; - blink::V8Inspector* inspector_; + V8NodeInspector* inspector_; v8::Platform* platform_; MessageQueue incoming_message_queue_; MessageQueue outgoing_message_queue_; @@ -271,16 +276,20 @@ class ChannelImpl final : public blink::protocol::FrontendChannel { AgentImpl* const agent_; }; -class V8NodeInspector : public blink::V8Inspector { +class V8NodeInspector : public blink::V8InspectorClient { public: V8NodeInspector(AgentImpl* agent, node::Environment* env, v8::Platform* platform) - : blink::V8Inspector(env->isolate(), env->context()), - agent_(agent), + : agent_(agent), isolate_(env->isolate()), platform_(platform), terminated_(false), - running_nested_loop_(false) {} + running_nested_loop_(false), + inspector_( + blink::V8Inspector::create(env->isolate(), this)) { + inspector_->contextCreated( + blink::V8ContextInfo(env->context(), 1, "NodeJS Main Context")); + } void runMessageLoopOnPause(int context_group_id) override { if (running_nested_loop_) @@ -303,12 +312,27 @@ class V8NodeInspector : public blink::V8Inspector { terminated_ = true; } + void connectFrontend() { + session_ = inspector_->connect(1, new ChannelImpl(agent_), nullptr); + } + + void disconnectFrontend() { + session_.reset(); + } + + void dispatchMessageFromFrontend(const String16& message) { + CHECK(session_); + session_->dispatchProtocolMessage(message); + } + private: AgentImpl* agent_; v8::Isolate* isolate_; v8::Platform* platform_; bool terminated_; bool running_nested_loop_; + std::unique_ptr inspector_; + std::unique_ptr session_; }; AgentImpl::AgentImpl(Environment* env) : port_(0), @@ -546,7 +570,7 @@ void AgentImpl::DispatchMessages() { backend_session_id_++; state_ = State::kConnected; fprintf(stderr, "Debugger attached.\n"); - inspector_->connectFrontend(new ChannelImpl(this)); + inspector_->connectFrontend(); } else if (message == TAG_DISCONNECT) { CHECK_EQ(State::kConnected, state_); if (shutting_down_) {