Browse Source

Implemented conditional breakpoints

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3461 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 17 years ago
parent
commit
dfb4d81407
  1. 13
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin
  2. 13
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  3. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/AstEvaluator.cs
  4. 26
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/EvaluateAstVisitor.cs
  5. 122
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs
  6. 130
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.Designer.cs
  7. 92
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs
  8. 120
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.resx
  9. 71
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  10. 28
      src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs
  11. 2
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  12. 24
      src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs

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

@ -4,7 +4,9 @@
</Manifest> </Manifest>
<Runtime> <Runtime>
<Import assembly="Debugger.AddIn.dll"/> <Import assembly="Debugger.AddIn.dll">
<ConditionEvaluator name = "IsBreakpointSet" class = "Debugger.AddIn.IsBreakpointCondition"/>
</Import>
<Import assembly="Debugger.Core.dll"/> <Import assembly="Debugger.Core.dll"/>
</Runtime> </Runtime>
@ -35,6 +37,13 @@
insertbefore = "Refactoring" insertbefore = "Refactoring"
type = "Separator"/> type = "Separator"/>
</Condition> </Condition>
<MenuItem id="BreakpointSeparator" type = "Separator" />
<Include id="SetBreakpoint" item="/SharpDevelop/Workbench/MainMenu/Debug/Toggle Breakpoint" />
<Condition name="IsBreakpointSet">
<MenuItem id="ChangeBreakPoint" label="${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ChangeBreakpoint}" type="Menu">
<MenuItem id="MenuBuilder" type="Builder" class="Debugger.AddIn.BreakpointChangeMenuBuilder" />
</MenuItem>
</Condition>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/Pads"> <Path name = "/SharpDevelop/Workbench/Pads">
@ -72,7 +81,7 @@
icon = "PadIcons.LocalVariables" icon = "PadIcons.LocalVariables"
shortcut = "Control|Alt|V" shortcut = "Control|Alt|V"
class = "ICSharpCode.SharpDevelop.Gui.Pads.LocalVarPad"/> class = "ICSharpCode.SharpDevelop.Gui.Pads.LocalVarPad"/>
<Pad id = "ConsolePad" <Pad id = "ConsolePad"
category = "Debugger" category = "Debugger"
title = "${res:MainWindow.Windows.Debug.Console}" title = "${res:MainWindow.Windows.Debug.Console}"

13
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -20,6 +20,7 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>Always</RunPostBuildEvent> <RunPostBuildEvent>Always</RunPostBuildEvent>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\HP\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -34,6 +35,10 @@
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\</OutputPath> <OutputPath>..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<StartAction>Program</StartAction>
<StartProgram>..\..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
@ -43,6 +48,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\IsBreakpointCondition.cs" />
<Compile Include="Src\Expressions\AstEvaluator.cs" /> <Compile Include="Src\Expressions\AstEvaluator.cs" />
<Compile Include="Src\Expressions\EvaluateAstVisitor.cs" /> <Compile Include="Src\Expressions\EvaluateAstVisitor.cs" />
<Compile Include="Src\Expressions\NotImplementedAstVisitor.cs" /> <Compile Include="Src\Expressions\NotImplementedAstVisitor.cs" />
@ -77,6 +83,10 @@
<EmbeddedResource Include="Src\Service\DebugeeExceptionForm.resx"> <EmbeddedResource Include="Src\Service\DebugeeExceptionForm.resx">
<DependentUpon>DebugeeExceptionForm.cs</DependentUpon> <DependentUpon>DebugeeExceptionForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Src\Service\EditBreakpointScriptForm.cs" />
<Compile Include="Src\Service\EditBreakpointScriptForm.Designer.cs">
<DependentUpon>EditBreakpointScriptForm.cs</DependentUpon>
</Compile>
<Compile Include="Src\Service\RemotingConfigurationHelpper.cs" /> <Compile Include="Src\Service\RemotingConfigurationHelpper.cs" />
<Compile Include="Src\Service\RunToCursorCommand.cs" /> <Compile Include="Src\Service\RunToCursorCommand.cs" />
<Compile Include="Src\Service\WindowsDebugger.cs" /> <Compile Include="Src\Service\WindowsDebugger.cs" />
@ -89,6 +99,9 @@
<EmbeddedResource Include="Src\Service\DebuggerEventForm.resx"> <EmbeddedResource Include="Src\Service\DebuggerEventForm.resx">
<DependentUpon>DebuggerEventForm.cs</DependentUpon> <DependentUpon>DebuggerEventForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Src\Service\EditBreakpointScriptForm.resx">
<DependentUpon>EditBreakpointScriptForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Src\Service\SetCurrentStatementCommand.cs" /> <Compile Include="Src\Service\SetCurrentStatementCommand.cs" />
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs"> <Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link> <Link>Configuration\GlobalAssemblyInfo.cs</Link>

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/AstEvaluator.cs

