Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: handler/win/crashy_test_program.cc

Issue 1392093003: win: Capture some CRITICAL_SECTION debugging data (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include <windows.h> 15 #include <windows.h>
16 #include <winternl.h> 16 #include <winternl.h>
17 17
18 // ntstatus.h conflicts with windows.h so define this locally. 18 // ntstatus.h conflicts with windows.h so define this locally.
19 #ifndef STATUS_NO_SUCH_FILE 19 #ifndef STATUS_NO_SUCH_FILE
20 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F) 20 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
21 #endif 21 #endif
22 22
23 #include "base/logging.h" 23 #include "base/logging.h"
24 #include "client/crashpad_client.h" 24 #include "client/crashpad_client.h"
25 #include "tools/tool_support.h" 25 #include "tools/tool_support.h"
26 26
27 namespace crashpad { 27 namespace crashpad {
28 namespace { 28 namespace {
29 29
30 CRITICAL_SECTION g_test_critical_section;
31
30 ULONG RtlNtStatusToDosError(NTSTATUS status) { 32 ULONG RtlNtStatusToDosError(NTSTATUS status) {
31 static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error = 33 static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error =
32 reinterpret_cast<decltype(::RtlNtStatusToDosError)*>( 34 reinterpret_cast<decltype(::RtlNtStatusToDosError)*>(
33 GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError")); 35 GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError"));
34 DCHECK(rtl_nt_status_to_dos_error); 36 DCHECK(rtl_nt_status_to_dos_error);
35 return rtl_nt_status_to_dos_error(status); 37 return rtl_nt_status_to_dos_error(status);
36 } 38 }
37 39
38 void SomeCrashyFunction() { 40 void SomeCrashyFunction() {
39 // SetLastError and NTSTATUS so that we have something to view in !gle in 41 // SetLastError and NTSTATUS so that we have something to view in !gle in
(...skipping 14 matching lines...) Expand all
54 CrashpadClient client; 56 CrashpadClient client;
55 if (!client.SetHandler(argv[1])) { 57 if (!client.SetHandler(argv[1])) {
56 LOG(ERROR) << "SetHandler"; 58 LOG(ERROR) << "SetHandler";
57 return 1; 59 return 1;
58 } 60 }
59 if (!client.UseHandler()) { 61 if (!client.UseHandler()) {
60 LOG(ERROR) << "UseHandler"; 62 LOG(ERROR) << "UseHandler";
61 return 1; 63 return 1;
62 } 64 }
63 65
66 InitializeCriticalSectionEx(
67 &g_test_critical_section, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO);
68 EnterCriticalSection(&g_test_critical_section);
69
64 SomeCrashyFunction(); 70 SomeCrashyFunction();
65 71
66 return 0; 72 return 0;
67 } 73 }
68 74
69 } // namespace 75 } // namespace
70 } // namespace crashpad 76 } // namespace crashpad
71 77
72 int wmain(int argc, wchar_t* argv[]) { 78 int wmain(int argc, wchar_t* argv[]) {
73 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); 79 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain);
74 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698