Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the error HR for the exception code for debug attach/detech fatal error #1509

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Common/Exceptions/ReportError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/Common/Exceptions/ReportError.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/Common/Exceptions/Throw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
10 changes: 6 additions & 4 deletions lib/Jsrt/JsrtDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return JsErrorFatal; [](start = 16, length = 20)

We won't reach here ever, can be simplified as Debugger_AttachDetach_fatal_error(scriptContext->OnDebuggerDetached())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, Debugger_AttachDetach_fatal_error doesn't check hr, and it can be in one line.
I'd rather save the sorry by returning....

}

Expand Down