@ -27,6 +27,7 @@ namespace Debugger.AddIn
} }
try { try {
EvaluateAstVisitor visitor = new EvaluateAstVisitor(context); EvaluateAstVisitor visitor = new EvaluateAstVisitor(context);
return astRoot.AcceptVisitor(visitor, null) as Value; return astRoot.AcceptVisitor(visitor, null) as Value;
} catch (NotImplementedException e) { } catch (NotImplementedException e) {
throw new GetValueException("Language feature not implemented: " + e.Message); throw new GetValueException("Language feature not implemented: " + e.Message);

26
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Expressions/EvaluateAstVisitor.cs

@ -142,5 +142,31 @@ namespace Debugger.AddIn
{ {
return context.GetThisValue(); return context.GetThisValue();
} }
public override object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data)
{
Value left = ((Value)binaryOperatorExpression.Left.AcceptVisitor(this, null)).GetPermanentReference();
Value right = ((Value)binaryOperatorExpression.Right.AcceptVisitor(this, null)).GetPermanentReference();
if (!left.IsReference && left.Type.FullName != right.Type.FullName) {
throw new GetValueException(string.Format("Type {0} expected, {1} seen", left.Type.FullName, right.Type.FullName));
}
Value val = Eval.NewObjectNoConstructor(DebugType.Create(context.Process, null, typeof(bool).FullName));
switch (binaryOperatorExpression.Op)
{
case BinaryOperatorType.Equality :
val.PrimitiveValue = (right.PrimitiveValue.ToString() == left.PrimitiveValue.ToString());
break;
case BinaryOperatorType.InEquality :
val.PrimitiveValue = (right.PrimitiveValue.ToString() != left.PrimitiveValue.ToString());
break;
default :
throw new NotImplementedException("BinaryOperator not implemented!");
}
return val;
}
} }
} }

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

