[pspplayer commit] r607 - trunk/Noxa.Emulation.Psp.Player/Debugger/Tools

2 views
Skip to first unread message

codesite...@google.com

unread,
Mar 30, 2008, 10:07:45 AM3/30/08
to psppla...@googlegroups.com
Author: ben.vanik
Date: Sun Mar 30 07:07:16 2008
New Revision: 607

Modified:
trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.Designer.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs

Log:
Added rename support for methods and labels - they are preserved across sessions.
Everything (including breakpoints) is saved after each modification -
not so fast when things get really big, but until the debugger is
stable and I know I won't be stopping it in VS, it's safer this way.

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 07:07:16 2008
@@ -57,6 +57,7 @@
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.addBreakpointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeBreakpointToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lineContextMenuStrip.SuspendLayout();
this.gutterContextMenuStrip.SuspendLayout();
this.SuspendLayout();
@@ -72,6 +73,7 @@
this.lineContextMenuStrip.Items.AddRange( new
System.Windows.Forms.ToolStripItem[] {
this.valueToolStripTextBox,
this.toolStripSeparator5,
+ this.renameToolStripMenuItem,
this.copyOperandToolStripMenuItem,
this.goToTargetToolStripMenuItem,
this.toolStripSeparator4,
@@ -85,7 +87,7 @@
this.toolStripSeparator3,
this.lineBreakpointToolStripMenuItem} );
this.lineContextMenuStrip.Name = "addressContextMenuStrip";
- this.lineContextMenuStrip.Size = new System.Drawing.Size( 188, 249 );
+ this.lineContextMenuStrip.Size = new System.Drawing.Size( 188, 271 );
this.lineContextMenuStrip.Closed += new
System.Windows.Forms.ToolStripDropDownClosedEventHandler(
this.GeneralContextClosed );
this.lineContextMenuStrip.Opening += new
System.ComponentModel.CancelEventHandler(
this.lineContextMenuStrip_Opening );
//
@@ -236,6 +238,14 @@
this.removeBreakpointToolStripMenuItem.Size = new
System.Drawing.Size( 177, 22 );
this.removeBreakpointToolStripMenuItem.Text = "&Delete Breakpoint";
this.removeBreakpointToolStripMenuItem.Click += new
System.EventHandler( this.removeBreakpointToolStripMenuItem_Click );
+ //
+ // renameToolStripMenuItem
+ //
+ this.renameToolStripMenuItem.Image = global::Noxa.Emulation.Psp.Player.Properties.Resources.RenameIcon;
+ this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
+ this.renameToolStripMenuItem.Size = new System.Drawing.Size( 187,
22 );
+ this.renameToolStripMenuItem.Text = "Re&name";
+ this.renameToolStripMenuItem.Click += new System.EventHandler(
renameToolStripMenuItem_Click );
this.lineContextMenuStrip.ResumeLayout( false );
this.lineContextMenuStrip.PerformLayout();
this.gutterContextMenuStrip.ResumeLayout( false );
@@ -267,5 +277,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem addBreakpointToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeBreakpointToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem;
}
}

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 07:07:16 2008
@@ -15,6 +15,7 @@
using Noxa.Emulation.Psp.Debugging.DebugModel;
using Noxa.Emulation.Psp.Player.Debugger.Dialogs;
using Noxa.Emulation.Psp.Player.Debugger.Model;
+using Noxa.Emulation.Psp.Player.Debugger.UserData;

