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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | minidump/minidump_thread_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: handler/win/crashy_test_program.cc
diff --git a/handler/win/crashy_test_program.cc b/handler/win/crashy_test_program.cc
index 07c9cf101278213f36b55e3025b8b1c88ece15a4..622a5e5df08d3218dbdd2e5d1a2ab7fca32992e2 100644
--- a/handler/win/crashy_test_program.cc
+++ b/handler/win/crashy_test_program.cc
@@ -12,15 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "client/crashpad_client.h"
+#include <windows.h>
+#include <winternl.h>
+
+// ntstatus.h conflicts with windows.h so define this locally.
+#ifndef STATUS_NO_SUCH_FILE
+#define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F)
+#endif
#include "base/logging.h"
+#include "client/crashpad_client.h"
#include "tools/tool_support.h"
namespace crashpad {
namespace {
+ULONG RtlNtStatusToDosError(NTSTATUS status) {
+ static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error =
+ reinterpret_cast<decltype(::RtlNtStatusToDosError)*>(
+ GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError"));
+ DCHECK(rtl_nt_status_to_dos_error);
+ return rtl_nt_status_to_dos_error(status);
+}
+
void SomeCrashyFunction() {
+ // SetLastError and NTSTATUS so that we have something to view in !gle in
+ // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the
+ // LastStatusError of the TEB as a side-effect, and we'll be setting
+ // ERROR_FILE_NOT_FOUND for GetLastError().
+ SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE));
volatile int* foo = reinterpret_cast<volatile int*>(7);
*foo = 42;
}
« 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