Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 20105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20116 | 20116 |
| 20117 | 20117 |
| 20118 static intptr_t PrintOneStacktrace(Isolate* isolate, | 20118 static intptr_t PrintOneStacktrace(Isolate* isolate, |
| 20119 GrowableArray<char*>* frame_strings, | 20119 GrowableArray<char*>* frame_strings, |
| 20120 uword pc, | 20120 uword pc, |
| 20121 const Function& function, | 20121 const Function& function, |
| 20122 const Code& code, | 20122 const Code& code, |
| 20123 intptr_t frame_index) { | 20123 intptr_t frame_index) { |
| 20124 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; | 20124 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; |
| 20125 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n"; | 20125 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n"; |
| 20126 const char* kFormatNoLine = "#%-6d %s (%s)\n"; | |
| 20126 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 20127 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 20127 const Script& script = Script::Handle(isolate, function.script()); | 20128 const Script& script = Script::Handle(isolate, function.script()); |
| 20128 const String& function_name = | 20129 const String& function_name = |
| 20129 String::Handle(isolate, function.QualifiedUserVisibleName()); | 20130 String::Handle(isolate, function.QualifiedUserVisibleName()); |
| 20130 const String& url = String::Handle(isolate, script.url()); | 20131 const String& url = String::Handle(isolate, script.url()); |
| 20131 intptr_t line = -1; | 20132 intptr_t line = -1; |
| 20132 intptr_t column = -1; | 20133 intptr_t column = -1; |
| 20133 if (token_pos >= 0) { | 20134 if (token_pos >= 0) { |
|
Ivan Posva
2015/02/04 21:15:29
(token_pos > 0)
Florian Schneider
2015/02/05 09:55:43
Done.
| |
| 20134 if (script.HasSource()) { | 20135 if (script.HasSource()) { |
| 20135 script.GetTokenLocation(token_pos, &line, &column); | 20136 script.GetTokenLocation(token_pos, &line, &column); |
| 20136 } else { | 20137 } else { |
| 20137 script.GetTokenLocation(token_pos, &line, NULL); | 20138 script.GetTokenLocation(token_pos, &line, NULL); |
| 20138 } | 20139 } |
| 20139 } | 20140 } |
| 20140 intptr_t len = 0; | 20141 intptr_t len = 0; |
| 20141 char* chars = NULL; | 20142 char* chars = NULL; |
| 20142 if (column >= 0) { | 20143 if (column >= 0) { |
| 20143 len = OS::SNPrint(NULL, 0, kFormatWithCol, | 20144 len = OS::SNPrint(NULL, 0, kFormatWithCol, |
| 20144 frame_index, function_name.ToCString(), | 20145 frame_index, function_name.ToCString(), |
| 20145 url.ToCString(), line, column); | 20146 url.ToCString(), line, column); |
| 20146 chars = isolate->current_zone()->Alloc<char>(len + 1); | 20147 chars = isolate->current_zone()->Alloc<char>(len + 1); |
| 20147 OS::SNPrint(chars, (len + 1), kFormatWithCol, | 20148 OS::SNPrint(chars, (len + 1), kFormatWithCol, |
| 20148 frame_index, | 20149 frame_index, |
| 20149 function_name.ToCString(), | 20150 function_name.ToCString(), |
| 20150 url.ToCString(), line, column); | 20151 url.ToCString(), line, column); |
| 20151 } else { | 20152 } else if (line >= 0) { |
|
hausner
2015/02/04 18:34:13
I believe line is always >= 0 (> 0 actually). GetT
Florian Schneider
2015/02/05 09:55:42
Oh yes, forgot to check that token_pos > 0 above.
| |
| 20152 len = OS::SNPrint(NULL, 0, kFormatNoCol, | 20153 len = OS::SNPrint(NULL, 0, kFormatNoCol, |
| 20153 frame_index, function_name.ToCString(), | 20154 frame_index, function_name.ToCString(), |
| 20154 url.ToCString(), line); | 20155 url.ToCString(), line); |
| 20155 chars = isolate->current_zone()->Alloc<char>(len + 1); | 20156 chars = isolate->current_zone()->Alloc<char>(len + 1); |
| 20156 OS::SNPrint(chars, (len + 1), kFormatNoCol, | 20157 OS::SNPrint(chars, (len + 1), kFormatNoCol, |
| 20157 frame_index, function_name.ToCString(), | 20158 frame_index, function_name.ToCString(), |
| 20158 url.ToCString(), line); | 20159 url.ToCString(), line); |
| 20160 } else { | |
| 20161 len = OS::SNPrint(NULL, 0, kFormatNoLine, | |
| 20162 frame_index, function_name.ToCString(), | |
| 20163 url.ToCString()); | |
| 20164 chars = isolate->current_zone()->Alloc<char>(len + 1); | |
| 20165 OS::SNPrint(chars, (len + 1), kFormatNoLine, | |
| 20166 frame_index, function_name.ToCString(), | |
| 20167 url.ToCString()); | |
| 20159 } | 20168 } |
| 20160 frame_strings->Add(chars); | 20169 frame_strings->Add(chars); |
| 20161 return len; | 20170 return len; |
| 20162 } | 20171 } |
| 20163 | 20172 |
| 20164 | 20173 |
| 20165 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, | 20174 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, |
| 20166 intptr_t max_frames) const { | 20175 intptr_t max_frames) const { |
| 20167 Isolate* isolate = Isolate::Current(); | 20176 Isolate* isolate = Isolate::Current(); |
| 20168 Function& function = Function::Handle(); | 20177 Function& function = Function::Handle(); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20565 return tag_label.ToCString(); | 20574 return tag_label.ToCString(); |
| 20566 } | 20575 } |
| 20567 | 20576 |
| 20568 | 20577 |
| 20569 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20578 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20570 Instance::PrintJSONImpl(stream, ref); | 20579 Instance::PrintJSONImpl(stream, ref); |
| 20571 } | 20580 } |
| 20572 | 20581 |
| 20573 | 20582 |
| 20574 } // namespace dart | 20583 } // namespace dart |
| OLD | NEW |