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

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

Issue 23850014: - Use simplified token location call where appropriate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« pkg/stack_trace/test/frame_test.dart ('K') | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 14837 matching lines...) Expand 10 before | Expand all | Expand 10 after
14848 JSONObject jsobj(stream); 14848 JSONObject jsobj(stream);
14849 } 14849 }
14850 14850
14851 14851
14852 static intptr_t PrintOneStacktrace(Isolate* isolate, 14852 static intptr_t PrintOneStacktrace(Isolate* isolate,
14853 GrowableArray<char*>* frame_strings, 14853 GrowableArray<char*>* frame_strings,
14854 uword pc, 14854 uword pc,
14855 const Function& function, 14855 const Function& function,
14856 const Code& code, 14856 const Code& code,
14857 intptr_t frame_index) { 14857 intptr_t frame_index) {
14858 const char* kFormat = "#%-6d %s (%s:%d:%d)\n"; 14858 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n";
14859 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n";
14859 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); 14860 const intptr_t token_pos = code.GetTokenIndexOfPC(pc);
14860 const Script& script = Script::Handle(isolate, function.script()); 14861 const Script& script = Script::Handle(isolate, function.script());
14861 const String& function_name = 14862 const String& function_name =
14862 String::Handle(isolate, function.QualifiedUserVisibleName()); 14863 String::Handle(isolate, function.QualifiedUserVisibleName());
14863 const String& url = String::Handle(isolate, script.url()); 14864 const String& url = String::Handle(isolate, script.url());
14864 intptr_t line = -1; 14865 intptr_t line = -1;
14865 intptr_t column = -1; 14866 intptr_t column = -1;
14866 if (token_pos >= 0) { 14867 if (token_pos >= 0) {
14867 script.GetTokenLocation(token_pos, &line, &column); 14868 if (script.HasSource()) {
14869 script.GetTokenLocation(token_pos, &line, &column);
14870 } else {
14871 script.GetTokenLocation(token_pos, &line, NULL);
14872 }
14868 } 14873 }
14869 intptr_t len = OS::SNPrint(NULL, 0, kFormat, 14874 intptr_t len = 0;
14870 frame_index, 14875 char* chars = NULL;
14871 function_name.ToCString(), 14876 if (column >= 0) {
14872 url.ToCString(), 14877 len = OS::SNPrint(NULL, 0, kFormatWithCol,
14873 line, column); 14878 frame_index, function_name.ToCString(),
14874 char* chars = isolate->current_zone()->Alloc<char>(len + 1); 14879 url.ToCString(), line, column);
14875 OS::SNPrint(chars, (len + 1), kFormat, 14880 chars = isolate->current_zone()->Alloc<char>(len + 1);
14876 frame_index, 14881 OS::SNPrint(chars, (len + 1), kFormatWithCol,
14877 function_name.ToCString(), 14882 frame_index,
14878 url.ToCString(), 14883 function_name.ToCString(),
14879 line, column); 14884 url.ToCString(), line, column);
14885 } else {
14886 len = OS::SNPrint(NULL, 0, kFormatNoCol,
14887 frame_index, function_name.ToCString(),
14888 url.ToCString(), line);
14889 chars = isolate->current_zone()->Alloc<char>(len + 1);
14890 OS::SNPrint(chars, (len + 1), kFormatNoCol,
14891 frame_index, function_name.ToCString(),
14892 url.ToCString(), line);
14893 }
14880 frame_strings->Add(chars); 14894 frame_strings->Add(chars);
14881 return len; 14895 return len;
14882 } 14896 }
14883 14897
14884 14898
14885 const char* Stacktrace::ToCStringInternal(intptr_t frame_index) const { 14899 const char* Stacktrace::ToCStringInternal(intptr_t frame_index) const {
14886 Isolate* isolate = Isolate::Current(); 14900 Isolate* isolate = Isolate::Current();
14887 Function& function = Function::Handle(); 14901 Function& function = Function::Handle();
14888 Code& code = Code::Handle(); 14902 Code& code = Code::Handle();
14889 // Iterate through the stack frames and create C string description 14903 // Iterate through the stack frames and create C string description
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
15122 return "_MirrorReference"; 15136 return "_MirrorReference";
15123 } 15137 }
15124 15138
15125 15139
15126 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15140 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15127 JSONObject jsobj(stream); 15141 JSONObject jsobj(stream);
15128 } 15142 }
15129 15143
15130 15144
15131 } // namespace dart 15145 } // namespace dart
OLDNEW
« pkg/stack_trace/test/frame_test.dart ('K') | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698