| 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(SYZYASAN) | 5 #if defined(SYZYASAN) |
| 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 | 12 |
| 13 #include "base/debug/crash_logging.h" | |
| 14 #include "base/guid.h" | 13 #include "base/guid.h" |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 16 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/win/wrapped_window_proc.h" | 17 #include "base/win/wrapped_window_proc.h" |
| 18 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 18 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
| 19 #include "chrome/app/chrome_watcher_client_win.h" | 19 #include "chrome/app/chrome_watcher_client_win.h" |
| 20 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 20 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/crash_keys.h" | 22 #include "chrome/common/crash_keys.h" |
| 23 #include "components/crash/app/crash_keys_win.h" | 23 #include "components/crash/app/crash_keys_win.h" |
| 24 #include "syzygy/kasko/api/client.h" | 24 #include "syzygy/kasko/api/client.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 54 "CrashKey and CustomInfoEntry structs are not compatible."); | 54 "CrashKey and CustomInfoEntry structs are not compatible."); |
| 55 static_assert( | 55 static_assert( |
| 56 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->name) == | 56 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->name) == |
| 57 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->name), | 57 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->name), |
| 58 "CrashKey and CustomInfoEntry structs are not compatible."); | 58 "CrashKey and CustomInfoEntry structs are not compatible."); |
| 59 static_assert( | 59 static_assert( |
| 60 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->value) == | 60 sizeof(reinterpret_cast<kasko::api::CrashKey*>(0)->value) == |
| 61 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->value), | 61 sizeof(reinterpret_cast<google_breakpad::CustomInfoEntry*>(0)->value), |
| 62 "CrashKey and CustomInfoEntry structs are not compatible."); | 62 "CrashKey and CustomInfoEntry structs are not compatible."); |
| 63 | 63 |
| 64 breakpad::CrashKeysWin* keeper = breakpad::CrashKeysWin::keeper(); |
| 65 if (!keeper) |
| 66 return; |
| 67 |
| 64 // Assign a GUID that can be used to correlate the Kasko report to the | 68 // Assign a GUID that can be used to correlate the Kasko report to the |
| 65 // Breakpad report, to verify data consistency. | 69 // Breakpad report, to verify data consistency. |
| 66 std::string guid = base::GenerateGUID(); | 70 std::string guid = base::GenerateGUID(); |
| 67 { | 71 { |
| 72 keeper->SetCrashKeyValue(base::ASCIIToUTF16(crash_keys::kKaskoGuid).c_str(), |
| 73 base::ASCIIToUTF16(guid).c_str()); |
| 74 |
| 68 base::debug::ScopedCrashKey kasko_guid(crash_keys::kKaskoGuid, guid); | 75 base::debug::ScopedCrashKey kasko_guid(crash_keys::kKaskoGuid, guid); |
| 69 size_t crash_key_count = | 76 size_t crash_key_count = keeper->custom_info_entries().size(); |
| 70 breakpad::CrashKeysWin::keeper()->custom_info_entries().size(); | |
| 71 const kasko::api::CrashKey* crash_keys = | 77 const kasko::api::CrashKey* crash_keys = |
| 72 reinterpret_cast<const kasko::api::CrashKey*>( | 78 reinterpret_cast<const kasko::api::CrashKey*>( |
| 73 breakpad::CrashKeysWin::keeper()->custom_info_entries().data()); | 79 keeper->custom_info_entries().data()); |
| 74 | 80 |
| 75 if (g_chrome_watcher_client && | 81 if (g_chrome_watcher_client && |
| 76 g_chrome_watcher_client->EnsureInitialized()) { | 82 g_chrome_watcher_client->EnsureInitialized()) { |
| 77 kasko::api::SendReport(info, protobuf, protobuf_length, crash_keys, | 83 kasko::api::SendReport(info, protobuf, protobuf_length, crash_keys, |
| 78 crash_key_count); | 84 crash_key_count); |
| 79 } | 85 } |
| 86 |
| 87 keeper->ClearCrashKeyValue( |
| 88 base::ASCIIToUTF16(crash_keys::kKaskoGuid).c_str()); |
| 80 } | 89 } |
| 81 | 90 |
| 82 { | 91 { |
| 83 base::debug::ScopedCrashKey kasko_equivalent_guid( | 92 keeper->SetCrashKeyValue( |
| 84 crash_keys::kKaskoEquivalentGuid, guid); | 93 base::ASCIIToUTF16(crash_keys::kKaskoEquivalentGuid).c_str(), |
| 94 base::ASCIIToUTF16(guid).c_str()); |
| 85 // While Kasko remains experimental, also report via Breakpad. | 95 // While Kasko remains experimental, also report via Breakpad. |
| 86 base::win::WinProcExceptionFilter crash_for_exception = | 96 base::win::WinProcExceptionFilter crash_for_exception = |
| 87 reinterpret_cast<base::win::WinProcExceptionFilter>(::GetProcAddress( | 97 reinterpret_cast<base::win::WinProcExceptionFilter>(::GetProcAddress( |
| 88 ::GetModuleHandle(chrome::kBrowserProcessExecutableName), | 98 ::GetModuleHandle(chrome::kBrowserProcessExecutableName), |
| 89 "CrashForException")); | 99 "CrashForException")); |
| 90 crash_for_exception(info); | 100 crash_for_exception(info); |
| 101 keeper->ClearCrashKeyValue( |
| 102 base::ASCIIToUTF16(crash_keys::kKaskoEquivalentGuid).c_str()); |
| 91 } | 103 } |
| 92 } | 104 } |
| 93 | 105 |
| 94 #endif // defined(SYZYASAN) | 106 #endif // defined(SYZYASAN) |
| OLD | NEW |