[pspplayer commit] r606 - in trunk/Noxa.Emulation.Psp.Player: . Debugger/Dialogs Debugger/Tools

1 view
Skip to first unread message

codesite...@google.com

unread,
Mar 30, 2008, 9:26:38 AM3/30/08
to psppla...@googlegroups.com
Author: ben.vanik
Date: Sun Mar 30 06:25:25 2008
New Revision: 606

Added:
trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.Designer.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.resx
Modified:
trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.Designer.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs
trunk/Noxa.Emulation.Psp.Player/Noxa.Emulation.Psp.Player.csproj

Log:
Allow renaming of breakpoints and show their name in their tooltips

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.Designer.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.Designer.cs Sun Mar 30 06:25:25 2008
@@ -0,0 +1,111 @@
+namespace Noxa.Emulation.Psp.Player.Debugger.Dialogs
+{
+ partial class RenameDialog
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing && ( components != null ) )
+ {
+ components.Dispose();
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.renameButton = new System.Windows.Forms.Button();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.nameTextBox = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // renameButton
+ //
+ this.renameButton.Anchor = ( ( System.Windows.Forms.AnchorStyles )( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) );
+ this.renameButton.Location = new System.Drawing.Point( 103, 51 );
+ this.renameButton.Name = "renameButton";
+ this.renameButton.Size = new System.Drawing.Size( 75, 23 );
+ this.renameButton.TabIndex = 2;
+ this.renameButton.Text = "&Rename";
+ this.renameButton.UseVisualStyleBackColor = true;
+ this.renameButton.Click += new System.EventHandler( this.renameButton_Click );
+ //
+ // cancelButton
+ //
+ this.cancelButton.Anchor = ( ( System.Windows.Forms.AnchorStyles )( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) );
+ this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelButton.Location = new System.Drawing.Point( 184, 51 );
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size( 75, 23 );
+ this.cancelButton.TabIndex = 3;
+ this.cancelButton.Text = "&Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler( this.cancelButton_Click );
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point( 12, 9 );
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size( 136, 13 );
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Enter a name for the target:";
+ //
+ // nameTextBox
+ //
+ this.nameTextBox.Anchor = ( ( System.Windows.Forms.AnchorStyles )( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left )
+ | System.Windows.Forms.AnchorStyles.Right ) ) );
+ this.nameTextBox.Font = new System.Drawing.Font( "Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( ( byte )( 0 ) ) );
+ this.nameTextBox.Location = new System.Drawing.Point( 15, 25 );
+ this.nameTextBox.Name = "nameTextBox";
+ this.nameTextBox.Size = new System.Drawing.Size( 244, 20 );
+ this.nameTextBox.TabIndex = 1;
+ //
+ // RenameDialog
+ //
+ this.AcceptButton = this.renameButton;
+ this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.cancelButton;
+ this.ClientSize = new System.Drawing.Size( 271, 86 );
+ this.Controls.Add( this.nameTextBox );
+ this.Controls.Add( this.label1 );
+ this.Controls.Add( this.cancelButton );
+ this.Controls.Add( this.renameButton );
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "RenameDialog";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Rename";
+ this.Activated += new System.EventHandler( this.RenameDialog_Activated );
+ this.ResumeLayout( false );
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button renameButton;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox nameTextBox;
+ }
+}
\ No newline at end of file

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.cs Sun Mar 30 06:25:25 2008
@@ -0,0 +1,90 @@
+// ----------------------------------------------------------------------------
+// PSP Player Emulation Suite
+// Copyright (C) 2008 Ben Vanik (noxa)
+// Licensed under the LGPL - see License.txt in the project root for details
+// ----------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.Media;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Noxa.Emulation.Psp.Player.Debugger.Dialogs
+{
+ enum RenameTarget
+ {
+ Breakpoint,
+ Method,
+ Label,
+ Bookmark,
+ }
+
+ partial class RenameDialog : Form
+ {
+ public RenameTarget Target;
+ public string Value;
+
+ public RenameDialog()
+ {
+ this.InitializeComponent();
+
+ this.DialogResult = DialogResult.Cancel;
+ }
+
+ protected override void OnShown( EventArgs e )
+ {
+ base.OnShown( e );
+
+ this.Text = "Rename";
+ switch( this.Target )
+ {
+ case RenameTarget.Bookmark:
+ this.Text += " Bookmark";
+ break;
+ case RenameTarget.Breakpoint:
+ this.Text += " Breakpoint";
+ break;
+ case RenameTarget.Label:
+ this.Text += " Label";
+ break;
+ case RenameTarget.Method:
+ this.Text += " Method";
+ break;
+ }
+
+ this.nameTextBox.Text = this.Value;
+ }
+
+ private void renameButton_Click( object sender, EventArgs e )
+ {
+ string value = this.nameTextBox.Text.Trim();
+ if( value.Length == 0 )
+ {
+ SystemSounds.Exclamation.Play();
+ this.nameTextBox.Focus();
+ this.nameTextBox.SelectAll();
+ return;
+ }
+ this.Value = value;
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+ private void cancelButton_Click( object sender, EventArgs e )
+ {
+ this.DialogResult = DialogResult.Cancel;
+ this.Close();
+ }
+
+ private void RenameDialog_Activated( object sender, EventArgs e )
+ {
+ this.nameTextBox.Focus();
+ this.nameTextBox.SelectAll();
+ }
+ }
+}

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.resx
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Dialogs/RenameDialog.resx Sun Mar 30 06:25:25 2008
@@ -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>
\ No newline at end of file

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.Designer.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.Designer.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.Designer.cs Sun Mar 30 06:25:25 2008
@@ -185,7 +185,6 @@
this.lineBreakpointToolStripMenuItem.Name = "lineBreakpointToolStripMenuItem";
this.lineBreakpointToolStripMenuItem.Size = new System.Drawing.Size( 187, 22 );
this.lineBreakpointToolStripMenuItem.Text = "&Breakpoint";
- this.lineBreakpointToolStripMenuItem.Text = "&Breakpoint";
//
// gutterContextMenuStrip
//
@@ -196,6 +195,7 @@
this.addBreakpointToolStripMenuItem,
this.removeBreakpointToolStripMenuItem} );
this.gutterContextMenuStrip.Name = "gutterContextMenuStrip";
+ this.gutterContextMenuStrip.OwnerItem = this.lineBreakpointToolStripMenuItem;
this.gutterContextMenuStrip.Size = new System.Drawing.Size( 178, 98 );
this.gutterContextMenuStrip.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler( this.GeneralContextClosed );
this.gutterContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler( this.gutterContextMenuStrip_Opening );

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs Sun Mar 30 06:25:25 2008
@@ -13,6 +13,7 @@
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using Noxa.Emulation.Psp.Debugging.DebugModel;
+using Noxa.Emulation.Psp.Player.Debugger.Dialogs;
using Noxa.Emulation.Psp.Player.Debugger.Model;

