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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 void GetPlatformCrashpadAnnotations( | 34 void GetPlatformCrashpadAnnotations( |
35 std::map<std::string, std::string>* annotations) { | 35 std::map<std::string, std::string>* annotations) { |
36 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 36 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
37 base::FilePath exe_file; | 37 base::FilePath exe_file; |
38 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); | 38 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); |
39 base::string16 product_name, version, special_build, channel_name; | 39 base::string16 product_name, version, special_build, channel_name; |
40 crash_reporter_client->GetProductNameAndVersion( | 40 crash_reporter_client->GetProductNameAndVersion( |
41 exe_file, &product_name, &version, &special_build, &channel_name); | 41 exe_file.value(), &product_name, &version, &special_build, |
| 42 &channel_name); |
42 (*annotations)["prod"] = base::UTF16ToUTF8(product_name); | 43 (*annotations)["prod"] = base::UTF16ToUTF8(product_name); |
43 (*annotations)["ver"] = base::UTF16ToUTF8(version); | 44 (*annotations)["ver"] = base::UTF16ToUTF8(version); |
44 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); | 45 (*annotations)["channel"] = base::UTF16ToUTF8(channel_name); |
45 if (!special_build.empty()) | 46 if (!special_build.empty()) |
46 (*annotations)["special"] = base::UTF16ToUTF8(special_build); | 47 (*annotations)["special"] = base::UTF16ToUTF8(special_build); |
47 #if defined(ARCH_CPU_X86) | 48 #if defined(ARCH_CPU_X86) |
48 (*annotations)["plat"] = std::string("Win32"); | 49 (*annotations)["plat"] = std::string("Win32"); |
49 #elif defined(ARCH_CPU_X86_64) | 50 #elif defined(ARCH_CPU_X86_64) |
50 (*annotations)["plat"] = std::string("Win64"); | 51 (*annotations)["plat"] = std::string("Win64"); |
51 #endif | 52 #endif |
52 } | 53 } |
53 | 54 |
54 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 55 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
55 bool browser_process, | 56 bool browser_process, |
56 bool embedded_handler) { | 57 bool embedded_handler) { |
57 base::FilePath database_path; // Only valid in the browser process. | 58 base::FilePath database_path; // Only valid in the browser process. |
58 bool result; | 59 bool result; |
59 | 60 |
60 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; | 61 const char kPipeNameVar[] = "CHROME_CRASHPAD_PIPE_NAME"; |
61 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; | 62 const char kServerUrlVar[] = "CHROME_CRASHPAD_SERVER_URL"; |
62 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 63 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
63 | 64 |
64 if (initial_client) { | 65 if (initial_client) { |
65 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 66 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
66 crash_reporter_client->GetCrashDumpLocation(&database_path); | 67 |
| 68 base::string16 database_path_str; |
| 69 if (crash_reporter_client->GetCrashDumpLocation(&database_path_str)) |
| 70 database_path = base::FilePath(database_path_str); |
67 | 71 |
68 std::map<std::string, std::string> process_annotations; | 72 std::map<std::string, std::string> process_annotations; |
69 GetPlatformCrashpadAnnotations(&process_annotations); | 73 GetPlatformCrashpadAnnotations(&process_annotations); |
70 | 74 |
71 #if defined(GOOGLE_CHROME_BUILD) | 75 #if defined(GOOGLE_CHROME_BUILD) |
72 std::string url = "https://clients2.google.com/cr/report"; | 76 std::string url = "https://clients2.google.com/cr/report"; |
73 #else | 77 #else |
74 std::string url; | 78 std::string url; |
75 #endif | 79 #endif |
76 | 80 |
77 // Allow the crash server to be overridden for testing. If the variable | 81 // Allow the crash server to be overridden for testing. If the variable |
78 // isn't present in the environment then the default URL will remain. | 82 // isn't present in the environment then the default URL will remain. |
79 env->GetVar(kServerUrlVar, &url); | 83 env->GetVar(kServerUrlVar, &url); |
80 | 84 |
81 base::FilePath exe_file; | 85 base::FilePath exe_file; |
82 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); | 86 CHECK(PathService::Get(base::FILE_EXE, &exe_file)); |
83 | 87 |
84 bool is_per_user_install = | 88 bool is_per_user_install = |
85 crash_reporter_client->GetIsPerUserInstall(exe_file); | 89 crash_reporter_client->GetIsPerUserInstall(exe_file.value()); |
86 if (crash_reporter_client->GetShouldDumpLargerDumps(is_per_user_install)) { | 90 if (crash_reporter_client->GetShouldDumpLargerDumps(is_per_user_install)) { |
87 const uint32_t kIndirectMemoryLimit = 4 * 1024 * 1024; | 91 const uint32_t kIndirectMemoryLimit = 4 * 1024 * 1024; |
88 crashpad::CrashpadInfo::GetCrashpadInfo() | 92 crashpad::CrashpadInfo::GetCrashpadInfo() |
89 ->set_gather_indirectly_referenced_memory( | 93 ->set_gather_indirectly_referenced_memory( |
90 crashpad::TriState::kEnabled, kIndirectMemoryLimit); | 94 crashpad::TriState::kEnabled, kIndirectMemoryLimit); |
91 } | 95 } |
92 | 96 |
93 // If the handler is embedded in the binary (e.g. chrome, setup), we | 97 // If the handler is embedded in the binary (e.g. chrome, setup), we |
94 // reinvoke it with --type=crashpad-handler. Otherwise, we use the | 98 // reinvoke it with --type=crashpad-handler. Otherwise, we use the |
95 // standalone crashpad_handler.exe (for tests, etc.). | 99 // standalone crashpad_handler.exe (for tests, etc.). |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 291 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
288 void* start) { | 292 void* start) { |
289 ExceptionHandlerRecord* record = | 293 ExceptionHandlerRecord* record = |
290 reinterpret_cast<ExceptionHandlerRecord*>(start); | 294 reinterpret_cast<ExceptionHandlerRecord*>(start); |
291 | 295 |
292 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 296 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
293 } | 297 } |
294 #endif // ARCH_CPU_X86_64 | 298 #endif // ARCH_CPU_X86_64 |
295 | 299 |
296 } // extern "C" | 300 } // extern "C" |
OLD | NEW |