diff options
author | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 01:33:49 +0000 |
---|---|---|
committer | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 01:33:49 +0000 |
commit | f0e4ea57f792dc5eac03519b4c7707b22e28f2c8 (patch) | |
tree | 9a6b2401abe3b037e30034f85791f81edcd2b803 /ppapi | |
parent | 12ef4a3b66dcb302711c249cd42a43b5c338c900 (diff) | |
download | chromium_src-f0e4ea57f792dc5eac03519b4c7707b22e28f2c8.zip chromium_src-f0e4ea57f792dc5eac03519b4c7707b22e28f2c8.tar.gz chromium_src-f0e4ea57f792dc5eac03519b4c7707b22e28f2c8.tar.bz2 |
Add PNaCl UMA stats for error cases.
Also add a few TODOs for time and size histograms.
Will need some tests for this too.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=3136
TEST= just existing pnacl naclmore tests for now. Also manually tried running without --enable-pnacl to make sure the JS console message shows up.
Review URL: https://codereview.chromium.org/11366187
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
8 files changed, 272 insertions, 61 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index c8c9194..64c27c9 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -1187,6 +1187,11 @@ void Plugin::BitcodeDidTranslate(int32_t pp_error) { PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); return; } + + // TODO(dschuff,jvoung): We could have a UMA stat for total time taken + // to translate. We may also want a breakdown (how long does it take + // to start up the LLC nexe process, LD nexe process, etc.). + // Inform JavaScript that we successfully translated the bitcode to a nexe. EnqueueProgressEvent(kProgressEventProgress); nacl::scoped_ptr<nacl::DescWrapper> @@ -1512,7 +1517,7 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { translate_callback)); return; } else { - error_info.SetReport(ERROR_UNKNOWN, + error_info.SetReport(ERROR_PNACL_NOT_ENABLED, "PNaCl has not been enabled (e.g., by setting " "the --enable-pnacl flag)."); } diff --git a/ppapi/native_client/src/trusted/plugin/plugin_error.h b/ppapi/native_client/src/trusted/plugin/plugin_error.h index 827a9a3..1654846 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin_error.h +++ b/ppapi/native_client/src/trusted/plugin/plugin_error.h @@ -64,6 +64,36 @@ enum PluginErrorCode { ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, ERROR_START_PROXY_CRASH = 37, ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38, + ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39, + ERROR_PNACL_CACHE_OPEN_NOACCESS = 40, + ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41, + ERROR_PNACL_CACHE_OPEN_NOSPACE = 42, + ERROR_PNACL_CACHE_OPEN_OTHER = 43, + ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44, + ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45, + ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46, + ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47, + ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48, + ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49, + ERROR_PNACL_CACHE_FETCH_NOACCESS = 50, + ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51, + ERROR_PNACL_CACHE_FETCH_OTHER = 52, + ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53, + ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54, + ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55, + ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56, + ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57, + ERROR_PNACL_RESOURCE_FETCH = 58, + ERROR_PNACL_PEXE_FETCH = 59, + ERROR_PNACL_THREAD_CREATE = 60, + ERROR_PNACL_LLC_SETUP = 61, + ERROR_PNACL_LD_SETUP = 62, + ERROR_PNACL_LLC_INTERNAL = 63, + ERROR_PNACL_LD_INTERNAL = 64, + ERROR_PNACL_CREATE_TEMP = 65, + // Remove this next code when pnacl is no longer behind a flag (when we + // remove the --enable-pnacl flag). + ERROR_PNACL_NOT_ENABLED = 66, // If you add a code, read the enum comment above on how to update histograms. ERROR_MAX }; diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc index b26c7f2..fe0556f 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc @@ -227,7 +227,9 @@ int32_t PnaclCoordinator::GetLoadedFileDesc(int32_t pp_error, if (pp_error == PP_ERROR_ABORTED) { plugin_->ReportLoadAbort(); } else { - ReportPpapiError(pp_error, component + " load failed."); + ReportPpapiError(ERROR_PNACL_RESOURCE_FETCH, + pp_error, + component + " load failed."); } return NACL_NO_FILE_DESC; } @@ -270,20 +272,26 @@ PnaclCoordinator::~PnaclCoordinator() { } } -void PnaclCoordinator::ReportNonPpapiError(const nacl::string& message) { - error_info_.SetReport(ERROR_UNKNOWN, +void PnaclCoordinator::ReportNonPpapiError(enum PluginErrorCode err_code, + const nacl::string& message) { + error_info_.SetReport(err_code, nacl::string("PnaclCoordinator: ") + message); - ReportPpapiError(PP_ERROR_FAILED); + ExitWithError(PP_ERROR_FAILED); } -void PnaclCoordinator::ReportPpapiError(int32_t pp_error, +void PnaclCoordinator::ReportPpapiError(enum PluginErrorCode err_code, + int32_t pp_error, const nacl::string& message) { - error_info_.SetReport(ERROR_UNKNOWN, - nacl::string("PnaclCoordinator: ") + message); - ReportPpapiError(pp_error); + nacl::stringstream ss; + ss << "PnaclCoordinator: " << message << " pp_error=" << pp_error; + error_info_.SetReport(err_code, ss.str()); + ExitWithError(pp_error); } -void PnaclCoordinator::ReportPpapiError(int32_t pp_error) { +void PnaclCoordinator::ExitWithError(int32_t pp_error) { + // TODO(jvoung,dschuff): pp_error isn't very useful at this point. + // We just need to call the translate_notify_callback with an error boolean + // so that the plugin doesn't try to load a failed-to-translate nexe. PLUGIN_PRINTF(("PnaclCoordinator::ReportPpappiError (pp_error=%" NACL_PRId32", error_code=%d, message='%s')\n", pp_error, error_info_.error_code(), @@ -300,7 +308,7 @@ void PnaclCoordinator::ReportPpapiError(int32_t pp_error) { error_already_reported_ = true; translate_notify_callback_.Run(pp_error); } else { - PLUGIN_PRINTF(("PnaclCoordinator::ReportPpapiError an earlier error was " + PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError an earlier error was " "already reported -- Skipping.\n")); } } @@ -311,12 +319,12 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) { NACL_PRId32")\n", pp_error)); // Bail out if there was an earlier error (e.g., pexe load failure). if (translate_finish_error_ != PP_OK) { - ReportPpapiError(translate_finish_error_); + ExitWithError(translate_finish_error_); return; } // Bail out if there is an error from the translation thread. if (pp_error != PP_OK) { - ReportPpapiError(pp_error); + ExitWithError(pp_error); return; } @@ -343,7 +351,37 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) { void PnaclCoordinator::CachedNexeOpenedForWrite(int32_t pp_error) { if (pp_error != PP_OK) { - ReportPpapiError(pp_error, "Failed to open cache file for write."); + if (pp_error == PP_ERROR_NOACCESS) { + ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOACCESS, + pp_error, + "PNaCl translation cache failed to open file for write." + " No access."); + return; + } + if (pp_error == PP_ERROR_NOQUOTA) { + ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA, + pp_error, + "PNaCl translation cache failed to open file for write." + " No quota."); + return; + } + if (pp_error == PP_ERROR_NOSPACE) { + ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOSPACE, + pp_error, + "PNaCl translation cache failed to open file for write." + " No space."); + return; + } + if (pp_error == PP_ERROR_NOTAFILE) { + ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE, + pp_error, + "PNaCl translation cache failed to open file for write." + " File already exists as a directory."); + return; + } + ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_OTHER, + pp_error, + "PNaCl translation cache failed to open file for write."); return; } @@ -434,9 +472,23 @@ void PnaclCoordinator::DidCopyNexeToCachePartial(int32_t pp_error, void PnaclCoordinator::NexeWasCopiedToCache(int32_t pp_error) { if (pp_error != PP_OK) { - // TODO(jvoung): This should probably try to delete the cache file - // before returning... - ReportPpapiError(pp_error, "Failed to copy nexe to cache."); + // TODO(jvoung): This should try to delete the partially written + // cache file before returning... + if (pp_error == PP_ERROR_NOQUOTA) { + ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA, + pp_error, + "Failed to copy translated nexe to cache. No quota."); + return; + } + if (pp_error == PP_ERROR_NOSPACE) { + ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE, + pp_error, + "Failed to copy translated nexe to cache. No space."); + return; + } + ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER, + pp_error, + "Failed to copy translated nexe to cache."); return; } // Rename the cached_nexe_file_ file to the cache id, to finalize. @@ -448,14 +500,36 @@ void PnaclCoordinator::NexeWasCopiedToCache(int32_t pp_error) { void PnaclCoordinator::NexeFileWasRenamed(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed (pp_error=%" NACL_PRId32")\n", pp_error)); - // NOTE: if the file already existed, it looks like the rename will - // happily succeed. However, we should add a test for this. if (pp_error != PP_OK) { - ReportPpapiError(pp_error, "Failed to place cached bitcode translation."); - return; + if (pp_error == PP_ERROR_NOACCESS) { + ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS, + pp_error, + "Failed to finalize cached translation. No access."); + return; + } else if (pp_error != PP_ERROR_FILEEXISTS) { + ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER, + pp_error, + "Failed to finalize cached translation."); + return; + } else { // pp_error == PP_ERROR_FILEEXISTS. + // NOTE: if the file already existed, it looks like the rename will + // happily succeed. However, we should add a test for this. + // Could be a hash collision, or it could also be two tabs racing to + // translate the same pexe. The file could also be a corrupt left-over, + // but that case can be removed by doing the TODO for cleanup. + // We may want UMA stats to know if this happens. + // For now, assume that it is a race and try to continue. + // If there is truly a corrupted file, then sel_ldr should prevent the + // file from loading due to the file size not matching the ELF header. + PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed file existed\n")); + } } cached_nexe_file_->FinishRename(); + + // TODO(dschuff,jvoung): We could have a UMA stat for the size of + // the cached nexes, to know how much cache we are using. + // Open the cache file for reading. pp::CompletionCallback cb = callback_factory_.NewCallback(&PnaclCoordinator::NexeReadDidOpen); @@ -466,7 +540,21 @@ void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::NexeReadDidOpen (pp_error=%" NACL_PRId32")\n", pp_error)); if (pp_error != PP_OK) { - ReportPpapiError(pp_error, "Failed to open translated nexe."); + if (pp_error == PP_ERROR_FILENOTFOUND) { + ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOTFOUND, + pp_error, + "Failed to open translated nexe. Not found."); + return; + } + if (pp_error == PP_ERROR_NOACCESS) { + ReportPpapiError(ERROR_PNACL_CACHE_FETCH_NOACCESS, + pp_error, + "Failed to open translated nexe. No access."); + return; + } + ReportPpapiError(ERROR_PNACL_CACHE_FETCH_OTHER, + pp_error, + "Failed to open translated nexe."); return; } @@ -484,7 +572,8 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::ResourcesDidLoad (pp_error=%" NACL_PRId32")\n", pp_error)); if (pp_error != PP_OK) { - ReportPpapiError(pp_error, "resources failed to load."); + // Finer-grained error code should have already been reported by + // the PnaclResources class. return; } @@ -492,8 +581,24 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { // Open the local temporary FS to see if we get a hit in the cache. pp::CompletionCallback cb = callback_factory_.NewCallback(&PnaclCoordinator::FileSystemDidOpen); - if (!file_system_->Open(0, cb)) { - ReportNonPpapiError("failed to open file system."); + int32_t open_error = file_system_->Open(0, cb); + if (open_error != PP_OK_COMPLETIONPENDING) { + // At this point, no async request has kicked off to check for + // permissions, space, etc., so the only error that can be detected + // now is that an open() is already in progress (or a really terrible + // error). + if (pp_error == PP_ERROR_INPROGRESS) { + ReportPpapiError( + ERROR_PNACL_CACHE_OPEN_INPROGRESS, + pp_error, + "File system for PNaCl translation cache failed to open." + " In progress."); + return; + } + ReportPpapiError( + ERROR_PNACL_CACHE_OPEN_OTHER, + pp_error, + "File system for PNaCl translation cache failed to open."); } } else { // We don't have a cache, so do the non-cached codepath. @@ -505,8 +610,30 @@ void PnaclCoordinator::FileSystemDidOpen(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::FileSystemDidOpen (pp_error=%" NACL_PRId32")\n", pp_error)); if (pp_error != PP_OK) { - ReportPpapiError(pp_error, "file system didn't open."); - return; + if (pp_error == PP_ERROR_NOACCESS) { + ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOACCESS, + pp_error, + "File system for PNaCl translation cache failed to open." + " No access."); + return; + } + if (pp_error == PP_ERROR_NOQUOTA) { + ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOQUOTA, + pp_error, + "File system for PNaCl translation cache failed to open." + " No quota."); + return; + } + if (pp_error == PP_ERROR_NOSPACE) { + ReportPpapiError(ERROR_PNACL_CACHE_OPEN_NOSPACE, + pp_error, + "File system for PNaCl translation cache failed to open." + " No space."); + return; + } + ReportPpapiError(ERROR_PNACL_CACHE_OPEN_OTHER, + pp_error, + "File system for PNaCl translation cache failed to open."); } dir_ref_.reset(new pp::FileRef(*file_system_, kPnaclTempDir)); // Attempt to create the directory. @@ -520,7 +647,18 @@ void PnaclCoordinator::DirectoryWasCreated(int32_t pp_error) { NACL_PRId32")\n", pp_error)); if (pp_error != PP_ERROR_FILEEXISTS && pp_error != PP_OK) { // Directory did not exist and could not be created. - ReportPpapiError(pp_error, "directory creation/check failed."); + if (pp_error == PP_ERROR_NOACCESS) { + ReportPpapiError( + ERROR_PNACL_CACHE_DIRECTORY_CREATE, + pp_error, + "PNaCl translation cache directory creation/check failed. " + "No access."); + return; + } + ReportPpapiError( + ERROR_PNACL_CACHE_DIRECTORY_CREATE, + pp_error, + "PNaCl translation cache directory creation/check failed."); return; } if (cache_identity_ != "") { @@ -543,13 +681,16 @@ void PnaclCoordinator::CachedFileDidOpen(int32_t pp_error) { NexeReadDidOpen(PP_OK); return; } + // Otherwise, the cache file is missing, or the cache simply + // cannot be created (e.g., incognito mode), so we must translate. // Create the translation thread object immediately. This ensures that any // pieces of the file that get downloaded before the compilation thread // is accepting SRPCs won't get dropped. translate_thread_.reset(new PnaclTranslateThread()); if (translate_thread_ == NULL) { - ReportNonPpapiError("could not allocate translation thread."); + ReportNonPpapiError(ERROR_PNACL_THREAD_CREATE, + "could not allocate translation thread."); return; } // We also want to open the object file now so the @@ -567,7 +708,8 @@ void PnaclCoordinator::CachedFileDidOpen(int32_t pp_error) { // TODO(dschuff): need to use url_util_->ResolveRelativeToURL? if (!streaming_downloader_->OpenStream(pexe_url_, cb, this)) { - ReportNonPpapiError(nacl::string("failed to open stream ") + pexe_url_); + ReportNonPpapiError(ERROR_PNACL_PEXE_FETCH, + nacl::string("failed to open stream ") + pexe_url_); } } @@ -578,8 +720,13 @@ void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { // Defer reporting the error and cleanup until after the translation // thread returns, because it may be accessing the coordinator's // objects or writing to the files. + // TODO(dschuff,jvoung): If this is a PP_ERROR_ABORTED, we probably + // want the UMA stat to show that the user aborted the action + // (vs a network error). + // We also want to track the total number of bytes of the pexe + // to know the typical application sizes. translate_finish_error_ = pp_error; - error_info_.SetReport(ERROR_UNKNOWN, + error_info_.SetReport(ERROR_PNACL_PEXE_FETCH, nacl::string("PnaclCoordinator: pexe load failed.")); translate_thread_->AbortSubprocesses(); } @@ -602,7 +749,9 @@ void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" NACL_PRId32")\n", pp_error)); if (pp_error != PP_OK) { - ReportPpapiError(pp_error); + ReportPpapiError(ERROR_PNACL_CREATE_TEMP, + pp_error, + "Failed to open scratch object file."); return; } // Create the nexe file for connecting ld and sel_ldr. diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h index 6d23557..55d9e60 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h @@ -116,12 +116,17 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { const nacl::string& component); // Run |translate_notify_callback_| with an error condition that is not - // PPAPI specific. - void ReportNonPpapiError(const nacl::string& message); + // PPAPI specific. Also set ErrorInfo report. + void ReportNonPpapiError(PluginErrorCode err, const nacl::string& message); // Run when faced with a PPAPI error condition. Bring control back to the // plugin by invoking the |translate_notify_callback_|. - void ReportPpapiError(int32_t pp_error, const nacl::string& message); - void ReportPpapiError(int32_t pp_error); + // Also set ErrorInfo report. + void ReportPpapiError(PluginErrorCode err, + int32_t pp_error, const nacl::string& message); + // Bring control back to the plugin by invoking the + // |translate_notify_callback_|. This does not set the ErrorInfo report, + // it is assumed that it was already set. + void ExitWithError(int32_t pp_error); // Implement FileDownloader's template of the CallbackSource interface. // This method returns a callback which will be called by the FileDownloader diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc index 8d70796..d1b3b34 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc @@ -116,9 +116,11 @@ void PnaclResources::StartLoad() { nacl::string full_url; ErrorInfo error_info; if (!manifest_->ResolveURL(resource_urls_[i], &full_url, &error_info)) { - coordinator_->ReportNonPpapiError(nacl::string("failed to resolve ") + - resource_urls_[i] + ": " + - error_info.message() + "."); + coordinator_->ReportNonPpapiError( + ERROR_PNACL_RESOURCE_FETCH, + nacl::string("failed to resolve ") + + resource_urls_[i] + ": " + + error_info.message() + "."); break; } pp::CompletionCallback ready_callback = @@ -128,8 +130,10 @@ void PnaclResources::StartLoad() { full_url); if (!plugin_->StreamAsFile(full_url, ready_callback.pp_completion_callback())) { - coordinator_->ReportNonPpapiError(nacl::string("failed to download ") + - resource_urls_[i] + "."); + coordinator_->ReportNonPpapiError( + ERROR_PNACL_RESOURCE_FETCH, + nacl::string("failed to download ") + + resource_urls_[i] + "."); break; } } @@ -142,9 +146,11 @@ void PnaclResources::StartLoad() { nacl::string full_url; ErrorInfo error_info; if (!manifest_->ResolveURL(resource_urls_[i], &full_url, &error_info)) { - coordinator_->ReportNonPpapiError(nacl::string("failed to resolve ") + - url + ": " + - error_info.message() + "."); + coordinator_->ReportNonPpapiError( + ERROR_PNACL_RESOURCE_FETCH, + nacl::string("failed to resolve ") + + url + ": " + + error_info.message() + "."); break; } nacl::string filename = PnaclUrls::PnaclComponentURLToFilename(full_url); @@ -152,6 +158,7 @@ void PnaclResources::StartLoad() { int32_t fd = PnaclResources::GetPnaclFD(plugin_, filename.c_str()); if (fd < 0) { coordinator_->ReportNonPpapiError( + ERROR_PNACL_RESOURCE_FETCH, nacl::string("PnaclLocalResources::StartLoad failed for: ") + filename); result = PP_ERROR_FILENOTFOUND; @@ -177,7 +184,8 @@ void PnaclResources::ResourceReady(int32_t pp_error, full_url, "resource " + url); if (fd < 0) { - coordinator_->ReportPpapiError(pp_error, + coordinator_->ReportPpapiError(ERROR_PNACL_RESOURCE_FETCH, + pp_error, "PnaclResources::ResourceReady failed."); } else { resource_wrappers_[url] = diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc index 6704ff5..bd551eb 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc @@ -6,6 +6,7 @@ #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" #include "native_client/src/trusted/plugin/plugin.h" +#include "native_client/src/trusted/plugin/plugin_error.h" #include "native_client/src/trusted/plugin/pnacl_resources.h" #include "native_client/src/trusted/plugin/srpc_params.h" #include "native_client/src/trusted/plugin/temporary_file.h" @@ -51,7 +52,8 @@ void PnaclTranslateThread::RunTranslate( report_translate_finished_ = finish_callback; translate_thread_.reset(new NaClThread); if (translate_thread_ == NULL) { - TranslateFailed("could not allocate thread struct."); + TranslateFailed(ERROR_PNACL_THREAD_CREATE, + "could not allocate thread struct."); return; } const int32_t kArbitraryStackSize = 128 * 1024; @@ -59,7 +61,8 @@ void PnaclTranslateThread::RunTranslate( DoTranslateThread, this, kArbitraryStackSize)) { - TranslateFailed("could not create thread."); + TranslateFailed(ERROR_PNACL_THREAD_CREATE, + "could not create thread."); translate_thread_.reset(NULL); } } @@ -130,7 +133,8 @@ void PnaclTranslateThread::DoTranslate() { llc_subprocess_.reset( StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); if (llc_subprocess_ == NULL) { - TranslateFailed("Compile process could not be created: " + + TranslateFailed(ERROR_PNACL_LLC_SETUP, + "Compile process could not be created: " + error_info.message()); return; } @@ -148,10 +152,12 @@ void PnaclTranslateThread::DoTranslate() { if (llc_subprocess_->srpc_client()->GetLastError() == NACL_SRPC_RESULT_APP_ERROR) { // The error message is only present if the error was returned from llc - TranslateFailed(nacl::string("Stream init failed: ") + + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + nacl::string("Stream init failed: ") + nacl::string(params.outs()[0]->arrays.str)); } else { - TranslateFailed("Stream init internal error"); + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + "Stream init internal error"); } return; } @@ -177,7 +183,8 @@ void PnaclTranslateThread::DoTranslate() { ¶ms, &data[0], data.size())) { - TranslateFailed("Compile stream chunk failed."); + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + "Compile stream chunk failed."); return; } PLUGIN_PRINTF(("StreamChunk Successful\n")); @@ -194,9 +201,11 @@ void PnaclTranslateThread::DoTranslate() { if (llc_subprocess_->srpc_client()->GetLastError() == NACL_SRPC_RESULT_APP_ERROR) { // The error string is only present if the error was sent back from llc - TranslateFailed(params.outs()[3]->arrays.str); + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + params.outs()[3]->arrays.str); } else { - TranslateFailed("Compile StreamEnd internal error"); + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + "Compile StreamEnd internal error"); } return; } @@ -230,7 +239,8 @@ bool PnaclTranslateThread::RunLdSubprocess(int is_shared_library, SrpcParams params; // Reset object file for reading first. if (!obj_file_->Reset()) { - TranslateFailed("Link process could not reset object file"); + TranslateFailed(ERROR_PNACL_LD_SETUP, + "Link process could not reset object file"); return false; } nacl::DescWrapper* ld_in_file = obj_file_->read_wrapper(); @@ -242,7 +252,8 @@ bool PnaclTranslateThread::RunLdSubprocess(int is_shared_library, ld_subprocess_.reset( StartSubprocess(PnaclUrls::GetLdUrl(), ld_manifest_, &error_info)); if (ld_subprocess_ == NULL) { - TranslateFailed("Link process could not be created: " + + TranslateFailed(ERROR_PNACL_LD_SETUP, + "Link process could not be created: " + error_info.message()); return false; } @@ -260,7 +271,8 @@ bool PnaclTranslateThread::RunLdSubprocess(int is_shared_library, is_shared_library, soname.c_str(), lib_dependencies.c_str())) { - TranslateFailed("link failed."); + TranslateFailed(ERROR_PNACL_LD_INTERNAL, + "link failed."); return false; } PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", @@ -273,14 +285,16 @@ bool PnaclTranslateThread::RunLdSubprocess(int is_shared_library, return true; } -void PnaclTranslateThread::TranslateFailed(const nacl::string& error_string) { +void PnaclTranslateThread::TranslateFailed( + enum PluginErrorCode err_code, + const nacl::string& error_string) { PLUGIN_PRINTF(("PnaclTranslateThread::TranslateFailed (error_string='%s')\n", error_string.c_str())); pp::Core* core = pp::Module::Get()->core(); if (coordinator_error_info_->message().empty()) { // Only use our message if one hasn't already been set by the coordinator // (e.g. pexe load failed). - coordinator_error_info_->SetReport(ERROR_UNKNOWN, + coordinator_error_info_->SetReport(err_code, nacl::string("PnaclCoordinator: ") + error_string); } diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h index 727e4f6..d823a71 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h +++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h @@ -69,7 +69,8 @@ class PnaclTranslateThread { // Runs the streaming translation. Called from the helper thread. void DoTranslate() ; // Signal that Pnacl translation failed, from the translation thread only. - void TranslateFailed(const nacl::string& error_string); + void TranslateFailed(enum PluginErrorCode err_code, + const nacl::string& error_string); // Run the LD subprocess, returning true on success bool RunLdSubprocess(int is_shared_library, const nacl::string& soname, diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc index c5b9f7e..320d989 100644 --- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -344,11 +344,10 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( cache_identity, translate_callback)); } else { - // TODO(jvoung): Separate the error codes? nacl::MutexLocker take(&mu_); *p->op_complete_ptr = true; // done... *p->out_desc = -1; // but failed. - p->error_info->SetReport(ERROR_MANIFEST_OPEN, + p->error_info->SetReport(ERROR_PNACL_NOT_ENABLED, "ServiceRuntime: GetPnaclFd failed -- pnacl not " "enabled with --enable-pnacl."); NaClXCondVarBroadcast(&cv_); |