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

Side by Side Diff: runtime/bin/builtin_natives.cc

Issue 11361032: Fix error in debug printing from the Dart executable, introduced in r14357. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | 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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 } 97 }
98 return NULL; 98 return NULL;
99 } 99 }
100 100
101 101
102 // Implementation of native functions which are used for some 102 // Implementation of native functions which are used for some
103 // test/debug functionality in standalone dart mode. 103 // test/debug functionality in standalone dart mode.
104 104
105 void Builtin::PrintString(FILE* out, Dart_Handle str) { 105 void Builtin::PrintString(FILE* out, Dart_Handle str) {
106 intptr_t length = 0; 106 const char* chars = NULL;
107 Dart_Handle result = Dart_StringLength(str, &length); 107
108 DART_CHECK_VALID(result); 108 Dart_Handle result = Dart_StringToCString(str, &chars);
109 uint8_t* chars = reinterpret_cast<uint8_t*>(malloc(length * sizeof(uint8_t)));
110 result = Dart_StringToUTF8(str, chars, &length);
111 if (Dart_IsError(result)) { 109 if (Dart_IsError(result)) {
112 // TODO(turnidge): Consider propagating some errors here. What if 110 // TODO(turnidge): Consider propagating some errors here. What if
113 // an isolate gets interrupted by the embedder in the middle of 111 // an isolate gets interrupted by the embedder in the middle of
114 // Dart_StringToBytes? We need to make sure not to swallow the 112 // Dart_StringToBytes? We need to make sure not to swallow the
115 // interrupt. 113 // interrupt.
116 fputs(Dart_GetError(result), out); 114 fputs(Dart_GetError(result), out);
117 } else { 115 } else {
116 intptr_t length = strlen(chars);
118 fwrite(chars, sizeof(*chars), length, out); 117 fwrite(chars, sizeof(*chars), length, out);
119 } 118 }
120 fputc('\n', out); 119 fputc('\n', out);
121 fflush(out); 120 fflush(out);
122 free(chars);
123 } 121 }
124 122
125 123
126 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { 124 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) {
127 Dart_EnterScope(); 125 Dart_EnterScope();
128 Builtin::PrintString(stdout, Dart_GetNativeArgument(args, 0)); 126 Builtin::PrintString(stdout, Dart_GetNativeArgument(args, 0));
129 Dart_ExitScope(); 127 Dart_ExitScope();
130 } 128 }
131 129
132 130
133 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) { 131 void FUNCTION_NAME(Exit)(Dart_NativeArguments args) {
134 Dart_EnterScope(); 132 Dart_EnterScope();
135 int64_t status = 0; 133 int64_t status = 0;
136 // Ignore result if passing invalid argument and just exit 0. 134 // Ignore result if passing invalid argument and just exit 0.
137 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); 135 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status);
138 Dart_ExitScope(); 136 Dart_ExitScope();
139 exit(status); 137 exit(status);
140 } 138 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698