public Task <VariablesResponse> Handle(VariablesArguments request, CancellationToken cancellationToken) { VariableDetailsBase[] variables = _debugService.GetVariables( (int)request.VariablesReference); VariablesResponse variablesResponse = null; try { variablesResponse = new VariablesResponse { Variables = variables .Select(LspDebugUtils.CreateVariable) .ToArray() }; } catch (Exception) { // TODO: This shouldn't be so broad } return(Task.FromResult(variablesResponse)); }
public void CheckEnum(string caller_trace, VariablesResponse variablesResponse, string VarName, string ExpectedResult) { foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VarName) { Assert.Equal(ExpectedResult, Variable.value, @"__FILE__:__LINE__" + "\n" + caller_trace); return; } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void CheckEnum(VariablesResponse variablesResponse, string VarName, string ExpectedResult) { foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VarName) { Assert.True(Variable.value == ExpectedResult); return; } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public int GetChildVariablesReference(string caller_trace, int VariablesReference, string VariableName) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = VariablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VariableName) { return(Variable.variablesReference); } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void EvalVariable(int variablesReference, string Type, string Name, string Value) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == Name) { Assert.True(Type == Variable.type && Value == Variable.value); return; } } }
public void EvalVariableByIndex(string caller_trace, int variablesReference, string Type, int Index, string Value) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); if (Index < variablesResponse.body.variables.Count) { var Variable = variablesResponse.body.variables[Index]; Assert.Equal(Type, Variable.type, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(Value, Variable.value, @"__FILE__:__LINE__" + "\n" + caller_trace); return; } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void EvalVariableByIndex(int variablesReference, string Type, int Index, string Value) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); if (Index < variablesResponse.body.variables.Count) { var Variable = variablesResponse.body.variables[Index]; Assert.True(Type == Variable.type && Value == Variable.value); return; } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public static int GetChildVariablesReference(int VariablesReference, string VariableName) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = VariablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VariableName) { return(Variable.variablesReference); } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public bool EvalVariable(string caller_trace, int variablesReference, string ExpectedResult, string ExpectedType, string VariableName) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VariableName) { Assert.Equal(ExpectedType, Variable.type, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(ExpectedResult, Variable.value, @"__FILE__:__LINE__" + "\n" + caller_trace); return(true); } } return(false); }
public void EvalVariable(string caller_trace, int variablesReference, string Type, string Name, string Value) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == Name) { Assert.Equal(Type, Variable.type, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(Value, Variable.value, @"__FILE__:__LINE__" + "\n" + caller_trace); return; } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
static void Main(string[] args) { Label.Checkpoint("init", "values_test", (Object context) => { Context Context = (Context)context; Context.PrepareStart(@"__FILE__:__LINE__"); Context.AddBreakpoint(@"__FILE__:__LINE__", "bp"); Context.SetBreakpoints(@"__FILE__:__LINE__"); Context.PrepareEnd(@"__FILE__:__LINE__"); Context.WasEntryPointHit(@"__FILE__:__LINE__"); Context.Continue(@"__FILE__:__LINE__"); }); // Note, we test for same behaviour as MS vsdbg have. enum1 enum1_test0 = (enum1)0; // check for wrong code logic, result = 0 - out of enumeration enum1 enum1_test1 = enum1.read; enum1 enum1_test2 = enum1.write; enum1 enum1_test3 = enum1.append; enum1 enum1_test4 = enum1.read & enum1.write; // check for wrong code logic, result = 0 enum1 enum1_test5 = enum1.read | enum1.write; // check for wrong code logic, result = append - not flags enumeration can't be OR-ed enum1 enum1_test6 = (enum1)101; // check for wrong code logic, result = 101 - out of enumeration enum2 enum2_test0 = (enum2)0; // result = None enum2 enum2_test1 = enum2.read; enum2 enum2_test2 = enum2.write; enum2 enum2_test3 = enum2.append; enum2 enum2_test4 = enum2.read & enum2.write; // check for wrong code logic, result = None enum2 enum2_test5 = enum2.read | enum2.write; // check for wrong code logic, result = append - not flags enumeration can't be OR-ed enum2 enum2_test6 = (enum2)101; // check for wrong code logic, result = 101 - out of enumeration enum3 enum3_test0 = (enum3)0; // check for wrong code logic, result = 0 - out of enumeration enum3 enum3_test1 = enum3.read; enum3 enum3_test2 = enum3.write; enum3 enum3_test3 = enum3.append; enum3 enum3_test4 = enum3.read & enum3.write; // check for wrong code logic, result = 0 - out of enumeration enum3 enum3_test5 = enum3.read | enum3.write | enum3.append; // check that debugger care about enum sequence in case of flags attribute, result = read | write | append enum3 enum3_test6 = (enum3)101; // check for wrong code logic, result = 101 - out of enumeration enum4 enum4_test0 = (enum4)0; // result = None enum4 enum4_test1 = enum4.read; enum4 enum4_test2 = enum4.write; enum4 enum4_test3 = enum4.append; enum4 enum4_test4 = enum4.read & enum4.write; // check for wrong code logic, result = None enum4 enum4_test5 = enum4.read | enum4.write | enum4.append; // check that debugger care about enum sequence in case of flags attribute, result = read | write | append enum4 enum4_test6 = (enum4)101; // check for wrong code logic, result = 101 - out of enumeration enum5 enum5_test1 = enum5.append; // check that debugger care about enum sequence in case of flags attribute, result = append enum5 enum5_test2 = enum5.read | enum5.write; // check that debugger care about enum sequence in case of flags attribute, result = append enum5 enum5_test3 = enum5.write | enum5.read; // check that debugger care about enum sequence in case of flags attribute, result = append enum6 enum6_test1 = enum6.append; // check that debugger care about enum sequence in case of flags attribute, result = append enum6 enum6_test2 = enum6.read | enum6.write; // check that debugger care about enum sequence in case of flags attribute, result = append enum6 enum6_test3 = enum6.write | enum6.read; // check that debugger care about enum sequence in case of flags attribute, result = append enum7 enum7_test1 = enum7.read; enum7 enum7_test2 = enum7.write; enum8 enum8_test1 = enum8.read; enum8 enum8_test2 = enum8.write; enum9 enum9_test1 = enum9.read; enum9 enum9_test2 = enum9.write; enum10 enum10_test1 = enum10.read; enum10 enum10_test2 = enum10.write; Console.WriteLine("A breakpoint \"bp\" is set on this line"); Label.Breakpoint("bp"); Label.Checkpoint("values_test", "finish", (Object context) => { Context Context = (Context)context; Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp"); Int64 frameId = Context.DetectFrameId(@"__FILE__:__LINE__", "bp"); VariablesResponse variablesResponse = Context.GetLocalVariables(@"__FILE__:__LINE__", frameId); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test0", "0"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test4", "0"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test5", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum1_test6", "101"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test0", "None"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test4", "None"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test5", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum2_test6", "101"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test0", "0"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test4", "0"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test5", "read | write | append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum3_test6", "101"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test0", "None"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test4", "None"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test5", "read | write | append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum4_test6", "101"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum5_test1", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum5_test2", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum5_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum6_test1", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum6_test2", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum6_test3", "append"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum7_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum7_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum8_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum8_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum9_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum9_test2", "write"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum10_test1", "read"); Context.CheckEnum(@"__FILE__:__LINE__", variablesResponse, "enum10_test2", "write"); Context.Continue(@"__FILE__:__LINE__"); }); Label.Checkpoint("finish", "", (Object context) => { Context Context = (Context)context; Context.WasExit(@"__FILE__:__LINE__"); Context.DebuggerExit(@"__FILE__:__LINE__"); }); }