| 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 "chrome/app/chrome_watcher_client_win.h" | 17 #include "chrome/app/chrome_watcher_client_win.h" |
| 18 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 18 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
| 19 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 20 #include "components/crash/content/app/crash_keys_win.h" | 20 #include "components/crash/content/app/crashpad.h" |
| 21 #include "syzygy/kasko/api/client.h" | 21 #include "syzygy/kasko/api/client.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 ChromeWatcherClient* g_chrome_watcher_client = nullptr; | 25 ChromeWatcherClient* g_chrome_watcher_client = nullptr; |
| 26 kasko::api::MinidumpType g_minidump_type = kasko::api::SMALL_DUMP_TYPE; | 26 kasko::api::MinidumpType g_minidump_type = kasko::api::SMALL_DUMP_TYPE; |
| 27 | 27 |
| 28 base::LazyInstance<std::vector<kasko::api::CrashKey>>::Leaky |
| 29 g_kasko_crash_keys = LAZY_INSTANCE_INITIALIZER; |
| 30 |
| 28 void GetKaskoCrashKeys(const kasko::api::CrashKey** crash_keys, | 31 void GetKaskoCrashKeys(const kasko::api::CrashKey** crash_keys, |
| 29 size_t* crash_key_count) { | 32 size_t* crash_key_count) { |
| 30 static_assert( | 33 crash_reporter::GetCrashKeysForKasko(g_kasko_crash_keys.Pointer()); |
| 31 sizeof(kasko::api::CrashKey) == sizeof(google_breakpad::CustomInfoEntry), | 34 *crash_key_count = g_kasko_crash_keys.Pointer()->size(); |
| 32 "CrashKey and CustomInfoEntry structs are not compatible."); | 35 *crash_keys = g_kasko_crash_keys.Pointer()->data(); |
| 33 static_assert(offsetof(kasko::api::CrashKey, name) == | |
| 34 offsetof(google_breakpad::CustomInfoEntry, name), | |
| 35 "CrashKey and CustomInfoEntry structs are not compatible."); | |
| 36 static_assert(offsetof(kasko::api::CrashKey, value) == | |
| 37 offsetof(google_breakpad::CustomInfoEntry, value), | |
| 38 "CrashKey and CustomInfoEntry structs are not compatible."); | |
| 39 static_assert( | |
| 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 | |
| 48 *crash_key_count = | |
| 49 breakpad::CrashKeysWin::keeper()->custom_info_entries().size(); | |
| 50 *crash_keys = reinterpret_cast<const kasko::api::CrashKey*>( | |
| 51 breakpad::CrashKeysWin::keeper()->custom_info_entries().data()); | |
| 52 } | 36 } |
| 53 | 37 |
| 54 } // namespace | 38 } // namespace |
| 55 | 39 |
| 56 KaskoClient::KaskoClient(ChromeWatcherClient* chrome_watcher_client, | 40 KaskoClient::KaskoClient(ChromeWatcherClient* chrome_watcher_client, |
| 57 kasko::api::MinidumpType minidump_type) { | 41 kasko::api::MinidumpType minidump_type) { |
| 58 DCHECK(!g_chrome_watcher_client); | 42 DCHECK(!g_chrome_watcher_client); |
| 59 g_minidump_type = minidump_type; | 43 g_minidump_type = minidump_type; |
| 60 g_chrome_watcher_client = chrome_watcher_client; | 44 g_chrome_watcher_client = chrome_watcher_client; |
| 61 | 45 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 terminate_process_without_dump(); | 104 terminate_process_without_dump(); |
| 121 } | 105 } |
| 122 | 106 |
| 123 extern "C" void __declspec(dllexport) ReportCrashWithProtobuf( | 107 extern "C" void __declspec(dllexport) ReportCrashWithProtobuf( |
| 124 EXCEPTION_POINTERS* info, const char* protobuf, size_t protobuf_length) { | 108 EXCEPTION_POINTERS* info, const char* protobuf, size_t protobuf_length) { |
| 125 ReportCrashWithProtobufAndMemoryRanges(info, protobuf, protobuf_length, | 109 ReportCrashWithProtobufAndMemoryRanges(info, protobuf, protobuf_length, |
| 126 nullptr, nullptr); | 110 nullptr, nullptr); |
| 127 } | 111 } |
| 128 | 112 |
| 129 #endif // defined(KASKO) | 113 #endif // defined(KASKO) |
| OLD | NEW |