public List<WatchValueInfo> GetWatchContent(CpuType cpuType, List<WatchValueInfo> previousValues) { WatchFormatStyle defaultStyle = ConfigManager.Config.Debug.Debugger.WatchFormat; int defaultByteLength = 1; if(defaultStyle == WatchFormatStyle.Signed) { defaultByteLength = 4; } var list = new List<WatchValueInfo>(); for(int i = 0; i < _watchEntries.Count; i++) { string expression = _watchEntries[i].Trim(); string newValue = ""; EvalResultType resultType; string exprToEvaluate = expression; WatchFormatStyle style = defaultStyle; int byteLength = defaultByteLength; if(expression.StartsWith("{") && expression.EndsWith("}")) { //Default to 2-byte values when using {} syntax byteLength = 2; } ProcessFormatSpecifier(ref exprToEvaluate, ref style, ref byteLength); bool forceHasChanged = false; Match match = _arrayWatchRegex.Match(expression); if(match.Success) { //Watch expression matches the array display syntax (e.g: [$300,10] = display 10 bytes starting from $300) newValue = ProcessArrayDisplaySyntax(style, ref forceHasChanged, match); } else { Int32 result = DebugApi.EvaluateExpression(exprToEvaluate, cpuType, out resultType, true); switch(resultType) { case EvalResultType.Numeric: newValue = FormatValue(result, style, byteLength); break; case EvalResultType.Boolean: newValue = result == 0 ? "false" : "true"; break; case EvalResultType.Invalid: newValue = "<invalid expression>"; forceHasChanged = true; break; case EvalResultType.DivideBy0: newValue = "<division by zero>"; forceHasChanged = true; break; case EvalResultType.OutOfScope: newValue = "<label out of scope>"; forceHasChanged = true; break; } } list.Add(new WatchValueInfo() { Expression = expression, Value = newValue, HasChanged = forceHasChanged || (i < previousValues.Count ? (previousValues[i].Value != newValue) : false) }); } return list; }
protected override bool ValidateInput() { if (txtCondition.Text.Trim().Length > 0) { EvalResultType resultType; DebugApi.EvaluateExpression(txtCondition.Text.Replace(Environment.NewLine, " "), _cpuType, out resultType, false); if (resultType == EvalResultType.Invalid) { picExpressionWarning.Visible = true; return(false); } } picExpressionWarning.Visible = false; SnesMemoryType type = cboBreakpointType.GetEnumValue <SnesMemoryType>(); int maxValue = DebugApi.GetMemorySize(type) - 1; if (radSpecificAddress.Checked) { if (ValidateAddress(txtAddress, maxValue) < 0) { return(false); } } else if (radRange.Checked) { int start = ValidateAddress(txtFrom, maxValue); int end = ValidateAddress(txtTo, maxValue); if (start < 0 || end < 0 || end < start) { return(false); } } return(chkRead.Checked || chkWrite.Checked || (chkExec.Checked && Breakpoint.IsTypeCpuBreakpoint(type)) || txtCondition.Text.Length > 0); }