[pspplayer commit] r604 - in trunk: Noxa.Emulation.Psp Noxa.Emulation.Psp.Bios.ManagedHLE Noxa.Emulation.Psp.Bios.Ma...

3 views
Skip to first unread message

codesite...@google.com

unread,
Mar 30, 2008, 1:38:38 AM3/30/08
to psppla...@googlegroups.com
Author: ben.vanik
Date: Sat Mar 29 22:37:34 2008
New Revision: 604

Added:
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ModuleInfo.cs
Modified:
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/BiosDebugHook.cs
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel Types/KModule.cs
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel.cs
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.Analysis.cs
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.cs
trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Modules/ModuleMgrForUser.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Model/CodeCache.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Model/MethodBody.cs
trunk/Noxa.Emulation.Psp.Player/Debugger/Tools/CodeViewControl.cs
trunk/Noxa.Emulation.Psp/Bios/LoadParameters.cs
trunk/Noxa.Emulation.Psp/Bios/LoadResults.cs
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Method.cs
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Symbol.cs
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ThreadInfo.cs
trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Variable.cs
trunk/Noxa.Emulation.Psp/Debugging/Hooks/IBiosHook.cs
trunk/Noxa.Emulation.Psp/Games/GameLoader.cs
trunk/Noxa.Emulation.Psp/Noxa.Emulation.Psp.csproj

Log:
Added basic module info stuff to debugger - all symbols are attributed to the module they come from. Right now the only UI change is that methods in the disassembly view are prefixed with the name of the module they are from.

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/BiosDebugHook.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/BiosDebugHook.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/BiosDebugHook.cs Sat Mar 29 22:37:34 2008
@@ -23,6 +23,8 @@
this.Bios = bios;
}

+ #region Threads
+
public uint ActiveThreadID
{
get
@@ -107,5 +109,29 @@
return;
thread.Exit( -1 );
}
+
+ #endregion
+
+ #region Modules
+
+ public ModuleInfo[] GetModules()
+ {
+ Kernel kernel = this.Bios._kernel;
+ List<ModuleInfo> moduleInfos = new List<ModuleInfo>();
+ foreach( KModule module in kernel.UserModules )
+ {
+ ModuleInfo moduleInfo = new ModuleInfo();
+ moduleInfo.ModuleID = module.UID;
+ moduleInfo.Name = module.Name;
+ moduleInfo.Path = module.LoadParameters.FilePath;
+ moduleInfo.EntryAddress = module.LoadResults.EntryAddress;
+ moduleInfo.LowerBounds = module.LoadResults.LowerBounds;
+ moduleInfo.UpperBounds = module.LoadResults.UpperBounds;
+ moduleInfos.Add( moduleInfo );
+ }
+ return moduleInfos.ToArray();
+ }
+
+ #endregion
}
}

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel Types/KModule.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel Types/KModule.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel Types/KModule.cs Sat Mar 29 22:37:34 2008
@@ -16,6 +16,7 @@

public BiosModule MetaModule;
public Module Module;
+ public LoadParameters LoadParameters;
public LoadResults LoadResults;

public string Name;

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Kernel.cs Sat Mar 29 22:37:34 2008
@@ -182,10 +182,12 @@

// Get bootstream
Debug.Assert( Bios.BootStream == null );
- Bios.BootStream = GameLoader.FindBootStream( Bios.Game );
+ string filePath;
+ Bios.BootStream = GameLoader.FindBootStream( Bios.Game, out filePath );
Debug.Assert( Bios.BootStream != null );

LoadParameters loadParams = new LoadParameters();
+ loadParams.FilePath = filePath;
loadParams.Path = Bios.Game.Folder;
#if DEBUG
loadParams.AppendDatabase = true;
@@ -215,9 +217,15 @@
public KHandle AddHandle( KHandle handle )
{
Debug.Assert( handle != null );
- handle.UID = ( uint )Interlocked.Increment( ref _lastUid ) - 1;
+ if( handle.UID <= 0 )
+ handle.UID = this.AllocateID();
Handles.Add( handle.UID, handle );
return handle;
+ }
+
+ internal uint AllocateID()
+ {
+ return ( uint )Interlocked.Increment( ref _lastUid ) - 1;
}

