diff --git a/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs b/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs index c576c35fd..39090e1f0 100644 --- a/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs +++ b/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs @@ -58,20 +58,13 @@ public async Task BreakpointModified(object sender, EventArgs args) string bkptId = null; // // =breakpoint-modified, - // bkpt ={number="2",type="breakpoint",disp="keep",enabled="y",addr="",times="0",original-location="main.cpp:220"}, + // bkpt ={number="2",type="breakpoint",disp="keep",enabled="y",addr="",times="0",original-location="main.cpp:220"},locations=[ // { number="2.1",enabled="y",addr="0x9c2149a9",func="Foo::bar(int)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]}, - // { number="2.2",enabled="y",addr="0x9c2149f2",func="Foo::bar(float)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]} + // { number="2.2",enabled="y",addr="0x9c2149f2",func="Foo::bar(float)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]}]} // note: the ".x" part of the breakpoint number never appears in stopping events, that is, when executing at one of these addresses // the stopping event delivered contains bkptno="2" - if (bkpt is MICore.ValueListValue) - { - MICore.ValueListValue list = bkpt as MICore.ValueListValue; - bkptId = list.Content[0].FindString("number"); // 0 is the "" entry - } - else - { - bkptId = bkpt.FindString("number"); - } + bkptId = bkpt.FindString("number"); + AD7PendingBreakpoint pending = CodeBreakpoints.FirstOrDefault((p) => { return p.BreakpointId == bkptId; }); if (pending == null) { diff --git a/src/MIDebugEngine/Engine.Impl/Breakpoints.cs b/src/MIDebugEngine/Engine.Impl/Breakpoints.cs index 356eb8efb..1f22ae702 100644 --- a/src/MIDebugEngine/Engine.Impl/Breakpoints.cs +++ b/src/MIDebugEngine/Engine.Impl/Breakpoints.cs @@ -146,12 +146,11 @@ private static async Task EvalBindResult(Results bindResult, AD7Pend if (b is TupleValue) { bkpt = b as TupleValue; - } - else if (b is ValueListValue) - { - // "" sometimes includes a list of bound breakpoints - list = b as ValueListValue; - bkpt = list.Content[0] as TupleValue; + // The locations field is present if the breakpoint has multiple locations. + if (b.TryFind("locations", out var locations) && locations is ValueListValue) + { + list = (ValueListValue) locations; + } } } else @@ -189,9 +188,9 @@ private static async Task EvalBindResult(Results bindResult, AD7Pend else // with list of addresses { BindResult res = new BindResult(bp); - for (int i = 1; i < list.Content.Length; ++i) + foreach (var t in list.Content) { - BoundBreakpoint bbp = await bp.GetBoundBreakpoint(list.Content[i] as TupleValue); + BoundBreakpoint bbp = await bp.GetBoundBreakpoint(t as TupleValue); res.BoundBreakpoints.Add(bbp); } return res; @@ -290,12 +289,13 @@ internal async Task> BindAddresses(ResultValue bkpt) return resultList; } BoundBreakpoint bbp = null; - if (bkpt is ValueListValue) + + // The locations field is present if the breakpoint has multiple locations. + if (bkpt.TryFind("locations", out var locations) && locations is ValueListValue list) { - var list = (ValueListValue)bkpt; - for (int i = 1; i < list.Content.Length; ++i) + foreach (var t in list.Content) { - bbp = await GetBoundBreakpoint(list.Content[i] as TupleValue); + bbp = await GetBoundBreakpoint(t as TupleValue); if (bbp != null) resultList.Add(bbp); } diff --git a/test/CppTests/Tests/BreakpointTests.cs b/test/CppTests/Tests/BreakpointTests.cs index 046aecb12..4ea4279b9 100644 --- a/test/CppTests/Tests/BreakpointTests.cs +++ b/test/CppTests/Tests/BreakpointTests.cs @@ -125,7 +125,7 @@ public void FunctionBreakpointsBasic(ITestSettings settings) runner.Launch(settings.DebuggerSettings, debuggee, "-fCalling"); this.Comment("Set initial function breakpoints"); - FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("Arguments::CoreRun", "Calling::CoreRun", "a()"); + FunctionBreakpoints functionBreakpoints = new FunctionBreakpoints("Arguments::CoreRun", "Calling::CoreRun", "a"); runner.SetFunctionBreakpoints(functionBreakpoints); this.Comment("Launch and run until first initial breakpoint"); @@ -137,7 +137,7 @@ public void FunctionBreakpointsBasic(ITestSettings settings) .AfterContinue(); this.Comment("Remove and replace third initial function breakpoint while in break mode"); - functionBreakpoints.Remove("a()"); + functionBreakpoints.Remove("a"); functionBreakpoints.Add("b()"); runner.SetFunctionBreakpoints(functionBreakpoints); diff --git a/test/CppTests/debuggees/kitchensink/src/calling.cpp b/test/CppTests/debuggees/kitchensink/src/calling.cpp index d1ea2aa91..4b4b5b45e 100644 --- a/test/CppTests/debuggees/kitchensink/src/calling.cpp +++ b/test/CppTests/debuggees/kitchensink/src/calling.cpp @@ -52,4 +52,10 @@ void Calling::CoreRun() this->Log("Calling variable arg function."); double ave = average(10, 1.0, 3.0, 4.5, 11.0, -30.0, 17.4, 2.1, -4.0, 0.0, 12.1); this->Log("Average ", ave); +} + +int a(int count) +{ + b(); + return count - 1; } \ No newline at end of file