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

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

Issue 1232193003: Provide stdout and stderr output in the Observatory debugger. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: before commit Created 5 years, 5 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
« no previous file with comments | « no previous file | runtime/bin/file.cc » ('j') | 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_tools_api.h"
10 11
11 #include "platform/assert.h" 12 #include "platform/assert.h"
12 13
13 #include "bin/builtin.h" 14 #include "bin/builtin.h"
14 #include "bin/dartutils.h" 15 #include "bin/dartutils.h"
15 #include "bin/io_natives.h" 16 #include "bin/io_natives.h"
16 #include "bin/platform.h" 17 #include "bin/platform.h"
17 18
18 namespace dart { 19 namespace dart {
19 namespace bin { 20 namespace bin {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 for (int i = 0; i < num_entries; i++) { 113 for (int i = 0; i < num_entries; i++) {
113 struct NativeEntries* entry = &(BuiltinEntries[i]); 114 struct NativeEntries* entry = &(BuiltinEntries[i]);
114 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { 115 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) {
115 return reinterpret_cast<const uint8_t*>(entry->name_); 116 return reinterpret_cast<const uint8_t*>(entry->name_);
116 } 117 }
117 } 118 }
118 return IONativeSymbol(nf); 119 return IONativeSymbol(nf);
119 } 120 }
120 121
121 122
123 extern bool capture_stdout;
124
125
122 // Implementation of native functions which are used for some 126 // Implementation of native functions which are used for some
123 // test/debug functionality in standalone dart mode. 127 // test/debug functionality in standalone dart mode.
124 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) { 128 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) {
125 intptr_t length = 0; 129 intptr_t length = 0;
126 uint8_t* chars = NULL; 130 uint8_t* chars = NULL;
127 Dart_Handle str = Dart_GetNativeArgument(args, 0); 131 Dart_Handle str = Dart_GetNativeArgument(args, 0);
128 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); 132 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length);
129 if (Dart_IsError(result)) { 133 if (Dart_IsError(result)) Dart_PropagateError(result);
130 // TODO(turnidge): Consider propagating some errors here. What if 134
131 // an isolate gets interrupted by the embedder in the middle of 135 // Uses fwrite to support printing NUL bytes.
132 // Dart_StringToUTF8? We need to make sure not to swallow the 136 fwrite(chars, 1, length, stdout);
133 // interrupt. 137 fputs("\n", stdout);
134 fprintf(stdout, "%s\n", Dart_GetError(result)); 138 fflush(stdout);
135 } else { 139 if (capture_stdout) {
136 // Uses fwrite to support printing NUL bytes. 140 // For now we report print output on the Stdout stream.
137 fwrite(chars, 1, length, stdout); 141 uint8_t newline[] = { '\n' };
138 fputs("\n", stdout); 142 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
143 Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
144 newline, sizeof(newline));
139 } 145 }
140 fflush(stdout);
141 } 146 }
142 147
143 } // namespace bin 148 } // namespace bin
144 } // namespace dart 149 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698