Chromium Code Reviews| Index: runtime/bin/file.cc |
| diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc |
| index 59f8300a266fb602b639043a82ebd4f2e0ed2980..d5b201320bde4dc31b6e6da90aae111d2cf38b8e 100644 |
| --- a/runtime/bin/file.cc |
| +++ b/runtime/bin/file.cc |
| @@ -10,12 +10,22 @@ |
| #include "bin/utils.h" |
| #include "include/dart_api.h" |
| +#include "include/dart_tools_api.h" |
| namespace dart { |
| namespace bin { |
| static const int kMSPerSecond = 1000; |
| +// Are we capturing output from either stdout or stderr for the VM Service? |
| +bool captureStdio = false; |
|
Cutch
2015/07/13 14:10:29
capture_stdio
turnidge
2015/07/13 22:50:36
Done.
|
| + |
| +// Are we capturing output from stdout for the VM service? |
| +bool captureStdout = false; |
|
Cutch
2015/07/13 14:10:29
capture_stdout
...
turnidge
2015/07/13 22:50:36
Done.
|
| + |
| +// Are we capturing output from stderr for the VM service? |
| +bool captureStderr = false; |
| + |
| // The file pointer has been passed into Dart as an intptr_t and it is safe |
| // to pull it out of Dart as a 64-bit integer, cast it to an intptr_t and |
| @@ -52,6 +62,18 @@ bool File::WriteFully(const void* buffer, int64_t num_bytes) { |
| remaining -= bytes_written; // Reduce the number of remaining bytes. |
| current_buffer += bytes_written; // Move the buffer forward. |
| } |
| + if (captureStdio) { |
| + intptr_t fd = GetFD(); |
| + if (fd == 1 && captureStdout) { |
|
Cutch
2015/07/13 14:10:29
(fd == STDOUT_FILENO) &&
turnidge
2015/07/13 22:50:36
Done. Also fixed existing usage of 0, 1, 2 in Fil
|
| + Dart_ServiceSendDataEvent("Stdout", "WriteEvent", |
| + reinterpret_cast<const uint8_t*>(buffer), |
| + num_bytes); |
| + } else if (fd == 2 && captureStderr) { |
|
Cutch
2015/07/13 14:10:29
(fd == STDERR_FILENO) &&
turnidge
2015/07/13 22:50:36
Done.
|
| + Dart_ServiceSendDataEvent("Stderr", "WriteEvent", |
| + reinterpret_cast<const uint8_t*>(buffer), |
| + num_bytes); |
| + } |
| + } |
| return true; |
| } |