diff options
author | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 11:41:13 +0000 |
---|---|---|
committer | halyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 11:41:13 +0000 |
commit | 401b9079df2f9060dfe117a7995a58854a5dc531 (patch) | |
tree | c17107e0b3769d30d6e60f011babd9be385474ab /chrome/browser | |
parent | 9834372e712aab2753fa453efe09d3f230acaa2f (diff) | |
download | chromium_src-401b9079df2f9060dfe117a7995a58854a5dc531.zip chromium_src-401b9079df2f9060dfe117a7995a58854a5dc531.tar.gz chromium_src-401b9079df2f9060dfe117a7995a58854a5dc531.tar.bz2 |
Add nacl-gdb-script switch.
It points to a script that will be executed by nacl-gdb at startup.
BUG= 117010
TEST= browser_tests --gtest_filter=NaClGdbScript*
Review URL: https://chromiumcodereview.appspot.com/10447012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/about_flags.cc | 7 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 12 | ||||
-rw-r--r-- | chrome/browser/nacl_host/test/mock_nacl_gdb.cc | 10 | ||||
-rw-r--r-- | chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc | 59 |
4 files changed, 66 insertions, 22 deletions
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index f45cd1c..5d4d65f 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -277,6 +277,13 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kNaClGdb) }, { + "nacl-gdb-script", // FLAGS:RECORD_UMA + IDS_FLAGS_NACL_GDB_SCRIPT_NAME, + IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION, + kOsAll, + SINGLE_VALUE_TYPE(switches::kNaClGdbScript) + }, + { "extension-apis", // FLAGS:RECORD_UMA IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME, IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION, 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"); } |