namespace Noxa.Emulation.Psp.Player.Debugger.Tools
@@ -148,6 +149,20 @@

private int _hoveredIndex = -1;

+ private Instruction GetHoveredInstruction()
+ {
+ int index = _hoveredIndex;
+ if( index < 0 )
+ return null;
+ int lineSum;
+ int methodIndex = this.IndexOfMethodAt( index, out lineSum );
+ MethodBody method = _debugger.CodeCache.Methods[ methodIndex ];
+ int lineIndex = ( index - lineSum );
+ List<Line> lines = ( List<Line> )method.UserCache;
+ Line line = lines[ lineIndex ];
+ return line.Instruction;
+ }
+
protected override void OnMouseDown( MouseEventArgs e )
{
base.OnMouseDown( e );
@@ -214,9 +229,23 @@
_hoveredIndex = Math.Min( _firstVisibleLine + y, _totalLines );

if( e.X < 2 + _gutterWidth + 1 )
+ {
this.ContextMenuStrip = this.gutterContextMenuStrip;
+ Instruction instr = this.GetHoveredInstruction();
+ if( instr.Breakpoint != null )
+ {
+ string tipText = "Breakpoint: " + ( instr.Breakpoint.Name ?? instr.Breakpoint.ID.ToString() );
+ if( this.toolTip.GetToolTip( this ) != tipText )
+ this.toolTip.SetToolTip( this, tipText );
+ }
+ else
+ this.toolTip.SetToolTip( this, null );
+ }
else
+ {
this.ContextMenuStrip = this.lineContextMenuStrip;
+ this.toolTip.SetToolTip( this, null );
+ }
}

protected override void OnMouseUp( MouseEventArgs e )
@@ -919,8 +948,15 @@
if( instr == null )
return;

- //Breakpoint bp = this.Debugger.Breakpoints[ instr.BreakpointID ];
- // TODO: rename breakpoint
+ Breakpoint bp = instr.Breakpoint;
+ RenameDialog dialog = new RenameDialog();
+ dialog.Target = RenameTarget.Breakpoint;
+ dialog.Value = bp.Name ?? "";
+ if( dialog.ShowDialog( this.FindForm() ) == DialogResult.OK )
+ {
+ bp.Name = dialog.Value;
+ _debugger.Breakpoints.Save();
+ }

this.ContextReturn();
}

Modified: trunk/Noxa.Emulation.Psp.Player/Noxa.Emulation.Psp.Player.csproj
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Noxa.Emulation.Psp.Player.csproj (original)
+++ trunk/Noxa.Emulation.Psp.Player/Noxa.Emulation.Psp.Player.csproj Sun Mar 30 06:25:25 2008
@@ -102,6 +102,12 @@
<Compile Include="Debugger\DebuggerWindow.Designer.cs">
<DependentUpon>DebuggerWindow.cs</DependentUpon>
</Compile>
+ <Compile Include="Debugger\Dialogs\RenameDialog.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Debugger\Dialogs\RenameDialog.Designer.cs">
+ <DependentUpon>RenameDialog.cs</DependentUpon>
+ </Compile>
<Compile Include="Debugger\Dialogs\DelayThreadDialog.cs">
<SubType>Form</SubType>
</Compile>
@@ -288,6 +294,10 @@
</EmbeddedResource>
<EmbeddedResource Include="Debugger\DebuggerWindow.resx">
<DependentUpon>DebuggerWindow.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Debugger\Dialogs\RenameDialog.resx">
+ <DependentUpon>RenameDialog.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Debugger\Dialogs\DelayThreadDialog.resx">

Reply all
Reply to author
Forward
0 new messages