From 936f730238a8eaeef76fae405f1bb75b31fcacc8 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 28 Oct 2020 16:47:34 -0700 Subject: [PATCH] Fixing todo --- src/MICore/CommandFactories/lldb.cs | 2 +- src/OpenDebugAD7/AD7DebugSession.cs | 34 +++++++++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/MICore/CommandFactories/lldb.cs b/src/MICore/CommandFactories/lldb.cs index 80fe9f8f6..e2181942c 100644 --- a/src/MICore/CommandFactories/lldb.cs +++ b/src/MICore/CommandFactories/lldb.cs @@ -186,7 +186,7 @@ public override async Task ExecJump(string filename, int line) public override async Task ExecJump(ulong address) { - string command = "jump *" + string.Format("0x{0:X}", address); + string command = "jump *" + string.Format(CultureInfo.InvariantCulture, "0x{0:X}", address); await _debugger.CmdAsync(command, ResultClass.running); } diff --git a/src/OpenDebugAD7/AD7DebugSession.cs b/src/OpenDebugAD7/AD7DebugSession.cs index 9f65bcf1f..23e3563c7 100644 --- a/src/OpenDebugAD7/AD7DebugSession.cs +++ b/src/OpenDebugAD7/AD7DebugSession.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -42,7 +43,9 @@ internal sealed class AD7DebugSession : DebugAdapterBase, IDebugPortNotify2, IDe private readonly DebugEventLogger m_logger; private readonly Dictionary> m_breakpoints; - private readonly List m_gotoCodeContexts = new List(); + + private readonly ConcurrentDictionary m_gotoCodeContexts = new ConcurrentDictionary(); + private int m_nextContextId = 1; private Dictionary m_functionBreakpoints; private readonly Dictionary m_threadFrameEnumInfos = new Dictionary(); @@ -1268,15 +1271,17 @@ protected override void HandleGotoRequestAsync(IRequestResponder var builder = new ErrorBuilder(() => AD7Resources.Error_UnableToSetNextStatement); try { - var gotoTarget = m_gotoCodeContexts[responder.Arguments.TargetId]; - IDebugThread2 thread = null; - lock (m_threads) + if (m_gotoCodeContexts.TryGetValue(responder.Arguments.TargetId, out IDebugCodeContext2 gotoTarget)) { - if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread)) - throw new AD7Exception("Unknown thread id: " + responder.Arguments.ThreadId.ToString(CultureInfo.InvariantCulture)); + 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)); } - BeforeContinue(); - builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); } catch (AD7Exception e) { @@ -1321,11 +1326,16 @@ protected override void HandleGotoTargetsRequestAsync(IRequestResponder