Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 static const auto delete_proc_thread_attribute_list = | 125 static const auto delete_proc_thread_attribute_list = |
| 126 GET_FUNCTION_REQUIRED(L"kernel32.dll", ::DeleteProcThreadAttributeList); | 126 GET_FUNCTION_REQUIRED(L"kernel32.dll", ::DeleteProcThreadAttributeList); |
| 127 delete_proc_thread_attribute_list(proc_thread_attribute_list); | 127 delete_proc_thread_attribute_list(proc_thread_attribute_list); |
| 128 } | 128 } |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 using ScopedProcThreadAttributeList = | 131 using ScopedProcThreadAttributeList = |
| 132 base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, | 132 base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, |
| 133 ScopedProcThreadAttributeListTraits>; | 133 ScopedProcThreadAttributeListTraits>; |
| 134 | 134 |
| 135 // Adds |handle| to |handle_list| if it appears valid. | 135 // Adds |handle| to |handle_list| if it appears valid, and is not already in |
| 136 // |handle_list|. | |
| 136 // | 137 // |
| 137 // Invalid handles (including INVALID_HANDLE_VALUE and null handles) cannot be | 138 // Invalid handles (including INVALID_HANDLE_VALUE and null handles) cannot be |
| 138 // added to a PPROC_THREAD_ATTRIBUTE_LIST’s PROC_THREAD_ATTRIBUTE_HANDLE_LIST. | 139 // added to a PPROC_THREAD_ATTRIBUTE_LIST’s PROC_THREAD_ATTRIBUTE_HANDLE_LIST. |
| 139 // If INVALID_HANDLE_VALUE appears, CreateProcess() will fail with | 140 // If INVALID_HANDLE_VALUE appears, CreateProcess() will fail with |
| 140 // ERROR_INVALID_PARAMETER. If a null handle appears, the child process will | 141 // ERROR_INVALID_PARAMETER. If a null handle appears, the child process will |
| 141 // silently not inherit any handles. | 142 // silently not inherit any handles. |
| 142 // | 143 // |
| 143 // Use this function to add handles with uncertain validities. | 144 // Use this function to add handles with uncertain validities. |
| 144 void AddHandleToListIfValid(std::vector<HANDLE>* handle_list, HANDLE handle) { | 145 void AddHandleToListIfValid(std::vector<HANDLE>* handle_list, HANDLE handle) { |
| 145 if (handle && handle != INVALID_HANDLE_VALUE) { | 146 if (handle && handle != INVALID_HANDLE_VALUE) { |
| 146 handle_list->push_back(handle); | 147 // There doesn't seem to be any documentation of this, but if there's a |
| 148 // handle duplicated in this list, CreateProcess() fails with | |
| 149 // ERROR_INVALID_PARAMETER. | |
| 150 if (std::find(handle_list->begin(), handle_list->end(), handle) == | |
|
Mark Mentovai
2015/11/19 19:20:57
Just && this into the if that’s currently wrapping
scottmg
2015/11/19 19:25:33
Done.
| |
| 151 handle_list->end()) { | |
| 152 handle_list->push_back(handle); | |
| 153 } | |
| 147 } | 154 } |
| 148 } | 155 } |
| 149 | 156 |
| 150 } // namespace | 157 } // namespace |
| 151 | 158 |
| 152 namespace crashpad { | 159 namespace crashpad { |
| 153 | 160 |
| 154 CrashpadClient::CrashpadClient() | 161 CrashpadClient::CrashpadClient() |
| 155 : ipc_pipe_() { | 162 : ipc_pipe_() { |
| 156 } | 163 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 DCHECK(!ipc_pipe_.empty()); | 337 DCHECK(!ipc_pipe_.empty()); |
| 331 return ipc_pipe_; | 338 return ipc_pipe_; |
| 332 } | 339 } |
| 333 | 340 |
| 334 bool CrashpadClient::UseHandler() { | 341 bool CrashpadClient::UseHandler() { |
| 335 DCHECK(!ipc_pipe_.empty()); | 342 DCHECK(!ipc_pipe_.empty()); |
| 336 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); | 343 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); |
| 337 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); | 344 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); |
| 338 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); | 345 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); |
| 339 DCHECK(!g_critical_section_with_debug_info.DebugInfo); | 346 DCHECK(!g_critical_section_with_debug_info.DebugInfo); |
| 347 DCHECK(!g_non_crash_dump_lock); | |
| 340 | 348 |
| 341 ClientToServerMessage message; | 349 ClientToServerMessage message; |
| 342 memset(&message, 0, sizeof(message)); | 350 memset(&message, 0, sizeof(message)); |
| 343 message.type = ClientToServerMessage::kRegister; | 351 message.type = ClientToServerMessage::kRegister; |
| 344 message.registration.version = RegistrationRequest::kMessageVersion; | 352 message.registration.version = RegistrationRequest::kMessageVersion; |
| 345 message.registration.client_process_id = GetCurrentProcessId(); | 353 message.registration.client_process_id = GetCurrentProcessId(); |
| 346 message.registration.crash_exception_information = | 354 message.registration.crash_exception_information = |
| 347 reinterpret_cast<WinVMAddress>(&g_crash_exception_information); | 355 reinterpret_cast<WinVMAddress>(&g_crash_exception_information); |
| 348 message.registration.non_crash_exception_information = | 356 message.registration.non_crash_exception_information = |
| 349 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information); | 357 reinterpret_cast<WinVMAddress>(&g_non_crash_exception_information); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); | 442 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); |
| 435 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; | 443 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; |
| 436 } | 444 } |
| 437 | 445 |
| 438 // static | 446 // static |
| 439 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) { | 447 void CrashpadClient::DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) { |
| 440 UnhandledExceptionHandler(exception_pointers); | 448 UnhandledExceptionHandler(exception_pointers); |
| 441 } | 449 } |
| 442 | 450 |
| 443 } // namespace crashpad | 451 } // namespace crashpad |
| OLD | NEW |