Browse Source

Removed unused conditional breakpoint types and improved workflow of breakpoints.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3581 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
122177828b
  1. 21
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin
  2. 89
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs
  3. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs
  4. 32
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  5. 14
      src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs
  6. 2
      src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs

21
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin

@ -6,6 +6,7 @@
<Runtime> <Runtime>
<Import assembly="Debugger.AddIn.dll"> <Import assembly="Debugger.AddIn.dll">
<ConditionEvaluator name = "IsBreakpointSet" class = "Debugger.AddIn.IsBreakpointCondition"/> <ConditionEvaluator name = "IsBreakpointSet" class = "Debugger.AddIn.IsBreakpointCondition"/>
<ConditionEvaluator name = "IsBreakpointActive" class="Debugger.AddIn.IsActiveBreakpointCondition" />
</Import> </Import>
<Import assembly="Debugger.Core.dll"/> <Import assembly="Debugger.Core.dll"/>
</Runtime> </Runtime>
@ -38,12 +39,28 @@
type = "Separator"/> type = "Separator"/>
</Condition> </Condition>
<MenuItem id="BreakpointSeparator" type = "Separator" /> <MenuItem id="BreakpointSeparator" type = "Separator" />
<MenuItem id="ChangeBreakPoint" label="${res:MainWindow.Windows.Debug.Conditional.Breakpoints.Breakpoint}" type="Menu">
<Include id="SetBreakpoint" item="/SharpDevelop/Workbench/MainMenu/Debug/Toggle Breakpoint" /> <Include id="SetBreakpoint" item="/SharpDevelop/Workbench/MainMenu/Debug/Toggle Breakpoint" />
<Condition name="IsBreakpointSet"> <Condition name="IsBreakpointSet">
<MenuItem id="ChangeBreakPoint" label="${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ChangeBreakpoint}" type="Menu"> <Condition name="IsBreakpointActive">
<MenuItem id="DisableBreakpoint"
class="Debugger.AddIn.DisableBreakpointMenuCommand"
label= "${res:MainWindow.Windows.Debug.Conditional.Breakpoints.DisableBreakpoint}" />
</Condition>
<ComplexCondition>
<Not>
<Condition name="IsBreakpointActive" />
</Not>
<MenuItem id="EnableBreakpoint"
class="Debugger.AddIn.EnableBreakpointMenuCommand"
label= "${res:MainWindow.Windows.Debug.Conditional.Breakpoints.EnableBreakpoint}" />
</ComplexCondition>
<MenuItem id="BreakpointSeparator" type = "Separator" />
<MenuItem id="MenuBuilder" type="Builder" class="Debugger.AddIn.BreakpointChangeMenuBuilder" /> <MenuItem id="MenuBuilder" type="Builder" class="Debugger.AddIn.BreakpointChangeMenuBuilder" />
</MenuItem>
</Condition> </Condition>
</MenuItem>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/Pads"> <Path name = "/SharpDevelop/Workbench/Pads">

89
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs

