diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 20:04:06 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 20:04:06 +0000 |
commit | 5ca93bef094ace0fcc1856437776d95c9809157d (patch) | |
tree | c283aa4aa5955ebd952d067474b434c3d1a18dad /chrome/browser | |
parent | f04c1b203cf4c40071a17ef667bfff287f31bdb9 (diff) | |
download | chromium_src-5ca93bef094ace0fcc1856437776d95c9809157d.zip chromium_src-5ca93bef094ace0fcc1856437776d95c9809157d.tar.gz chromium_src-5ca93bef094ace0fcc1856437776d95c9809157d.tar.bz2 |
NaCl: Allow hardware exception handling to be enabled on Linux and Mac
On Linux and Mac, enabling exception handling is just a matter of
passing a flag through to NaClChromeMainStart().
This change also fixes exception handling on x86-32 Windows, which we
broke a while ago when we made the exception handling syscalls
conditionally enabled on the NaCl side.
Exception handling on x86-64 Windows will require further work to hook
up the debug helper process. Because of this, and because x86-32
Windows is not covered by the Chromium trybots, I'm not enabling
NaCl's exception handling test for Windows yet.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2651
TEST=run_inbrowser_exception_test in nacl_integration
Review URL: http://codereview.chromium.org/9724002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 40 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.h | 4 |
2 files changed, 25 insertions, 19 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index 450e456..77f3db1 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -237,15 +237,24 @@ static bool RunningOnWOW64() { NaClProcessHost::NaClProcessHost(const std::wstring& url) : reply_msg_(NULL), internal_(new NaClInternal()), - ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), + enable_exception_handling_(false) { process_.reset(content::BrowserChildProcessHost::Create( content::PROCESS_TYPE_NACL_LOADER, this)); process_->SetName(WideToUTF16Hack(url)); + + // We allow untrusted hardware exception handling to be enabled via + // an env var for consistency with the standalone build of NaCl. + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNaClExceptionHandling) || + getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { + enable_exception_handling_ = true; #if defined(OS_WIN) - if (!RunningOnWOW64()) { - debug_context_ = new DebugContext(); - } + if (!RunningOnWOW64()) { + debug_context_ = new DebugContext(); + } #endif + } } NaClProcessHost::~NaClProcessHost() { @@ -286,7 +295,8 @@ NaClProcessHost::~NaClProcessHost() { switches::kNaClGdb).empty()) { NaClBrokerService::GetInstance()->OnLoaderDied(); } - } else { + } + if (debug_context_ != NULL) { debug_context_->SetChildProcessHost(NULL); } #endif @@ -590,11 +600,6 @@ void NaClProcessHost::IrtReady() { } #if defined(OS_WIN) -bool NaClProcessHost::IsHardwareExceptionHandlingEnabled() { - return CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableNaClExceptionHandling) && !RunningOnWOW64(); -} - void NaClProcessHost::OnChannelConnected(int32 peer_pid) { // Set process handle, if it was not set previously. // This is needed when NaCl process is launched with nacl-gdb. @@ -614,7 +619,7 @@ void NaClProcessHost::OnChannelConnected(int32 peer_pid) { LOG(ERROR) << "Failed to get process handle"; } } - if (!IsHardwareExceptionHandlingEnabled()) { + if (debug_context_ == NULL) { return; } // Start new thread for debug loop @@ -648,7 +653,7 @@ void NaClProcessHost::OnChannelConnected(int32 peer_pid) { // pid in different thread is fine. dbg_thread->message_loop()->PostTask(FROM_HERE, base::Bind(&NaClProcessHost::DebugContext::AttachDebugger, - debug_context_, peer_pid, process)); + debug_context_, peer_pid, process)); } #else void NaClProcessHost::OnChannelConnected(int32 peer_pid) { @@ -790,16 +795,17 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) { handles_for_sel_ldr.push_back(memory_fd); #endif + IPC::Message* start_message = + new NaClProcessMsg_Start(handles_for_sel_ldr, enable_exception_handling_); #if defined(OS_WIN) - if (IsHardwareExceptionHandlingEnabled()) { - debug_context_->SetStartMessage( - new NaClProcessMsg_Start(handles_for_sel_ldr)); + if (debug_context_ != NULL) { + debug_context_->SetStartMessage(start_message); debug_context_->SendStartMessage(); } else { - process_->Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); + process_->Send(start_message); } #else - process_->Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); + process_->Send(start_message); #endif internal_->sockets_for_sel_ldr.clear(); diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h index 0543852..1bc54af 100644 --- a/chrome/browser/nacl_host/nacl_process_host.h +++ b/chrome/browser/nacl_host/nacl_process_host.h @@ -69,8 +69,6 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { void IrtReady(); void SendStart(base::PlatformFile irt_file); - bool IsHardwareExceptionHandlingEnabled(); - private: #if defined(OS_WIN) class DebugContext; @@ -93,6 +91,8 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate { scoped_ptr<content::BrowserChildProcessHost> process_; + bool enable_exception_handling_; + DISALLOW_COPY_AND_ASSIGN(NaClProcessHost); }; |