public KHandle GetHandle( uint uid )

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.Analysis.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.Analysis.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.Analysis.cs Sat Mar 29 22:37:34 2008
@@ -19,7 +19,7 @@
{
unsafe partial class Loader
{
- private void Analyze( IDebugDatabase db, byte* text, uint textLength, uint baseAddress )
+ private void Analyze( uint moduleId, IDebugDatabase db, byte* text, uint textLength, uint baseAddress )
{
// We start at the base and try to build functions
// The logic here is similar to my dynarec
@@ -68,7 +68,7 @@
//}

// End method
- Method method = new Method( MethodType.User, methodStart, address - methodStart + 4 );
+ Method method = new Method( moduleId, MethodType.User, methodStart, address - methodStart + 4 );
db.AddSymbol( method );
methodStart = address + 4;
lastBranchTarget = 0;
@@ -107,7 +107,7 @@
if( address - 4 > methodStart )
{
// Final end - ideally we'd never have to do this
- Method method = new Method( MethodType.User, methodStart, address - 4 - methodStart );
+ Method method = new Method( moduleId, MethodType.User, methodStart, address - 4 - methodStart );
db.AddSymbol( method );
Log.WriteLine( Verbosity.Normal, Feature.Loader, "Analyze didn't finish .text cleanly - last method: {0}", method.ToString() );
}

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Loader.cs Sat Mar 29 22:37:34 2008
@@ -638,6 +638,10 @@
db.BeginUpdate();
}

+ // Assign ID now so we can use it for symbols/etc
+ uint moduleId = _bios._kernel.AllocateID();
+ results.ModuleID = moduleId;
+
int variableExportCount = 0;
int functionExportCount = 0;

@@ -773,7 +777,7 @@
// Add to debug database
if( db != null )
{
- Method method = new Method( MethodType.Bios, function.StubAddress, 8, new BiosFunctionToken( stubImport.Function ) );
+ Method method = new Method( moduleId, MethodType.Bios, function.StubAddress, 8, new BiosFunctionToken( stubImport.Function ) );
db.AddSymbol( method );
}
}
@@ -815,12 +819,12 @@
if( symType == 0x1 )
{
// OBJECT
- symbol = new Variable( address, sym->st_size, name );
+ symbol = new Variable( moduleId, address, sym->st_size, name );
}
else if( symType == 0x2 )
{
// FUNC
- symbol = new Method( MethodType.User, address, sym->st_size, name );
+ symbol = new Method( moduleId, MethodType.User, address, sym->st_size, name );
}
if( symbol != null )
db.AddSymbol( symbol );
@@ -838,7 +842,7 @@
uint textAddress = baseAddress + textShdr->sh_addr;
byte* text = memory.TranslateMainMemory( ( int )textAddress );
uint size = textShdr->sh_size;
- this.Analyze( db, text, size, textAddress );
+ this.Analyze( moduleId, db, text, size, textAddress );

Log.WriteLine( Verbosity.Verbose, Feature.Loader, "Found {0} methods by analysis", db.MethodCount );
}
@@ -879,6 +883,8 @@
if( type == ModuleType.Boot )
{
KModule module = new KModule( kernel, new BiosModule( results.Name, results.Exports.ToArray() ) );
+ module.UID = moduleId;
+ module.LoadParameters = parameters;
module.LoadResults = results;
kernel.UserModules.Add( module );
Debug.Assert( kernel.MainModule == null );
@@ -926,6 +932,9 @@
if( Diag.IsAttached == true )
Diag.Instance.Client.OnBootModuleLoaded( results.EntryAddress );

+ if( Diag.IsAttached == true )
+ Diag.Instance.Client.OnModuleLoaded();
+
//kernel.MemorySystem.DumpMainMemory( "startup.bin" );
}
}
@@ -935,9 +944,6 @@
if( pbuffer != IntPtr.Zero )
Marshal.FreeHGlobal( pbuffer );
}
-
- if( Diag.IsAttached == true )
- Diag.Instance.Client.OnModuleLoaded();

return results;
}

