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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin_natives.cc
diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc
index 80a03cf2747242edfd54c6d9a3d2b8fb1c7147f7..844e9dbe8cda9f1aa6ae688aa42213b822d05579 100644
--- a/runtime/bin/builtin_natives.cc
+++ b/runtime/bin/builtin_natives.cc
@@ -7,6 +7,7 @@
#include <string.h>
#include "include/dart_api.h"
+#include "include/dart_tools_api.h"
#include "platform/assert.h"
@@ -119,6 +120,9 @@ const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) {
}
+extern bool capture_stdout;
+
+
// Implementation of native functions which are used for some
// test/debug functionality in standalone dart mode.
void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) {
@@ -126,18 +130,19 @@ void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) {
uint8_t* chars = NULL;
Dart_Handle str = Dart_GetNativeArgument(args, 0);
Dart_Handle result = Dart_StringToUTF8(str, &chars, &length);
- if (Dart_IsError(result)) {
- // TODO(turnidge): Consider propagating some errors here. What if
- // an isolate gets interrupted by the embedder in the middle of
- // Dart_StringToUTF8? We need to make sure not to swallow the
- // interrupt.
- fprintf(stdout, "%s\n", Dart_GetError(result));
- } else {
- // Uses fwrite to support printing NUL bytes.
- fwrite(chars, 1, length, stdout);
- fputs("\n", stdout);
- }
+ if (Dart_IsError(result)) Dart_PropagateError(result);
+
+ // Uses fwrite to support printing NUL bytes.
+ fwrite(chars, 1, length, stdout);
+ fputs("\n", stdout);
fflush(stdout);
+ if (capture_stdout) {
+ // For now we report print output on the Stdout stream.
+ uint8_t newline[] = { '\n' };
+ Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
+ Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
+ newline, sizeof(newline));
+ }
}
} // namespace bin
« 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