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

Unified 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 side-by-side diff with in-line comments
Download patch
« pkg/stack_trace/test/frame_test.dart ('K') | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 27787)
+++ runtime/vm/object.cc (working copy)
@@ -14855,7 +14855,8 @@
const Function& function,
const Code& code,
intptr_t frame_index) {
- const char* kFormat = "#%-6d %s (%s:%d:%d)\n";
+ const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n";
+ const char* kFormatNoCol = "#%-6d %s (%s:%d)\n";
const intptr_t token_pos = code.GetTokenIndexOfPC(pc);
const Script& script = Script::Handle(isolate, function.script());
const String& function_name =
@@ -14864,19 +14865,32 @@
intptr_t line = -1;
intptr_t column = -1;
if (token_pos >= 0) {
- script.GetTokenLocation(token_pos, &line, &column);
+ if (script.HasSource()) {
+ script.GetTokenLocation(token_pos, &line, &column);
+ } else {
+ script.GetTokenLocation(token_pos, &line, NULL);
+ }
}
- intptr_t len = OS::SNPrint(NULL, 0, kFormat,
- frame_index,
- function_name.ToCString(),
- url.ToCString(),
- line, column);
- char* chars = isolate->current_zone()->Alloc<char>(len + 1);
- OS::SNPrint(chars, (len + 1), kFormat,
- frame_index,
- function_name.ToCString(),
- url.ToCString(),
- line, column);
+ intptr_t len = 0;
+ char* chars = NULL;
+ if (column >= 0) {
+ len = OS::SNPrint(NULL, 0, kFormatWithCol,
+ frame_index, function_name.ToCString(),
+ url.ToCString(), line, column);
+ chars = isolate->current_zone()->Alloc<char>(len + 1);
+ OS::SNPrint(chars, (len + 1), kFormatWithCol,
+ frame_index,
+ function_name.ToCString(),
+ url.ToCString(), line, column);
+ } else {
+ len = OS::SNPrint(NULL, 0, kFormatNoCol,
+ frame_index, function_name.ToCString(),
+ url.ToCString(), line);
+ chars = isolate->current_zone()->Alloc<char>(len + 1);
+ OS::SNPrint(chars, (len + 1), kFormatNoCol,
+ frame_index, function_name.ToCString(),
+ url.ToCString(), line);
+ }
frame_strings->Add(chars);
return len;
}
« 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