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 #include "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #if BUILDFLAG(ENABLE_KASKO) | 10 #if BUILDFLAG(ENABLE_KASKO) |
11 #include <psapi.h> | 11 #include <psapi.h> |
12 #endif // BUILDFLAG(ENABLE_KASKO) | 12 #endif // BUILDFLAG(ENABLE_KASKO) |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <map> | 15 #include <map> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/auto_reset.h" | 18 #include "base/auto_reset.h" |
19 #include "base/base_paths.h" | 19 #include "base/base_paths.h" |
20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
21 #include "base/debug/crash_logging.h" | 21 #include "base/debug/crash_logging.h" |
22 #include "base/debug/dump_without_crashing.h" | 22 #include "base/debug/dump_without_crashing.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
| 25 #include "base/path_service.h" |
25 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/string_piece.h" | 27 #include "base/strings/string_piece.h" |
27 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
28 #include "base/strings/sys_string_conversions.h" | 29 #include "base/strings/sys_string_conversions.h" |
29 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
30 #include "build/build_config.h" | 31 #include "build/build_config.h" |
31 #include "components/crash/content/app/crash_reporter_client.h" | 32 #include "components/crash/content/app/crash_reporter_client.h" |
32 #include "third_party/crashpad/crashpad/client/crash_report_database.h" | 33 #include "third_party/crashpad/crashpad/client/crash_report_database.h" |
33 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 34 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
34 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 35 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 const base::Process& process, | 361 const base::Process& process, |
361 std::vector<kasko::api::CrashKey>* crash_keys) { | 362 std::vector<kasko::api::CrashKey>* crash_keys) { |
362 // Reopen process with necessary access. | 363 // Reopen process with necessary access. |
363 base::win::ScopedHandle process_handle(::OpenProcess( | 364 base::win::ScopedHandle process_handle(::OpenProcess( |
364 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process.Pid())); | 365 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process.Pid())); |
365 if (!process_handle.IsValid()) | 366 if (!process_handle.IsValid()) |
366 return; | 367 return; |
367 | 368 |
368 // The executable name is the same for the browser process and the crash | 369 // The executable name is the same for the browser process and the crash |
369 // reporter. | 370 // reporter. |
370 wchar_t exe_file[MAX_PATH] = {}; | 371 base::FilePath exe_path; |
371 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); | 372 base::PathService::Get(base::FILE_EXE, &exe_path); |
372 | |
373 base::FilePath exe_path(exe_file); | |
374 | |
375 HMODULE module = GetModuleInProcess(process_handle.Get(), | 373 HMODULE module = GetModuleInProcess(process_handle.Get(), |
376 exe_path.BaseName().value().c_str()); | 374 exe_path.BaseName().value().c_str()); |
377 if (!module) | 375 if (!module) |
378 return; | 376 return; |
379 | 377 |
380 std::map<std::string, std::string> annotations; | 378 std::map<std::string, std::string> annotations; |
381 crashpad::ReadModuleAnnotations(process_handle.Get(), module, &annotations); | 379 crashpad::ReadModuleAnnotations(process_handle.Get(), module, &annotations); |
382 | 380 |
383 // Append the annotations to the crash keys. | 381 // Append the annotations to the crash keys. |
384 for (const auto& entry : annotations) { | 382 for (const auto& entry : annotations) { |
(...skipping 22 matching lines...) Expand all Loading... |
407 base::UTF16ToUTF8(value)); | 405 base::UTF16ToUTF8(value)); |
408 } | 406 } |
409 | 407 |
410 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { | 408 void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl(const wchar_t* key) { |
411 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); | 409 crash_reporter::ClearCrashKey(base::UTF16ToUTF8(key)); |
412 } | 410 } |
413 | 411 |
414 } // extern "C" | 412 } // extern "C" |
415 | 413 |
416 #endif // OS_WIN | 414 #endif // OS_WIN |
OLD | NEW |