diff options
Diffstat (limited to 'ppapi')
4 files changed, 42 insertions, 0 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 8a88489..496f135 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -1146,6 +1146,28 @@ void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); } +static void LogLineToConsole(Plugin* plugin, nacl::string one_line) { + PLUGIN_PRINTF(("LogLineToConsole: %s\n", + one_line.c_str())); + plugin->AddToConsole(one_line); +} + +void Plugin::CopyCrashLogToJsConsole() { + nacl::string fatal_msg(main_service_runtime()->GetCrashLogOutput()); + size_t ix_start = 0; + size_t ix_end; + + PLUGIN_PRINTF(("Plugin::CopyCrashLogToJsConsole: got %d bytes\n", + fatal_msg.size())); + while (nacl::string::npos != (ix_end = fatal_msg.find('\n', ix_start))) { + LogLineToConsole(this, fatal_msg.substr(ix_start, ix_end - ix_start)); + ix_start = ix_end + 1; + } + if (ix_start != fatal_msg.size()) { + LogLineToConsole(this, fatal_msg.substr(ix_start)); + } +} + void Plugin::NexeDidCrash(int32_t pp_error) { PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%"NACL_PRId32")\n", pp_error)); @@ -1172,6 +1194,7 @@ void Plugin::NexeDidCrash(int32_t pp_error) { " suppressing\n")); return; } + if (nacl_ready_state() == DONE) { ReportDeadNexe(); } else { @@ -1180,6 +1203,8 @@ void Plugin::NexeDidCrash(int32_t pp_error) { "Nexe crashed during startup"); ReportLoadError(error_info); } + + CopyCrashLogToJsConsole(); } void Plugin::BitcodeDidTranslate(int32_t pp_error) { diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h index 253cfd5..ce6df11 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/ppapi/native_client/src/trusted/plugin/plugin.h @@ -418,6 +418,12 @@ class Plugin : public pp::InstancePrivate { // Shuts down the proxy for PPAPI nexes. void ShutdownProxy(); // Nexe shutdown + proxy deletion. + // Copy the main service runtime's most recent NaClLog output to the + // JavaScript console. Valid to use only after a crash, e.g., via a + // detail level LOG_FATAL NaClLog entry. If the crash was not due + // to a LOG_FATAL this method will do nothing. + void CopyCrashLogToJsConsole(); + ScriptablePlugin* scriptable_plugin_; int argc_; diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc index 5c3b4fd..76fb5789 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -412,6 +412,7 @@ void PluginReverseInterface::CloseManifestEntry_MainThreadContinuation( void PluginReverseInterface::ReportCrash() { NaClLog(4, "PluginReverseInterface::ReportCrash\n"); + if (crash_cb_.pp_completion_callback().func != NULL) { NaClLog(4, "PluginReverseInterface::ReportCrash: invoking CB\n"); pp::Module::Get()->core()->CallOnMainThread(0, crash_cb_, PP_OK); @@ -741,4 +742,12 @@ void ServiceRuntime::set_exit_status(int exit_status) { exit_status_ = exit_status & 0xff; } +nacl::string ServiceRuntime::GetCrashLogOutput() { + if (NULL != subprocess_.get()) { + return subprocess_->GetCrashLogOutput(); + } else { + return ""; + } +} + } // namespace plugin diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.h b/ppapi/native_client/src/trusted/plugin/service_runtime.h index 554942a..5af0c51 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.h +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.h @@ -235,6 +235,8 @@ class ServiceRuntime { int exit_status(); // const, but grabs mutex etc. void set_exit_status(int exit_status); + nacl::string GetCrashLogOutput(); + // To establish quota callbacks the pnacl coordinator needs to communicate // with the reverse interface. PluginReverseInterface* rev_interface() const { return rev_interface_; } |