namespace Noxa.Emulation.Psp.Player.Debugger.Tools
{
@@ -846,8 +847,9 @@
private int _contextIndex = -1;
private Operand _contextOperand;

- private Instruction GetContextInstruction()
+ private Line GetContextLine( out MethodBody method )
{
+ method = null;
if( _contextIndex < 0 )
{
if( _hoveredIndex < 0 )
@@ -856,10 +858,16 @@
}
int lineSum;
int methodIndex = this.IndexOfMethodAt( _contextIndex, out lineSum );
- MethodBody method = _debugger.CodeCache.Methods[ methodIndex ];
+ method = _debugger.CodeCache.Methods[ methodIndex ];
int lineIndex = ( _contextIndex - lineSum );
List<Line> lines = ( List<Line> )method.UserCache;
- Line line = lines[ lineIndex ];
+ return lines[ lineIndex ];
+ }
+
+ private Instruction GetContextInstruction()
+ {
+ MethodBody method;
+ Line line = this.GetContextLine( out method );
return line.Instruction;
}

@@ -981,19 +989,37 @@

private void lineContextMenuStrip_Opening( object sender,
CancelEventArgs e )
{
- //if( _hoveredIndex < 0 )
- // return;
- //_contextIndex = _hoveredIndex;
- //if( ( _hoveredColumn == Column.Instruction ) &&
- // ( _hoveredValue != null ) )
- //{
- // if( _hoveredValue is CachedOperand )
- // _contextOperand = ( ( CachedOperand )_hoveredValue ).Operand;
- //}
- Instruction instr = this.GetContextInstruction();
- if( instr == null )
+ this.renameToolStripMenuItem.Visible = false;
+ this.valueToolStripTextBox.Visible = false;
+ this.toolStripSeparator5.Visible = false;
+ this.copyOperandToolStripMenuItem.Visible = false;
+ this.goToTargetToolStripMenuItem.Visible = false;
+ this.toolStripSeparator4.Visible = false;
+
+ MethodBody method;
+ Line line = this.GetContextLine( out method );
+ if( line == null )
return;
+ switch( line.Type )
+ {
+ case LineType.Header:
+ this.renameToolStripMenuItem.Visible = true;
+ this.toolStripSeparator4.Visible = true;
+ return;
+ case LineType.Label:
+ this.renameToolStripMenuItem.Visible = true;
+ this.toolStripSeparator4.Visible = true;
+ return;
+ default:
+ if( line.Instruction == null )
+ {
+ e.Cancel = true;
+ return;
+ }
+ break;
+ }

+ Instruction instr = line.Instruction;
bool hasOperand = ( _contextOperand != null );
bool referenceOperand = false;
if( hasOperand == true )
@@ -1031,6 +1057,92 @@
this.goToTargetToolStripMenuItem.Visible = hasOperand && referenceOperand;
this.toolStripSeparator4.Visible = hasOperand;
}
+
+ #region General
+
+ private void renameToolStripMenuItem_Click( object sender,
System.EventArgs e )
+ {
+ MethodBody method;
+ Line line = this.GetContextLine( out method );
+ if( line == null )
+ return;
+ RenameTarget target = RenameTarget.Method;
+ string value = "";
+ switch( line.Type )
+ {
+ case LineType.Header:
+ target = RenameTarget.Method;
+ value = method.Name;
+ break;
+ case LineType.Label:
+ target = RenameTarget.Label;
+ value = line.Instruction.Label.Name;
+ break;
+ default:
+ return;
+ }
+
+ RenameDialog dialog = new RenameDialog();
+ dialog.Target = target;
+ dialog.Value = value;
+ if( dialog.ShowDialog( this.FindForm() ) == DialogResult.OK )
+ {
+ switch( line.Type )
+ {
+ case LineType.Header:
+ method.Name = dialog.Value;
+ {
+ bool found = false;
+ foreach( TagInfo tag in _debugger.UserData.CodeTags.MethodNames )
+ {
+ if( tag.Address == method.Address )
+ {
+ found = true;
+ tag.Value = dialog.Value;
+ break;
+ }
+ }
+ if( found == false )
+ {
+ TagInfo tag = new TagInfo();
+ tag.Address = method.Address;
+ tag.Value = dialog.Value;
+ _debugger.UserData.CodeTags.MethodNames.Add( tag );
+ }
+ _debugger.UserData.Save();
+ }
+ break;
+ case LineType.Label:
+ line.Instruction.Label.Name = dialog.Value;
+ {
+ bool found = false;
+ foreach( TagInfo tag in _debugger.UserData.CodeTags.LabelNames )
+ {
+ if( tag.Address == line.Instruction.Address )
+ {
+ found = true;
+ tag.Value = dialog.Value;
+ break;
+ }
+ }
+ if( found == false )
+ {
+ TagInfo tag = new TagInfo();
+ tag.Address = line.Instruction.Address;
+ tag.Value = dialog.Value;
+ _debugger.UserData.CodeTags.LabelNames.Add( tag );
+ }
+ _debugger.UserData.Save();
+ }
+ break;
+ }
+ this.Invalidate();
+ }
+
+ this.ContextReturn();
+ }
+
+ #endregion

#region Operands

Reply all
Reply to author
Forward
0 new messages