[pspplayer commit] r605 - in trunk: Noxa.Emulation.Psp.Player Noxa.Emulation.Psp.Player/Debugger Noxa.Emulation.Psp....

2 views
Skip to first unread message

codesite...@google.com

unread,
Mar 30, 2008, 9:12:36 AM3/30/08
to psppla...@googlegroups.com
Author: ben.vanik
Date: Sun Mar 30 06:11:42 2008
New Revision: 605

Added:
trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/
trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BookmarkStore.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BreakpointStore.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/CodeTagStore.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/UserDataStore.cs
Modified:
trunk/Noxa.Emulation.Psp.Player/Debugger/InprocDebugger.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Model/BreakpointManager.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Model/CodeCache.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Model/MethodBody.cs
trunk/Noxa.Emulation.Psp.Player/Noxa.Emulation.Psp.Player.csproj
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Breakpoint.cs

Log:
Basic user data storage
Currently only breakpoints are stored, but everything is setup for code comments/renames - just need to add the UI for it

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/InprocDebugger.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/InprocDebugger.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/InprocDebugger.cs Sun Mar 30 06:11:42 2008
@@ -16,6 +16,7 @@
using Noxa.Emulation.Psp.Player.Debugger.Dialogs;
using Noxa.Emulation.Psp.Player.Debugger.Model;
using Noxa.Emulation.Psp.Player.Debugger.Tools;
+using Noxa.Emulation.Psp.Player.Debugger.UserData;

