| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if defined(KASKO) | 5 #if defined(KASKO) |
| 6 | 6 |
| 7 #include "chrome/app/kasko_client.h" | 7 #include "chrome/app/kasko_client.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 16 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_watcher_client_win.h" | 18 #include "chrome/app/chrome_watcher_client_win.h" |
| 18 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 19 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
| 19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 20 #include "components/crash/content/app/crash_keys_win.h" | 21 #include "components/crash/content/app/crashpad.h" |
| 21 #include "syzygy/kasko/api/client.h" | 22 #include "syzygy/kasko/api/client.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 ChromeWatcherClient* g_chrome_watcher_client = nullptr; | 26 ChromeWatcherClient* g_chrome_watcher_client = nullptr; |
| 26 kasko::api::MinidumpType g_minidump_type = kasko::api::SMALL_DUMP_TYPE; | 27 kasko::api::MinidumpType g_minidump_type = kasko::api::SMALL_DUMP_TYPE; |
| 27 | 28 |
| 29 base::LazyInstance<std::vector<kasko::api::CrashKey>>::Leaky |
| 30 g_kasko_crash_keys = LAZY_INSTANCE_INITIALIZER; |
| 31 |
| 28 void GetKaskoCrashKeys(const kasko::api::CrashKey** crash_keys, | 32 void GetKaskoCrashKeys(const kasko::api::CrashKey** crash_keys, |
| 29 size_t* crash_key_count) { | 33 size_t* crash_key_count) { |
| 30 static_assert( | 34 const auto& pairs = crash_reporter::GetCrashKeys(); |
| 31 sizeof(kasko::api::CrashKey) == sizeof(google_breakpad::CustomInfoEntry), | 35 g_kasko_crash_keys.Pointer()->reserve(pairs.size()); |
| 32 "CrashKey and CustomInfoEntry structs are not compatible."); | 36 for (const auto& pair : pairs) { |
| 33 static_assert(offsetof(kasko::api::CrashKey, name) == | 37 kasko::api::CrashKey kv; |
| 34 offsetof(google_breakpad::CustomInfoEntry, name), | 38 wcscpy_s(kv.name, arraysize(kv.name), |
| 35 "CrashKey and CustomInfoEntry structs are not compatible."); | 39 base::UTF8ToUTF16(pair.first).c_str()); |
| 36 static_assert(offsetof(kasko::api::CrashKey, value) == | 40 wcscpy_s(kv.value, arraysize(kv.value), |
| 37 offsetof(google_breakpad::CustomInfoEntry, value), | 41 base::UTF8ToUTF16(pair.second).c_str()); |
| 38 "CrashKey and CustomInfoEntry structs are not compatible."); | 42 g_kasko_crash_keys.Pointer()->push_back(kv); |
| 39 static_assert( | 43 } |
| 40 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->name) == | |
| 41 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->name), | |
| 42 "CrashKey and CustomInfoEntry structs are not compatible."); | |
| 43 static_assert( | |
| 44 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->value) == | |
| 45 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->value), | |
| 46 "CrashKey and CustomInfoEntry structs are not compatible."); | |
| 47 | 44 |
| 48 *crash_key_count = | 45 *crash_key_count = g_kasko_crash_keys.Pointer()->size(); |
| 49 breakpad::CrashKeysWin::keeper()->custom_info_entries().size(); | 46 *crash_keys = g_kasko_crash_keys.Pointer()->data(); |
| 50 *crash_keys = reinterpret_cast<const kasko::api::CrashKey*>( | |
| 51 breakpad::CrashKeysWin::keeper()->custom_info_entries().data()); | |
| 52 } | 47 } |
| 53 | 48 |
| 54 } // namespace | 49 } // namespace |
| 55 | 50 |
| 56 KaskoClient::KaskoClient(ChromeWatcherClient* chrome_watcher_client, | 51 KaskoClient::KaskoClient(ChromeWatcherClient* chrome_watcher_client, |
| 57 kasko::api::MinidumpType minidump_type) { | 52 kasko::api::MinidumpType minidump_type) { |
| 58 DCHECK(!g_chrome_watcher_client); | 53 DCHECK(!g_chrome_watcher_client); |
| 59 g_minidump_type = minidump_type; | 54 g_minidump_type = minidump_type; |
| 60 g_chrome_watcher_client = chrome_watcher_client; | 55 g_chrome_watcher_client = chrome_watcher_client; |
| 61 | 56 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 terminate_process_without_dump(); | 115 terminate_process_without_dump(); |
| 121 } | 116 } |
| 122 | 117 |
| 123 extern "C" void __declspec(dllexport) ReportCrashWithProtobuf( | 118 extern "C" void __declspec(dllexport) ReportCrashWithProtobuf( |
| 124 EXCEPTION_POINTERS* info, const char* protobuf, size_t protobuf_length) { | 119 EXCEPTION_POINTERS* info, const char* protobuf, size_t protobuf_length) { |
| 125 ReportCrashWithProtobufAndMemoryRanges(info, protobuf, protobuf_length, | 120 ReportCrashWithProtobufAndMemoryRanges(info, protobuf, protobuf_length, |
| 126 nullptr, nullptr); | 121 nullptr, nullptr); |
| 127 } | 122 } |
| 128 | 123 |
| 129 #endif // defined(KASKO) | 124 #endif // defined(KASKO) |
| OLD | NEW |