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

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

Issue 1533183002: win: Capture some memory pointed at by context (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: mac Created 4 years, 11 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
« no previous file with comments | « no previous file | minidump/minidump_exception_writer.h » ('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 <intrin.h>
15 #include <stdint.h> 16 #include <stdint.h>
16 #include <stdlib.h> 17 #include <stdlib.h>
17 #include <sys/types.h> 18 #include <sys/types.h>
18 #include <windows.h> 19 #include <windows.h>
19 #include <winternl.h> 20 #include <winternl.h>
20 21
21 #include <map> 22 #include <map>
22 #include <string> 23 #include <string>
23 #include <vector> 24 #include <vector>
24 25
25 #include "base/files/file_path.h" 26 #include "base/files/file_path.h"
26 #include "base/logging.h" 27 #include "base/logging.h"
27 #include "base/macros.h" 28 #include "base/macros.h"
28 #include "client/crashpad_client.h" 29 #include "client/crashpad_client.h"
29 #include "util/win/critical_section_with_debug_info.h" 30 #include "util/win/critical_section_with_debug_info.h"
30 #include "util/win/get_function.h" 31 #include "util/win/get_function.h"
31 32
32 // ntstatus.h conflicts with windows.h so define this locally. 33 // ntstatus.h conflicts with windows.h so define this locally.
33 #ifndef STATUS_NO_SUCH_FILE 34 #ifndef STATUS_NO_SUCH_FILE
34 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F) 35 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
35 #endif 36 #endif
36 37
37 namespace crashpad { 38 namespace crashpad {
38 namespace { 39 namespace {
39 40
40 CRITICAL_SECTION g_test_critical_section; 41 CRITICAL_SECTION g_test_critical_section;
41 42
43 unsigned char g_test_memory[] = {
44 99, 98, 97, 96, 95, 94, 93, 92, 91, 90,
45 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
46 };
47
42 ULONG RtlNtStatusToDosError(NTSTATUS status) { 48 ULONG RtlNtStatusToDosError(NTSTATUS status) {
43 static const auto rtl_nt_status_to_dos_error = 49 static const auto rtl_nt_status_to_dos_error =
44 GET_FUNCTION_REQUIRED(L"ntdll.dll", ::RtlNtStatusToDosError); 50 GET_FUNCTION_REQUIRED(L"ntdll.dll", ::RtlNtStatusToDosError);
45 return rtl_nt_status_to_dos_error(status); 51 return rtl_nt_status_to_dos_error(status);
46 } 52 }
47 53
48 void AllocateMemoryOfVariousProtections() { 54 void AllocateMemoryOfVariousProtections() {
49 SYSTEM_INFO system_info; 55 SYSTEM_INFO system_info;
50 GetSystemInfo(&system_info); 56 GetSystemInfo(&system_info);
51 57
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 PCHECK(result) << "VirtualAlloc MEM_COMMIT " << i; 89 PCHECK(result) << "VirtualAlloc MEM_COMMIT " << i;
84 } 90 }
85 } 91 }
86 92
87 void SomeCrashyFunction() { 93 void SomeCrashyFunction() {
88 // SetLastError and NTSTATUS so that we have something to view in !gle in 94 // SetLastError and NTSTATUS so that we have something to view in !gle in
89 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the 95 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the
90 // LastStatusError of the TEB as a side-effect, and we'll be setting 96 // LastStatusError of the TEB as a side-effect, and we'll be setting
91 // ERROR_FILE_NOT_FOUND for GetLastError(). 97 // ERROR_FILE_NOT_FOUND for GetLastError().
92 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE)); 98 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE));
99
100 // Set a register to point at some memory we can test to confirm it makes it
101 // into the minidump. We use __movsb as a way to set SI/DI without needing an
102 // external .asm file.
103 __movsb(g_test_memory, g_test_memory, 0);
104
93 volatile int* foo = reinterpret_cast<volatile int*>(7); 105 volatile int* foo = reinterpret_cast<volatile int*>(7);
94 *foo = 42; 106 *foo = 42;
95 } 107 }
96 108
97 int CrashyMain(int argc, wchar_t* argv[]) { 109 int CrashyMain(int argc, wchar_t* argv[]) {
98 CrashpadClient client; 110 CrashpadClient client;
99 111
100 if (argc == 2) { 112 if (argc == 2) {
101 if (!client.SetHandlerIPCPipe(argv[1])) { 113 if (!client.SetHandlerIPCPipe(argv[1])) {
102 LOG(ERROR) << "SetHandler"; 114 LOG(ERROR) << "SetHandler";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 146
135 return EXIT_SUCCESS; 147 return EXIT_SUCCESS;
136 } 148 }
137 149
138 } // namespace 150 } // namespace
139 } // namespace crashpad 151 } // namespace crashpad
140 152
141 int wmain(int argc, wchar_t* argv[]) { 153 int wmain(int argc, wchar_t* argv[]) {
142 return crashpad::CrashyMain(argc, argv); 154 return crashpad::CrashyMain(argc, argv);
143 } 155 }
OLDNEW
« no previous file with comments | « no previous file | minidump/minidump_exception_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698