@ -0,0 +1,122 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision: 2039 $</version>
// </file>
using Debugger.AddIn.Service;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace Debugger.AddIn
{
public class IsBreakpointCondition : IConditionEvaluator
{
public IsBreakpointCondition()
{
}
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;
foreach (BreakpointBookmark mark in DebuggerService.Breakpoints) {
if ((mark.FileName == provider.TextEditorControl.FileName) &&
(mark.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line))
return true;
}
return false;
}
}
public class BreakpointChangeMenuBuilder : ISubmenuBuilder
{
public System.Windows.Forms.ToolStripItem[] BuildSubmenu(Codon codon, object owner)
{
List<ToolStripItem> items = new List<ToolStripItem>();
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;
}
}
foreach (string item in BreakpointAction.GetNames(typeof(BreakpointAction))) {
items.Add(MakeItem("${res:MainWindow.Windows.Debug.Conditional.Breakpoints." + item + "}", item, point, point.Action.ToString(), delegate(object sender, EventArgs e) {HandleItem(sender);}));
}
return items.ToArray();
}
void HandleItem(object sender)
{
ToolStripMenuItem item = null;
if (sender is ToolStripMenuItem)
item = (ToolStripMenuItem)sender;
if (item != null) {
BreakpointBookmark bookmark = (BreakpointBookmark)item.Tag;
switch (item.Name) {
case "Ask":
bookmark.Action = BreakpointAction.Ask;
break;
case "Break":
bookmark.Action = BreakpointAction.Break;
break;
case "Continue":
bookmark.Action = BreakpointAction.Continue;
break;
case "Script":
EditBreakpointScriptForm form = new EditBreakpointScriptForm(bookmark);
if (form.ShowDialog() == DialogResult.OK) {
bookmark = form.Data;
}
break;
case "Terminate":
bookmark.Action = BreakpointAction.Terminate;
break;
case "Trace":
bookmark.Action = BreakpointAction.Trace;
break;
}
}
}
ToolStripMenuItem MakeItem(string title, string name, BreakpointBookmark tag, string data, EventHandler onClick)
{
ToolStripMenuItem menuItem = new ToolStripMenuItem(StringParser.Parse(title));
menuItem.Click += onClick;
menuItem.Name = name;
menuItem.Tag = tag;
if (name == tag.Action.ToString())
menuItem.Checked = true;
return menuItem;
}
}
}

130
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.Designer.cs generated

@ -0,0 +1,130 @@
/*
* Created by SharpDevelop.
* User: HP
* Date: 25.08.2008
* Time: 09:37
*/
namespace Debugger.AddIn.Service
{
partial class EditBreakpointScriptForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.txtCode = new ICSharpCode.TextEditor.TextEditorControl();
this.cmbLanguage = new System.Windows.Forms.ComboBox();
this.btnCheckSyntax = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// txtCode
//
this.txtCode.IsReadOnly = false;
this.txtCode.Location = new System.Drawing.Point(3, 31);
this.txtCode.Name = "txtCode";
this.txtCode.Size = new System.Drawing.Size(575, 355);
this.txtCode.TabIndex = 0;
//
// cmbLanguage
//
this.cmbLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbLanguage.FormattingEnabled = true;
this.cmbLanguage.Location = new System.Drawing.Point(153, 4);
this.cmbLanguage.Name = "cmbLanguage";
this.cmbLanguage.Size = new System.Drawing.Size(121, 21);
this.cmbLanguage.TabIndex = 1;
this.cmbLanguage.SelectedIndexChanged += new System.EventHandler(this.CmbLanguageSelectedIndexChanged);
//
// btnCheckSyntax
//
this.btnCheckSyntax.Location = new System.Drawing.Point(280, 2);
this.btnCheckSyntax.Name = "btnCheckSyntax";
this.btnCheckSyntax.Size = new System.Drawing.Size(119, 22);
this.btnCheckSyntax.TabIndex = 2;
this.btnCheckSyntax.Text = "Check Syntax";
this.btnCheckSyntax.UseVisualStyleBackColor = true;
this.btnCheckSyntax.Click += new System.EventHandler(this.BtnCheckSyntaxClick);
//
// label1
//
this.label1.Location = new System.Drawing.Point(3, 7);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 16);
this.label1.TabIndex = 3;
this.label1.Text = "Scripting Language:";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(415, 390);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 4;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.BtnOKClick);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(496, 390);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// EditBreakpointScriptForm
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(583, 418);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnCheckSyntax);
this.Controls.Add(this.cmbLanguage);
this.Controls.Add(this.txtCode);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EditBreakpointScriptForm";
this.ShowIcon = false;
this.Text = "Edit Debugger Script";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnCheckSyntax;
private System.Windows.Forms.ComboBox cmbLanguage;
private ICSharpCode.TextEditor.TextEditorControl txtCode;
}
}

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

