[gardening] Integrate Crashpad with run_vm_tests.
Change-Id: Ia18b5e22cefe1fb4dfa8d8ed9361789304eb8acc Reviewed-on: https://dart-review.googlesource.com/c/81826 Commit-Queue: Vyacheslav Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com> Auto-Submit: Vyacheslav Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
71ac95c53d
commit
f185012d20
+31
-13
@@ -89,6 +89,35 @@ build_libdart_builtin("libdart_builtin_product_fuchsia") {
|
||||
]
|
||||
}
|
||||
|
||||
static_library("crashpad") {
|
||||
configs += [
|
||||
"..:dart_arch_config",
|
||||
"..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_os_fuchsia_config",
|
||||
]
|
||||
if (is_fuchsia) {
|
||||
configs -= [ "//build/config:symbol_visibility_hidden" ]
|
||||
}
|
||||
include_dirs = [ ".." ]
|
||||
sources = [
|
||||
"crashpad.cc",
|
||||
]
|
||||
|
||||
if (dart_use_crashpad) {
|
||||
assert(is_win, "dart_use_crashpad is only supported on Windows")
|
||||
deps = [
|
||||
"//third_party/crashpad/crashpad/client",
|
||||
"//third_party/mini_chromium/mini_chromium/base",
|
||||
|
||||
# This binary is used to handle crashes of the dart binary.
|
||||
"//third_party/crashpad/crashpad/handler:crashpad_handler",
|
||||
]
|
||||
include_dirs += [ "//third_party/crashpad" ]
|
||||
defines = [ "DART_USE_CRASHPAD" ]
|
||||
}
|
||||
}
|
||||
|
||||
template("build_gen_snapshot") {
|
||||
extra_configs = []
|
||||
if (defined(invoker.extra_configs)) {
|
||||
@@ -664,6 +693,7 @@ template("dart_executable") {
|
||||
":libdart_builtin",
|
||||
"//third_party/boringssl",
|
||||
"//third_party/zlib",
|
||||
":crashpad",
|
||||
] + extra_deps
|
||||
|
||||
defines = extra_defines
|
||||
@@ -680,19 +710,6 @@ template("dart_executable") {
|
||||
"//third_party",
|
||||
]
|
||||
|
||||
if (dart_use_crashpad) {
|
||||
assert(is_win, "dart_use_crashpad is only supported on Windows")
|
||||
deps += [
|
||||
"//third_party/crashpad/crashpad/client",
|
||||
"//third_party/mini_chromium/mini_chromium/base",
|
||||
|
||||
# This binary is used to handle crashes of the dart binary.
|
||||
"//third_party/crashpad/crashpad/handler:crashpad_handler",
|
||||
]
|
||||
include_dirs += [ "//third_party/crashpad" ]
|
||||
defines += [ "DART_USE_CRASHPAD" ]
|
||||
}
|
||||
|
||||
sources = [
|
||||
"dart_embedder_api_impl.cc",
|
||||
"error_exit.cc",
|
||||
@@ -882,6 +899,7 @@ executable("run_vm_tests") {
|
||||
}
|
||||
|
||||
deps = [
|
||||
":crashpad",
|
||||
":dart_kernel_platform_cc",
|
||||
":dart_snapshot_cc",
|
||||
":gen_kernel_bytecode_dill",
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "bin/crashpad.h"
|
||||
|
||||
#if defined(DART_USE_CRASHPAD)
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "crashpad/client/crashpad_client.h"
|
||||
#include "crashpad/client/crashpad_info.h"
|
||||
#endif
|
||||
|
||||
#include "bin/error_exit.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/platform.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
#if defined(DART_USE_CRASHPAD)
|
||||
#if !defined(HOST_OS_WINDOWS)
|
||||
#error "Currently we only support Crashpad on Windows"
|
||||
#endif
|
||||
|
||||
void InitializeCrashpadClient() {
|
||||
// DART_CRASHPAD_HANDLER and DART_CRASHPAD_CRASHES_DIR are set by the
|
||||
// testing framework.
|
||||
wchar_t* handler = _wgetenv(L"DART_CRASHPAD_HANDLER");
|
||||
wchar_t* crashes_dir = _wgetenv(L"DART_CRASHPAD_CRASHES_DIR");
|
||||
if (handler == nullptr || crashes_dir == nullptr || wcslen(handler) == 0 ||
|
||||
wcslen(crashes_dir) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Crashpad uses STL so we use it here too even though in general we
|
||||
// avoid it.
|
||||
const base::FilePath handler_path{std::wstring(handler)};
|
||||
const base::FilePath crashes_dir_path{std::wstring(crashes_dir)};
|
||||
const std::string url("");
|
||||
std::map<std::string, std::string> annotations;
|
||||
char* test_name = getenv("DART_TEST_NAME");
|
||||
if (test_name != nullptr) {
|
||||
annotations["dart_test_name"] = test_name;
|
||||
}
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
crashpad::CrashpadClient client;
|
||||
|
||||
// Prevent crashpad_handler from inheriting our standard output and error
|
||||
// handles. Otherwise we would not be able to close them ourselves making
|
||||
// tests that rely on that fail.
|
||||
HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
|
||||
SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
|
||||
const bool success =
|
||||
client.StartHandler(handler_path, crashes_dir_path, crashes_dir_path, url,
|
||||
annotations, arguments,
|
||||
/*restartable=*/true,
|
||||
/*asynchronous_start=*/false);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
|
||||
SetStdHandle(STD_ERROR_HANDLE, original_stderr);
|
||||
|
||||
if (!success) {
|
||||
Log::PrintErr("Failed to start the crash handler!\n");
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
crashpad::CrashpadInfo::GetCrashpadInfo()
|
||||
->set_gather_indirectly_referenced_memory(crashpad::TriState::kEnabled,
|
||||
/*limit=*/500 * MB);
|
||||
}
|
||||
#else
|
||||
void InitializeCrashpadClient() {}
|
||||
#endif // DART_USE_CRASHPAD
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef RUNTIME_BIN_CRASHPAD_H_
|
||||
#define RUNTIME_BIN_CRASHPAD_H_
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
void InitializeCrashpadClient();
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // RUNTIME_BIN_CRASHPAD_H_
|
||||
+3
-63
@@ -11,13 +11,9 @@
|
||||
#include "include/dart_embedder_api.h"
|
||||
#include "include/dart_tools_api.h"
|
||||
|
||||
#if defined(DART_USE_CRASHPAD)
|
||||
#include "crashpad/client/crashpad_client.h"
|
||||
#include "crashpad/client/crashpad_info.h"
|
||||
#endif
|
||||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/console.h"
|
||||
#include "bin/crashpad.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/dfe.h"
|
||||
#include "bin/directory.h"
|
||||
@@ -25,6 +21,7 @@
|
||||
#include "bin/eventhandler.h"
|
||||
#include "bin/extensions.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/gzip.h"
|
||||
#include "bin/isolate_data.h"
|
||||
#include "bin/loader.h"
|
||||
#include "bin/log.h"
|
||||
@@ -39,7 +36,6 @@
|
||||
#include "platform/growable_array.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/text_buffer.h"
|
||||
#include "bin/gzip.h"
|
||||
|
||||
#include "vm/flags.h"
|
||||
|
||||
@@ -952,59 +948,6 @@ Dart_Handle GetVMServiceAssetsArchiveCallback() {
|
||||
static Dart_GetVMServiceAssetsArchive GetVMServiceAssetsArchiveCallback = NULL;
|
||||
#endif // !defined(NO_OBSERVATORY)
|
||||
|
||||
#if defined(DART_USE_CRASHPAD)
|
||||
#if !defined(HOST_OS_WINDOWS)
|
||||
#error "Currently we only support Crashpad on Windows"
|
||||
#endif
|
||||
|
||||
static void ConfigureCrashpadClient(crashpad::CrashpadClient* client) {
|
||||
// DART_CRASHPAD_HANDLER and DART_CRASHPAD_CRASHES_DIR are set by the
|
||||
// testing framework.
|
||||
wchar_t* handler = _wgetenv(L"DART_CRASHPAD_HANDLER");
|
||||
wchar_t* crashes_dir = _wgetenv(L"DART_CRASHPAD_CRASHES_DIR");
|
||||
if (handler == nullptr || crashes_dir == nullptr || wcslen(handler) == 0 ||
|
||||
wcslen(crashes_dir) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Crashpad uses STL so we use it here too even though in general we
|
||||
// avoid it.
|
||||
const base::FilePath handler_path{std::wstring(handler)};
|
||||
const base::FilePath crashes_dir_path{std::wstring(crashes_dir)};
|
||||
const std::string url("");
|
||||
std::map<std::string, std::string> annotations;
|
||||
char* test_name = getenv("DART_TEST_NAME");
|
||||
if (test_name != nullptr) {
|
||||
annotations["dart_test_name"] = test_name;
|
||||
}
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
// Prevent crashpad_handler from inheriting our standard output and error
|
||||
// handles. Otherwise we would not be able to close them ourselves making
|
||||
// tests that rely on that fail.
|
||||
HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
|
||||
SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
|
||||
const bool success =
|
||||
client->StartHandler(handler_path, crashes_dir_path, crashes_dir_path,
|
||||
url, annotations, arguments,
|
||||
/*restartable=*/true,
|
||||
/*asynchronous_start=*/false);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
|
||||
SetStdHandle(STD_ERROR_HANDLE, original_stderr);
|
||||
|
||||
if (!success) {
|
||||
Log::PrintErr("Failed to start the crash handler!\n");
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
crashpad::CrashpadInfo::GetCrashpadInfo()
|
||||
->set_gather_indirectly_referenced_memory(crashpad::TriState::kEnabled,
|
||||
/*limit=*/500 * MB);
|
||||
}
|
||||
#endif // DART_USE_CRASHPAD
|
||||
|
||||
void main(int argc, char** argv) {
|
||||
char* script_name;
|
||||
const int EXTRA_VM_ARGUMENTS = 10;
|
||||
@@ -1068,10 +1011,7 @@ void main(int argc, char** argv) {
|
||||
}
|
||||
DartUtils::SetEnvironment(Options::environment());
|
||||
|
||||
#if defined(DART_USE_CRASHPAD)
|
||||
crashpad::CrashpadClient crashpad_client;
|
||||
ConfigureCrashpadClient(&crashpad_client);
|
||||
#endif
|
||||
InitializeCrashpadClient();
|
||||
|
||||
Loader::InitOnce();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "bin/console.h"
|
||||
#include "bin/crashpad.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/dfe.h"
|
||||
#include "bin/eventhandler.h"
|
||||
@@ -220,6 +221,8 @@ static int Main(int argc, const char** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dart::bin::InitializeCrashpadClient();
|
||||
|
||||
// Save the console state so we can restore it later.
|
||||
dart::bin::Console::SaveConfig();
|
||||
|
||||
|
||||
@@ -446,12 +446,13 @@ class VMTestSuite extends TestSuite {
|
||||
VMTestSuite(TestConfiguration configuration)
|
||||
: dartDir = Repository.dir.toNativePath(),
|
||||
super(configuration, "vm", ["runtime/tests/vm/vm.status"]) {
|
||||
var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
|
||||
// For running the tests we use the given '$runnerName' binary
|
||||
targetRunnerPath = '$buildDir/run_vm_tests';
|
||||
targetRunnerPath = '$buildDir/run_vm_tests$binarySuffix';
|
||||
|
||||
// For listing the tests we use the '$runnerName.host' binary if it exists
|
||||
// and use '$runnerName' if it doesn't.
|
||||
var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
var hostBinary = '$targetRunnerPath.host$binarySuffix';
|
||||
if (new File(hostBinary).existsSync()) {
|
||||
hostRunnerPath = hostBinary;
|
||||
|
||||
Reference in New Issue
Block a user