summaryrefslogtreecommitdiffstats
path: root/chrome/browser/nacl_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc12
-rw-r--r--chrome/browser/nacl_host/test/mock_nacl_gdb.cc10
-rw-r--r--chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc59
3 files changed, 59 insertions, 22 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index bd4449a..5cb071f 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -313,6 +313,12 @@ scoped_ptr<CommandLine> NaClProcessHost::GetCommandForLaunchWithGdb(
cmd_line->AppendArgNative(FILE_PATH_LITERAL("nacl-manifest ") +
manifest_path.value());
}
+ FilePath script = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kNaClGdbScript);
+ if (!script.empty()) {
+ cmd_line->AppendArg("--command");
+ cmd_line->AppendArgNative(script.value());
+ }
cmd_line->AppendArg("--args");
const CommandLine::StringVector& argv = line->argv();
for (size_t i = 0; i < argv.size(); i++) {
@@ -386,6 +392,12 @@ bool NaClProcessHost::LaunchNaClGdb(base::ProcessId pid) {
cmd_line.AppendArg("dump binary value /proc/" +
base::IntToString(base::GetCurrentProcId()) +
"/fd/" + base::IntToString(fds[1]) + " (char)0");
+ FilePath script = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kNaClGdbScript);
+ if (!script.empty()) {
+ cmd_line.AppendArg("--command");
+ cmd_line.AppendArgNative(script.value());
+ }
// wait on fds[0]
// If the debugger crashes before attaching to the NaCl process, the user can
// release resources by terminating the NaCl loader in Chrome Task Manager.
diff --git a/chrome/browser/nacl_host/test/mock_nacl_gdb.cc b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
index c723684..e7a75d0 100644
--- a/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
+++ b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
@@ -14,6 +14,7 @@
static const char kArgs[] = "--args";
static const char kEvalCommand[] = "--eval-command";
+static const char kCommand[] = "--command";
static const char kNaClIrt[] = "nacl-irt ";
static const char kPass[] = "PASS";
static const char kDump[] = "dump binary value ";
@@ -64,6 +65,15 @@ int main(int argc, char** argv) {
}
continue;
}
+ if (strcmp(argv[i], kCommand) == 0) {
+ // Command line shouldn't end with --command switch without value.
+ i += 2;
+ CHECK_LE(i, argc);
+ std::string nacl_gdb_script(argv[i - 1]);
+ file_util::WriteFile(FilePath::FromUTF8Unsafe(nacl_gdb_script),
+ kPass, strlen(kPass));
+ continue;
+ }
// Unknown argument.
NOTREACHED() << "Invalid argument " << argv[i];
}
diff --git a/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc
index cc0537c0..ec356708 100644
--- a/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc
+++ b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc
@@ -29,7 +29,43 @@ class NaClGdbTest : public PPAPINaClTest {
EXPECT_TRUE(PathService::Get(base::DIR_EXE, &mock_nacl_gdb));
mock_nacl_gdb = mock_nacl_gdb.Append(kMockNaClGdb);
command_line->AppendSwitchPath(switches::kNaClGdb, mock_nacl_gdb);
+ EXPECT_TRUE(file_util::CreateTemporaryFile(&script_));
+ command_line->AppendSwitchPath(switches::kNaClGdbScript, script_);
}
+
+ void RunWithNaClGdb(std::string test_name) {
+ FilePath mock_nacl_gdb_file;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::string content;
+ // TODO(halyavin): Make this test work on Windows 32-bit. Currently this
+ // is not possible because NaCl doesn't work without sandbox since 1Gb of
+ // space is not reserved. We can't reserve 1Gb of space because
+ // base::LaunchProcess doesn't support creating suspended processes. We need
+ // to either add suspended process support to base::LaunchProcess or use
+ // Win API.
+#if defined(OS_WIN)
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_DISABLED) {
+ return;
+ }
+#endif
+ EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file));
+ env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe());
+ RunTestViaHTTP(test_name);
+ env->UnSetVar("MOCK_NACL_GDB");
+
+ EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content));
+ EXPECT_STREQ("PASS", content.c_str());
+ EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false));
+
+ content.clear();
+ EXPECT_TRUE(file_util::ReadFileToString(script_, &content));
+ EXPECT_STREQ("PASS", content.c_str());
+ EXPECT_TRUE(file_util::Delete(script_, false));
+ }
+
+ private:
+ FilePath script_;
};
// Fails on the ASAN test bot. See http://crbug.com/122219
@@ -39,26 +75,5 @@ class NaClGdbTest : public PPAPINaClTest {
#define MAYBE_Empty Empty
#endif
IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) {
- FilePath mock_nacl_gdb_file;
- scoped_ptr<base::Environment> env(base::Environment::Create());
- std::string content;
- // TODO(halyavin): Make this test to work on Windows 32-bit. Currently this
- // is not possible because NaCl doesn't work without sandbox since 1Gb of
- // space is not reserved. We can't reserve 1Gb of space because
- // base::LaunchProcess doesn't support creating suspended processes. We need
- // to either add suspended process support to base::LaunchProcess or use
- // Win API.
-#if defined(OS_WIN)
- if (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_DISABLED) {
- return;
- }
-#endif
- EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file));
- env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe());
- RunTestViaHTTP("Empty");
- env->UnSetVar("MOCK_NACL_GDB");
- EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content));
- EXPECT_STREQ("PASS", content.c_str());
- EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false));
+ RunWithNaClGdb("Empty");
}