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

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

Issue 10928050: Open socket for NaCl GDB debug stub in browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
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 21 matching lines...) Expand all
32 #include "chrome/common/nacl_messages.h" 32 #include "chrome/common/nacl_messages.h"
33 #include "chrome/common/render_messages.h" 33 #include "chrome/common/render_messages.h"
34 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
35 #include "content/public/browser/browser_child_process_host.h" 35 #include "content/public/browser/browser_child_process_host.h"
36 #include "content/public/browser/child_process_data.h" 36 #include "content/public/browser/child_process_data.h"
37 #include "content/public/common/child_process_host.h" 37 #include "content/public/common/child_process_host.h"
38 #include "ipc/ipc_channel.h" 38 #include "ipc/ipc_channel.h"
39 #include "ipc/ipc_switches.h" 39 #include "ipc/ipc_switches.h"
40 #include "native_client/src/shared/imc/nacl_imc.h" 40 #include "native_client/src/shared/imc/nacl_imc.h"
41 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
42 #include "net/base/tcp_listen_socket.h"
42 #include "ppapi/proxy/ppapi_messages.h" 43 #include "ppapi/proxy/ppapi_messages.h"
43 44
44 #if defined(OS_POSIX) 45 #if defined(OS_POSIX)
45 #include <fcntl.h> 46 #include <fcntl.h>
46 47
47 #include "ipc/ipc_channel_posix.h" 48 #include "ipc/ipc_channel_posix.h"
48 #elif defined(OS_WIN) 49 #elif defined(OS_WIN)
49 #include <windows.h> 50 #include <windows.h>
50 51
51 #include "base/threading/thread.h" 52 #include "base/threading/thread.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 627
627 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( 628 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
628 reply_msg_, handles_for_renderer, channel_handle); 629 reply_msg_, handles_for_renderer, channel_handle);
629 chrome_render_message_filter_->Send(reply_msg_); 630 chrome_render_message_filter_->Send(reply_msg_);
630 chrome_render_message_filter_ = NULL; 631 chrome_render_message_filter_ = NULL;
631 reply_msg_ = NULL; 632 reply_msg_ = NULL;
632 internal_->sockets_for_renderer.clear(); 633 internal_->sockets_for_renderer.clear();
633 return true; 634 return true;
634 } 635 }
635 636
637 #if defined(OS_POSIX)
638 SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
639 SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1", 4014);
Mark Seaborn 2012/09/10 15:39:45 Nit: Can you make 4014 a named constant? And comm
halyavin 2012/09/11 11:16:12 Done.
640 if (listen(s, 1)) {
641 LOG(ERROR) << "Failed to listen debug stub socket";
Mark Seaborn 2012/09/10 15:39:45 Missing a preposition. Maybe "listen() failed on
halyavin 2012/09/11 11:16:12 Done.
642 return net::TCPListenSocket::kInvalidSocket;
643 }
644 return s;
645 }
646 #endif
647
636 bool NaClProcessHost::StartNaClExecution() { 648 bool NaClProcessHost::StartNaClExecution() {
637 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 649 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
638 650
639 nacl::NaClStartParams params; 651 nacl::NaClStartParams params;
640 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 652 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
641 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 653 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
642 params.version = chrome::VersionInfo().CreateVersionString(); 654 params.version = chrome::VersionInfo().CreateVersionString();
643 params.enable_exception_handling = enable_exception_handling_; 655 params.enable_exception_handling = enable_exception_handling_;
644 params.enable_debug_stub = enable_debug_stub_; 656 params.enable_debug_stub = enable_debug_stub_;
645 params.enable_ipc_proxy = enable_ipc_proxy_; 657 params.enable_ipc_proxy = enable_ipc_proxy_;
646 658
647 base::PlatformFile irt_file = nacl_browser->IrtFile(); 659 base::PlatformFile irt_file = nacl_browser->IrtFile();
648 CHECK_NE(irt_file, base::kInvalidPlatformFileValue); 660 CHECK_NE(irt_file, base::kInvalidPlatformFileValue);
649 661
650 const ChildProcessData& data = process_->GetData(); 662 const ChildProcessData& data = process_->GetData();
651 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) { 663 for (size_t i = 0; i < internal_->sockets_for_sel_ldr.size(); i++) {
652 if (!ShareHandleToSelLdr(data.handle, 664 if (!ShareHandleToSelLdr(data.handle,
653 internal_->sockets_for_sel_ldr[i], true, 665 internal_->sockets_for_sel_ldr[i], true,
654 &params.handles)) { 666 &params.handles)) {
655 return false; 667 return false;
656 } 668 }
657 } 669 }
658 670
659 // Send over the IRT file handle. We don't close our own copy! 671 // Send over the IRT file handle. We don't close our own copy!
660 if (!ShareHandleToSelLdr(data.handle, irt_file, false, &params.handles)) 672 if (!ShareHandleToSelLdr(data.handle, irt_file, false, &params.handles))
661 return false; 673 return false;
662 674
675 #if defined(OS_POSIX)
676 if (enable_debug_stub_) {
Mark Seaborn 2012/09/10 15:39:45 Nit: can you put this after the Mac shared memory
halyavin 2012/09/11 11:16:12 Done.
677 SocketDescriptor server_socket = GetDebugStubSocketHandle();
678 if (server_socket != net::TCPListenSocket::kInvalidSocket) {
679 params.debug_stub_server_socket =
680 nacl::FileDescriptor(server_socket, true);
681 }
682 }
683 #endif
684
663 #if defined(OS_MACOSX) 685 #if defined(OS_MACOSX)
664 // For dynamic loading support, NaCl requires a file descriptor that 686 // For dynamic loading support, NaCl requires a file descriptor that
665 // was created in /tmp, since those created with shm_open() are not 687 // was created in /tmp, since those created with shm_open() are not
666 // mappable with PROT_EXEC. Rather than requiring an extra IPC 688 // mappable with PROT_EXEC. Rather than requiring an extra IPC
667 // round trip out of the sandbox, we create an FD here. 689 // round trip out of the sandbox, we create an FD here.
668 base::SharedMemory memory_buffer; 690 base::SharedMemory memory_buffer;
669 base::SharedMemoryCreateOptions options; 691 base::SharedMemoryCreateOptions options;
670 options.size = 1; 692 options.size = 1;
671 options.executable = true; 693 options.executable = true;
672 if (!memory_buffer.Create(options)) { 694 if (!memory_buffer.Create(options)) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } else { 860 } else {
839 NaClStartDebugExceptionHandlerThread( 861 NaClStartDebugExceptionHandlerThread(
840 process_handle.Take(), info, 862 process_handle.Take(), info,
841 base::MessageLoopProxy::current(), 863 base::MessageLoopProxy::current(),
842 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 864 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
843 weak_factory_.GetWeakPtr())); 865 weak_factory_.GetWeakPtr()));
844 return true; 866 return true;
845 } 867 }
846 } 868 }
847 #endif 869 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698