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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 10823019: Ensure that errors that occur during load will get crash log info to JS console (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code review based changes Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/native_client/src/trusted/plugin/service_runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifdef _MSC_VER 5 #ifdef _MSC_VER
6 // Do not warn about use of std::copy with raw pointers. 6 // Do not warn about use of std::copy with raw pointers.
7 #pragma warning(disable : 4996) 7 #pragma warning(disable : 4996)
8 #endif 8 #endif
9 9
10 #include "native_client/src/trusted/plugin/plugin.h" 10 #include "native_client/src/trusted/plugin/plugin.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 static_cast<void*>(new_service_runtime))); 607 static_cast<void*>(new_service_runtime)));
608 if (NULL == new_service_runtime) { 608 if (NULL == new_service_runtime) {
609 error_info->SetReport(ERROR_SEL_LDR_INIT, 609 error_info->SetReport(ERROR_SEL_LDR_INIT,
610 "sel_ldr init failure " + subprocess->description()); 610 "sel_ldr init failure " + subprocess->description());
611 return false; 611 return false;
612 } 612 }
613 613
614 bool service_runtime_started = 614 bool service_runtime_started =
615 new_service_runtime->Start(wrapper, 615 new_service_runtime->Start(wrapper,
616 error_info, 616 error_info,
617 manifest_base_url()); 617 manifest_base_url(),
618 crash_cb);
618 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", 619 PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n",
619 service_runtime_started)); 620 service_runtime_started));
620 if (!service_runtime_started) { 621 if (!service_runtime_started) {
621 return false; 622 return false;
622 } 623 }
623 624
624 // Try to start the Chrome IPC-based proxy. 625 // Try to start the Chrome IPC-based proxy.
625 if (nacl_interface_->StartPpapiProxy(pp_instance())) { 626 if (nacl_interface_->StartPpapiProxy(pp_instance())) {
626 using_ipc_proxy_ = true; 627 using_ipc_proxy_ = true;
627 // We need to explicitly schedule this here. It is normally called in 628 // We need to explicitly schedule this here. It is normally called in
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 static_cast<float>(ready_time_ - init_time_) / NACL_MICROS_PER_MILLI); 1140 static_cast<float>(ready_time_ - init_time_) / NACL_MICROS_PER_MILLI);
1140 1141
1141 ReportLoadSuccess(LENGTH_IS_COMPUTABLE, nexe_size_, nexe_size_); 1142 ReportLoadSuccess(LENGTH_IS_COMPUTABLE, nexe_size_, nexe_size_);
1142 } else { 1143 } else {
1143 NaClLog(4, "NexeFileDidOpenContinuation: failed."); 1144 NaClLog(4, "NexeFileDidOpenContinuation: failed.");
1144 ReportLoadError(error_info); 1145 ReportLoadError(error_info);
1145 } 1146 }
1146 NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); 1147 NaClLog(4, "Leaving NexeFileDidOpenContinuation\n");
1147 } 1148 }
1148 1149
1149 static void LogLineToConsole(Plugin* plugin, nacl::string one_line) { 1150 static void LogLineToConsole(Plugin* plugin, const nacl::string& one_line) {
1150 PLUGIN_PRINTF(("LogLineToConsole: %s\n", 1151 PLUGIN_PRINTF(("LogLineToConsole: %s\n",
1151 one_line.c_str())); 1152 one_line.c_str()));
1152 plugin->AddToConsole(one_line); 1153 plugin->AddToConsole(one_line);
1153 } 1154 }
1154 1155
1155 void Plugin::CopyCrashLogToJsConsole() { 1156 void Plugin::CopyCrashLogToJsConsole() {
1156 nacl::string fatal_msg(main_service_runtime()->GetCrashLogOutput()); 1157 nacl::string fatal_msg(main_service_runtime()->GetCrashLogOutput());
1157 size_t ix_start = 0; 1158 size_t ix_start = 0;
1158 size_t ix_end; 1159 size_t ix_end;
1159 1160
(...skipping 25 matching lines...) Expand all
1185 " so this is a \"controlled crash\".\n"), 1186 " so this is a \"controlled crash\".\n"),
1186 exit_status)); 1187 exit_status));
1187 } 1188 }
1188 // If the crash occurs during load, we just want to report an error 1189 // If the crash occurs during load, we just want to report an error
1189 // that fits into our load progress event grammar. If the crash 1190 // that fits into our load progress event grammar. If the crash
1190 // occurs after loaded/loadend, then we use ReportDeadNexe to send a 1191 // occurs after loaded/loadend, then we use ReportDeadNexe to send a
1191 // "crash" event. 1192 // "crash" event.
1192 if (nexe_error_reported()) { 1193 if (nexe_error_reported()) {
1193 PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;" 1194 PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;"
1194 " suppressing\n")); 1195 " suppressing\n"));
1195 return; 1196 } else {
1197 if (nacl_ready_state() == DONE) {
1198 ReportDeadNexe();
1199 } else {
1200 ErrorInfo error_info;
1201 // The error is not quite right. In particular, the crash
1202 // reported by this path could be due to NaCl application
1203 // crashes that occur after the pepper proxy has started.
1204 error_info.SetReport(ERROR_START_PROXY_CRASH,
1205 "Nexe crashed during startup");
1206 ReportLoadError(error_info);
1207 }
1196 } 1208 }
1197 1209
1198 if (nacl_ready_state() == DONE) { 1210 // In all cases, try to grab the crash log. The first error
1199 ReportDeadNexe(); 1211 // reported may have come from the start_module RPC reply indicating
1200 } else { 1212 // a validation error or something similar, which wouldn't grab the
1201 ErrorInfo error_info; 1213 // crash log. In the event that this is called twice, the second
1202 error_info.SetReport(ERROR_START_PROXY_CRASH, // Not quite right. 1214 // invocation will just be a no-op, since all the crash log will
1203 "Nexe crashed during startup"); 1215 // have been received and we'll just get an EOF indication.
1204 ReportLoadError(error_info);
1205 }
1206
1207 CopyCrashLogToJsConsole(); 1216 CopyCrashLogToJsConsole();
1208 } 1217 }
1209 1218
1210 void Plugin::BitcodeDidTranslate(int32_t pp_error) { 1219 void Plugin::BitcodeDidTranslate(int32_t pp_error) {
1211 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n", 1220 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n",
1212 pp_error)); 1221 pp_error));
1213 if (pp_error != PP_OK) { 1222 if (pp_error != PP_OK) {
1214 // Error should have been reported by pnacl. Just return. 1223 // Error should have been reported by pnacl. Just return.
1215 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); 1224 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n"));
1216 return; 1225 return;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 static_cast<uint32_t>(text.size())); 1951 static_cast<uint32_t>(text.size()));
1943 const PPB_Console_Dev* console_interface = 1952 const PPB_Console_Dev* console_interface =
1944 static_cast<const PPB_Console_Dev*>( 1953 static_cast<const PPB_Console_Dev*>(
1945 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); 1954 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE));
1946 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); 1955 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str);
1947 var_interface->Release(prefix); 1956 var_interface->Release(prefix);
1948 var_interface->Release(str); 1957 var_interface->Release(str);
1949 } 1958 }
1950 1959
1951 } // namespace plugin 1960 } // namespace plugin
OLDNEW
« no previous file with comments | « no previous file | ppapi/native_client/src/trusted/plugin/service_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698