From ef065f4da8f5b5c0d9ff06ae01f8956fd035a27c Mon Sep 17 00:00:00 2001 From: Curtis Man Date: Mon, 29 Aug 2016 09:46:38 -0700 Subject: [PATCH] Use the error HR for the exception code for debug attach/detech fatal error --- lib/Common/Exceptions/ReportError.cpp | 4 ++-- lib/Common/Exceptions/ReportError.h | 2 +- lib/Common/Exceptions/Throw.h | 2 +- lib/Jsrt/JsrtDiag.cpp | 10 ++++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Common/Exceptions/ReportError.cpp b/lib/Common/Exceptions/ReportError.cpp index a0d9661623e..c1263e57e40 100644 --- a/lib/Common/Exceptions/ReportError.cpp +++ b/lib/Common/Exceptions/ReportError.cpp @@ -114,10 +114,10 @@ _NOINLINE void FromDOM_NoScriptScope_fatal_error() ReportFatalException(NULL, E_UNEXPECTED, EnterScript_FromDOM_NoScriptScope, scenario); } -_NOINLINE void Debugger_AttachDetach_fatal_error() +_NOINLINE void Debugger_AttachDetach_fatal_error(HRESULT hr) { int scenario = 5; - ReportFatalException(NULL, E_UNEXPECTED, Fatal_Debugger_AttachDetach_Failure, scenario); + ReportFatalException(NULL, hr, Fatal_Debugger_AttachDetach_Failure, scenario); } _NOINLINE void EntryExitRecord_Corrupted_fatal_error() diff --git a/lib/Common/Exceptions/ReportError.h b/lib/Common/Exceptions/ReportError.h index a577fcdd672..e5a30ba2ed8 100644 --- a/lib/Common/Exceptions/ReportError.h +++ b/lib/Common/Exceptions/ReportError.h @@ -64,7 +64,7 @@ void LargeHeapBlock_Metadata_Corrupted( #endif void FromDOM_NoScriptScope_fatal_error(); -void Debugger_AttachDetach_fatal_error(); +void Debugger_AttachDetach_fatal_error(HRESULT hr); #ifndef DISABLE_SEH // RtlReportException is available on Vista and up, but we cannot use it for OOB release. diff --git a/lib/Common/Exceptions/Throw.h b/lib/Common/Exceptions/Throw.h index 7b9a760b698..55015a4c234 100644 --- a/lib/Common/Exceptions/Throw.h +++ b/lib/Common/Exceptions/Throw.h @@ -256,4 +256,4 @@ namespace Js { catch (ex) \ { -#define DEBUGGER_ATTACHDETACH_FATAL_ERROR_IF_FAILED(hr) if (hr != S_OK) Debugger_AttachDetach_fatal_error(); +#define DEBUGGER_ATTACHDETACH_FATAL_ERROR_IF_FAILED(hr) if (hr != S_OK) Debugger_AttachDetach_fatal_error(hr); diff --git a/lib/Jsrt/JsrtDiag.cpp b/lib/Jsrt/JsrtDiag.cpp index d740d616de7..cea91f23bf2 100644 --- a/lib/Jsrt/JsrtDiag.cpp +++ b/lib/Jsrt/JsrtDiag.cpp @@ -87,9 +87,10 @@ CHAKRA_API JsDiagStartDebugging( debugContext->SetHostDebugContext(jsrtDebugManager); } - if (FAILED(scriptContext->OnDebuggerAttached())) + HRESULT hr; + if (FAILED(hr = scriptContext->OnDebuggerAttached())) { - Debugger_AttachDetach_fatal_error(); // Inconsistent state, we can't continue from here + Debugger_AttachDetach_fatal_error(hr); // Inconsistent state, we can't continue from here return JsErrorFatal; } @@ -129,9 +130,10 @@ CHAKRA_API JsDiagStopDebugging( { Assert(scriptContext->IsScriptContextInDebugMode()); - if (FAILED(scriptContext->OnDebuggerDetached())) + HRESULT hr; + if (FAILED(hr = scriptContext->OnDebuggerDetached())) { - Debugger_AttachDetach_fatal_error(); // Inconsistent state, we can't continue from here + Debugger_AttachDetach_fatal_error(hr); // Inconsistent state, we can't continue from here return JsErrorFatal; }