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

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

Issue 1364803004: win: Save contents of TEBs allowing !teb and !gle to work in windbg (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@dump-without-crashing
Patch Set: . Created 5 years, 2 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_thread_writer.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 "client/crashpad_client.h" 15 #include <windows.h>
16 #include <winternl.h>
17
18 // ntstatus.h conflicts with windows.h so define this locally.
19 #ifndef STATUS_NO_SUCH_FILE
20 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
21 #endif
16 22
17 #include "base/logging.h" 23 #include "base/logging.h"
24 #include "client/crashpad_client.h"
18 #include "tools/tool_support.h" 25 #include "tools/tool_support.h"
19 26
20 namespace crashpad { 27 namespace crashpad {
21 namespace { 28 namespace {
22 29
30 ULONG RtlNtStatusToDosError(NTSTATUS status) {
31 static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error =
32 reinterpret_cast<decltype(::RtlNtStatusToDosError)*>(
33 GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError"));
34 DCHECK(rtl_nt_status_to_dos_error);
35 return rtl_nt_status_to_dos_error(status);
36 }
37
23 void SomeCrashyFunction() { 38 void SomeCrashyFunction() {
39 // SetLastError and NTSTATUS so that we have something to view in !gle in
40 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the
41 // LastStatusError of the TEB as a side-effect, and we'll be setting
42 // ERROR_FILE_NOT_FOUND for GetLastError().
43 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE));
24 volatile int* foo = reinterpret_cast<volatile int*>(7); 44 volatile int* foo = reinterpret_cast<volatile int*>(7);
25 *foo = 42; 45 *foo = 42;
26 } 46 }
27 47
28 int CrashyMain(int argc, char* argv[]) { 48 int CrashyMain(int argc, char* argv[]) {
29 if (argc != 2) { 49 if (argc != 2) {
30 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); 50 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]);
31 return 1; 51 return 1;
32 } 52 }
33 53
(...skipping 11 matching lines...) Expand all
45 65
46 return 0; 66 return 0;
47 } 67 }
48 68
49 } // namespace 69 } // namespace
50 } // namespace crashpad 70 } // namespace crashpad
51 71
52 int wmain(int argc, wchar_t* argv[]) { 72 int wmain(int argc, wchar_t* argv[]) {
53 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); 73 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain);
54 } 74 }
OLDNEW
« no previous file with comments | « no previous file | minidump/minidump_thread_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698