|
2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
3 | 3 |
|
4 | 4 | using System;
|
| 5 | +using System.Collections.Concurrent; |
5 | 6 | using System.Collections.Generic;
|
6 | 7 | using System.Diagnostics;
|
7 | 8 | using System.Globalization;
|
@@ -42,7 +43,9 @@ internal sealed class AD7DebugSession : DebugAdapterBase, IDebugPortNotify2, IDe
|
42 | 43 |
|
43 | 44 | private readonly DebugEventLogger m_logger;
|
44 | 45 | private readonly Dictionary<string, Dictionary<int, IDebugPendingBreakpoint2>> m_breakpoints;
|
45 |
| - private readonly List<IDebugCodeContext2> m_gotoCodeContexts = new List<IDebugCodeContext2>(); |
| 46 | + |
| 47 | + private readonly ConcurrentDictionary<int, IDebugCodeContext2> m_gotoCodeContexts = new ConcurrentDictionary<int, IDebugCodeContext2>(); |
| 48 | + private int m_nextContextId = 1; |
46 | 49 |
|
47 | 50 | private Dictionary<string, IDebugPendingBreakpoint2> m_functionBreakpoints;
|
48 | 51 | private readonly Dictionary<int, ThreadFrameEnumInfo> m_threadFrameEnumInfos = new Dictionary<int, ThreadFrameEnumInfo>();
|
@@ -705,7 +708,8 @@ protected override void HandleInitializeRequestAsync(IRequestResponder<Initializ
|
705 | 708 | SupportsReadMemoryRequest = true,
|
706 | 709 | SupportsGotoTargetsRequest = true,
|
707 | 710 | SupportsModulesRequest = true,
|
708 |
| - AdditionalModuleColumns = additionalModuleColumns |
| 711 | + AdditionalModuleColumns = additionalModuleColumns, |
| 712 | + SupportsDisassembleRequest = true |
709 | 713 | };
|
710 | 714 |
|
711 | 715 | responder.SetResponse(initializeResponse);
|
@@ -1240,15 +1244,17 @@ protected override void HandleGotoRequestAsync(IRequestResponder<GotoArguments>
|
1240 | 1244 | var builder = new ErrorBuilder(() => AD7Resources.Error_UnableToSetNextStatement);
|
1241 | 1245 | try
|
1242 | 1246 | {
|
1243 |
| - var gotoTarget = m_gotoCodeContexts[responder.Arguments.TargetId]; |
1244 |
| - IDebugThread2 thread = null; |
1245 |
| - lock (m_threads) |
| 1247 | + if (m_gotoCodeContexts.TryGetValue(responder.Arguments.TargetId, out IDebugCodeContext2 gotoTarget)) |
1246 | 1248 | {
|
1247 |
| - if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread)) |
1248 |
| - throw new AD7Exception("Unknown thread id: " + responder.Arguments.ThreadId.ToString(CultureInfo.InvariantCulture)); |
| 1249 | + IDebugThread2 thread = null; |
| 1250 | + lock (m_threads) |
| 1251 | + { |
| 1252 | + if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread)) |
| 1253 | + throw new AD7Exception("Unknown thread id: " + responder.Arguments.ThreadId.ToString(CultureInfo.InvariantCulture)); |
| 1254 | + } |
| 1255 | + BeforeContinue(); |
| 1256 | + builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); |
1249 | 1257 | }
|
1250 |
| - BeforeContinue(); |
1251 |
| - builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); |
1252 | 1258 | }
|
1253 | 1259 | catch (AD7Exception e)
|
1254 | 1260 | {
|
@@ -1293,11 +1299,16 @@ protected override void HandleGotoTargetsRequestAsync(IRequestResponder<GotoTarg
|
1293 | 1299 | IDebugDocumentContext2 documentContext;
|
1294 | 1300 | if (codeContext.GetDocumentContext(out documentContext) == HRConstants.S_OK)
|
1295 | 1301 | {
|
1296 |
| - var pos = new TEXT_POSITION[1]; |
1297 |
| - if (documentContext.GetStatementRange(pos, null) == HRConstants.S_OK) |
1298 |
| - line = m_pathConverter.ConvertDebuggerLineToClient((int)pos[0].dwLine); |
| 1302 | + var startPos = new TEXT_POSITION[1]; |
| 1303 | + var endPos = new TEXT_POSITION[1]; |
| 1304 | + if (documentContext.GetStatementRange(startPos, endPos) == HRConstants.S_OK) |
| 1305 | + line = m_pathConverter.ConvertDebuggerLineToClient((int)startPos[0].dwLine); |
1299 | 1306 | }
|
1300 |
| - targets.Add(new GotoTarget(m_gotoCodeContexts.Create(codeContext), contextName, line)); |
| 1307 | + |
| 1308 | + int codeContextId = m_nextContextId++; |
| 1309 | + m_gotoCodeContexts.TryAdd(codeContextId, codeContext); |
| 1310 | + |
| 1311 | + targets.Add(new GotoTarget(codeContextId, contextName, line)); |
1301 | 1312 | }
|
1302 | 1313 | }
|
1303 | 1314 |
|
|
0 commit comments