Commit 7e3c4177 authored by scottmg's avatar scottmg Committed by Commit bot

Remove CAPS

One less crash_service, which is especially confusing because there's two
crash_service targets and also a content_shell_crash_service.exe.

TBR=sky

Review URL: https://codereview.chromium.org/1858883004

Cr-Commit-Position: refs/heads/master@{#389907}
parent e2ee0b0a
......@@ -225,7 +225,6 @@
}],
['OS=="win"', {
'dependencies': [
'../chrome/tools/crash_service/caps/caps.gyp:*',
'../chrome_elf/chrome_elf.gyp:*',
'../courgette/courgette.gyp:*',
'../rlz/rlz.gyp:*',
......
......@@ -707,10 +707,6 @@
# to the GN build.
'../chrome/chrome.gyp:sb_sigutil',
# This project is up in the air. Don't need to convert it unless
# we decide we need for something. Owner: scottmg.
'../chrome/tools/crash_service/caps/caps.gyp:caps',
'../components/test_runner/test_runner.gyp:layout_test_helper',
'../content/content_shell_and_tests.gyp:content_shell_crash_service',
'../gpu/gpu.gyp:angle_end2end_tests',
......
# Copyright 2015 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.
assert(is_win)
executable("crash_service") {
sources = [
"main.cc",
]
configs -= [ "//build/config/win:console" ]
configs += [ "//build/config/win:windowed" ]
deps = [
"//base",
"//chrome/common:constants",
"//chrome/installer/util:with_no_strings",
"//components/crash/content/tools:crash_service",
"//content/public/common:static_switches",
]
}
if (target_cpu == "x86" && current_cpu == "x86") {
# Cross-compile a 64-bit version when compiling a 64-bit target.
copy("crash_service_win64") {
if (is_clang) {
maybe_clang = "clang_"
} else {
maybe_clang = ""
}
crash_service_64_target =
":crash_service(//build/toolchain/win:${maybe_clang}x64)"
sources = [
# It would be nice if get_target_outputs would work on the executable,
# but instead we have to manually compute the executable name.
get_label_info(crash_service_64_target, "root_out_dir") +
"/crash_service.exe",
]
outputs = [
"$root_build_dir/crash_service_win64.exe",
]
deps = [
crash_service_64_target,
]
}
}
cpu@chromium.org
scottmg@chromium.org
# Copyright 2015 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.
{
'variables': {
'chromium_code': 1,
},
'includes': [
'../../../../build/util/version.gypi',
'../../../../build/win_precompile.gypi',
],
'targets': [
{
'target_name': 'caps_resources',
'type': 'none',
'variables': {
'branding_path': '../../../app/theme/<(branding_path_component)/BRANDING',
'output_dir': 'caps',
'template_input_path': '../../../app/chrome_version.rc.version',
},
'sources': [
'caps.ver',
],
'includes': [
'../../../version_resource_rules.gypi',
],
},
{
'target_name': 'caps',
'type': 'executable',
'include_dirs': [
'..',
],
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/caps/caps_version.rc',
'exit_codes.h',
'logger_win.cc',
'logger_win.h',
'main_win.cc',
'process_singleton_win.cc',
'process_singleton_win.h',
],
'dependencies': [
'caps_resources',
'../../../../base/base.gyp:base',
'../../../../components/components.gyp:generate_version_info',
],
'msvs_settings': {
'VCLinkerTool': {
# Set /SUBSYSTEM:WINDOWS.
'SubSystem': '2',
},
},
},
],
}
INTERNAL_NAME=caps
ORIGINAL_FILENAME=caps.exe
// Copyright 2015 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.
#ifndef CHROME_TOOLS_CRASH_SERVICE_CAPS_EXIT_CODES_H_
#define CHROME_TOOLS_CRASH_SERVICE_CAPS_EXIT_CODES_H_
namespace caps {
// Exit codes for CAPS. Don't reorder these values.
enum ExitCodes {
EC_NORMAL_EXIT = 0,
EC_EXISTING_INSTANCE,
EC_INIT_ERROR,
EC_LAST_CODE
};
} // namespace caps
#endif // CHROME_TOOLS_CRASH_SERVICE_CAPS_EXIT_CODES_H_
// Copyright 2015 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 <windows.h>
#include <stddef.h>
#include <time.h>
#include "base/files/file_path.h"
#include "base/strings/stringprintf.h"
#include "chrome/tools/crash_service/caps/logger_win.h"
#include "components/version_info/version_info_values.h"
namespace {
// Every message has this structure:
// <index>~ <tick_count> <message> ~\n"
const char kMessageHeader[] = "%03d~ %08x %s ~\n";
// Do not re-order these messages. Only add at the end.
const char* kMessages[] {
"start pid(%lu) version(%s) time(%s)", // 0
"exit pid(%lu) time(%s)", // 1
"instance found", // 2
};
bool WriteLogLine(HANDLE file, const std::string& txt) {
if (txt.empty())
return true;
DWORD written;
auto rc = ::WriteFile(file, txt.c_str(),
static_cast<DWORD>(txt.size()),
&written,
nullptr);
return (rc == TRUE);
}
// Uses |kMessages| at |index| above to write to disk a formatted log line.
bool WriteFormattedLogLine(HANDLE file, size_t index, ...) {
va_list ap;
va_start(ap, index);
auto fmt = base::StringPrintf(
kMessageHeader, index, ::GetTickCount(), kMessages[index]);
auto msg = base::StringPrintV(fmt.c_str(), ap);
auto rc = WriteLogLine(file, msg.c_str());
va_end(ap);
return rc;
}
// Returns the current time and date formatted in standard C style.
std::string DateTime() {
time_t current_time = 0;
time(&current_time);
struct tm local_time = {0};
char time_buf[26] = {0};
localtime_s(&local_time, &current_time);
asctime_s(time_buf, &local_time);
time_buf[24] = '\0';
return time_buf;
}
} // namespace
namespace caps {
Logger::Logger(const base::FilePath& path) : file_(INVALID_HANDLE_VALUE) {
auto logfile = path.Append(L"caps_log.txt");
// Opening a file like so allows atomic appends, but can't be used
// for anything else.
DWORD kShareAll = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
file_ = ::CreateFile(logfile.value().c_str(),
FILE_APPEND_DATA, kShareAll,
nullptr,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
nullptr);
if (file_ == INVALID_HANDLE_VALUE)
return;
WriteFormattedLogLine(
file_, 0, ::GetCurrentProcessId(), PRODUCT_VERSION, DateTime().c_str());
}
Logger::~Logger() {
if (file_ != INVALID_HANDLE_VALUE) {
WriteFormattedLogLine(
file_, 1, ::GetCurrentProcessId(), DateTime().c_str());
::CloseHandle(file_);
}
}
} // namespace caps
// Copyright 2015 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.
#ifndef CHROME_TOOLS_CRASH_SERVICE_CAPS_LOGGER_WIN_H_
#define CHROME_TOOLS_CRASH_SERVICE_CAPS_LOGGER_WIN_H_
#include <windows.h>
#include "base/macros.h"
namespace base {
class FilePath;
}
namespace caps {
// Creates a human-readable activity log file.
class Logger {
public:
explicit Logger(const base::FilePath& path);
~Logger();
private:
HANDLE file_;
DISALLOW_COPY_AND_ASSIGN(Logger);
};
} // namespace caps
#endif // CHROME_TOOLS_CRASH_SERVICE_CAPS_LOGGER_WIN_H_
// Copyright 2015 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 <windows.h>
#include "base/at_exit.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/version.h"
#include "chrome/tools/crash_service/caps/exit_codes.h"
#include "chrome/tools/crash_service/caps/logger_win.h"
#include "chrome/tools/crash_service/caps/process_singleton_win.h"
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
base::AtExitManager at_exit_manager;
base::FilePath dir_exe;
if (!PathService::Get(base::DIR_EXE, &dir_exe))
return caps::EC_INIT_ERROR;
// What directory we write depends if we are being run from the actual
// location (a versioned directory) or from a build output directory.
base::Version version(dir_exe.BaseName().MaybeAsASCII());
auto data_path = version.IsValid() ? dir_exe.DirName() : dir_exe;
// Start logging.
caps::Logger logger(data_path);
// Check for an existing running instance.
caps::ProcessSingleton process_singleton;
if (process_singleton.other_instance())
return caps::EC_EXISTING_INSTANCE;
return caps::EC_NORMAL_EXIT;
}
// Copyright 2015 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 <windows.h>
#include "chrome/tools/crash_service/caps/process_singleton_win.h"
namespace caps {
ProcessSingleton::ProcessSingleton() : mutex_(nullptr) {
auto mutex = ::CreateMutex(nullptr, TRUE, L"CHROME.CAPS.V1");
if (!mutex)
return;
if (::GetLastError() == ERROR_ALREADY_EXISTS) {
::CloseHandle(mutex);
return;
}
// We are now the single instance.
mutex_ = mutex;
}
ProcessSingleton::~ProcessSingleton() {
if (mutex_)
::CloseHandle(mutex_);
}
} // namespace caps
// Copyright 2015 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.
#ifndef CHROME_TOOLS_CRASH_SERVICE_CAPS_PROCESS_SINGLETON_WIN_H_
#define CHROME_TOOLS_CRASH_SERVICE_CAPS_PROCESS_SINGLETON_WIN_H_
#include <windows.h>
#include "base/macros.h"
namespace caps {
// Uses a named mutex to make sure that only one process of
// with this particular version is launched.
class ProcessSingleton {
public:
ProcessSingleton();
~ProcessSingleton();
bool other_instance() const { return mutex_ == NULL; }
private:
HANDLE mutex_;
DISALLOW_COPY_AND_ASSIGN(ProcessSingleton);
};
} // namespace caps
#endif // CHROME_TOOLS_CRASH_SERVICE_CAPS_PROCESS_SINGLETON_WIN_H_
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!--The compatibility section will be merged from build/win/compatibility.manifest -->
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
<ms_asmv2:security>
<ms_asmv2:requestedPrivileges>
<ms_asmv2:requestedExecutionLevel level="asInvoker">
</ms_asmv2:requestedExecutionLevel>
</ms_asmv2:requestedPrivileges>
</ms_asmv2:security>
</ms_asmv2:trustInfo>
</assembly>
// Copyright (c) 2010 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 <windows.h>
#include <stdlib.h>
#include <tchar.h>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "components/crash/content/tools/crash_service.h"
namespace {
const wchar_t kStandardLogFile[] = L"operation_log.txt";
bool GetCrashServiceDirectory(base::FilePath* dir) {
base::FilePath temp_dir;
if (!base::GetTempDir(&temp_dir))
return false;
temp_dir = temp_dir.Append(L"chrome_crashes");
if (!base::PathExists(temp_dir)) {
if (!base::CreateDirectory(temp_dir))
return false;
}
*dir = temp_dir;
return true;
}
} // namespace.
int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line,
int show_mode) {
// Manages the destruction of singletons.
base::AtExitManager exit_manager;
base::CommandLine::Init(0, NULL);
chrome::RegisterPathProvider();
// We use/create a directory under the user's temp folder, for logging.
base::FilePath operating_dir;
GetCrashServiceDirectory(&operating_dir);
base::FilePath log_file = operating_dir.Append(kStandardLogFile);
// Logging to stderr (to help with debugging failures on the
// buildbots) and to a file.
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_ALL;
settings.log_file = log_file.value().c_str();
logging::InitLogging(settings);
// Logging with pid, tid and timestamp.
logging::SetLogItems(true, true, true, false);
VLOG(1) << "session start. cmdline is [" << cmd_line << "]";
base::FilePath dumps_path;
if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) {
LOG(ERROR) << "could not get DIR_CRASH_DUMPS";
return 1;
}
breakpad::CrashService crash_service;
if (!crash_service.Initialize(operating_dir, dumps_path))
return 1;
VLOG(1) << "ready to process crash requests";
// Enter the message loop.
int retv = crash_service.ProcessingLoop();
// Time to exit.
VLOG(1) << "session end. return code is " << retv;
return retv;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment