[vm, gardening] Move --trace-service output to stderr.

Prevents interleaving with output on stdout that is parsed. E.g.,

R=cbernaschina@google.com

FormatException: Invalid character (at character 24)
http://127.0.0.1:59909/[+400ms] Isolate kernel-service.dart.snapshot$main-5...
Review-Url: https://codereview.chromium.org/2998713002 .
This commit is contained in:
Ryan Macnak 2017-08-09 13:06:11 -07:00
parent 8a426f3d67
commit 8879e6a2c0
6 changed files with 47 additions and 45 deletions

View file

@ -83,8 +83,8 @@ class RegisterRunningIsolatesVisitor : public IsolateVisitor {
const Object& r =
Object::Handle(DartEntry::InvokeFunction(register_function_, args));
if (FLAG_trace_service) {
OS::Print("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), port_id);
OS::PrintErr("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), port_id);
}
ASSERT(!r.IsError());
}
@ -135,7 +135,7 @@ DEFINE_NATIVE_ENTRY(VMService_SendObjectRootServiceMessage, 1) {
DEFINE_NATIVE_ENTRY(VMService_OnStart, 0) {
if (FLAG_trace_service) {
OS::Print("vm-service: Booting dart:vmservice library.\n");
OS::PrintErr("vm-service: Booting dart:vmservice library.\n");
}
// Boot the dart:vmservice library.
ServiceIsolate::BootVmServiceLibrary();
@ -146,7 +146,7 @@ DEFINE_NATIVE_ENTRY(VMService_OnStart, 0) {
// Register running isolates with service.
RegisterRunningIsolatesVisitor register_isolates(thread);
if (FLAG_trace_service) {
OS::Print("vm-service: Registering running isolates.\n");
OS::PrintErr("vm-service: Registering running isolates.\n");
}
Isolate::VisitIsolates(&register_isolates);
#endif
@ -155,10 +155,10 @@ DEFINE_NATIVE_ENTRY(VMService_OnStart, 0) {
DEFINE_NATIVE_ENTRY(VMService_OnExit, 0) {
if (FLAG_trace_service) {
OS::Print("vm-service: processed exit message.\n");
OS::PrintErr("vm-service: processed exit message.\n");
MessageHandler* message_handler = isolate->message_handler();
OS::Print("vm-service: live ports = %" Pd "\n",
message_handler->live_ports());
OS::PrintErr("vm-service: live ports = %" Pd "\n",
message_handler->live_ports());
}
return Object::null();
}

View file

@ -587,8 +587,8 @@ void IsolateMessageHandler::NotifyPauseOnStart() {
ServiceEvent pause_event(I, ServiceEvent::kPauseStart);
Service::HandleEvent(&pause_event);
} else if (FLAG_trace_service) {
OS::Print("vm-service: Dropping event of type PauseStart (%s)\n",
I->name());
OS::PrintErr("vm-service: Dropping event of type PauseStart (%s)\n",
I->name());
}
}
@ -603,7 +603,8 @@ void IsolateMessageHandler::NotifyPauseOnExit() {
ServiceEvent pause_event(I, ServiceEvent::kPauseExit);
Service::HandleEvent(&pause_event);
} else if (FLAG_trace_service) {
OS::Print("vm-service: Dropping event of type PauseExit (%s)\n", I->name());
OS::PrintErr("vm-service: Dropping event of type PauseExit (%s)\n",
I->name());
}
}
#endif // !PRODUCT
@ -2161,13 +2162,13 @@ RawObject* Isolate::InvokePendingServiceExtensionCalls() {
arguments.SetAt(kPendingEntrySize, Bool::Get(FLAG_trace_service));
if (FLAG_trace_service) {
OS::Print("[+%" Pd64 "ms] Isolate %s invoking _runExtension for %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
OS::PrintErr("[+%" Pd64 "ms] Isolate %s invoking _runExtension for %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
}
result = DartEntry::InvokeFunction(run_extension, arguments);
if (FLAG_trace_service) {
OS::Print("[+%" Pd64 "ms] Isolate %s : _runExtension complete for %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
OS::PrintErr("[+%" Pd64 "ms] Isolate %s _runExtension complete for %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
}
// Propagate the error.
if (result.IsError()) {
@ -2203,8 +2204,9 @@ void Isolate::AppendServiceExtensionCall(const Instance& closure,
const Instance& reply_port,
const Instance& id) {
if (FLAG_trace_service) {
OS::Print("[+%" Pd64 "ms] Isolate %s ENQUEUING request for extension %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
OS::PrintErr("[+%" Pd64
"ms] Isolate %s ENQUEUING request for extension %s\n",
Dart::UptimeMillis(), name(), method_name.ToCString());
}
GrowableObjectArray& calls =
GrowableObjectArray::Handle(pending_service_extension_calls());

View file

@ -124,8 +124,8 @@ void JSONStream::Setup(Zone* zone,
ASSERT(isolate != NULL);
const char* isolate_name = isolate->name();
setup_time_micros_ = OS::GetCurrentTimeMicros();
OS::Print("[+%" Pd64 "ms] Isolate %s processing service request %s\n",
Dart::UptimeMillis(), isolate_name, method_);
OS::PrintErr("[+%" Pd64 "ms] Isolate %s processing service request %s\n",
Dart::UptimeMillis(), isolate_name, method_);
}
buffer_.Printf("{\"jsonrpc\":\"2.0\", \"result\":");
}
@ -282,15 +282,15 @@ void JSONStream::PostReply() {
const char* isolate_name = isolate->name();
int64_t total_time = OS::GetCurrentTimeMicros() - setup_time_micros_;
if (result) {
OS::Print("[+%" Pd64
"ms] Isolate %s processed service request %s "
"(%" Pd64 "us)\n",
Dart::UptimeMillis(), isolate_name, method_, total_time);
OS::PrintErr("[+%" Pd64
"ms] Isolate %s processed service request %s "
"(%" Pd64 "us)\n",
Dart::UptimeMillis(), isolate_name, method_, total_time);
} else {
OS::Print("[+%" Pd64
"ms] Isolate %s processed service request %s "
"(%" Pd64 "us) FAILED\n",
Dart::UptimeMillis(), isolate_name, method_, total_time);
OS::PrintErr("[+%" Pd64
"ms] Isolate %s processed service request %s "
"(%" Pd64 "us) FAILED\n",
Dart::UptimeMillis(), isolate_name, method_, total_time);
}
}
}

View file

@ -130,7 +130,7 @@ static StreamInfo* streams_[] = {
bool Service::ListenStream(const char* stream_id) {
if (FLAG_trace_service) {
OS::Print("vm-service: starting stream '%s'\n", stream_id);
OS::PrintErr("vm-service: starting stream '%s'\n", stream_id);
}
intptr_t num_streams = sizeof(streams_) / sizeof(streams_[0]);
for (intptr_t i = 0; i < num_streams; i++) {
@ -149,7 +149,7 @@ bool Service::ListenStream(const char* stream_id) {
void Service::CancelStream(const char* stream_id) {
if (FLAG_trace_service) {
OS::Print("vm-service: stopping stream '%s'\n", stream_id);
OS::PrintErr("vm-service: stopping stream '%s'\n", stream_id);
}
intptr_t num_streams = sizeof(streams_) / sizeof(streams_[0]);
for (intptr_t i = 0; i < num_streams; i++) {
@ -912,7 +912,7 @@ void Service::SendEvent(const char* stream_id,
ASSERT(!ServiceIsolate::IsServiceIsolateDescendant(isolate));
if (FLAG_trace_service) {
OS::Print(
OS::PrintErr(
"vm-service: Pushing ServiceEvent(isolate='%s', kind='%s',"
" len=%" Pd ") to stream %s\n",
isolate->name(), event_type, bytes_length, stream_id);
@ -1097,7 +1097,7 @@ void Service::PostEvent(Isolate* isolate,
if (isolate != NULL) {
isolate_name = isolate->name();
}
OS::Print(
OS::PrintErr(
"vm-service: Pushing ServiceEvent(isolate='%s', kind='%s') "
"to stream %s\n",
isolate_name, kind, stream_id);

View file

@ -199,8 +199,8 @@ bool ServiceIsolate::SendIsolateStartupMessage() {
writer.WriteMessage(list);
intptr_t len = writer.BytesWritten();
if (FLAG_trace_service) {
OS::Print("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), Dart_GetMainPortId());
OS::PrintErr("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), Dart_GetMainPortId());
}
return PortMap::PostMessage(
new Message(port_, data, len, Message::kNormalPriority));
@ -227,8 +227,8 @@ bool ServiceIsolate::SendIsolateShutdownMessage() {
writer.WriteMessage(list);
intptr_t len = writer.BytesWritten();
if (FLAG_trace_service) {
OS::Print("vm-service: Isolate %s %" Pd64 " deregistered.\n",
name.ToCString(), Dart_GetMainPortId());
OS::PrintErr("vm-service: Isolate %s %" Pd64 " deregistered.\n",
name.ToCString(), Dart_GetMainPortId());
}
return PortMap::PostMessage(
new Message(port_, data, len, Message::kNormalPriority));
@ -242,7 +242,7 @@ void ServiceIsolate::SendServiceExitMessage() {
return;
}
if (FLAG_trace_service) {
OS::Print("vm-service: sending service exit message.\n");
OS::PrintErr("vm-service: sending service exit message.\n");
}
PortMap::PostMessage(new Message(port_, exit_message_, exit_message_length_,
Message::kNormalPriority));
@ -366,7 +366,7 @@ class RunServiceTask : public ThreadPool::Task {
protected:
static void ShutdownIsolate(uword parameter) {
if (FLAG_trace_service) {
OS::Print("vm-service: ShutdownIsolate\n");
OS::PrintErr("vm-service: ShutdownIsolate\n");
}
Isolate* I = reinterpret_cast<Isolate*>(parameter);
ASSERT(ServiceIsolate::IsServiceIsolate(I));
@ -396,7 +396,7 @@ class RunServiceTask : public ThreadPool::Task {
// Shut the isolate down.
Dart::ShutdownIsolate(I);
if (FLAG_trace_service) {
OS::Print("vm-service: Shutdown.\n");
OS::PrintErr("vm-service: Shutdown.\n");
}
ServiceIsolate::FinishedExiting();
}
@ -411,7 +411,7 @@ class RunServiceTask : public ThreadPool::Task {
Library::Handle(Z, I->object_store()->root_library());
if (root_library.IsNull()) {
if (FLAG_trace_service) {
OS::Print("vm-service: Embedder did not install a script.");
OS::PrintErr("vm-service: Embedder did not install a script.");
}
// Service isolate is not supported by embedder.
return false;
@ -424,7 +424,7 @@ class RunServiceTask : public ThreadPool::Task {
if (entry.IsNull()) {
// Service isolate is not supported by embedder.
if (FLAG_trace_service) {
OS::Print("vm-service: Embedder did not provide a main function.");
OS::PrintErr("vm-service: Embedder did not provide a main function.");
}
return false;
}
@ -436,8 +436,8 @@ class RunServiceTask : public ThreadPool::Task {
// Service isolate did not initialize properly.
if (FLAG_trace_service) {
const Error& error = Error::Cast(result);
OS::Print("vm-service: Calling main resulted in an error: %s",
error.ToErrorCString());
OS::PrintErr("vm-service: Calling main resulted in an error: %s",
error.ToErrorCString());
}
if (result.IsUnwindError()) {
return true;

View file

@ -510,8 +510,8 @@ void Thread::DeferOOBMessageInterrupts() {
}
}
if (FLAG_trace_service && FLAG_trace_service_verbose) {
OS::Print("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n",
Dart::UptimeMillis(), isolate()->name());
OS::PrintErr("[+%" Pd64 "ms] Isolate %s deferring OOB interrupts\n",
Dart::UptimeMillis(), isolate()->name());
}
}
@ -532,8 +532,8 @@ void Thread::RestoreOOBMessageInterrupts() {
deferred_interrupts_ = 0;
}
if (FLAG_trace_service && FLAG_trace_service_verbose) {
OS::Print("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n",
Dart::UptimeMillis(), isolate()->name());
OS::PrintErr("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n",
Dart::UptimeMillis(), isolate()->name());
}
}