summaryrefslogtreecommitdiffstats
path: root/ppapi/native_client
diff options
context:
space:
mode:
authorbsy@google.com <bsy@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 20:51:06 +0000
committerbsy@google.com <bsy@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 20:51:06 +0000
commitd009e6b2a4c4ea81ca56b2010d233c3237cbdc65 (patch)
treedeebe37a00bfbd47ca1a2237f7dfc4270e3fed8a /ppapi/native_client
parent78e057248c5f93a0d9fea84e37d47d4fd00bf2d6 (diff)
downloadchromium_src-d009e6b2a4c4ea81ca56b2010d233c3237cbdc65.zip
chromium_src-d009e6b2a4c4ea81ca56b2010d233c3237cbdc65.tar.gz
chromium_src-d009e6b2a4c4ea81ca56b2010d233c3237cbdc65.tar.bz2
After LOG_FATAL occurs, have plugin show recent NaClLog outputs on JavaScript console.
This is a duplicate of http://codereview.chromium.org/10806005/ now that we no longer reference the SDK version of nacl_log.h (stale). BUG= http://code.google.com/p/nativeclient/issues/detail?id=2776 TEST= Manual. Review URL: https://chromiumcodereview.appspot.com/10802055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc25
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h6
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.cc9
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.h2
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_; }