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