Modified: trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Modules/ModuleMgrForUser.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Modules/ModuleMgrForUser.cs (original)
+++ trunk/Noxa.Emulation.Psp.Bios.ManagedHLE/Modules/ModuleMgrForUser.cs Sat Mar 29 22:37:34 2008
@@ -74,6 +74,7 @@
if( file != null )
{
loadParams.Path = file.Parent;
+ loadParams.FilePath = file.AbsolutePath;
string fileName = file.Name.ToLowerInvariant();
foreach( string blacklisted in _moduleBlacklist )
{
@@ -124,7 +125,12 @@

// We spoof the caller in to thinking we worked right... by just returning 0 ^_^
KModule fakemod = new KModule( _kernel, null );
+ fakemod.LoadParameters = loadParams;
_kernel.AddHandle( fakemod );
+
+ if( Diag.IsAttached == true )
+ Diag.Instance.Client.OnModuleLoaded();
+
return ( int )fakemod.UID;
}

@@ -148,9 +154,14 @@
_kernel.Bios._metaModuleLookup.Add( module.Name, module );

KModule kmod = new KModule( _kernel, module );
+ kmod.UID = results.ModuleID;
+ kmod.LoadParameters = loadParams;
kmod.LoadResults = results;
_kernel.UserModules.Add( kmod );
_kernel.AddHandle( kmod );
+
+ if( Diag.IsAttached == true )
+ Diag.Instance.Client.OnModuleLoaded();

return ( int )kmod.UID;
}

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 Sat Mar 29 22:37:34 2008
@@ -27,13 +27,24 @@

public void Update()
{
+ ModuleInfo[] moduleInfos = this.Debugger.DebugHost.BiosHook.GetModules();
+
//Method[] userMethods = this.Debugger.DebugHost.Database.GetMethods( MethodType.User );
Method[] methods = this.Debugger.DebugHost.Database.GetMethods();
this.Methods.Clear();
foreach( Method method in methods )
{
+ ModuleInfo module = null;
+ foreach( ModuleInfo moduleInfo in moduleInfos )
+ {
+ if( moduleInfo.ModuleID == method.ModuleID )
+ {
+ module = moduleInfo;
+ break;
+ }
+ }
//MethodBody body = new MethodBody( method.Address, method.Length, null );
- MethodBody body = this.BuildMethodBody( method );
+ MethodBody body = this.BuildMethodBody( module, method );
// Name, etc?
this.Methods.Add( body );
}
@@ -98,7 +109,7 @@
}
}