namespace Noxa.Emulation.Psp.Player.Debugger
{
@@ -43,6 +44,7 @@
public uint PC;
public BreakpointManager Breakpoints;
public CodeCache CodeCache;
+ public UserDataStore UserData;

public InprocDebugger( Host host )
{
@@ -54,6 +56,7 @@
this.State = DebuggerState.Idle;
this.Breakpoints = new BreakpointManager( this );
this.CodeCache = new CodeCache( this );
+ this.UserData = new UserDataStore();

this.SetupNavigation();

@@ -78,7 +81,7 @@
this.CodeTool.Show( this.Window.DockPanel );
this.LogTool.Show( this.Window.DockPanel );
this.ThreadsTool.Show( this.Window.DockPanel );
-
+
WeifenLuo.WinFormsUI.Docking.DockPane dp;
dp = this.Window.DockPanel.DockPaneFactory.CreateDockPane( this.CodeTool, WeifenLuo.WinFormsUI.Docking.DockState.Document, true );
this.StatisticsTool.Show( dp, WeifenLuo.WinFormsUI.Docking.DockAlignment.Right, 0.45 );
@@ -130,6 +133,11 @@

public void OnBootModuleLoaded( uint entryAddress )
{
+ string dataPath = "Data-" + this.DebugHost.Emulator.CurrentInstance.Bios.Game.Parameters.DiscID + ".ddb";
+ this.UserData.Setup( dataPath );
+ this.UserData.Load();
+ this.Breakpoints.Load();
+
//Breakpoint startupBp = new Breakpoint( this.AllocateID(), BreakpointType.CodeExecute, entryAddress );
//this.Breakpoints.Add( startupBp );

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/Model/BreakpointManager.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/Model/BreakpointManager.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Model/BreakpointManager.cs Sun Mar 30 06:11:42 2008
@@ -11,6 +11,7 @@

using Noxa.Emulation.Psp.Bios;
using Noxa.Emulation.Psp.Debugging.DebugModel;
+using Noxa.Emulation.Psp.Player.Debugger.UserData;

namespace Noxa.Emulation.Psp.Player.Debugger.Model
{
@@ -22,6 +23,7 @@
private Dictionary<int, Breakpoint> _breakpointLookup;
private Dictionary<uint, Breakpoint> _addressBreakpointLookup;
private Dictionary<BiosFunctionToken, Breakpoint> _biosBreakpointLookup;
+ private bool _suspendSave;

public BreakpointManager( InprocDebugger debugger )
{
@@ -39,6 +41,43 @@
public event EventHandler<BreakpointEventArgs> Removed;
public event EventHandler<BreakpointEventArgs> Toggled;

+ public void Load()
+ {
+ // Remove all and readd - slow?
+ _suspendSave = true;
+ foreach( Breakpoint bp in _breakpoints )
+ this.Remove( bp );
+ foreach( BreakpointInfo info in this.Debugger.UserData.Breakpoints.Infos )
+ {
+ Breakpoint bp = new Breakpoint( this.Debugger.AllocateID(), info.Type, info.Address );
+ bp.Name = info.Name;
+ bp.AccessType = info.AccessType;
+ bp.Mode = info.Mode;
+ bp.Enabled = info.Enabled;
+ this.Add( bp );
+ }
+ _suspendSave = false;
+ }
+
+ public void Save()
+ {
+ if( _suspendSave == true )
+ return;
+ this.Debugger.UserData.Breakpoints.Infos.Clear();
+ foreach( Breakpoint bp in _breakpoints )
+ {
+ BreakpointInfo info = new BreakpointInfo();
+ info.Type = bp.Type;
+ info.Address = bp.Address;
+ info.Name = bp.Name;
+ info.AccessType = bp.AccessType;
+ info.Mode = bp.Mode;
+ info.Enabled = bp.Enabled;
+ this.Debugger.UserData.Breakpoints.Infos.Add( info );
+ }
+ this.Debugger.UserData.Save();
+ }
+
public void Update()
{
foreach( Breakpoint breakpoint in _breakpoints )
@@ -91,6 +130,7 @@
break;
}
this.OnBreakpointAdded( breakpoint );
+ this.Save();
}

public void Remove( Breakpoint breakpoint )
@@ -125,6 +165,7 @@
break;
}
this.OnBreakpointRemoved( breakpoint );
+ this.Save();
}

public Breakpoint this[ int id ]
@@ -211,6 +252,7 @@
dummy.Mode = breakpoint.Mode;
dummy.Enabled = !old;
this.OnBreakpointToggled( breakpoint, dummy );
+ this.Save();
}

internal void OnBreakpointToggled( Breakpoint breakpoint, Breakpoint changed )

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/Model/CodeCache.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/Model/CodeCache.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Model/CodeCache.cs Sun Mar 30 06:11:42 2008
@@ -9,6 +9,7 @@
using System.Diagnostics;
using System.Text;
using Noxa.Emulation.Psp.Debugging.DebugModel;
+using Noxa.Emulation.Psp.Player.Debugger.UserData;

namespace Noxa.Emulation.Psp.Player.Debugger.Model
{
@@ -55,6 +56,8 @@

this.LinkReferences();

+ this.ApplyTags();
+
this.Version++;
}

@@ -106,6 +109,48 @@
}
if( ( method.IncomingReferences.Count > 0 ) || ( method.OutgoingReferences.Count > 0 ) )
method.FinalizeReferences();
+ }
+ }
+
+ private void ApplyTags()
+ {
+ CodeTagStore tags = this.Debugger.UserData.CodeTags;
+ List<TagInfo> methodNames = new List<TagInfo>( tags.MethodNames );
+ List<TagInfo> labelNames = new List<TagInfo>( tags.LabelNames );
+ foreach( MethodBody method in this.Methods )
+ {
+ foreach( TagInfo tag in methodNames )
+ {
+ if( tag.Address == method.Address )
+ {
+ method.Name = tag.Value;
+ methodNames.Remove( tag );
+ break;
+ }
+ }
+
+ foreach( Label label in method.Labels )
+ {
+ foreach( TagInfo tag in labelNames )
+ {
+ if( tag.Address == label.Address )
+ {
+ label.Name = tag.Value;
+ labelNames.Remove( tag );
+ break;
+ }
+ }
+ }
+
+ foreach( TagInfo tag in tags.Comments )
+ {
+ if( ( tag.Address > method.Address ) &&
+ ( tag.Address <= ( method.Address + method.Length ) ) )
+ {
+ uint offset = ( tag.Address - method.Address ) / 4;
+ method.Instructions[ ( int )offset ].Comment = tag.Value;
+ }
+ }
}
}

Modified: trunk/Noxa.Emulation.Psp.Player/Debugger/Model/MethodBody.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Player/Debugger/Model/MethodBody.cs (original)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/Model/MethodBody.cs Sun Mar 30 06:11:42 2008
@@ -367,7 +367,7 @@
public Reference Reference;
public ExternalReference ExternalReference;

- public string Annotation;
+ public string Comment;

