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

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

Issue 51793002: Add an API function to get a debugger stack trace from an error handle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 6054 matching lines...) Expand 10 before | Expand all | Expand 10 after
6065 } 6065 }
6066 static intptr_t NextFieldOffset() { 6066 static intptr_t NextFieldOffset() {
6067 // Indicates this class cannot be extended by dart code. 6067 // Indicates this class cannot be extended by dart code.
6068 return -kWordSize; 6068 return -kWordSize;
6069 } 6069 }
6070 6070
6071 friend class Class; 6071 friend class Class;
6072 }; 6072 };
6073 6073
6074 6074
6075 class ExceptionStackTrace;
rmacnak 2013/11/07 21:31:12 Move to top of file?
6076 class ExceptionStackFrame;
6077
6075 // Internal stacktrace object used in exceptions for printing stack traces. 6078 // Internal stacktrace object used in exceptions for printing stack traces.
6076 class Stacktrace : public Instance { 6079 class Stacktrace : public Instance {
6077 public: 6080 public:
6078 static const int kPreallocatedStackdepth = 10; 6081 static const int kPreallocatedStackdepth = 10;
6079 6082
6080 intptr_t Length() const; 6083 intptr_t Length() const;
6081 6084
6082 RawFunction* FunctionAtFrame(intptr_t frame_index) const; 6085 RawFunction* FunctionAtFrame(intptr_t frame_index) const;
6083 6086
6084 RawCode* CodeAtFrame(intptr_t frame_index) const; 6087 RawCode* CodeAtFrame(intptr_t frame_index) const;
(...skipping 10 matching lines...) Expand all
6095 static intptr_t InstanceSize() { 6098 static intptr_t InstanceSize() {
6096 return RoundedAllocationSize(sizeof(RawStacktrace)); 6099 return RoundedAllocationSize(sizeof(RawStacktrace));
6097 } 6100 }
6098 static RawStacktrace* New(const Array& code_array, 6101 static RawStacktrace* New(const Array& code_array,
6099 const Array& pc_offset_array, 6102 const Array& pc_offset_array,
6100 Heap::Space space = Heap::kNew); 6103 Heap::Space space = Heap::kNew);
6101 6104
6102 RawString* FullStacktrace() const; 6105 RawString* FullStacktrace() const;
6103 const char* ToCStringInternal(intptr_t* frame_index) const; 6106 const char* ToCStringInternal(intptr_t* frame_index) const;
6104 6107
6108 ExceptionStackTrace* BuildExceptionStackTrace() const;
rmacnak 2013/11/07 21:31:12 Ditto bad name.
6109
6105 private: 6110 private:
6106 void set_code_array(const Array& code_array) const; 6111 void set_code_array(const Array& code_array) const;
6107 void set_pc_offset_array(const Array& pc_offset_array) const; 6112 void set_pc_offset_array(const Array& pc_offset_array) const;
6108 void set_catch_code_array(const Array& code_array) const; 6113 void set_catch_code_array(const Array& code_array) const;
6109 void set_catch_pc_offset_array(const Array& pc_offset_array) const; 6114 void set_catch_pc_offset_array(const Array& pc_offset_array) const;
6110 bool expand_inlined() const; 6115 bool expand_inlined() const;
6111 6116
6112 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); 6117 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance);
6113 friend class Class; 6118 friend class Class;
6114 }; 6119 };
6115 6120
6116 6121
6122 // Constructed and handed out by the API to avoid repeatedly iterating through
6123 // frames to expand inlined frames and skip invisible frames.
6124 // Cf. DebuggerStackTrace.
6125 class ExceptionStackTrace : public ZoneAllocated {
6126 public:
6127 explicit ExceptionStackTrace(int capacity)
6128 : frames_(capacity) { }
6129
6130 intptr_t Length() const { return frames_.length(); }
6131
6132 ExceptionStackFrame* FrameAt(int i) const { return frames_[i]; }
6133
6134 private:
6135 void AddFrame(ExceptionStackFrame* frame) { frames_.Add(frame); }
6136 ZoneGrowableArray<ExceptionStackFrame*> frames_;
6137
6138 friend class Stacktrace;
6139 friend class Debugger;
6140 DISALLOW_COPY_AND_ASSIGN(ExceptionStackTrace);
6141 };
6142
6143
6144 class ExceptionStackFrame : public ZoneAllocated {
6145 public:
6146 explicit ExceptionStackFrame(
6147 String& function_name,
6148 String& script_uri,
6149 intptr_t line_number,
6150 intptr_t column_number)
6151 : function_name_(String::ZoneHandle(function_name.raw())),
6152 script_uri_(String::ZoneHandle(script_uri.raw())),
6153 line_number_(line_number),
6154 column_number_(column_number) { }
6155
6156 RawString* function_name() const { return function_name_.raw(); }
6157 RawString* script_uri() const { return script_uri_.raw(); }
6158 intptr_t line_number() const { return line_number_; }
6159 intptr_t column_number() const { return column_number_; }
6160
6161 private:
6162 const String& function_name_;
6163 const String& script_uri_;
6164 const intptr_t line_number_;
6165 const intptr_t column_number_;
6166
6167 friend class Stacktrace;
6168 DISALLOW_COPY_AND_ASSIGN(ExceptionStackFrame);
6169 };
6170
6171
6117 // Internal JavaScript regular expression object. 6172 // Internal JavaScript regular expression object.
6118 class JSRegExp : public Instance { 6173 class JSRegExp : public Instance {
6119 public: 6174 public:
6120 // Meaning of RegExType: 6175 // Meaning of RegExType:
6121 // kUninitialized: the type of th regexp has not been initialized yet. 6176 // kUninitialized: the type of th regexp has not been initialized yet.
6122 // kSimple: A simple pattern to match against, using string indexOf operation. 6177 // kSimple: A simple pattern to match against, using string indexOf operation.
6123 // kComplex: A complex pattern to match. 6178 // kComplex: A complex pattern to match.
6124 enum RegExType { 6179 enum RegExType {
6125 kUnitialized = 0, 6180 kUnitialized = 0,
6126 kSimple, 6181 kSimple,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6381 6436
6382 6437
6383 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6438 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6384 intptr_t index) { 6439 intptr_t index) {
6385 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6440 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6386 } 6441 }
6387 6442
6388 } // namespace dart 6443 } // namespace dart
6389 6444
6390 #endif // VM_OBJECT_H_ 6445 #endif // VM_OBJECT_H_
OLDNEW
« runtime/vm/debugger.h ('K') | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698