Skip to content

Commit

Permalink
Catch ProtocolException in HandleEvaluateAsync (#1360)
Browse files Browse the repository at this point in the history
* Catch ProtocolException

Catch ProtocolException from GetDebugPropertyFromExpression.
If frames change and then we get a request,
GetDebugPropertyFromException would throw and crash the debug adapter.

This PR catches the exception and sets it to the responder of the
Caller in HandleEvaluateAsync
  • Loading branch information
WardenGnaw authored Oct 18, 2022
1 parent 111363a commit 4908ae6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/OpenDebugAD7/AD7DebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2979,6 +2979,8 @@ protected override void HandleCompletionsRequestAsync(IRequestResponder<Completi

protected override void HandleEvaluateRequestAsync(IRequestResponder<EvaluateArguments, EvaluateResponse> responder)
{
try
{
EvaluateArguments.ContextValue context = responder.Arguments.Context.GetValueOrDefault(EvaluateArguments.ContextValue.Unknown);
int frameId = responder.Arguments.FrameId.GetValueOrDefault(-1);
string expression = responder.Arguments.Expression;
Expand Down Expand Up @@ -3065,6 +3067,13 @@ protected override void HandleEvaluateRequestAsync(IRequestResponder<EvaluateArg
VariablesReference = variable.VariablesReference,
MemoryReference = memoryReference
});

}
catch (Exception e)
{
responder.SetError(new ProtocolException(e.Message));
return;
}
}

protected override void HandleReadMemoryRequestAsync(IRequestResponder<ReadMemoryArguments, ReadMemoryResponse> responder)
Expand Down

0 comments on commit 4908ae6

Please sign in to comment.