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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 10836197: NaCl: Permit using the debug exception handler when the debug stub is enabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « chrome/browser/nacl_host/nacl_process_host.h ('k') | no next file » | 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 #include "chrome/browser/nacl_host/nacl_process_host.h" 5 #include "chrome/browser/nacl_host/nacl_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #elif defined(OS_LINUX) 121 #elif defined(OS_LINUX)
122 wait_for_nacl_gdb_(false), 122 wait_for_nacl_gdb_(false),
123 #endif 123 #endif
124 reply_msg_(NULL), 124 reply_msg_(NULL),
125 #if defined(OS_WIN) 125 #if defined(OS_WIN)
126 debug_exception_handler_requested_(false), 126 debug_exception_handler_requested_(false),
127 #endif 127 #endif
128 internal_(new NaClInternal()), 128 internal_(new NaClInternal()),
129 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 129 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
130 enable_exception_handling_(false), 130 enable_exception_handling_(false),
131 enable_debug_stub_(false),
131 off_the_record_(off_the_record) { 132 off_the_record_(off_the_record) {
132 process_.reset(content::BrowserChildProcessHost::Create( 133 process_.reset(content::BrowserChildProcessHost::Create(
133 content::PROCESS_TYPE_NACL_LOADER, this)); 134 content::PROCESS_TYPE_NACL_LOADER, this));
134 135
135 // Set the display name so the user knows what plugin the process is running. 136 // Set the display name so the user knows what plugin the process is running.
136 // We aren't on the UI thread so getting the pref locale for language 137 // We aren't on the UI thread so getting the pref locale for language
137 // formatting isn't possible, so IDN will be lost, but this is probably OK 138 // formatting isn't possible, so IDN will be lost, but this is probably OK
138 // for this use case. 139 // for this use case.
139 process_->SetName(net::FormatUrl(manifest_url_, std::string())); 140 process_->SetName(net::FormatUrl(manifest_url_, std::string()));
140 141
141 // We allow untrusted hardware exception handling to be enabled via 142 // We allow untrusted hardware exception handling to be enabled via
142 // an env var for consistency with the standalone build of NaCl. 143 // an env var for consistency with the standalone build of NaCl.
143 if (CommandLine::ForCurrentProcess()->HasSwitch( 144 if (CommandLine::ForCurrentProcess()->HasSwitch(
144 switches::kEnableNaClExceptionHandling) || 145 switches::kEnableNaClExceptionHandling) ||
145 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) { 146 getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) {
146 enable_exception_handling_ = true; 147 enable_exception_handling_ = true;
147 } 148 }
149 enable_debug_stub_ = CommandLine::ForCurrentProcess()->HasSwitch(
150 switches::kEnableNaClDebug);
148 151
149 enable_ipc_proxy_ = CommandLine::ForCurrentProcess()->HasSwitch( 152 enable_ipc_proxy_ = CommandLine::ForCurrentProcess()->HasSwitch(
150 switches::kEnableNaClIPCProxy); 153 switches::kEnableNaClIPCProxy);
151 } 154 }
152 155
153 NaClProcessHost::~NaClProcessHost() { 156 NaClProcessHost::~NaClProcessHost() {
154 int exit_code; 157 int exit_code;
155 process_->GetTerminationStatus(&exit_code); 158 process_->GetTerminationStatus(&exit_code);
156 std::string message = 159 std::string message =
157 base::StringPrintf("NaCl process exited with status %i (0x%x)", 160 base::StringPrintf("NaCl process exited with status %i (0x%x)",
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 618 }
616 619
617 bool NaClProcessHost::StartNaClExecution() { 620 bool NaClProcessHost::StartNaClExecution() {
618 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 621 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
619 622
620 nacl::NaClStartParams params; 623 nacl::NaClStartParams params;
621 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 624 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
622 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 625 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
623 params.version = chrome::VersionInfo().CreateVersionString(); 626 params.version = chrome::VersionInfo().CreateVersionString();
624 params.enable_exception_handling = enable_exception_handling_; 627 params.enable_exception_handling = enable_exception_handling_;
625 params.enable_debug_stub = 628 params.enable_debug_stub = enable_debug_stub_;
626 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaClDebug);
627 params.enable_ipc_proxy = enable_ipc_proxy_; 629 params.enable_ipc_proxy = enable_ipc_proxy_;
628 630
629 base::PlatformFile irt_file = nacl_browser->IrtFile(); 631 base::PlatformFile irt_file = nacl_browser->IrtFile();
630 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); 632 CHECK_NE(irt_file, base::kInvalidPlatformFileValue);
631 633
632 const ChildProcessData& data = process_->GetData(); 634 const ChildProcessData& data = process_->GetData();
633 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { 635 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) {
634 if (!ShareHandleToSelLdr(data.handle, 636 if (!ShareHandleToSelLdr(data.handle,
635 internal_->sockets_for_sel_ldr[i], true, 637 internal_->sockets_for_sel_ldr[i], true,
636 &params.handles)) { 638 &params.handles)) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 if (!AttachDebugExceptionHandler(info, reply_msg)) { 730 if (!AttachDebugExceptionHandler(info, reply_msg)) {
729 // Send failure message. 731 // Send failure message.
730 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg, 732 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg,
731 false); 733 false);
732 Send(reply_msg); 734 Send(reply_msg);
733 } 735 }
734 } 736 }
735 737
736 bool NaClProcessHost::AttachDebugExceptionHandler(const std::string& info, 738 bool NaClProcessHost::AttachDebugExceptionHandler(const std::string& info,
737 IPC::Message* reply_msg) { 739 IPC::Message* reply_msg) {
738 if (!enable_exception_handling_) { 740 if (!enable_exception_handling_ && !enable_debug_stub_) {
739 DLOG(ERROR) << 741 DLOG(ERROR) <<
740 "Exception handling requested by NaCl process when not enabled"; 742 "Debug exception handler requested by NaCl process when not enabled";
741 return false; 743 return false;
742 } 744 }
743 if (debug_exception_handler_requested_) { 745 if (debug_exception_handler_requested_) {
744 // The NaCl process should not request this multiple times. 746 // The NaCl process should not request this multiple times.
745 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received"; 747 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received";
746 return false; 748 return false;
747 } 749 }
748 debug_exception_handler_requested_ = true; 750 debug_exception_handler_requested_ = true;
749 751
750 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle); 752 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 } else { 784 } else {
783 NaClStartDebugExceptionHandlerThread( 785 NaClStartDebugExceptionHandlerThread(
784 process_handle.Take(), info, 786 process_handle.Take(), info,
785 base::MessageLoopProxy::current(), 787 base::MessageLoopProxy::current(),
786 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 788 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
787 weak_factory_.GetWeakPtr())); 789 weak_factory_.GetWeakPtr()));
788 return true; 790 return true;
789 } 791 }
790 } 792 }
791 #endif 793 #endif
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698