Skip to content

Commit

Permalink
don't throw exceptions in DAP handler and get the correct source line…
Browse files Browse the repository at this point in the history
… for goto targets
  • Loading branch information
Trass3r committed Sep 11, 2020
1 parent b553574 commit ce66883
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/OpenDebugAD7/AD7DebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,17 +1206,17 @@ protected override void HandleGotoRequestAsync(IRequestResponder<GotoArguments>
return;
}

var gotoTarget = m_gotoCodeContexts[responder.Arguments.TargetId];
IDebugThread2 thread = null;
lock (m_threads)
{
if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread))
throw new AD7Exception("Could not find thread!");
}
BeforeContinue();
var builder = new ErrorBuilder(() => AD7Resources.Error_UnableToSetNextStatement);
try
{
var gotoTarget = m_gotoCodeContexts[responder.Arguments.TargetId];
IDebugThread2 thread = null;
lock (m_threads)
{
if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread))
throw new AD7Exception("Unknown thread id: " + responder.Arguments.ThreadId.ToString(CultureInfo.InvariantCulture));
}
BeforeContinue();
builder.CheckHR(thread.SetNextStatement(null, gotoTarget));
}
catch (AD7Exception e)
Expand Down Expand Up @@ -1258,18 +1258,22 @@ protected override void HandleGotoTargetsRequestAsync(IRequestResponder<GotoTarg
var codeContext = codeContexts[0];
string contextName;
codeContext.GetName(out contextName);
targets.Add(new GotoTarget(m_gotoCodeContexts.Create(codeContext), contextName, responder.Arguments.Line)); // TODO: get the real line
line = responder.Arguments.Line;
IDebugDocumentContext2 documentContext;
if (codeContext.GetDocumentContext(out documentContext) == HRConstants.S_OK)
{
var pos = new TEXT_POSITION[1];
if (documentContext.GetStatementRange(pos, null) == HRConstants.S_OK)
line = m_pathConverter.ConvertDebuggerLineToClient((int)pos[0].dwLine);
}
targets.Add(new GotoTarget(m_gotoCodeContexts.Create(codeContext), contextName, line));
}
}

response.Targets = targets;
}
catch (Exception e)
catch (AD7Exception e)
{
e = Utilities.GetInnerMost(e);
if (Utilities.IsCorruptingException(e))
Utilities.ReportException(e);

responder.SetError(new ProtocolException(e.Message));
return;
}
Expand Down

0 comments on commit ce66883

Please sign in to comment.