OLD | NEW |
1 // Copyright 2016 The Crashpad Authors. All rights reserved. | 1 // Copyright 2016 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 <stdio.h> | 15 #include <stdio.h> |
16 #include <windows.h> | 16 #include <windows.h> |
17 | 17 |
18 #include "base/debug/alias.h" | 18 #include "base/debug/alias.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "client/crashpad_client.h" | 21 #include "client/crashpad_client.h" |
22 #include "client/crashpad_info.h" | 22 #include "client/crashpad_info.h" |
23 | 23 |
24 DWORD WINAPI Thread1(LPVOID dummy) { | 24 DWORD WINAPI Thread1(LPVOID dummy) { |
| 25 // We set the thread priority up by one as a hacky way to signal to the other |
| 26 // test program that this is the thread we want to dump. |
| 27 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); |
25 Sleep(INFINITE); | 28 Sleep(INFINITE); |
26 return 0; | 29 return 0; |
27 } | 30 } |
28 | 31 |
29 DWORD WINAPI Thread2(LPVOID dummy) { | 32 DWORD WINAPI Thread2(LPVOID dummy) { |
30 Sleep(INFINITE); | 33 Sleep(INFINITE); |
31 return 0; | 34 return 0; |
32 } | 35 } |
33 | 36 |
34 DWORD WINAPI Thread3(LPVOID dummy) { | 37 DWORD WINAPI Thread3(LPVOID dummy) { |
(...skipping 14 matching lines...) Expand all Loading... |
49 if (argc == 2) { | 52 if (argc == 2) { |
50 if (!client.SetHandlerIPCPipe(argv[1])) { | 53 if (!client.SetHandlerIPCPipe(argv[1])) { |
51 LOG(ERROR) << "SetHandler"; | 54 LOG(ERROR) << "SetHandler"; |
52 return EXIT_FAILURE; | 55 return EXIT_FAILURE; |
53 } | 56 } |
54 } else { | 57 } else { |
55 fprintf(stderr, "Usage: %ls <server_pipe_name>\n", argv[0]); | 58 fprintf(stderr, "Usage: %ls <server_pipe_name>\n", argv[0]); |
56 return EXIT_FAILURE; | 59 return EXIT_FAILURE; |
57 } | 60 } |
58 | 61 |
59 if (!client.UseHandler()) { | |
60 LOG(ERROR) << "UseHandler"; | |
61 return EXIT_FAILURE; | |
62 } | |
63 | |
64 // Make sure this module has a CrashpadInfo structure. | 62 // Make sure this module has a CrashpadInfo structure. |
65 crashpad::CrashpadInfo* crashpad_info = | 63 crashpad::CrashpadInfo* crashpad_info = |
66 crashpad::CrashpadInfo::GetCrashpadInfo(); | 64 crashpad::CrashpadInfo::GetCrashpadInfo(); |
67 base::debug::Alias(crashpad_info); | 65 base::debug::Alias(crashpad_info); |
68 | 66 |
69 HANDLE threads[3]; | 67 HANDLE threads[3]; |
70 threads[0] = CreateThread(nullptr, 0, Thread1, nullptr, 0, nullptr); | 68 threads[0] = CreateThread(nullptr, 0, Thread1, nullptr, 0, nullptr); |
71 threads[1] = CreateThread(nullptr, 0, Thread2, nullptr, 0, nullptr); | 69 threads[1] = CreateThread(nullptr, 0, Thread2, nullptr, 0, nullptr); |
72 threads[2] = CreateThread(nullptr, 0, Thread3, nullptr, 0, nullptr); | 70 threads[2] = CreateThread(nullptr, 0, Thread3, nullptr, 0, nullptr); |
73 | 71 |
74 // Our whole process is going to hang when the loaded DLL hangs in its | 72 // Our whole process is going to hang when the loaded DLL hangs in its |
75 // DllMain(), so we can't signal to our parent that we're "ready". So, use a | 73 // DllMain(), so we can't signal to our parent that we're "ready". So, use a |
76 // hokey delay of 1s after we spawn the threads, and hope that we make it to | 74 // hokey delay of 1s after we spawn the threads, and hope that we make it to |
77 // the FreeLibrary call by then. | 75 // the FreeLibrary call by then. |
78 Sleep(1000); | 76 Sleep(1000); |
79 | 77 |
80 fprintf(stdout, " "); | 78 fprintf(stdout, " "); |
81 fflush(stdout); | 79 fflush(stdout); |
82 | 80 |
83 WaitForMultipleObjects(ARRAYSIZE(threads), threads, true, INFINITE); | 81 WaitForMultipleObjects(ARRAYSIZE(threads), threads, true, INFINITE); |
84 | 82 |
85 return 0; | 83 return 0; |
86 } | 84 } |
OLD | NEW |