- private MethodBody BuildMethodBody( Method method )
+ private MethodBody BuildMethodBody( ModuleInfo moduleInfo, Method method )
{
Debug.Assert( this.Debugger.DebugHost.CpuHook != null );
uint[] codes = this.Debugger.DebugHost.CpuHook.GetMethodBody( method );
@@ -111,7 +122,7 @@
instrs.Add( instr );
instrAddress += 4;
}
- MethodBody methodBody = new MethodBody( method.Address, ( uint )method.Length, instrs.ToArray() );
+ MethodBody methodBody = new MethodBody( moduleInfo, method.Address, ( uint )method.Length, instrs.ToArray() );
if( method.Type == MethodType.Bios )
{
if( method.Function.MethodName != null )

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 Sat Mar 29 22:37:34 2008
@@ -14,6 +14,7 @@
{
class MethodBody
{
+ public readonly ModuleInfo Module;
public string Name;
public uint TotalLines;
public BiosFunctionToken Function;
@@ -35,8 +36,9 @@
public int UserTop;
public uint UserLines;

- public MethodBody( uint address, uint length, Instruction[] instructions )
+ public MethodBody( ModuleInfo moduleInfo, uint address, uint length, Instruction[] instructions )
{
+ this.Module = moduleInfo;
this.Name = string.Format( "sub_{0:X8}", address );
this.TotalLines = length / 4;

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 Sat Mar 29 22:37:34 2008
@@ -704,8 +704,9 @@
{
case LineType.Header:
{
- g.DrawString( string.Format( "// {0}", body.Name ), _font, _commentFontBrush, codex, y );
- g.DrawLine( _commentLinePen, codex + ( _charSize.Width * ( body.Name.Length + 4 ) ), y + ( _charSize.Height / 2.0f ), this.ClientRectangle.Width - 10, y + ( _charSize.Height / 2.0f ) );
+ string fullName = string.Format( "// {0}::{1}", body.Module.Name, body.Name );
+ g.DrawString( fullName, _font, _commentFontBrush, codex, y );
+ g.DrawLine( _commentLinePen, codex + ( _charSize.Width * ( fullName.Length + 1 ) ), y + ( _charSize.Height / 2.0f ), this.ClientRectangle.Width - 10, y + ( _charSize.Height / 2.0f ) );
}
break;
case LineType.Footer:
@@ -741,31 +742,38 @@
}
else
{
- g.DrawString( instr.Opcode.ToString(), _font, codeBrush, opcodex, y, _stringFormat );
-
- // Operands
- for( int m = 0; m < instr.Operands.Length; m++ )
+ if( instr.Opcode == null )
{
- Operand op = instr.Operands[ m ];
- string resolved = instr.GetResolvedOperandString( op, this.UseHex );
- Brush fontBrush = codeBrush;
- switch( op.Type )
- {
- case OperandType.BranchTarget:
- fontBrush = _referenceFontBrush;
- break;
- case OperandType.JumpTarget:
- fontBrush = _referenceFontBrush;
- break;
- }
- g.DrawString( resolved, _font, fontBrush, realx, y, _stringFormat );
- realx += ( int )_charSize.Width * resolved.Length;
+ g.DrawString( "UNKNOWN", _font, codeBrush, opcodex, y, _stringFormat );
+ }
+ else
+ {
+ g.DrawString( instr.Opcode.ToString(), _font, codeBrush, opcodex, y, _stringFormat );

- bool last = ( m == instr.Operands.Length - 1 );
- if( last == false )
+ // Operands
+ for( int m = 0; m < instr.Operands.Length; m++ )
{
- g.DrawString( ", ", _font, codeBrush, realx - 2, y, _stringFormat );
- realx += ( int )_charSize.Width * 2 - 2;
+ Operand op = instr.Operands[ m ];
+ string resolved = instr.GetResolvedOperandString( op, this.UseHex );
+ Brush fontBrush = codeBrush;
+ switch( op.Type )
+ {
+ case OperandType.BranchTarget:
+ fontBrush = _referenceFontBrush;
+ break;
+ case OperandType.JumpTarget:
+ fontBrush = _referenceFontBrush;
+ break;
+ }
+ g.DrawString( resolved, _font, fontBrush, realx, y, _stringFormat );
+ realx += ( int )_charSize.Width * resolved.Length;
+
+ bool last = ( m == instr.Operands.Length - 1 );
+ if( last == false )
+ {
+ g.DrawString( ", ", _font, codeBrush, realx - 2, y, _stringFormat );
+ realx += ( int )_charSize.Width * 2 - 2;
+ }
}
}
}

Modified: trunk/Noxa.Emulation.Psp/Bios/LoadParameters.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Bios/LoadParameters.cs (original)
+++ trunk/Noxa.Emulation.Psp/Bios/LoadParameters.cs Sat Mar 29 22:37:34 2008
@@ -17,6 +17,11 @@
public class LoadParameters
{
/// <summary>
+ /// The human-readable path of the module, if available.
+ /// </summary>
+ public string FilePath;
+
+ /// <summary>
/// The path of the game or module.
/// </summary>
public IMediaFolder Path;

Modified: trunk/Noxa.Emulation.Psp/Bios/LoadResults.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Bios/LoadResults.cs (original)
+++ trunk/Noxa.Emulation.Psp/Bios/LoadResults.cs Sat Mar 29 22:37:34 2008
@@ -26,6 +26,11 @@
public bool Ignored;

/// <summary>
+ /// The ID of the module to use.
+ /// </summary>
+ public uint ModuleID;
+
+ /// <summary>
/// The lower memory address of the module after loading.
/// </summary>
public uint LowerBounds;

Modified: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Method.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Method.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Method.cs Sat Mar 29 22:37:34 2008
@@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
-
using Noxa.Emulation.Psp.Bios;

namespace Noxa.Emulation.Psp.Debugging.DebugModel
@@ -52,14 +51,15 @@
/// <summary>
/// Initializes a new <see cref="Method"/> instance with the given parameters.
/// </summary>
+ /// <param name="moduleId">The ID of the module the symbol resides in.</param>
/// <param name="type">The type of the method.</param>
/// <param name="address">The start address of the method.</param>
/// <param name="length">The length of the method, in bytes.</param>
- public Method( MethodType type, uint address, uint length )
- : base( address, length )
+ public Method( uint moduleId, MethodType type, uint address, uint length )
+ : base( moduleId, address, length )
{
- Type = type;
-
+ this.Type = type;
+
//Debug.Assert( address % 4 == 0 );
Debug.Assert( length % 4 == 0 );
}
@@ -67,27 +67,29 @@
/// <summary>
/// Initializes a new <see cref="Method"/> instance with the given parameters.
/// </summary>
+ /// <param name="moduleId">The ID of the module the symbol resides in.</param>
/// <param name="type">The type of the method.</param>
/// <param name="address">The start address of the method.</param>
/// <param name="length">The length of the method, in bytes.</param>
/// <param name="name">The name of the method, if available.</param>
- public Method( MethodType type, uint address, uint length, string name )
- : this( type, address, length )
+ public Method( uint moduleId, MethodType type, uint address, uint length, string name )
+ : this( moduleId, type, address, length )
{
- Name = name;
+ this.Name = name;
}

/// <summary>
/// Initializes a new <see cref="Method"/> instance with the given parameters.
/// </summary>
+ /// <param name="moduleId">The ID of the module the symbol resides in.</param>
/// <param name="type">The type of the method.</param>
/// <param name="address">The start address of the method.</param>
/// <param name="length">The length of the method, in bytes.</param>
/// <param name="function">The BIOS function, if available.</param>
- public Method( MethodType type, uint address, uint length, BiosFunctionToken function )
- : this( type, address, length )
+ public Method( uint moduleId, MethodType type, uint address, uint length, BiosFunctionToken function )
+ : this( moduleId, type, address, length )
{
- Function = function;
+ this.Function = function;
}

/// <summary>

Added: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ModuleInfo.cs
==============================================================================
--- (empty file)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ModuleInfo.cs Sat Mar 29 22:37:34 2008
@@ -0,0 +1,48 @@
+// ----------------------------------------------------------------------------
+// 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.Debugging.DebugModel
+{
+ /// <summary>
+ /// Module info.
+ /// </summary>
+ public class ModuleInfo
+ {
+ /// <summary>
+ /// The ID of the module.
+ /// </summary>
+ public uint ModuleID;
+
+ /// <summary>
+ /// The name of the module.
+ /// </summary>
+ public string Name;
+
+ /// <summary>
+ /// The path of the module file.
+ /// </summary>
+ public string Path;
+
+ /// <summary>
+ /// The entry address, as defined by the module.
+ /// </summary>
+ public uint EntryAddress;
+
+ /// <summary>
+ /// The lower memory address of the module after loading.
+ /// </summary>
+ public uint LowerBounds;
+
+ /// <summary>
+ /// The upper memory address of the module after loading.
+ /// </summary>
+ public uint UpperBounds;
+ }
+}

Modified: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Symbol.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Symbol.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Symbol.cs Sat Mar 29 22:37:34 2008
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using Noxa.Emulation.Psp.Bios;

namespace Noxa.Emulation.Psp.Debugging.DebugModel
{
@@ -17,6 +18,11 @@
public abstract class Symbol
{
/// <summary>
+ /// The module this symbol resides in.
+ /// </summary>
+ public readonly uint ModuleID;
+
+ /// <summary>
/// The start address of the symbol.
/// </summary>
public readonly uint Address;
@@ -29,12 +35,14 @@
/// <summary>
/// Initializes a new <see cref="Symbol"/> instance with the given parameters.
/// </summary>
+ /// <param name="moduleId">The ID of the module the symbol resides in.</param>
/// <param name="address">The start address of the symbol.</param>
/// <param name="length">The length of the symbol, in bytes.</param>
- public Symbol( uint address, uint length )
+ public Symbol( uint moduleId, uint address, uint length )
{
- Address = address;
- Length = length;
+ this.ModuleID = moduleId;
+ this.Address = address;
+ this.Length = length;
}
}
}

Modified: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ThreadInfo.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ThreadInfo.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/ThreadInfo.cs Sat Mar 29 22:37:34 2008
@@ -68,12 +68,33 @@
/// </summary>
public enum ThreadState
{
+ /// <summary>
+ /// The thread is currently running.
+ /// </summary>
Running = 1,
+ /// <summary>
+ /// The thread is ready and waiting to run.
+ /// </summary>
Ready = 2,
+ /// <summary>
+ /// The thread is waiting on something.
+ /// </summary>
Waiting = 4,
+ /// <summary>
+ /// The thread is suspended.
+ /// </summary>
Suspended = 8,
+ /// <summary>
+ /// The thread is suspended while waiting on something.
+ /// </summary>
WaitSuspended = 12,
+ /// <summary>
+ /// The thread is stopped.
+ /// </summary>
Stopped = 16,
+ /// <summary>
+ /// The thread is dead.
+ /// </summary>
Dead = 32,
}

Modified: trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Variable.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Variable.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/DebugModel/Variable.cs Sat Mar 29 22:37:34 2008
@@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
+using Noxa.Emulation.Psp.Bios;

namespace Noxa.Emulation.Psp.Debugging.DebugModel
{
@@ -25,13 +26,14 @@
/// <summary>
/// Initializes a new <see cref="Variable"/> instance with the given parameters.
/// </summary>
+ /// <param name="moduleId">The ID of the module the symbol resides in.</param>
/// <param name="address">The start address of the variable.</param>
/// <param name="length">The length of the variable, in bytes.</param>
/// <param name="name">The name of the method, if available.</param>
- public Variable( uint address, uint length, string name )
- : base( address, length )
+ public Variable( uint moduleId, uint address, uint length, string name )
+ : base( moduleId, address, length )
{
- Name = name;
+ this.Name = name;
}

/// <summary>

Modified: trunk/Noxa.Emulation.Psp/Debugging/Hooks/IBiosHook.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Debugging/Hooks/IBiosHook.cs (original)
+++ trunk/Noxa.Emulation.Psp/Debugging/Hooks/IBiosHook.cs Sat Mar 29 22:37:34 2008
@@ -17,6 +17,8 @@
/// </summary>
public interface IBiosHook : IHook
{
+ #region Threads
+
/// <summary>
/// Gets the ID of the active thread.
/// </summary>
@@ -58,5 +60,17 @@
/// </summary>
/// <param name="threadId">The ID of the thread to kill.</param>
void KillThread( uint threadId );
+
+ #endregion
+
+ #region Modules
+
+ /// <summary>
+ /// Get the information of all loaded modules.
+ /// </summary>
+ /// <returns>Information for the loaded modules.</returns>
+ ModuleInfo[] GetModules();
+
+ #endregion
}
}

Modified: trunk/Noxa.Emulation.Psp/Games/GameLoader.cs
==============================================================================
--- trunk/Noxa.Emulation.Psp/Games/GameLoader.cs (original)
+++ trunk/Noxa.Emulation.Psp/Games/GameLoader.cs Sat Mar 29 22:37:34 2008
@@ -31,68 +31,75 @@
/// Find and retrieve the boot stream for the given game.
/// </summary>
/// <param name="game">Game to look for.</param>
+ /// <param name="filePath">The path of the boot file.</param>
/// <returns>The games boot stream (from BOOT.BIN, etc) or <c>null</c> if it could not be found.</returns>
- public static Stream FindBootStream( GameInformation game )
+ public static Stream FindBootStream( GameInformation game, out string filePath )
{
+ filePath = null;
Debug.Assert( game != null );
if( game == null )
return null;

Stream bootStream = null;
-
- string kernelLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- string prxLocation = Path.Combine(kernelLocation, "BOOT");
+
+ string kernelLocation = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
+ string prxLocation = Path.Combine( kernelLocation, "BOOT" );
// DiscID might be more appropriate than Title
- string lookasideBoot = Path.Combine(Path.Combine(prxLocation, game.Parameters.Title), "BOOT.BIN");
- if (File.Exists(lookasideBoot) == true)
+ string lookasideBoot = Path.Combine( Path.Combine( prxLocation, game.Parameters.Title ), "BOOT.BIN" );
+ if( File.Exists( lookasideBoot ) == true )
{
// Load ours instead
- Log.WriteLine(Verbosity.Normal, Feature.Bios, "Lookaside boot found at {0}", lookasideBoot);
- bootStream = File.OpenRead(lookasideBoot);
+ Log.WriteLine( Verbosity.Normal, Feature.Bios, "Lookaside boot found at {0}", lookasideBoot );
+ bootStream = File.OpenRead( lookasideBoot );
+ filePath = lookasideBoot;
}
else
{
IMediaFolder folder = game.Folder;
- if (folder["PSP_GAME"] != null)
- folder = folder["PSP_GAME"] as IMediaFolder;
- if (folder["SYSDIR"] != null)
- folder = folder["SYSDIR"] as IMediaFolder;
+ if( folder[ "PSP_GAME" ] != null )
+ folder = folder[ "PSP_GAME" ] as IMediaFolder;
+ if( folder[ "SYSDIR" ] != null )
+ folder = folder[ "SYSDIR" ] as IMediaFolder;
IMediaFile bootBin = null;
- bootBin = folder["BOOT.BIN"] as IMediaFile;
- if (bootBin == null)
- bootBin = folder["EBOOT.BIN"] as IMediaFile;
- if (bootBin == null)
- bootBin = folder["BOOT.ELF"] as IMediaFile;
- if (bootBin == null)
- bootBin = folder["EBOOT.ELF"] as IMediaFile;
-
- if (bootBin == null)
+ bootBin = folder[ "BOOT.BIN" ] as IMediaFile;
+ if( bootBin == null )
+ bootBin = folder[ "EBOOT.BIN" ] as IMediaFile;
+ if( bootBin == null )
+ bootBin = folder[ "BOOT.ELF" ] as IMediaFile;
+ if( bootBin == null )
+ bootBin = folder[ "EBOOT.ELF" ] as IMediaFile;
+
+ if( bootBin == null )
{
// Probably in PBP - unless exploited!
- if (folder.Name.Contains("__SCE__") == true)
+ if( folder.Name.Contains( "__SCE__" ) == true )
{
// If this is exploited, the eboot.pbp IS the elf!
- bootStream = (folder["EBOOT.PBP"] as IMediaFile).OpenRead();
+ IMediaFile pbp = folder[ "EBOOT.PBP" ] as IMediaFile;
+ filePath = pbp.AbsolutePath;
+ bootStream = pbp.OpenRead();
}
else
{
- IMediaFile pbp = folder["EBOOT.PBP"] as IMediaFile;
- using (Stream stream = pbp.OpenRead())
+ IMediaFile pbp = folder[ "EBOOT.PBP" ] as IMediaFile;
+ using( Stream stream = pbp.OpenRead() )
{
- PbpReader reader = new PbpReader(stream);
- if (reader.ContainsEntry(PbpReader.PbpEntryType.DataPsp) == true)
+ PbpReader reader = new PbpReader( stream );
+ if( reader.ContainsEntry( PbpReader.PbpEntryType.DataPsp ) == true )
{
- bootStream = reader.Read(stream, PbpReader.PbpEntryType.DataPsp);
+ filePath = pbp.AbsolutePath;
+ bootStream = reader.Read( stream, PbpReader.PbpEntryType.DataPsp );
}
}
}
}
else
{
+ filePath = bootBin.AbsolutePath;
bootStream = bootBin.OpenRead();
}
}
-
+
return bootStream;
}

@@ -309,7 +316,7 @@
{
IMediaFolder folder = device.Root;
IMediaFile umdData = folder[ "UMD_DATA.BIN" ] as IMediaFile;
-
+
//[4 alpha country code]-[4 digit game id]|16 digit binhex|0001|G
// Get code from SFO
string uniqueId;
@@ -321,7 +328,7 @@
}

IMediaFile sfoData = folder.FindFile( @"PSP_GAME\PARAM.SFO" );
-
+
GameParameters gameParams;
using( Stream stream = sfoData.OpenRead() )
gameParams = ReadSfo( stream );
@@ -389,7 +396,7 @@
gp.Region = ( int )reader[ "REGION" ].Data;
if( reader[ "LANGUAGE" ] != null )
gp.Language = reader[ "LANGUAGE" ].Data as string;
-
+
return gp;
}

Modified: trunk/Noxa.Emulation.Psp/Noxa.Emulation.Psp.csproj
==============================================================================
--- trunk/Noxa.Emulation.Psp/Noxa.Emulation.Psp.csproj (original)
+++ trunk/Noxa.Emulation.Psp/Noxa.Emulation.Psp.csproj Sat Mar 29 22:37:34 2008
@@ -72,6 +72,7 @@
<Compile Include="Debugging\DebugModel\Breakpoint.cs" />
<Compile Include="Debugging\DebugModel\CpuError.cs" />
<Compile Include="Debugging\DebugModel\MemoryError.cs" />
+ <Compile Include="Debugging\DebugModel\ModuleInfo.cs" />
<Compile Include="Debugging\DebugModel\Symbol.cs" />
<Compile Include="Debugging\DebugModel\ThreadInfo.cs" />
<Compile Include="Debugging\DebugModel\Variable.cs" />

Reply all
Reply to author
Forward
0 new messages