blob: 17d5c1b46b0392ac6b58d6c1676ddc764494521e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mojo/runner/init.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/files/file_path.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>
#elif (OS_POSIX)
#include <unistd.h>
#endif
namespace mojo {
namespace runner {
void InitializeLogging() {
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
// To view log output with IDs and timestamps use "adb logcat -v threadtime".
logging::SetLogItems(false, // Process ID
false, // Thread ID
false, // Timestamp
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 = "launcher";
if (command_line->HasSwitch(switches::kChildProcess)) {
app = command_line->GetSwitchValuePath(switches::kChildProcess)
.BaseName()
.RemoveExtension()
.MaybeAsASCII();
}
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
|