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

Unified Diff: runtime/vm/debugger.h

Issue 8775060: Debugger step 2 (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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/debugger.h
===================================================================
--- runtime/vm/debugger.h (revision 1987)
+++ runtime/vm/debugger.h (working copy)
@@ -13,12 +13,102 @@
class Isolate;
class ObjectPointerVisitor;
+
+// Breakpoint represents a location in Dart source and the corresponding
+// address in compiled code.
+class Breakpoint {
+ public:
+ Breakpoint(const Function& func, intptr_t pc_desc_index);
+
+ RawFunction* function() const { return function_; }
+ uword pc() const { return pc_; }
+
+ RawScript* SourceCode();
siva 2011/12/05 19:21:44 const?
hausner 2011/12/05 21:11:23 Can't be const because it's not initialized in the
+ RawString* SourceUrl();
siva 2011/12/05 19:21:44 const?
hausner 2011/12/05 21:11:23 ditto.
+ intptr_t LineNumber();
+
+ private:
+ void VisitObjectPointers(ObjectPointerVisitor* visitor);
+
+ void set_next(Breakpoint* value) { next_ = value; }
+ Breakpoint* next() const { return this->next_; }
+
+ RawFunction* function_;
+ intptr_t pc_desc_index_;
+ intptr_t token_index_;
+ uword pc_;
+ intptr_t line_number_;
+ Breakpoint* next_;
+
+ friend class Debugger;
+ DISALLOW_COPY_AND_ASSIGN(Breakpoint);
+};
+
+
+// ActivationFrame represents one dart function activation frame
+// on the call stack.
+class ActivationFrame : public ZoneAllocated {
+ public:
+ explicit ActivationFrame(uword pc);
+
+ uword pc() const { return pc_; }
+
+ RawFunction* DartFunction();
+ RawString* SourceUrl();
+ RawScript* SourceScript();
+ intptr_t TokenIndex();
siva 2011/12/05 19:21:44 above 4 methods can be 'const'?
hausner 2011/12/05 21:11:23 Unfortunately not. DartFunction() assigns to a fie
+ intptr_t LineNumber();
+ char* ToCString();
siva 2011/12/05 19:21:44 'const'?
hausner 2011/12/05 21:11:23 const char* as the return type? Yes. Done. The fun
+
+ // Returns an array of String values containing variable names
+ // in this activation frame.
+ RawArray* Variables();
+
+ // Returns the value of the given variable in the context of the
+ // activation frame.
+ RawInstance* Value(const String& variable_name);
+
+ private:
+ uword pc_;
+ RawFunction* function_;
+ intptr_t token_index_;
+ intptr_t line_number_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivationFrame);
+};
+
+
+// Array of function activations on the call stack.
+class StackTrace : public ZoneAllocated {
+ public:
+ explicit StackTrace(int capacity) : trace_(capacity) { }
+
+ intptr_t Length() const { return trace_.length(); }
+
+ ActivationFrame* ActivationFrameAt(int i) const {
+ ASSERT(i < trace_.length());
+ return trace_[i];
+ }
+ private:
+ void AddActivation(ActivationFrame* frame);
+ ZoneGrowableArray<ActivationFrame*> trace_;
+
+ friend class Debugger;
+ DISALLOW_COPY_AND_ASSIGN(StackTrace);
+};
+
+
+typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack);
+
+
class Debugger {
public:
Debugger();
void Initialize(Isolate* isolate);
+ void SetBreakpointHandler(BreakpointHandler* handler);
+
// Set breakpoint at closest location to function entry.
void SetBreakpointAtEntry(const String& class_name,
const String& function_name);
@@ -28,10 +118,14 @@
// Returns NULL if no breakpoint exists for the given address.
Breakpoint* GetBreakpoint(uword breakpoint_address);
+ // Called from Runtime when a breakpoint in Dart code is reached.
+ void BreakpointCallback();
+
private:
void AddBreakpoint(Breakpoint* bpt);
bool initialized_;
+ BreakpointHandler* bp_handler_;
Breakpoint* breakpoints_;
DISALLOW_COPY_AND_ASSIGN(Debugger);
};

Powered by Google App Engine
This is Rietveld 408576698