Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 2122423002: [DevTools] Remove functionDetails from protocol.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-generator-details-from-protocol
Patch Set: addressed comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "platform/v8_inspector/Atomics.h" 34 #include "platform/v8_inspector/Atomics.h"
35 #include "platform/v8_inspector/DebuggerScript.h" 35 #include "platform/v8_inspector/DebuggerScript.h"
36 #include "platform/v8_inspector/InspectedContext.h" 36 #include "platform/v8_inspector/InspectedContext.h"
37 #include "platform/v8_inspector/ScriptBreakpoint.h" 37 #include "platform/v8_inspector/ScriptBreakpoint.h"
38 #include "platform/v8_inspector/V8Compat.h" 38 #include "platform/v8_inspector/V8Compat.h"
39 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" 39 #include "platform/v8_inspector/V8ConsoleAgentImpl.h"
40 #include "platform/v8_inspector/V8ConsoleMessage.h" 40 #include "platform/v8_inspector/V8ConsoleMessage.h"
41 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 41 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
42 #include "platform/v8_inspector/V8InjectedScriptHost.h" 42 #include "platform/v8_inspector/V8InjectedScriptHost.h"
43 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 43 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
44 #include "platform/v8_inspector/V8InternalValueType.h"
44 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 45 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
45 #include "platform/v8_inspector/V8StackTraceImpl.h" 46 #include "platform/v8_inspector/V8StackTraceImpl.h"
46 #include "platform/v8_inspector/V8StringUtil.h" 47 #include "platform/v8_inspector/V8StringUtil.h"
47 #include "platform/v8_inspector/public/V8DebuggerClient.h" 48 #include "platform/v8_inspector/public/V8DebuggerClient.h"
48 #include <v8-profiler.h> 49 #include <v8-profiler.h>
49 50
50 namespace blink { 51 namespace blink {
51 52
52 namespace { 53 namespace {
53 const char stepIntoV8MethodName[] = "stepIntoStatement"; 54 const char stepIntoV8MethodName[] = "stepIntoStatement";
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternali zed).ToLocalChecked(); 645 return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternali zed).ToLocalChecked();
645 } 646 }
646 647
647 v8::MaybeLocal<v8::Value> V8DebuggerImpl::functionScopes(v8::Local<v8::Function> function) 648 v8::MaybeLocal<v8::Value> V8DebuggerImpl::functionScopes(v8::Local<v8::Function> function)
648 { 649 {
649 if (!enabled()) { 650 if (!enabled()) {
650 NOTREACHED(); 651 NOTREACHED();
651 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); 652 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
652 } 653 }
653 v8::Local<v8::Value> argv[] = { function }; 654 v8::Local<v8::Value> argv[] = { function };
654 return callDebuggerMethod("getFunctionScopes", 1, argv); 655 v8::Local<v8::Value> scopesValue;
656 if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue) || !scopesValue->IsArray())
657 return v8::MaybeLocal<v8::Value>();
658 v8::Local<v8::Array> scopes = scopesValue.As<v8::Array>();
659 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate);
660 if (!markAsInternal(context, scopes, V8InternalValueType::kScopeList))
661 return v8::MaybeLocal<v8::Value>();
662 if (!markArrayEntriesAsInternal(context, scopes, V8InternalValueType::kScope ))
663 return v8::MaybeLocal<v8::Value>();
664 if (!scopes->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false))
665 return v8::Undefined(m_isolate);
666 return scopes;
655 } 667 }
656 668
657 v8::MaybeLocal<v8::Array> V8DebuggerImpl::internalProperties(v8::Local<v8::Conte xt> context, v8::Local<v8::Value> value) 669 v8::MaybeLocal<v8::Array> V8DebuggerImpl::internalProperties(v8::Local<v8::Conte xt> context, v8::Local<v8::Value> value)
658 { 670 {
659 v8::Local<v8::Array> properties; 671 v8::Local<v8::Array> properties;
660 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties) ) 672 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties) )
661 return v8::MaybeLocal<v8::Array>(); 673 return v8::MaybeLocal<v8::Array>();
674 if (value->IsFunction()) {
675 v8::Local<v8::Function> function = value.As<v8::Function>();
676 v8::Local<v8::Value> location = functionLocation(context, function);
677 if (location->IsObject()) {
678 properties->Set(properties->Length(), v8InternalizedString("[[Functi onLocation]]"));
679 properties->Set(properties->Length(), location);
680 }
681 }
682 if (value->IsFunction()) {
dgozman 2016/07/09 01:47:29 Merge these if block with previous.
kozy 2016/07/11 17:50:39 Done.
683 v8::Local<v8::Function> function = value.As<v8::Function>();
684 if (function->IsGeneratorFunction()) {
685 properties->Set(properties->Length(), v8InternalizedString("[[IsGene rator]]"));
686 properties->Set(properties->Length(), v8::True(m_isolate));
687 }
688 }
662 if (!enabled()) 689 if (!enabled())
663 return properties; 690 return properties;
664 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) { 691 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) {
665 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value)); 692 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value));
666 if (entries->IsArray()) { 693 if (entries->IsArray()) {
667 properties->Set(properties->Length(), v8InternalizedString("[[Entrie s]]")); 694 properties->Set(properties->Length(), v8InternalizedString("[[Entrie s]]"));
668 properties->Set(properties->Length(), entries); 695 properties->Set(properties->Length(), entries);
669 } 696 }
670 } 697 }
671 if (value->IsGeneratorObject()) { 698 if (value->IsGeneratorObject()) {
672 v8::Local<v8::Value> location = generatorObjectLocation(v8::Local<v8::Ob ject>::Cast(value)); 699 v8::Local<v8::Value> location = generatorObjectLocation(v8::Local<v8::Ob ject>::Cast(value));
673 if (location->IsObject()) { 700 if (location->IsObject()) {
674 properties->Set(properties->Length(), v8InternalizedString("[[Genera torLocation]]")); 701 properties->Set(properties->Length(), v8InternalizedString("[[Genera torLocation]]"));
675 properties->Set(properties->Length(), location); 702 properties->Set(properties->Length(), location);
676 } 703 }
677 } 704 }
705 if (value->IsFunction()) {
706 v8::Local<v8::Function> function = value.As<v8::Function>();
707 v8::Local<v8::Value> boundFunction = function->GetBoundFunction();
708 v8::Local<v8::Value> scopes;
709 if (boundFunction->IsUndefined() && functionScopes(function).ToLocal(&sc opes)) {
710 properties->Set(properties->Length(), v8InternalizedString("[[Scopes ]]"));
711 properties->Set(properties->Length(), scopes);
712 }
713 }
678 return properties; 714 return properties;
679 } 715 }
680 716
681 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Context> co ntext, v8::Local<v8::Object> object) 717 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Context> co ntext, v8::Local<v8::Object> object)
682 { 718 {
683 if (!enabled()) { 719 if (!enabled()) {
684 NOTREACHED(); 720 NOTREACHED();
685 return v8::Undefined(m_isolate); 721 return v8::Undefined(m_isolate);
686 } 722 }
687 v8::Local<v8::Value> argv[] = { object }; 723 v8::Local<v8::Value> argv[] = { object };
688 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked(); 724 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked();
689 if (!entriesValue->IsArray()) 725 if (!entriesValue->IsArray())
690 return v8::Undefined(m_isolate); 726 return v8::Undefined(m_isolate);
691 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>(); 727 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>();
692 for (size_t i = 0; i < entries->Length(); ++i) { 728 if (!markArrayEntriesAsInternal(context, entries, V8InternalValueType::kEntr y))
693 v8::Local<v8::Value> entry; 729 return v8::Undefined(m_isolate);
694 if (!entries->Get(context, i).ToLocal(&entry) || !entry->IsObject())
695 continue;
696 if (!entry.As<v8::Object>()->SetPrivate(context, V8InjectedScriptHost::i nternalEntryPrivate(m_isolate), v8::True(m_isolate)).FromMaybe(false))
697 continue;
698 }
699 if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) 730 if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false))
700 return v8::Undefined(m_isolate); 731 return v8::Undefined(m_isolate);
701 return entries; 732 return entries;
702 } 733 }
703 734
704 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectLocation(v8::Local<v8::Objec t> object) 735 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectLocation(v8::Local<v8::Objec t> object)
705 { 736 {
706 if (!enabled()) { 737 if (!enabled()) {
707 NOTREACHED(); 738 NOTREACHED();
708 return v8::Null(m_isolate); 739 return v8::Null(m_isolate);
709 } 740 }
710 v8::Local<v8::Value> argv[] = { object }; 741 v8::Local<v8::Value> argv[] = { object };
711 v8::Local<v8::Value> location = callDebuggerMethod("getGeneratorObjectLocati on", 1, argv).ToLocalChecked(); 742 v8::Local<v8::Value> location = callDebuggerMethod("getGeneratorObjectLocati on", 1, argv).ToLocalChecked();
712 if (!location->IsObject()) 743 if (!location->IsObject())
713 return v8::Null(m_isolate); 744 return v8::Null(m_isolate);
714 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate); 745 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate);
715 if (!location.As<v8::Object>()->SetPrivate(context, V8InjectedScriptHost::in ternalLocationPrivate(m_isolate), v8::True(m_isolate)).FromMaybe(false)) 746 if (!markAsInternal(context, v8::Local<v8::Object>::Cast(location), V8Intern alValueType::kLocation))
716 return v8::Null(m_isolate); 747 return v8::Null(m_isolate);
717 return location; 748 return location;
718 } 749 }
750
751 v8::Local<v8::Value> V8DebuggerImpl::functionLocation(v8::Local<v8::Context> con text, v8::Local<v8::Function> function)
752 {
753 int scriptId = function->ScriptId();
754 if (scriptId == v8::UnboundScript::kNoScriptId)
755 return v8::Null(m_isolate);
756 int lineNumber = function->GetScriptLineNumber();
757 int columnNumber = function->GetScriptColumnNumber();
758 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound)
759 return v8::Null(m_isolate);
760 v8::Local<v8::Object> location = v8::Object::New(m_isolate);
761 if (!location->Set(context, v8InternalizedString("scriptId"), toV8String(m_i solate, String16::number(scriptId))).FromMaybe(false))
762 return v8::Null(m_isolate);
763 if (!location->Set(context, v8InternalizedString("lineNumber"), v8::Integer: :New(m_isolate, lineNumber)).FromMaybe(false))
764 return v8::Null(m_isolate);
765 if (!location->Set(context, v8InternalizedString("columnNumber"), v8::Intege r::New(m_isolate, columnNumber)).FromMaybe(false))
766 return v8::Null(m_isolate);
767 if (!markAsInternal(context, location, V8InternalValueType::kLocation))
768 return v8::Null(m_isolate);
769 return location;
770 }
719 771
720 bool V8DebuggerImpl::isPaused() 772 bool V8DebuggerImpl::isPaused()
721 { 773 {
722 return !m_pausedContext.IsEmpty(); 774 return !m_pausedContext.IsEmpty();
723 } 775 }
724 776
725 v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Contex t> context, v8::Local<v8::Script> script) 777 v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Contex t> context, v8::Local<v8::Script> script)
726 { 778 {
727 // TODO(dgozman): get rid of this check. 779 // TODO(dgozman): get rid of this check.
728 if (!m_client->isExecutionAllowed()) 780 if (!m_client->isExecutionAllowed())
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1181
1130 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 1182 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
1131 { 1183 {
1132 if (!contextGroupId) 1184 if (!contextGroupId)
1133 return nullptr; 1185 return nullptr;
1134 SessionMap::iterator iter = m_sessions.find(contextGroupId); 1186 SessionMap::iterator iter = m_sessions.find(contextGroupId);
1135 return iter == m_sessions.end() ? nullptr : iter->second; 1187 return iter == m_sessions.end() ? nullptr : iter->second;
1136 } 1188 }
1137 1189
1138 } // namespace blink 1190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698