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

Unified Diff: mojo/runner/init.cc

Issue 1140553002: Make --wait-for-debugger work for mandoline launcher process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/runner/init.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/runner/init.cc
diff --git a/mojo/runner/init.cc b/mojo/runner/init.cc
index 0656c6ec90dd182b6ea47ff9daaac88b96c60d9b..4a8d7007ccea33f5b2eba3e665d5bbc3aa4d2467 100644
--- a/mojo/runner/init.cc
+++ b/mojo/runner/init.cc
@@ -4,7 +4,18 @@
#include "mojo/runner/init.h"
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/debug/debugger.h"
#include "base/logging.h"
+#include "base/stl_util.h"
+#include "base/strings/string_split.h"
+#include "base/strings/utf_string_conversions.h"
+#include "mojo/runner/switches.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
namespace mojo {
namespace runner {
@@ -20,5 +31,28 @@ void InitializeLogging() {
false); // Tick count
}
+void WaitForDebuggerIfNecessary() {
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kWaitForDebugger)) {
+ std::vector<std::string> apps_to_debug;
+ base::SplitString(
+ command_line->GetSwitchValueASCII(switches::kWaitForDebugger), ',',
+ &apps_to_debug);
+ std::string app = command_line->GetSwitchValueASCII(switches::kApp);
+ if (app.empty())
+ app = "launcher"; // If we're not in a child process look for "launcher".
+ if (apps_to_debug.empty() || ContainsValue(apps_to_debug, app)) {
+#if defined(OS_WIN)
+ base::string16 appw = base::UTF8ToUTF16(app);
+ MessageBox(NULL, appw.c_str(), appw.c_str(), MB_OK | MB_SETFOREGROUND);
+#else
+ LOG(ERROR) << app << " waiting for GDB. pid: " << getpid();
+ base::debug::WaitForDebugger(60, true);
+#endif
+ }
+ }
+}
+
} // namespace runner
} // namespace mojo
« no previous file with comments | « mojo/runner/init.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698