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

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

Issue 1406993008: win: Rename CrashpadClient::SetHandler() to SetHandlerIPCPipe() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Revise comment Created 5 years, 1 month 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
« no previous file with comments | « handler/handler.gyp ('k') | handler/win/crashy_test_z7_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h>
15 #include <stdlib.h> 16 #include <stdlib.h>
16 #include <windows.h> 17 #include <windows.h>
17 #include <winternl.h> 18 #include <winternl.h>
18 19
19 #include <string> 20 #include <string>
20 #include <map> 21 #include <map>
21 #include <vector> 22 #include <vector>
22 23
23 // ntstatus.h conflicts with windows.h so define this locally. 24 // ntstatus.h conflicts with windows.h so define this locally.
24 #ifndef STATUS_NO_SUCH_FILE 25 #ifndef STATUS_NO_SUCH_FILE
25 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F) 26 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
26 #endif 27 #endif
27 28
28 #include "base/basictypes.h" 29 #include "base/basictypes.h"
29 #include "base/files/file_path.h" 30 #include "base/files/file_path.h"
30 #include "base/logging.h" 31 #include "base/logging.h"
31 #include "base/strings/utf_string_conversions.h"
32 #include "client/crashpad_client.h" 32 #include "client/crashpad_client.h"
33 #include "tools/tool_support.h"
34 #include "util/win/critical_section_with_debug_info.h" 33 #include "util/win/critical_section_with_debug_info.h"
35 #include "util/win/get_function.h" 34 #include "util/win/get_function.h"
36 35
37 namespace crashpad { 36 namespace crashpad {
38 namespace { 37 namespace {
39 38
40 CRITICAL_SECTION g_test_critical_section; 39 CRITICAL_SECTION g_test_critical_section;
41 40
42 ULONG RtlNtStatusToDosError(NTSTATUS status) { 41 ULONG RtlNtStatusToDosError(NTSTATUS status) {
43 static const auto rtl_nt_status_to_dos_error = 42 static const auto rtl_nt_status_to_dos_error =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void SomeCrashyFunction() { 86 void SomeCrashyFunction() {
88 // SetLastError and NTSTATUS so that we have something to view in !gle in 87 // SetLastError and NTSTATUS so that we have something to view in !gle in
89 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the 88 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the
90 // LastStatusError of the TEB as a side-effect, and we'll be setting 89 // LastStatusError of the TEB as a side-effect, and we'll be setting
91 // ERROR_FILE_NOT_FOUND for GetLastError(). 90 // ERROR_FILE_NOT_FOUND for GetLastError().
92 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE)); 91 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE));
93 volatile int* foo = reinterpret_cast<volatile int*>(7); 92 volatile int* foo = reinterpret_cast<volatile int*>(7);
94 *foo = 42; 93 *foo = 42;
95 } 94 }
96 95
97 int CrashyMain(int argc, char* argv[]) { 96 int CrashyMain(int argc, wchar_t* argv[]) {
98 CrashpadClient client; 97 CrashpadClient client;
99 98
100 if (argc == 2) { 99 if (argc == 2) {
101 if (!client.SetHandler(argv[1])) { 100 if (!client.SetHandlerIPCPipe(argv[1])) {
102 LOG(ERROR) << "SetHandler"; 101 LOG(ERROR) << "SetHandler";
103 return EXIT_FAILURE; 102 return EXIT_FAILURE;
104 } 103 }
105 } else if (argc == 3) { 104 } else if (argc == 3) {
106 if (!client.StartHandler(base::FilePath(base::UTF8ToUTF16(argv[1])), 105 if (!client.StartHandler(base::FilePath(argv[1]),
107 base::FilePath(base::UTF8ToUTF16(argv[2])), 106 base::FilePath(argv[2]),
108 std::string(), 107 std::string(),
109 std::map<std::string, std::string>(), 108 std::map<std::string, std::string>(),
110 std::vector<std::string>())) { 109 std::vector<std::string>())) {
111 LOG(ERROR) << "StartHandler"; 110 LOG(ERROR) << "StartHandler";
112 return EXIT_FAILURE; 111 return EXIT_FAILURE;
113 } 112 }
114 } else { 113 } else {
115 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); 114 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]);
116 fprintf(stderr, " %s <handler_path> <database_path>\n", argv[0]); 115 fprintf(stderr, " %s <handler_path> <database_path>\n", argv[0]);
117 return EXIT_FAILURE; 116 return EXIT_FAILURE;
(...skipping 13 matching lines...) Expand all
131 130
132 SomeCrashyFunction(); 131 SomeCrashyFunction();
133 132
134 return EXIT_SUCCESS; 133 return EXIT_SUCCESS;
135 } 134 }
136 135
137 } // namespace 136 } // namespace
138 } // namespace crashpad 137 } // namespace crashpad
139 138
140 int wmain(int argc, wchar_t* argv[]) { 139 int wmain(int argc, wchar_t* argv[]) {
141 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); 140 return crashpad::CrashyMain(argc, argv);
142 } 141 }
OLDNEW
« no previous file with comments | « handler/handler.gyp ('k') | handler/win/crashy_test_z7_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698