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/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } else { | 150 } else { |
151 std::string pipe_name_utf8; | 151 std::string pipe_name_utf8; |
152 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { | 152 if (env->GetVar(kPipeNameVar, &pipe_name_utf8)) { |
153 GetCrashpadClient().SetHandlerIPCPipe(base::UTF8ToUTF16(pipe_name_utf8)); | 153 GetCrashpadClient().SetHandlerIPCPipe(base::UTF8ToUTF16(pipe_name_utf8)); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 return database_path; | 157 return database_path; |
158 } | 158 } |
159 | 159 |
160 // TODO(scottmg): http://crbug.com/546288 These exported functions are for | |
161 // compatibility with how Breakpad worked, but it seems like there's no need to | |
162 // do the CreateRemoteThread() dance with a minor extension of the Crashpad API | |
163 // (to just pass the pid we want a dump for). We should add that and then modify | |
164 // hang_crash_dump_win.cc to work in a more direct manner. | |
165 | |
166 // Used for dumping a process state when there is no crash. | |
167 extern "C" void __declspec(dllexport) __cdecl DumpProcessWithoutCrash() { | |
168 CRASHPAD_SIMULATE_CRASH(); | |
169 } | |
170 | |
171 namespace { | 160 namespace { |
172 | 161 |
173 // We need to prevent ICF from folding DumpProcessForHungInputThread(), | 162 // We need to prevent ICF from folding DumpProcessForHungInputThread(), |
174 // DumpProcessForHungInputNoCrashKeysThread() together, since that makes them | 163 // DumpProcessForHungInputNoCrashKeysThread() together, since that makes them |
175 // indistinguishable in crash dumps. We do this by making the function | 164 // indistinguishable in crash dumps. We do this by making the function |
176 // bodies unique, and prevent optimization from shuffling things around. | 165 // bodies unique, and prevent optimization from shuffling things around. |
177 MSVC_DISABLE_OPTIMIZE() | 166 MSVC_DISABLE_OPTIMIZE() |
178 MSVC_PUSH_DISABLE_WARNING(4748) | 167 MSVC_PUSH_DISABLE_WARNING(4748) |
179 | 168 |
180 // TODO(dtapuska): Remove when enough information is gathered where the crash | 169 // TODO(dtapuska): Remove when enough information is gathered where the crash |
181 // reports without crash keys come from. | 170 // reports without crash keys come from. |
182 DWORD WINAPI DumpProcessForHungInputThread(void* crash_keys_str) { | 171 DWORD WINAPI DumpProcessForHungInputThread(void* crash_keys_str) { |
183 base::StringPairs crash_keys; | 172 base::StringPairs crash_keys; |
184 if (crash_keys_str && base::SplitStringIntoKeyValuePairs( | 173 if (crash_keys_str && base::SplitStringIntoKeyValuePairs( |
185 reinterpret_cast<const char*>(crash_keys_str), ':', | 174 reinterpret_cast<const char*>(crash_keys_str), ':', |
186 ',', &crash_keys)) { | 175 ',', &crash_keys)) { |
187 for (const auto& crash_key : crash_keys) { | 176 for (const auto& crash_key : crash_keys) { |
188 base::debug::SetCrashKeyValue(crash_key.first, crash_key.second); | 177 base::debug::SetCrashKeyValue(crash_key.first, crash_key.second); |
189 } | 178 } |
190 } | 179 } |
191 DumpProcessWithoutCrash(); | 180 DumpWithoutCrashing(); |
192 return 0; | 181 return 0; |
193 } | 182 } |
194 | 183 |
195 // TODO(dtapuska): Remove when enough information is gathered where the crash | 184 // TODO(dtapuska): Remove when enough information is gathered where the crash |
196 // reports without crash keys come from. | 185 // reports without crash keys come from. |
197 DWORD WINAPI DumpProcessForHungInputNoCrashKeysThread(void* reason) { | 186 DWORD WINAPI DumpProcessForHungInputNoCrashKeysThread(void* reason) { |
198 #pragma warning(push) | 187 #pragma warning(push) |
199 #pragma warning(disable : 4311 4302) | 188 #pragma warning(disable : 4311 4302) |
200 base::debug::SetCrashKeyValue( | 189 base::debug::SetCrashKeyValue( |
201 "hung-reason", base::IntToString(reinterpret_cast<int>(reason))); | 190 "hung-reason", base::IntToString(reinterpret_cast<int>(reason))); |
202 #pragma warning(pop) | 191 #pragma warning(pop) |
203 | 192 |
204 DumpProcessWithoutCrash(); | 193 DumpWithoutCrashing(); |
205 return 0; | 194 return 0; |
206 } | 195 } |
207 | 196 |
208 MSVC_POP_WARNING() | 197 MSVC_POP_WARNING() |
209 MSVC_ENABLE_OPTIMIZE() | 198 MSVC_ENABLE_OPTIMIZE() |
210 | 199 |
211 } // namespace | 200 } // namespace |
212 | 201 |
213 } // namespace internal | 202 } // namespace internal |
214 } // namespace crash_reporter | 203 } // namespace crash_reporter |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( | 319 void __declspec(dllexport) __cdecl UnregisterNonABICompliantCodeRange( |
331 void* start) { | 320 void* start) { |
332 ExceptionHandlerRecord* record = | 321 ExceptionHandlerRecord* record = |
333 reinterpret_cast<ExceptionHandlerRecord*>(start); | 322 reinterpret_cast<ExceptionHandlerRecord*>(start); |
334 | 323 |
335 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 324 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
336 } | 325 } |
337 #endif // ARCH_CPU_X86_64 | 326 #endif // ARCH_CPU_X86_64 |
338 | 327 |
339 } // extern "C" | 328 } // extern "C" |
OLD | NEW |