public Breakpoint Breakpoint;

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BookmarkStore.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BookmarkStore.cs Sun Mar 30 06:11:42 2008
@@ -0,0 +1,21 @@
+// ----------------------------------------------------------------------------
+// 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.Text;
+
+namespace Noxa.Emulation.Psp.Player.Debugger.UserData
+{
+ public class BookmarkInfo
+ {
+ }
+
+ public class BookmarkStore
+ {
+ public List<BookmarkInfo> Infos = new List<BookmarkInfo>();
+ }
+}

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BreakpointStore.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/BreakpointStore.cs Sun Mar 30 06:11:42 2008
@@ -0,0 +1,29 @@
+// ----------------------------------------------------------------------------
+// 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.Text;
+using Noxa.Emulation.Psp.Debugging.DebugModel;
+using Noxa.Emulation.Psp.Debugging.Hooks;
+
+namespace Noxa.Emulation.Psp.Player.Debugger.UserData
+{
+ public class BreakpointInfo
+ {
+ public BreakpointType Type;
+ public MemoryAccessType AccessType;
+ public uint Address;
+ public BreakpointMode Mode;
+ public bool Enabled;
+ public string Name;
+ }
+
+ public class BreakpointStore
+ {
+ public List<BreakpointInfo> Infos = new List<BreakpointInfo>();
+ }
+}

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/CodeTagStore.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/CodeTagStore.cs Sun Mar 30 06:11:42 2008
@@ -0,0 +1,25 @@
+// ----------------------------------------------------------------------------
+// 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.Text;
+
+namespace Noxa.Emulation.Psp.Player.Debugger.UserData
+{
+ public class TagInfo
+ {
+ public uint Address;
+ public string Value;
+ }
+
+ public class CodeTagStore
+ {
+ public List<TagInfo> MethodNames = new List<TagInfo>();
+ public List<TagInfo> LabelNames = new List<TagInfo>();
+ public List<TagInfo> Comments = new List<TagInfo>();
+ }
+}

Added: trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/UserDataStore.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp.Player/Debugger/UserData/UserDataStore.cs Sun Mar 30 06:11:42 2008
@@ -0,0 +1,62 @@
+// ----------------------------------------------------------------------------
+// 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.IO;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace Noxa.Emulation.Psp.Player.Debugger.UserData
+{
+ public class UserDataStore
+ {
+ private JsonSerializer _serializer = new JsonSerializer();
+ private string _path;
+ public BreakpointStore Breakpoints = new BreakpointStore();
+ public CodeTagStore CodeTags = new CodeTagStore();
+ public BookmarkStore Bookmarks = new BookmarkStore();
+
+ public void Setup( string path )
+ {
+ _path = path;
+ }
+
+ public void Load()
+ {
+ if( File.Exists( _path ) == false )
+ return;
+ using( TextReader textReader = File.OpenText( _path ) )
+ using( JsonReader reader = new JsonReader( textReader ) )
+ {
+ PrimaryStore store = ( PrimaryStore )_serializer.Deserialize( reader, typeof( PrimaryStore ) );
+ this.Breakpoints = store.Breakpoints;
+ this.CodeTags = store.CodeTags;
+ this.Bookmarks = store.Bookmarks;
+ }
+ }
+
+ public void Save()
+ {
+ using( TextWriter textWriter = new StreamWriter( _path ) )
+ using( JsonWriter writer = new JsonWriter( textWriter ) )
+ {
+ PrimaryStore store = new PrimaryStore();
+ store.Breakpoints = this.Breakpoints;
+ store.CodeTags = this.CodeTags;
+ store.Bookmarks = this.Bookmarks;
+ _serializer.Serialize( writer, store );
+ }
+ }
+ }
+
+ public class PrimaryStore
+ {
+ public BreakpointStore Breakpoints;
+ public CodeTagStore CodeTags;
+ public BookmarkStore Bookmarks;
+ }
+}

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:11:42 2008
@@ -234,6 +234,10 @@
<Compile Include="Debugger\Tools\WatchTool.Designer.cs">
<DependentUpon>WatchTool.cs</DependentUpon>
</Compile>
+ <Compile Include="Debugger\UserData\BookmarkStore.cs" />
+ <Compile Include="Debugger\UserData\BreakpointStore.cs" />
+ <Compile Include="Debugger\UserData\CodeTagStore.cs" />
+ <Compile Include="Debugger\UserData\UserDataStore.cs" />
<Compile Include="GameCache.cs" />
<Compile Include="GamePicker\AdvancedGameListing.cs">
<SubType>UserControl</SubType>

Modified: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Breakpoint.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Breakpoint.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Breakpoint.cs Sun Mar 30 06:11:42 2008
@@ -73,14 +73,14 @@
public readonly BreakpointType Type;

/// <summary>
- /// The memory access type.
+ /// The address of the breakpoint.
/// </summary>
- public readonly MemoryAccessType AccessType;
+ public readonly uint Address;

/// <summary>
- /// The address of the breakpoint.
+ /// The memory access type.
/// </summary>
- public readonly uint Address;
+ public MemoryAccessType AccessType;

/// <summary>
/// The current mode of the breakpoint.

Reply all
Reply to author
Forward
0 new messages