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

Side by Side Diff: runtime/vm/debugger.h

Issue 8992020: First part of inspecting local variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_DEBUGGER_H_ 5 #ifndef VM_DEBUGGER_H_
6 #define VM_DEBUGGER_H_ 6 #define VM_DEBUGGER_H_
7 7
8 #include "vm/object.h" 8 #include "vm/object.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 class Breakpoint; 12 class Breakpoint;
13 class Isolate; 13 class Isolate;
14 class ObjectPointerVisitor; 14 class ObjectPointerVisitor;
15 class ActiveVariables;
15 16
16 17
17 // Breakpoint represents a location in Dart source and the corresponding 18 // Breakpoint represents a location in Dart source and the corresponding
18 // address in compiled code. 19 // address in compiled code.
19 class Breakpoint { 20 class Breakpoint {
20 public: 21 public:
21 Breakpoint(const Function& func, intptr_t pc_desc_index); 22 Breakpoint(const Function& func, intptr_t pc_desc_index);
22 23
23 RawFunction* function() const { return function_; } 24 RawFunction* function() const { return function_; }
24 uword pc() const { return pc_; } 25 uword pc() const { return pc_; }
(...skipping 29 matching lines...) Expand all
54 uword pc() const { return pc_; } 55 uword pc() const { return pc_; }
55 56
56 RawFunction* DartFunction(); 57 RawFunction* DartFunction();
57 RawString* QualifiedFunctionName(); 58 RawString* QualifiedFunctionName();
58 RawString* SourceUrl(); 59 RawString* SourceUrl();
59 RawScript* SourceScript(); 60 RawScript* SourceScript();
60 intptr_t TokenIndex(); 61 intptr_t TokenIndex();
61 intptr_t LineNumber(); 62 intptr_t LineNumber();
62 const char* ToCString(); 63 const char* ToCString();
63 64
64 // Returns an array of String values containing variable names 65 ActiveVariables* LocalVariables();
65 // in this activation frame.
66 RawArray* Variables();
67 66
68 // Returns the value of the given variable in the context of the 67 // Returns the value of the given variable in the context of the
69 // activation frame. 68 // activation frame.
70 RawInstance* Value(const String& variable_name); 69 RawInstance* Value(const String& variable_name);
71 70
72 private: 71 private:
73 uword pc_; 72 uword pc_;
74 RawFunction* function_; 73 RawFunction* function_;
siva 2011/12/20 19:11:26 How is this object pointer traversed during GC?
hausner 2011/12/20 21:43:55 Good point. Changed it into a handle.
75 intptr_t token_index_; 74 intptr_t token_index_;
76 intptr_t line_number_; 75 intptr_t line_number_;
76 ActiveVariables* locals_;
77 77
78 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); 78 DISALLOW_COPY_AND_ASSIGN(ActivationFrame);
79 }; 79 };
80 80
81 81
82 // Array of function activations on the call stack. 82 // Array of function activations on the call stack.
83 class StackTrace : public ZoneAllocated { 83 class StackTrace : public ZoneAllocated {
84 public: 84 public:
85 explicit StackTrace(int capacity) : trace_(capacity) { } 85 explicit StackTrace(int capacity) : trace_(capacity) { }
86 86
87 intptr_t Length() const { return trace_.length(); } 87 intptr_t Length() const { return trace_.length(); }
88 88
89 ActivationFrame* ActivationFrameAt(int i) const { 89 ActivationFrame* ActivationFrameAt(int i) const {
90 ASSERT(i < trace_.length()); 90 ASSERT(i < trace_.length());
91 return trace_[i]; 91 return trace_[i];
92 } 92 }
93 private: 93 private:
94 void AddActivation(ActivationFrame* frame); 94 void AddActivation(ActivationFrame* frame);
95 ZoneGrowableArray<ActivationFrame*> trace_; 95 ZoneGrowableArray<ActivationFrame*> trace_;
96 96
97 friend class Debugger; 97 friend class Debugger;
98 DISALLOW_COPY_AND_ASSIGN(StackTrace); 98 DISALLOW_COPY_AND_ASSIGN(StackTrace);
99 }; 99 };
100 100
101 101
102 class ActiveVariables : public ZoneAllocated {
103 public:
104 ActiveVariables(const Function& function, intptr_t token_pos);
105
106 intptr_t Length() const { return desc_indices_.length(); }
107
108 void VariableAt(intptr_t i,
109 String* name,
110 intptr_t* token_pos,
111 intptr_t* end_pos,
112 Instance* value) const;
113 private:
114 LocalVarDescriptors* descriptors_;
115 ZoneGrowableArray<intptr_t> desc_indices_;
116 DISALLOW_COPY_AND_ASSIGN(ActiveVariables);
117 };
118
119
102 typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack); 120 typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack);
103 121
104 122
105 class Debugger { 123 class Debugger {
106 public: 124 public:
107 Debugger(); 125 Debugger();
108 126
109 void Initialize(Isolate* isolate); 127 void Initialize(Isolate* isolate);
110 bool IsActive(); 128 bool IsActive();
111 129
(...skipping 23 matching lines...) Expand all
135 bool initialized_; 153 bool initialized_;
136 BreakpointHandler* bp_handler_; 154 BreakpointHandler* bp_handler_;
137 Breakpoint* breakpoints_; 155 Breakpoint* breakpoints_;
138 DISALLOW_COPY_AND_ASSIGN(Debugger); 156 DISALLOW_COPY_AND_ASSIGN(Debugger);
139 }; 157 };
140 158
141 159
142 } // namespace dart 160 } // namespace dart
143 161
144 #endif // VM_DEBUGGER_H_ 162 #endif // VM_DEBUGGER_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/debugger.cc » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698