summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/about_flags.cc7
-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
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/tools/chromeactions.txt1
8 files changed, 77 insertions, 22 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index dd81e4c..4123c76 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5106,6 +5106,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_NACL_GDB_DESCRIPTION" desc="Description of the 'Debug Native Client applications at startup' lab.">
Set path to nacl-gdb debugger. It will be attached to NaCl applications at startup.
</message>
+ <message name="IDS_FLAGS_NACL_GDB_SCRIPT_NAME" desc="Name of the 'Script executed by Native Client application debugger at startup' lab.">
+ Script to be executed by nacl-gdb at startup.
+ </message>
+ <message name="IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION" desc="Description of the 'Script executed by Native Client application debugger at startup' lab.">
+ Set path to script with gdb commands which will be executed by nacl-gdb at startup.
+ </message>
<message name="IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER" desc="Name of the 'Disable better ranking of previously selected shortcuts in omnibox' lab.">
Disable 'shortcuts' in the omnibox.
</message>
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");
}
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 06429f1..308b85f 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -833,6 +833,9 @@ const char kMultiProfiles[] = "multi-profiles";
// flag can't be used.
const char kNaClGdb[] = "nacl-gdb";
+// GDB script to pass to the nacl-gdb debugger at startup.
+const char kNaClGdbScript[] = "nacl-gdb-script";
+
// On POSIX only: the contents of this flag are prepended to the nacl-loader
// command line. Useful values might be "valgrind" or "xterm -e gdb --args".
const char kNaClLoaderCmdPrefix[] = "nacl-loader-cmd-prefix";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index a855f65..91704a9 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -226,6 +226,7 @@ extern const char kMessageLoopHistogrammer[];
extern const char kMetricsRecordingOnly[];
extern const char kMultiProfiles[];
extern const char kNaClGdb[];
+extern const char kNaClGdbScript[];
extern const char kNaClLoaderCmdPrefix[];
extern const char kNetLogLevel[];
extern const char kNoDefaultBrowserCheck[];
diff --git a/chrome/tools/chromeactions.txt b/chrome/tools/chromeactions.txt
index 05824a0..f50b740 100644
--- a/chrome/tools/chromeactions.txt
+++ b/chrome/tools/chromeactions.txt
@@ -27,6 +27,7 @@
0x681dbf08b11af420 AboutFlags_match-preview
0x0156f26c1be32122 AboutFlags_my-special-feature
0x94c46ee32cd0fd19 AboutFlags_nacl-gdb
+0xbec26a19fa263850 AboutFlags_nacl-gdb-script
0xb41d9c886871e31a AboutFlags_page-prerender
0x735ca25b198de8ab AboutFlags_prerender-from-omnibox
0xb33861525ba727a4 AboutFlags_print-preview