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

Side by Side Diff: third_party/crashpad/crashpad/handler/win/crashy_signal.cc

Issue 2555353002: Update Crashpad to 32981a3ee9d7c2769fb27afa038fe2e194cfa329 (Closed)
Patch Set: fix readme Created 4 years 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
(Empty)
1 // Copyright 2016 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <windows.h>
19
20 #include "base/logging.h"
21 #include "client/crashpad_client.h"
22
23 namespace crashpad {
24 namespace {
25
26 enum WhereToSignalFrom {
27 kUnknown = -1,
28 kMain = 0,
29 kBackground = 1,
30 };
31
32 WhereToSignalFrom MainOrBackground(wchar_t* name) {
33 if (wcscmp(name, L"main") == 0)
34 return kMain;
35 if (wcscmp(name, L"background") == 0)
36 return kBackground;
37 return kUnknown;
38 }
39
40 DWORD WINAPI BackgroundThread(void* arg) {
41 abort();
42 return 0;
43 }
44
45 int CrashySignalMain(int argc, wchar_t* argv[]) {
46 CrashpadClient client;
47
48 WhereToSignalFrom from;
49 if (argc == 3 && (from = MainOrBackground(argv[2])) != kUnknown) {
50 if (!client.SetHandlerIPCPipe(argv[1])) {
51 LOG(ERROR) << "SetHandler";
52 return EXIT_FAILURE;
53 }
54 } else {
55 fprintf(stderr, "Usage: %ls <server_pipe_name> main|background\n", argv[0]);
56 return EXIT_FAILURE;
57 }
58
59 // In debug builds part of abort() is to open a dialog. We don't want tests to
60 // block at that dialog, so disable it.
61 _set_abort_behavior(0, _WRITE_ABORT_MSG);
62
63 if (from == kBackground) {
64 HANDLE thread = CreateThread(nullptr,
65 0,
66 &BackgroundThread,
67 nullptr,
68 0,
69 nullptr);
70 if (!thread) {
71 PLOG(ERROR) << "CreateThread";
72 return EXIT_FAILURE;
73 }
74 if (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0) {
75 PLOG(ERROR) << "WaitForSingleObject";
76 return EXIT_FAILURE;
77 }
78 } else {
79 abort();
80 }
81
82 return EXIT_SUCCESS;
83 }
84
85 } // namespace
86 } // namespace crashpad
87
88 int wmain(int argc, wchar_t* argv[]) {
89 return crashpad::CrashySignalMain(argc, argv);
90 }
OLDNEW
« no previous file with comments | « third_party/crashpad/crashpad/handler/handler.gyp ('k') | third_party/crashpad/crashpad/minidump/minidump_exception_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698