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

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

Powered by Google App Engine
This is Rietveld 408576698