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

Unified Diff: src/debug/debug-scopes.h

Issue 1264993002: Debugger: refactor ScopeIterator, FrameInspector and DebugEvaluate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: readd include Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/debug/debug-scopes.h
diff --git a/src/debug/debug-scopes.h b/src/debug/debug-scopes.h
new file mode 100644
index 0000000000000000000000000000000000000000..0247cc4bcecfd77bd60e85e1a7920d10f855639f
--- /dev/null
+++ b/src/debug/debug-scopes.h
@@ -0,0 +1,126 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_DEBUG_DEBUG_SCOPES_H_
+#define V8_DEBUG_DEBUG_SCOPES_H_
+
+#include "src/debug/debug-frames.h"
+#include "src/frames.h"
+
+namespace v8 {
+namespace internal {
+
+// Iterate over the actual scopes visible from a stack frame or from a closure.
+// The iteration proceeds from the innermost visible nested scope outwards.
+// All scopes are backed by an actual context except the local scope,
+// which is inserted "artificially" in the context chain.
+class ScopeIterator {
+ public:
+ enum ScopeType {
+ ScopeTypeGlobal = 0,
+ ScopeTypeLocal,
+ ScopeTypeWith,
+ ScopeTypeClosure,
+ ScopeTypeCatch,
+ ScopeTypeBlock,
+ ScopeTypeScript,
+ ScopeTypeModule
+ };
+
+ static const int kScopeDetailsTypeIndex = 0;
+ static const int kScopeDetailsObjectIndex = 1;
+ static const int kScopeDetailsSize = 2;
+
+ ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
+ bool ignore_nested_scopes = false);
+
+ ScopeIterator(Isolate* isolate, Handle<JSFunction> function);
+
+ MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails();
+
+ // More scopes?
+ bool Done() {
+ DCHECK(!failed_);
+ return context_.is_null();
+ }
+
+ bool Failed() { return failed_; }
+
+ // Move to the next scope.
+ void Next();
+
+ // Return the type of the current scope.
+ ScopeType Type();
+
+ // Return the JavaScript object with the content of the current scope.
+ MaybeHandle<JSObject> ScopeObject();
+
+ bool HasContext();
+
+ // Set variable value and return true on success.
+ bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value);
+
+ Handle<ScopeInfo> CurrentScopeInfo();
+
+ // Return the context for this scope. For the local context there might not
+ // be an actual context.
+ Handle<Context> CurrentContext();
+
+#ifdef DEBUG
+ // Debug print of the content of the current scope.
+ void DebugPrint();
+#endif
+
+ private:
+ Isolate* isolate_;
+ FrameInspector* const frame_inspector_;
+ Handle<Context> context_;
+ List<Handle<ScopeInfo> > nested_scope_chain_;
+ bool seen_script_scope_;
+ bool failed_;
+
+ inline JavaScriptFrame* GetFrame() {
+ return frame_inspector_->GetArgumentsFrame();
+ }
+
+ inline Handle<JSFunction> GetFunction() {
+ return Handle<JSFunction>(
+ JSFunction::cast(frame_inspector_->GetFunction()));
+ }
+
+ void RetrieveScopeChain(Scope* scope, Handle<SharedFunctionInfo> shared_info);
+
+ MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope();
+ MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope();
+ MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope();
+ Handle<JSObject> MaterializeClosure();
+ Handle<JSObject> MaterializeCatchScope();
+ Handle<JSObject> MaterializeBlockScope();
+
+ bool SetLocalVariableValue(Handle<String> variable_name,
+ Handle<Object> new_value);
+ bool SetBlockVariableValue(Handle<String> variable_name,
+ Handle<Object> new_value);
+ bool SetClosureVariableValue(Handle<String> variable_name,
+ Handle<Object> new_value);
+ bool SetScriptVariableValue(Handle<String> variable_name,
+ Handle<Object> new_value);
+ bool SetCatchVariableValue(Handle<String> variable_name,
+ Handle<Object> new_value);
+ bool SetContextLocalValue(Handle<ScopeInfo> scope_info,
+ Handle<Context> context,
+ Handle<String> variable_name,
+ Handle<Object> new_value);
+
+ void CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
+ Handle<Context> context,
+ Handle<JSObject> scope_object);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator);
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_DEBUG_DEBUG_SCOPES_H_
« no previous file with comments | « src/debug/debug-frames.cc ('k') | src/debug/debug-scopes.cc » ('j') | src/debug/debug-scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698