@ -0,0 +1,92 @@
/*
* Created by SharpDevelop.
* User: HP
* Date: 25.08.2008
* Time: 09:37
*/
using ICSharpCode.SharpDevelop.Project;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Debugging;
namespace Debugger.AddIn.Service
{
/// <summary>
/// Description of EditBreakpointScriptForm.
/// </summary>
public partial class EditBreakpointScriptForm : Form
{
BreakpointBookmark data;
public BreakpointBookmark Data {
get { return data; }
}
public EditBreakpointScriptForm(BreakpointBookmark data)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.data = data;
this.data.Action = BreakpointAction.Script;
this.txtCode.Document.TextContent = data.Script;
this.cmbLanguage.Items.AddRange(new string[] { "C#", "VBNET" });
this.cmbLanguage.SelectedIndex =
(!string.IsNullOrEmpty(data.ScriptLanguage)) ?
this.cmbLanguage.Items.IndexOf(data.ScriptLanguage.ToUpper()) :
this.cmbLanguage.Items.IndexOf(ProjectService.CurrentProject.Language.ToUpper());
this.txtCode.SetHighlighting(data.ScriptLanguage.ToUpper());
// Setup translation text
this.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ScriptingWindow.Title}");
this.btnCancel.Text = StringParser.Parse("${res:Global.CancelButtonText}");
this.btnOK.Text = StringParser.Parse("${res:Global.OKButtonText}");
this.label1.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ScriptingWindow.ScriptingLanguage}") + ":";
this.btnCheckSyntax.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ScriptingWindow.CheckSyntax}");
}
void CmbLanguageSelectedIndexChanged(object sender, EventArgs e)
{
this.txtCode.SetHighlighting(this.cmbLanguage.SelectedItem.ToString());
this.data.ScriptLanguage = this.cmbLanguage.SelectedItem.ToString();
}
void BtnCheckSyntaxClick(object sender, EventArgs e)
{
CheckSyntax();
}
bool CheckSyntax()
{
SupportedLanguage language = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), this.cmbLanguage.SelectedItem.ToString().Replace("#", "Sharp"), true);
using (IParser parser = ParserFactory.CreateParser(language, new StringReader(this.txtCode.Document.TextContent))) {
parser.ParseExpression();
if (parser.Errors.Count > 0) {
MessageService.ShowError(parser.Errors.ErrorOutput);
return false;
}
}
return true;
}
void BtnOKClick(object sender, EventArgs e)
{
if (!this.CheckSyntax())
return;
this.data.Script = this.txtCode.Document.TextContent;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

120
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.resx

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

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

@ -192,7 +192,7 @@ namespace ICSharpCode.SharpDevelop.Services
if (attachForm.ShowDialog() == DialogResult.OK) { if (attachForm.ShowDialog() == DialogResult.OK) {
Attach(attachForm.Process); Attach(attachForm.Process);
} }
} }
} }
public void Attach(System.Diagnostics.Process existingProcess) public void Attach(System.Diagnostics.Process existingProcess)
@ -211,7 +211,7 @@ namespace ICSharpCode.SharpDevelop.Services
} else { } else {
if (DebugStarting != null) if (DebugStarting != null)
DebugStarting(this, EventArgs.Empty); DebugStarting(this, EventArgs.Empty);
Debugger.Process process = debugger.Attach(existingProcess); Debugger.Process process = debugger.Attach(existingProcess);
attached = true; attached = true;
SelectProcess(process); SelectProcess(process);
@ -240,11 +240,11 @@ namespace ICSharpCode.SharpDevelop.Services
case StopAttachedProcessDialogResult.Terminate: case StopAttachedProcessDialogResult.Terminate:
debuggedProcess.Terminate(); debuggedProcess.Terminate();
attached = false; attached = false;
break; break;
case StopAttachedProcessDialogResult.Detach: case StopAttachedProcessDialogResult.Detach:
Detach(); Detach();
attached = false; attached = false;
break; break;
} }
} else { } else {
debuggedProcess.Terminate(); debuggedProcess.Terminate();
@ -518,6 +518,52 @@ namespace ICSharpCode.SharpDevelop.Services
EventHandler<ProcessEventArgs> bp_debugger_ProcessExited = (sender, e) => { EventHandler<ProcessEventArgs> bp_debugger_ProcessExited = (sender, e) => {
setBookmarkColor(); setBookmarkColor();
}; };
EventHandler<BreakpointEventArgs> bp_debugger_BreakpointHit =
new EventHandler<BreakpointEventArgs>(
delegate(object sender, BreakpointEventArgs e)
{
LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Script);
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:
break;
case BreakpointAction.Continue:
this.debuggedProcess.AsyncContinue();
break;
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
this.debuggedProcess.AsyncContinue();
break;
case BreakpointAction.Terminate:
this.debuggedProcess.AsyncTerminate();
break;
case BreakpointAction.Trace:
DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber + 1, bookmark.FileName));
break;
}
});
BM.BookmarkEventHandler bp_bookmarkManager_Removed = null; BM.BookmarkEventHandler bp_bookmarkManager_Removed = null;
bp_bookmarkManager_Removed = (sender, e) => { bp_bookmarkManager_Removed = (sender, e) => {
if (bookmark == e.Bookmark) { if (bookmark == e.Bookmark) {
@ -526,15 +572,32 @@ namespace ICSharpCode.SharpDevelop.Services
// unregister the events // unregister the events
debugger.ProcessStarted -= bp_debugger_ProcessStarted; debugger.ProcessStarted -= bp_debugger_ProcessStarted;
debugger.ProcessExited -= bp_debugger_ProcessExited; debugger.ProcessExited -= bp_debugger_ProcessExited;
breakpoint.Hit -= bp_debugger_BreakpointHit;
BM.BookmarkManager.Removed -= bp_bookmarkManager_Removed; BM.BookmarkManager.Removed -= bp_bookmarkManager_Removed;
} }
}; };
// register the events // register the events
debugger.ProcessStarted += bp_debugger_ProcessStarted; debugger.ProcessStarted += bp_debugger_ProcessStarted;
debugger.ProcessExited += bp_debugger_ProcessExited; debugger.ProcessExited += bp_debugger_ProcessExited;
breakpoint.Hit += bp_debugger_BreakpointHit;
BM.BookmarkManager.Removed += bp_bookmarkManager_Removed; BM.BookmarkManager.Removed += bp_bookmarkManager_Removed;
} }
bool Evaluate(string code, string language)
{
try {
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.Replace("#", "Sharp"), true);
Value val = AstEvaluator.Evaluate(code, supportedLanguage, debuggedProcess.SelectedStackFrame);
if (val.PrimitiveValue is bool)
return (bool)val.PrimitiveValue;
else
return false;
} catch (GetValueException e) {
throw e;
}
}
void LogMessage(object sender, MessageEventArgs e) void LogMessage(object sender, MessageEventArgs e)
{ {
DebuggerService.PrintDebugMessage(e.Message); DebuggerService.PrintDebugMessage(e.Message);

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

@ -13,6 +13,10 @@ using ICSharpCode.SharpDevelop.Bookmarks;
namespace ICSharpCode.SharpDevelop.Debugging namespace ICSharpCode.SharpDevelop.Debugging
{ {
public enum BreakpointAction {
Ask, Break, Continue, Terminate, Trace, Script
}
public class BreakpointBookmark : SDMarkerBookmark public class BreakpointBookmark : SDMarkerBookmark
{ {
bool isHealthy = true; bool isHealthy = true;
@ -20,6 +24,25 @@ 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;
string script;
string scriptLanguage;
public string ScriptLanguage {
get { return scriptLanguage; }
set { scriptLanguage = value; }
}
public string Script {
get { return script; }
set { script = value; }
}
public BreakpointAction Action {
get { return action; }
set { this.action = value; }
}
public virtual bool IsHealthy { public virtual bool IsHealthy {
get { get {
return isHealthy; return isHealthy;
@ -38,8 +61,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
set { tooltip = value; } set { tooltip = value; }
} }
public BreakpointBookmark(string fileName, IDocument document, TextLocation location) : base(fileName, document, location) public BreakpointBookmark(string fileName, IDocument document, TextLocation location, BreakpointAction action, string scriptLanguage, string script) : base(fileName, document, location)
{ {
this.action = action;
this.scriptLanguage = scriptLanguage;
this.script = 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/Services/Debugger/DebuggerService.cs

@ -231,7 +231,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
int column = 0; int column = 0;
foreach (char ch in document.GetText(document.GetLineSegment(lineNumber))) { foreach (char ch in document.GetText(document.GetLineSegment(lineNumber))) {
if (!char.IsWhiteSpace(ch)) { if (!char.IsWhiteSpace(ch)) {
document.BookmarkManager.AddMark(new BreakpointBookmark(fileName, document, new TextLocation(column, lineNumber))); document.BookmarkManager.AddMark(new BreakpointBookmark(fileName, document, new TextLocation(column, lineNumber), BreakpointAction.Break, "", ""));
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber)); document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
document.CommitUpdate(); document.CommitUpdate();
break; break;

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

@ -5,11 +5,12 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.TextEditor; using ICSharpCode.Core;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using ICSharpCode.TextEditor;
namespace ICSharpCode.SharpDevelop.Bookmarks namespace ICSharpCode.SharpDevelop.Bookmarks
{ {
@ -28,11 +29,19 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
{ {
if (value is string) { if (value is string) {
string[] v = ((string)value).Split('|'); string[] v = ((string)value).Split('|');
if (v.Length != 5) if (v.Length != 8)
return null; return null;
string fileName = v[1]; string fileName = v[1];
int lineNumber = int.Parse(v[2], culture); int lineNumber = int.Parse(v[2], culture);
int columnNumber = int.Parse(v[3], culture); int columnNumber = int.Parse(v[3], culture);
Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
string scriptLanguage = "";
string script = "";
if (v[0] == "Breakpoint") {
action = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
scriptLanguage = v[6];
script = v[7];
}
if (lineNumber < 0) if (lineNumber < 0)
return null; return null;
if (columnNumber < 0) if (columnNumber < 0)
@ -40,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
SDBookmark bookmark; SDBookmark bookmark;
switch (v[0]) { switch (v[0]) {
case "Breakpoint": case "Breakpoint":
bookmark = new Debugging.BreakpointBookmark(fileName, null, new TextLocation(columnNumber, lineNumber)); bookmark = new Debugging.BreakpointBookmark(fileName, null, new TextLocation(columnNumber, lineNumber), action, scriptLanguage, script);
break; break;
default: default:
bookmark = new SDBookmark(fileName, null, new TextLocation(columnNumber, lineNumber)); bookmark = new SDBookmark(fileName, null, new TextLocation(columnNumber, lineNumber));
@ -71,6 +80,15 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
b.Append(bookmark.ColumnNumber); b.Append(bookmark.ColumnNumber);
b.Append('|'); b.Append('|');
b.Append(bookmark.IsEnabled.ToString()); b.Append(bookmark.IsEnabled.ToString());
if (bookmark is Debugging.BreakpointBookmark) {
Debugging.BreakpointBookmark bbm = (Debugging.BreakpointBookmark)bookmark;
b.Append('|');
b.Append(bbm.Action);
b.Append('|');
b.Append(bbm.ScriptLanguage);
b.Append('|');
b.Append(bbm.Script);
}
return b.ToString(); return b.ToString();
} else { } else {
return base.ConvertTo(context, culture, value, destinationType); return base.ConvertTo(context, culture, value, destinationType);

Loading…
Cancel
Save