From 8261e95f939dbe5585a1adae118309e812690f40 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sun, 4 Dec 2016 11:40:31 -0500 Subject: [PATCH] Debugger: Prevent adding breakpoints with invalid conditions --- Core/Debugger.cpp | 5 --- GUI.NET/Debugger/frmBreakpoint.Designer.cs | 48 ++++++++++++++------- GUI.NET/Debugger/frmBreakpoint.cs | 12 ++++++ GUI.NET/GUI.NET.csproj | 1 + GUI.NET/Properties/Resources.Designer.cs | 10 +++++ GUI.NET/Properties/Resources.resx | 3 ++ GUI.NET/Resources/Warning.png | Bin 0 -> 717 bytes 7 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 GUI.NET/Resources/Warning.png diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index d4d4397e..e1aebfff 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -191,11 +191,6 @@ void Debugger::UpdateBreakpoints() ExpressionEvaluator expEval(this); for(Breakpoint &bp : _newBreakpoints) { - if(!expEval.Validate(bp.GetCondition())) { - //Remove any invalid condition (syntax-wise) - bp.ClearCondition(); - } - for(int i = 0; i < Debugger::BreakpointTypeCount; i++) { if(bp.HasBreakpointType((BreakpointType)i)) { _breakpoints[i].push_back(bp); diff --git a/GUI.NET/Debugger/frmBreakpoint.Designer.cs b/GUI.NET/Debugger/frmBreakpoint.Designer.cs index f5bc93ee..6fb34654 100644 --- a/GUI.NET/Debugger/frmBreakpoint.Designer.cs +++ b/GUI.NET/Debugger/frmBreakpoint.Designer.cs @@ -35,11 +35,13 @@ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.picHelp = new System.Windows.Forms.PictureBox(); this.txtCondition = new System.Windows.Forms.TextBox(); + this.picExpressionWarning = new System.Windows.Forms.PictureBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.txtAddress = new System.Windows.Forms.TextBox(); this.chkAbsolute = new System.Windows.Forms.CheckBox(); this.radSpecificAddress = new System.Windows.Forms.RadioButton(); this.radAnyAddress = new System.Windows.Forms.RadioButton(); + this.lblAddressSign = new System.Windows.Forms.Label(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); this.flowLayoutPanel3 = new System.Windows.Forms.FlowLayoutPanel(); this.chkReadVram = new System.Windows.Forms.CheckBox(); @@ -50,10 +52,10 @@ this.chkRead = new System.Windows.Forms.CheckBox(); this.chkWrite = new System.Windows.Forms.CheckBox(); this.chkExec = new System.Windows.Forms.CheckBox(); - this.lblAddressSign = new System.Windows.Forms.Label(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picHelp)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picExpressionWarning)).BeginInit(); this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel4.SuspendLayout(); this.flowLayoutPanel3.SuspendLayout(); @@ -133,11 +135,14 @@ // // tableLayoutPanel2 // - this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnCount = 3; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel2.Controls.Add(this.picHelp, 1, 0); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel2.Controls.Add(this.picHelp, 2, 0); this.tableLayoutPanel2.Controls.Add(this.txtCondition, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.picExpressionWarning, 1, 0); this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel2.Location = new System.Drawing.Point(60, 94); this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); @@ -163,9 +168,20 @@ this.txtCondition.Location = new System.Drawing.Point(3, 3); this.txtCondition.MaxLength = 900; this.txtCondition.Name = "txtCondition"; - this.txtCondition.Size = new System.Drawing.Size(288, 20); + this.txtCondition.Size = new System.Drawing.Size(264, 20); this.txtCondition.TabIndex = 6; // + // picExpressionWarning + // + this.picExpressionWarning.Image = global::Mesen.GUI.Properties.Resources.Warning; + this.picExpressionWarning.Location = new System.Drawing.Point(273, 5); + this.picExpressionWarning.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3); + this.picExpressionWarning.Name = "picExpressionWarning"; + this.picExpressionWarning.Size = new System.Drawing.Size(18, 18); + this.picExpressionWarning.TabIndex = 9; + this.picExpressionWarning.TabStop = false; + this.picExpressionWarning.Visible = false; + // // tableLayoutPanel3 // this.tableLayoutPanel3.ColumnCount = 4; @@ -234,6 +250,17 @@ this.radAnyAddress.Text = "Any"; this.radAnyAddress.UseVisualStyleBackColor = true; // + // lblAddressSign + // + this.lblAddressSign.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblAddressSign.AutoSize = true; + this.lblAddressSign.Location = new System.Drawing.Point(72, 6); + this.lblAddressSign.Margin = new System.Windows.Forms.Padding(0); + this.lblAddressSign.Name = "lblAddressSign"; + this.lblAddressSign.Size = new System.Drawing.Size(13, 13); + this.lblAddressSign.TabIndex = 9; + this.lblAddressSign.Text = "$"; + // // tableLayoutPanel4 // this.tableLayoutPanel4.ColumnCount = 2; @@ -355,17 +382,6 @@ this.chkExec.UseVisualStyleBackColor = true; this.chkExec.Enter += new System.EventHandler(this.chkRead_Enter); // - // lblAddressSign - // - this.lblAddressSign.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblAddressSign.AutoSize = true; - this.lblAddressSign.Location = new System.Drawing.Point(72, 6); - this.lblAddressSign.Margin = new System.Windows.Forms.Padding(0); - this.lblAddressSign.Name = "lblAddressSign"; - this.lblAddressSign.Size = new System.Drawing.Size(13, 13); - this.lblAddressSign.TabIndex = 9; - this.lblAddressSign.Text = "$"; - // // frmBreakpoint // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -383,6 +399,7 @@ this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.picHelp)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picExpressionWarning)).EndInit(); this.tableLayoutPanel3.ResumeLayout(false); this.tableLayoutPanel3.PerformLayout(); this.tableLayoutPanel4.ResumeLayout(false); @@ -421,5 +438,6 @@ private System.Windows.Forms.RadioButton radCpu; private System.Windows.Forms.RadioButton radPpu; private System.Windows.Forms.Label lblAddressSign; + private System.Windows.Forms.PictureBox picExpressionWarning; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmBreakpoint.cs b/GUI.NET/Debugger/frmBreakpoint.cs index 91a714f8..edf9a468 100644 --- a/GUI.NET/Debugger/frmBreakpoint.cs +++ b/GUI.NET/Debugger/frmBreakpoint.cs @@ -36,6 +36,8 @@ namespace Mesen.GUI.Debugger AddBinding("BreakOnWriteVram", chkWriteVram); AddBinding("Condition", txtCondition); + this.toolTip.SetToolTip(this.picExpressionWarning, "Condition contains invalid syntax or symbols."); + this.toolTip.SetToolTip(this.chkAbsolute, "Check to set an absolute address based on the exact address in PRG/CHR ROM (not CPU/PPU memory)"); this.toolTip.SetToolTip(this.picHelp, "Most expressions/operators are accepted (C++ syntax)." + Environment.NewLine + @@ -61,6 +63,16 @@ namespace Mesen.GUI.Debugger protected override bool ValidateInput() { + if(txtCondition.Text.Length > 0) { + EvalResultType resultType; + InteropEmu.DebugEvaluateExpression(txtCondition.Text, out resultType); + if(resultType == EvalResultType.Invalid) { + picExpressionWarning.Visible = true; + return false; + } + } + picExpressionWarning.Visible = false; + return chkRead.Checked || chkWrite.Checked || chkExec.Checked || chkReadVram.Checked || chkWriteVram.Checked || txtCondition.Text.Length > 0; } diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index cc1d7624..cf7a1d0c 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -863,6 +863,7 @@ Always + diff --git a/GUI.NET/Properties/Resources.Designer.cs b/GUI.NET/Properties/Resources.Designer.cs index 34333240..b8fb7df5 100644 --- a/GUI.NET/Properties/Resources.Designer.cs +++ b/GUI.NET/Properties/Resources.Designer.cs @@ -449,5 +449,15 @@ namespace Mesen.GUI.Properties { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Warning { + get { + object obj = ResourceManager.GetObject("Warning", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/GUI.NET/Properties/Resources.resx b/GUI.NET/Properties/Resources.resx index 42f6e37e..4e51c4d8 100644 --- a/GUI.NET/Properties/Resources.resx +++ b/GUI.NET/Properties/Resources.resx @@ -235,4 +235,7 @@ ..\Resources\CheatCode.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Warning.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/GUI.NET/Resources/Warning.png b/GUI.NET/Resources/Warning.png new file mode 100644 index 0000000000000000000000000000000000000000..81e9ed29a560c6e478283f003da23194a31a443b GIT binary patch literal 717 zcmV;;0y6!HP)v(sQ968-{g5V4d9iG&ql zB_XjB39*n!l!ZhkMCnD-nwd_`OsDhR&TB!d)krKnt9SFeSKHT?_Q?{SkqPz%HJWA2Gu!d&yZ+uU4F9=A1xavUU#@oV#xN2bEr z(Wyyg?V-NAyj^DSY|t5OGx~O6_hyyOWs#W>LirtI6spysTCLgf7jNg4(7#}!uO1-L zo^o#$c5hN?w*{FFAQa5r^CVBb#0;E)NRUcIHj&ZYyS5k$cNV<$&h@EBx$X`(?PZZ_ z#7gwyB=eSB)^oFk)xB?ya2!A7(iP; zXmwjs5XrJsseXlE4qN#GehuuefEbeLR8oZP07l~2QChPoml&x{5Py3Q#)a?W*y1oK zh05enEnR5sI!e(7V9+YE&AL%R6PYU^jWUQuh93|OKUmUTkoq)IpC(9dssq8#u8va- z$|Y>&BQjS6u|GGr?;`2Tf*Cls{7sD^4C4?O0?A~Igu0`he<8>h{OWkA0^DEx zNJE2abi=j{>obkAl4|Ym>b4HbtGtQQ>ye4RyX;zAvKBcw_UcQcn(7Snnl3PAW$m@S zVbORK#i0=wIJx2$uJ2)>FVFS%p4B~>F3-uNOu}f?TtG97tUohWDm5l6^`znGid$I9 zjlEpz_1N#ZY&4pd$Woj2`S59$C#RosmjBHUh1~=Bl!W4-00000NkvXXu0mjf8+l9k literal 0 HcmV?d00001