@ -45,6 +45,84 @@ namespace Debugger.AddIn
} }
} }
public class IsActiveBreakpointCondition : IConditionEvaluator
{
public IsActiveBreakpointCondition()
{
}
public bool IsValid(object caller, Condition condition)
{
if (WorkbenchSingleton.Workbench == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null)
return false;
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider;
if (provider == null)
return false;
if (string.IsNullOrEmpty(provider.TextEditorControl.FileName))
return false;
BreakpointBookmark point = null;
foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) {
if ((breakpoint.FileName == provider.TextEditorControl.FileName) &&
(breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) {
point = breakpoint;
break;
}
}
if (point != null) {
return point.IsEnabled;
}
return false;
}
}
public class EnableBreakpointMenuCommand : AbstractMenuCommand
{
public override void Run()
{
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider;
BreakpointBookmark point = null;
foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) {
if ((breakpoint.FileName == provider.TextEditorControl.FileName) &&
(breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) {
point = breakpoint;
break;
}
}
if (point != null) {
point.IsEnabled = true;
}
}
}
public class DisableBreakpointMenuCommand : AbstractMenuCommand
{
public override void Run()
{
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider;
BreakpointBookmark point = null;
foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) {
if ((breakpoint.FileName == provider.TextEditorControl.FileName) &&
(breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) {
point = breakpoint;
break;
}
}
if (point != null) {
point.IsEnabled = false;
}
}
}
public class BreakpointChangeMenuBuilder : ISubmenuBuilder public class BreakpointChangeMenuBuilder : ISubmenuBuilder
{ {
public System.Windows.Forms.ToolStripItem[] BuildSubmenu(Codon codon, object owner) public System.Windows.Forms.ToolStripItem[] BuildSubmenu(Codon codon, object owner)
@ -80,25 +158,16 @@ namespace Debugger.AddIn
BreakpointBookmark bookmark = (BreakpointBookmark)item.Tag; BreakpointBookmark bookmark = (BreakpointBookmark)item.Tag;
switch (item.Name) { switch (item.Name) {
case "Ask":
bookmark.Action = BreakpointAction.Ask;
break;
case "Break": case "Break":
bookmark.Action = BreakpointAction.Break; bookmark.Action = BreakpointAction.Break;
break; break;
case "Continue": case "Condition":
bookmark.Action = BreakpointAction.Continue;
break;
case "Script":
EditBreakpointScriptForm form = new EditBreakpointScriptForm(bookmark); EditBreakpointScriptForm form = new EditBreakpointScriptForm(bookmark);
if (form.ShowDialog() == DialogResult.OK) { if (form.ShowDialog() == DialogResult.OK) {
bookmark = form.Data; bookmark = form.Data;
} }
break; break;
case "Terminate":
bookmark.Action = BreakpointAction.Terminate;
break;
case "Trace": case "Trace":
bookmark.Action = BreakpointAction.Trace; bookmark.Action = BreakpointAction.Trace;
break; break;

6
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs

@ -35,9 +35,9 @@ namespace Debugger.AddIn.Service
this.data = data; this.data = data;
this.data.Action = BreakpointAction.Script; this.data.Action = BreakpointAction.Condition;
this.txtCode.Document.TextContent = data.Script; this.txtCode.Document.TextContent = data.Condition;
this.cmbLanguage.Items.AddRange(new string[] { "C#", "VBNET" }); this.cmbLanguage.Items.AddRange(new string[] { "C#", "VBNET" });
this.cmbLanguage.SelectedIndex = this.cmbLanguage.SelectedIndex =
(!string.IsNullOrEmpty(data.ScriptLanguage)) ? (!string.IsNullOrEmpty(data.ScriptLanguage)) ?
@ -84,7 +84,7 @@ namespace Debugger.AddIn.Service
{ {
if (!this.CheckSyntax()) if (!this.CheckSyntax())
return; return;
this.data.Script = this.txtCode.Document.TextContent; this.data.Condition = this.txtCode.Document.TextContent;
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
this.Close(); this.Close();
} }

32
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -523,41 +523,17 @@ namespace ICSharpCode.SharpDevelop.Services
new EventHandler<BreakpointEventArgs>( new EventHandler<BreakpointEventArgs>(
delegate(object sender, BreakpointEventArgs e) delegate(object sender, BreakpointEventArgs e)
{ {
LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Script); LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Condition);
switch (bookmark.Action) { switch (bookmark.Action) {
case BreakpointAction.Ask:
Bitmap icon = WinFormsResourceService.GetBitmap(false ? "Icons.32x32.Error" : "Icons.32x32.Warning");
DebuggerEventForm.Result result =
DebuggerEventForm.Show(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHit}"),
string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}"), bookmark.LineNumber, bookmark.FileName), icon, true);
switch (result) {
case DebuggerEventForm.Result.Break:
break;
case DebuggerEventForm.Result.Continue:
this.debuggedProcess.AsyncContinue();
break;
case DebuggerEventForm.Result.Terminate:
this.debuggedProcess.AsyncTerminate();
break;
}
break;
case BreakpointAction.Break: case BreakpointAction.Break:
break; break;
case BreakpointAction.Continue: case BreakpointAction.Condition:
this.debuggedProcess.AsyncContinue(); if (Evaluate(bookmark.Condition, bookmark.ScriptLanguage))
break; DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber + 1, bookmark.FileName, bookmark.Condition));
case BreakpointAction.Script:
if (Evaluate(bookmark.Script, bookmark.ScriptLanguage))
DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber + 1, bookmark.FileName, bookmark.Script));
else else
this.debuggedProcess.AsyncContinue(); this.debuggedProcess.AsyncContinue();
break; break;
case BreakpointAction.Terminate:
this.debuggedProcess.AsyncTerminate();
break;
case BreakpointAction.Trace: case BreakpointAction.Trace:
DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber + 1, bookmark.FileName)); DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber + 1, bookmark.FileName));
break; break;

14
src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs

@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Bookmarks;
namespace ICSharpCode.SharpDevelop.Debugging namespace ICSharpCode.SharpDevelop.Debugging
{ {
public enum BreakpointAction { public enum BreakpointAction {
Ask, Break, Continue, Terminate, Trace, Script Break, Trace, Condition
} }
public class BreakpointBookmark : SDMarkerBookmark public class BreakpointBookmark : SDMarkerBookmark
@ -24,8 +24,8 @@ namespace ICSharpCode.SharpDevelop.Debugging
static readonly Color defaultColor = Color.FromArgb(180, 38, 38); static readonly Color defaultColor = Color.FromArgb(180, 38, 38);
BreakpointAction action = BreakpointAction.Ask; BreakpointAction action = BreakpointAction.Break;
string script; string condition;
string scriptLanguage; string scriptLanguage;
public string ScriptLanguage { public string ScriptLanguage {
@ -33,9 +33,9 @@ namespace ICSharpCode.SharpDevelop.Debugging
set { scriptLanguage = value; } set { scriptLanguage = value; }
} }
public string Script { public string Condition {
get { return script; } get { return condition; }
set { script = value; } set { condition = value; }
} }
public BreakpointAction Action { public BreakpointAction Action {
@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
{ {
this.action = action; this.action = action;
this.scriptLanguage = scriptLanguage; this.scriptLanguage = scriptLanguage;
this.script = script; this.condition = script;
} }
public override void Draw(IconBarMargin margin, Graphics g, Point p) public override void Draw(IconBarMargin margin, Graphics g, Point p)

2
src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs

@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
b.Append('|'); b.Append('|');
b.Append(bbm.ScriptLanguage); b.Append(bbm.ScriptLanguage);
b.Append('|'); b.Append('|');
b.Append(bbm.Script); b.Append(bbm.Condition);
} }
return b.ToString(); return b.ToString();
} else { } else {

Loading…
Cancel
Save