OLD | NEW |
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 cmd_line->AppendArg("--eval-command"); | 305 cmd_line->AppendArg("--eval-command"); |
306 const FilePath::StringType& irt_path = | 306 const FilePath::StringType& irt_path = |
307 NaClBrowser::GetInstance()->GetIrtFilePath().value(); | 307 NaClBrowser::GetInstance()->GetIrtFilePath().value(); |
308 cmd_line->AppendArgNative(FILE_PATH_LITERAL("nacl-irt ") + irt_path); | 308 cmd_line->AppendArgNative(FILE_PATH_LITERAL("nacl-irt ") + irt_path); |
309 FilePath manifest_path = GetManifestPath(); | 309 FilePath manifest_path = GetManifestPath(); |
310 if (!manifest_path.empty()) { | 310 if (!manifest_path.empty()) { |
311 cmd_line->AppendArg("--eval-command"); | 311 cmd_line->AppendArg("--eval-command"); |
312 cmd_line->AppendArgNative(FILE_PATH_LITERAL("nacl-manifest ") + | 312 cmd_line->AppendArgNative(FILE_PATH_LITERAL("nacl-manifest ") + |
313 manifest_path.value()); | 313 manifest_path.value()); |
314 } | 314 } |
| 315 FilePath script = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 316 switches::kNaClGdbScript); |
| 317 if (!script.empty()) { |
| 318 cmd_line->AppendArg("--command"); |
| 319 cmd_line->AppendArgNative(script.value()); |
| 320 } |
315 cmd_line->AppendArg("--args"); | 321 cmd_line->AppendArg("--args"); |
316 const CommandLine::StringVector& argv = line->argv(); | 322 const CommandLine::StringVector& argv = line->argv(); |
317 for (size_t i = 0; i < argv.size(); i++) { | 323 for (size_t i = 0; i < argv.size(); i++) { |
318 cmd_line->AppendArgNative(argv[i]); | 324 cmd_line->AppendArgNative(argv[i]); |
319 } | 325 } |
320 return scoped_ptr<CommandLine>(cmd_line); | 326 return scoped_ptr<CommandLine>(cmd_line); |
321 } | 327 } |
322 #elif defined(OS_LINUX) | 328 #elif defined(OS_LINUX) |
323 namespace { | 329 namespace { |
324 class NaClGdbWatchDelegate : public MessageLoopForIO::Watcher { | 330 class NaClGdbWatchDelegate : public MessageLoopForIO::Watcher { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 if (pipe(fds) != 0) | 384 if (pipe(fds) != 0) |
379 return false; | 385 return false; |
380 // Tell the debugger to send a byte to the writable end of the pipe. | 386 // Tell the debugger to send a byte to the writable end of the pipe. |
381 // We use a file descriptor in our process because the debugger will be | 387 // We use a file descriptor in our process because the debugger will be |
382 // typically launched in a separate terminal, and a lot of terminals close all | 388 // typically launched in a separate terminal, and a lot of terminals close all |
383 // file descriptors before launching external programs. | 389 // file descriptors before launching external programs. |
384 cmd_line.AppendArg("--eval-command"); | 390 cmd_line.AppendArg("--eval-command"); |
385 cmd_line.AppendArg("dump binary value /proc/" + | 391 cmd_line.AppendArg("dump binary value /proc/" + |
386 base::IntToString(base::GetCurrentProcId()) + | 392 base::IntToString(base::GetCurrentProcId()) + |
387 "/fd/" + base::IntToString(fds[1]) + " (char)0"); | 393 "/fd/" + base::IntToString(fds[1]) + " (char)0"); |
| 394 FilePath script = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 395 switches::kNaClGdbScript); |
| 396 if (!script.empty()) { |
| 397 cmd_line.AppendArg("--command"); |
| 398 cmd_line.AppendArgNative(script.value()); |
| 399 } |
388 // wait on fds[0] | 400 // wait on fds[0] |
389 // If the debugger crashes before attaching to the NaCl process, the user can | 401 // If the debugger crashes before attaching to the NaCl process, the user can |
390 // release resources by terminating the NaCl loader in Chrome Task Manager. | 402 // release resources by terminating the NaCl loader in Chrome Task Manager. |
391 nacl_gdb_watcher_delegate_.reset( | 403 nacl_gdb_watcher_delegate_.reset( |
392 new NaClGdbWatchDelegate( | 404 new NaClGdbWatchDelegate( |
393 fds[0], fds[1], | 405 fds[0], fds[1], |
394 base::Bind(&NaClProcessHost::OnNaClGdbAttached, | 406 base::Bind(&NaClProcessHost::OnNaClGdbAttached, |
395 weak_factory_.GetWeakPtr()))); | 407 weak_factory_.GetWeakPtr()))); |
396 MessageLoopForIO::current()->WatchFileDescriptor( | 408 MessageLoopForIO::current()->WatchFileDescriptor( |
397 fds[0], | 409 fds[0], |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 } else { | 763 } else { |
752 NaClStartDebugExceptionHandlerThread( | 764 NaClStartDebugExceptionHandlerThread( |
753 process_handle.Take(), info, | 765 process_handle.Take(), info, |
754 base::MessageLoopProxy::current(), | 766 base::MessageLoopProxy::current(), |
755 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 767 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
756 weak_factory_.GetWeakPtr())); | 768 weak_factory_.GetWeakPtr())); |
757 return true; | 769 return true; |
758 } | 770 } |
759 } | 771 } |
760 #endif | 772 #endif |
OLD | NEW |