Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
Handle uncaught user exceptions on Windows.
Browse files Browse the repository at this point in the history
This code is used for C++ exceptions thrown by user code.
  • Loading branch information
sas committed Apr 22, 2016
1 parent a984938 commit e487d7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Headers/DebugServer2/Host/Windows/ExtraWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <cstdio>
#include <windows.h>

#define DS2_EXCEPTION_UNCAUGHT_USER 0xE06D7363

// Some APIs are not exposed when building for UAP.
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

Expand Down
3 changes: 3 additions & 0 deletions Sources/Support/Windows/Stringify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//

#include "DebugServer2/Support/Stringify.h"
#include "DebugServer2/Host/Windows/ExtraWrappers.h"
#include "DebugServer2/Support/StringifyPrivate.h"
#include "DebugServer2/Utils/Log.h"

Expand Down Expand Up @@ -53,6 +54,8 @@ char const *Stringify::ExceptionCode(DWORD code) {
DO_STRINGIFY(EXCEPTION_PRIV_INSTRUCTION)
DO_STRINGIFY(EXCEPTION_SINGLE_STEP)
DO_STRINGIFY(EXCEPTION_STACK_OVERFLOW)
case DS2_EXCEPTION_UNCAUGHT_USER:
return "0xE06D7363 (uncaught user exception)";
DO_DEFAULT("unknown exception code", code)
}
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Target/Windows/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ void Thread::updateState(DEBUG_EVENT const &de) {

case EXCEPTION_INVALID_DISPOSITION:
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
case DS2_EXCEPTION_UNCAUGHT_USER:
_stopInfo.event = StopInfo::kEventStop;
_stopInfo.reason = StopInfo::kReasonInstructionError;
break;

default:
DS2BUG("unsupported exception code: %s",
Stringify::ExceptionCode(
Expand Down

0 comments on commit e487d7b

Please sign in to comment.