public EditBreakpointDialogDataContext(BreakpointInfo bpi) { this.BP = bpi; this.Line = this.BP.Line; this.Condition = this.BP.SqfCondition; this.IsActive = this.BP.IsEnabled; this.ConditionEnabled = !string.IsNullOrWhiteSpace(this.BP.SqfCondition); }
public async Task UpdateBreakpointAsync(BreakpointInfo bp) { if (!this.IsDebuggerAttached) { return; } await this.DebuggerInstance?.UpdateBreakpointAsync(bp); }
public void UpdateBreakpoint(BreakpointInfo b) { { var command = new JsonNode(new Dictionary <string, JsonNode>()); command.GetValue_Object()["command"] = new JsonNode((int)ESendCommands.AddBreakpointInfo); command.GetValue_Object()["data"] = b.Serialize(); this.WriteMessage(command); } }
protected static IBreakpointInfo CreateBreakpoint(string hitCondition, string filterCondition) { var breakpoint = new BreakpointInfo { IsCpuBreakpoint = true, HitType = BreakpointHitType.None }; if (hitCondition != null) { var condStart = 1; if (hitCondition.StartsWith("<=")) { breakpoint.HitType = BreakpointHitType.LessOrEqual; condStart = 2; } else if (hitCondition.StartsWith(">=")) { breakpoint.HitType = BreakpointHitType.GreaterOrEqual; condStart = 2; } else if (hitCondition.StartsWith("<")) { breakpoint.HitType = BreakpointHitType.Less; } else if (hitCondition.StartsWith(">")) { breakpoint.HitType = BreakpointHitType.Greater; } else if (hitCondition.StartsWith("=")) { breakpoint.HitType = BreakpointHitType.Equal; } else if (hitCondition.StartsWith("*")) { breakpoint.HitType = BreakpointHitType.Multiple; } breakpoint.HitConditionValue = ushort.Parse(hitCondition.Substring(condStart)); } if (filterCondition != null) { breakpoint.FilterCondition = filterCondition; var inputStream = new AntlrInputStream(filterCondition); var lexer = new Z80EvalLexer(inputStream); var tokenStream = new CommonTokenStream(lexer); var evalParser = new Z80EvalParser(tokenStream); var context = evalParser.compileUnit(); var visitor = new Z80EvalVisitor(); var z80Expr = (Z80ExpressionNode)visitor.Visit(context); breakpoint.FilterExpression = z80Expr.Expression; } return(breakpoint); }
public void RemoveBreakpoint(BreakpointInfo b) { this.BreakpointInfos.Remove(b); var node = new Newtonsoft.Json.Linq.JObject { { "command", (int)ESendCommands.DelBreakpoin }, { "data", b.AsJToken() } }; this.WriteMessage(node); }
//https://github.com/dedmen/ArmaDebugEngine/blob/master/BIDebugEngine/BIDebugEngine/breakPoint.cpp#L12 void BreakPoint::Serialize(JsonArchive& ar) /* * { * "action": { * "code": "string", * "basePath" : "string", * "type": 0 * }, * "condition": "string", * "filename": "string", * "line": 0 * } */ public static JObject AsJToken(this BreakpointInfo b) => new JObject { { "filename", b.FileRef.ArmAPath.Replace('/', '\\').Replace(@"\\", @"\") }, { "line", b.Line }, { "action", new JObject { { "type", 2 } } }, { "label", "" } };
public void Save() { if (_suspendSave == true) { return; } this.Debugger.UserData.Breakpoints.Infos.Clear(); foreach (Breakpoint bp in _breakpoints) { BreakpointInfo info = new BreakpointInfo(); info.Type = bp.Type; info.Address = bp.Address; info.Name = bp.Name; info.AccessType = bp.AccessType; info.Mode = bp.Mode; info.Enabled = bp.Enabled; this.Debugger.UserData.Breakpoints.Infos.Add(info); } this.Debugger.UserData.Save(); }
public BreakPointsChangedEventArgs(EMode mode, BreakpointInfo bp) { this.Mode = mode; this.Breakpoint = bp; }
public static Func <bool> EmitCondition(ref IDebuggable i_spectrum, BreakpointInfo i_breakpointInfo) { Func <bool> o_ILOut = null; if (i_breakpointInfo.AccessType == BreakPointConditionType.registryVsValue) { //e.g. PC == #0038 Type[] args = { typeof(CpuRegs) }; DynamicMethod dynamicMethod = new DynamicMethod( "RegVsValue", typeof(bool), //return type args, //arguments for the method typeof(CpuRegs).Module); //module as input ILGenerator il = dynamicMethod.GetILGenerator(); //1.Arg0 - registry il.Emit(OpCodes.Ldarg_0); // load m_spectrum.CPU.regs on stack FieldInfo testInfo1 = typeof(CpuRegs).GetField(i_breakpointInfo.LeftCondition, BindingFlags.Public | BindingFlags.Instance); il.Emit(OpCodes.Ldfld, testInfo1); //2.Arg1 - number il.Emit(OpCodes.Ldc_I4, (int)i_breakpointInfo.RightValue); //3.Compare EmitComparison(il, i_breakpointInfo.ConditionTypeSign); il.Emit(OpCodes.Ret); //Return: 1 => true(breakpoint is reached) otherwise 0 => false o_ILOut = (Func <bool>)dynamicMethod.CreateDelegate(typeof(Func <bool>), i_spectrum.CPU.regs); } else if (i_breakpointInfo.AccessType == BreakPointConditionType.flagVsValue) { //e.g.: fZ == 1 Type[] args = { typeof(CpuRegs) }; DynamicMethod dynamicMethod = new DynamicMethod( "FlagVsValue", typeof(bool), //return type args, //arguments for the method typeof(CpuRegs).Module); //module as input ILGenerator il = dynamicMethod.GetILGenerator(); //1.Arg0 - flag il.Emit(OpCodes.Ldarg_0); // load m_spectrum.CPU.regs on stack FieldInfo testInfo1 = typeof(CpuRegs).GetField("AF", BindingFlags.Public | BindingFlags.Instance); il.Emit(OpCodes.Ldfld, testInfo1); //get flag value(0 or 1) switch (i_breakpointInfo.LeftCondition) { case "FS": il.Emit(OpCodes.Ldc_I4, 0x80); break; case "FZ": il.Emit(OpCodes.Ldc_I4, 0x40); break; case "FH": il.Emit(OpCodes.Ldc_I4, 0x10); break; case "FPV": il.Emit(OpCodes.Ldc_I4, 0x04); break; case "FN": il.Emit(OpCodes.Ldc_I4, 0x02); break; case "FC": il.Emit(OpCodes.Ldc_I4, 0x01); break; default: throw new CommandParseException("Incorrect flag in condition emit..."); } il.Emit(OpCodes.And); //get flag value from F registry if (i_breakpointInfo.ConditionTypeSign == "==" && i_breakpointInfo.RightValue > 0) { i_breakpointInfo.RightValue = 0; i_breakpointInfo.ConditionTypeSign = "!="; } //2. Arg1 - right condition(must a number) il.Emit(OpCodes.Ldc_I4, (int)i_breakpointInfo.RightValue); //3. Compare EmitComparison(il, i_breakpointInfo.ConditionTypeSign); il.Emit(OpCodes.Ret); //Return: 1 => true(breakpoint is reached) otherwise 0 => false o_ILOut = (Func <bool>)dynamicMethod.CreateDelegate(typeof(Func <bool>), i_spectrum.CPU.regs); } else if (i_breakpointInfo.AccessType == BreakPointConditionType.memoryVsValue) { //e.g. (16384) == #FF00 //ToDo: Because it is not possible to dynamically emit code for interface method(IDebuggable.ReadMemory) // I temporary wrapped it into custom wrapper. InterfaceWrapper middleMan = new InterfaceWrapper(); middleMan.wrapInterface(i_spectrum); MethodInfo ReadMemoryMethod; if (i_breakpointInfo.RightValue > 0xFF) { ReadMemoryMethod = typeof(InterfaceWrapper).GetMethod("invokeReadMemory16Bit", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic , null , new Type[] { typeof(ushort) } , null); } else { ReadMemoryMethod = typeof(InterfaceWrapper).GetMethod("invokeReadMemory8Bit", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic , null , new Type[] { typeof(ushort) } , null); } DynamicMethod dynamicMethod = new DynamicMethod("ReadMemory" , typeof(bool) , new Type[] { typeof(InterfaceWrapper) } , typeof(InterfaceWrapper).Module ); ILGenerator IL = dynamicMethod.GetILGenerator(); //Arg0 - memory reference(static), e.g. (16384) IL.Emit(OpCodes.Ldarg_0); // load InterfaceWrapper on stack IL.Emit(OpCodes.Ldc_I4, i_breakpointInfo.LeftValue); // method parameter(for ReadMemoryMethod) IL.Emit(OpCodes.Call, ReadMemoryMethod); //Arg1 IL.Emit(OpCodes.Ldc_I4, i_breakpointInfo.RightValue); // <- compare to 8 or 16bit EmitComparison(IL, i_breakpointInfo.ConditionTypeSign); IL.Emit(OpCodes.Ret); //Return: 1 => true(breakpoint is reached) otherwise 0 => false o_ILOut = (Func <bool>)dynamicMethod.CreateDelegate(typeof(Func <bool>), middleMan); } else if (i_breakpointInfo.AccessType == BreakPointConditionType.registryMemoryReferenceVsValue) { // e.g.: (PC) == #D155 - instruction breakpoint //ToDo: Because it is not possible to dynamically emit code for interface method(IDebuggable.ReadMemory) // I temporary wrapped it into custom wrapper. InterfaceWrapper middleMan = new InterfaceWrapper(); middleMan.wrapInterface(i_spectrum); middleMan.wrapFields(i_spectrum.CPU.regs); MethodInfo ReadMemoryMethod; //Type[] args = { typeof(REGS) }; if (i_breakpointInfo.RightValue > 0xFF) { ReadMemoryMethod = typeof(InterfaceWrapper).GetMethod("invokeReadMemory16BitViaRegistryValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic , null , new Type[] { typeof(string) } , null); } else { ReadMemoryMethod = typeof(InterfaceWrapper).GetMethod("invokeReadMemory8BitViaRegistryValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic , null , new Type[] { typeof(string) } , null); } DynamicMethod dynamicMethod = new DynamicMethod("ReadMemoryViaRegistry", typeof(bool), new Type[] { typeof(InterfaceWrapper) }); ILGenerator IL = dynamicMethod.GetILGenerator(); //Arg0, e.g. (PC) IL.Emit(OpCodes.Ldarg_0); // load InterfaceWrapper on stack string registry = DebuggerManager.getRegistryFromReference(i_breakpointInfo.LeftCondition); IL.Emit(OpCodes.Ldstr, registry); IL.Emit(OpCodes.Call, ReadMemoryMethod); //Arg1, number(right condition) IL.Emit(OpCodes.Ldc_I4, i_breakpointInfo.RightValue); // <- compare to 8 or 16bit EmitComparison(IL, i_breakpointInfo.ConditionTypeSign); IL.Emit(OpCodes.Ret); //Return: 1 => true(breakpoint is reached) otherwise 0 => false o_ILOut = (Func <bool>)dynamicMethod.CreateDelegate(typeof(Func <bool>), middleMan); } return(o_ILOut); }
public void UpdateBreakpoint(BreakpointInfo b) { throw new NotSupportedException(); }
public static async Task UpdateBreakpointAsync(this IDebuggerPlugin dbgr, BreakpointInfo b) { await Task.Run(() => dbgr.UpdateBreakpoint(b)); }