Implemented basic Step and RunTo functionality in the debug mode. Still very simple and probably bugged/incomplete. Just need to make some story in the svn, before doing some new big work. :D

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4121 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
feal87@gmail.com 2010-12-22 09:19:58 +00:00
parent e085883e1c
commit 0962198a3b
5 changed files with 171 additions and 14 deletions

View File

@ -9,6 +9,7 @@ using System.Diagnostics;
using GSDumpGUI.Properties;
using System.IO;
using TCPLibrary.MessageBased.Core;
using System.Drawing;
namespace GSDumpGUI
{
@ -23,6 +24,8 @@ namespace GSDumpGUI
static private GSDump dump;
static private GSDXWrapper wrap;
static private TreeNode CurrentNode;
[STAThread]
static void Main(String[] args)
{
@ -43,15 +46,16 @@ namespace GSDumpGUI
{
while (true)
{
IntPtr pt = Process.GetCurrentProcess().MainWindowHandle;
if (ChangeIcon)
{
IntPtr pt = Process.GetCurrentProcess().MainWindowHandle;
if (pt.ToInt64() != 0)
{
NativeMethods.SetClassLong(pt, -14, Resources.AppIcon.Handle.ToInt64());
ChangeIcon = false;
}
}
Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
if (tmp != 0)
Process.GetCurrentProcess().Kill();
@ -178,13 +182,20 @@ namespace GSDumpGUI
switch (parts[1])
{
case "Transfer":
nodes.Add(new TreeNode(parts[0] + " - " + parts[1] + " - " + parts[2]));
TreeNode tn2 = new TreeNode();
tn2.Name = parts[0];
tn2.Text = parts[0] + " - " + parts[1] + " - " + parts[2];
nodes.Add(tn2);
break;
case "ReadFIFO2":
nodes.Add(new TreeNode(parts[0] + " - " + parts[1]));
TreeNode tn3 = new TreeNode();
tn3.Name = parts[0];
tn3.Text = parts[0] + " - " + parts[1];
nodes.Add(tn3);
break;
case "VSync":
TreeNode tn = new TreeNode();
tn.Name = parts[0];
tn.Text = parts[0] + " - " + parts[1];
tn.Nodes.AddRange(nodes.ToArray());
parents.Add(tn);
@ -192,13 +203,32 @@ namespace GSDumpGUI
nodes.Clear();
break;
case "Registers":
nodes.Add(new TreeNode(parts[0] + " - " + parts[1]));
TreeNode tn4 = new TreeNode();
tn4.Name = parts[0];
tn4.Text = parts[0] + " - " + parts[1];
nodes.Add(tn4);
break;
}
}
frmMain.treTreeView.Nodes.AddRange(parents.ToArray());
}), new object[] { null });
break;
case MessageType.Step:
case MessageType.RunToCursor:
frmMain.Invoke(new Action<object>(delegate(object e)
{
int idtoselect = (int)Mess.Parameters[0];
TreeNode[] noes = frmMain.treTreeView.Nodes.Find(idtoselect.ToString(), true);
if (noes.Length > 0)
{
if (CurrentNode != null)
CurrentNode.BackColor = Color.White;
noes[0].BackColor = Color.LightBlue;
CurrentNode = noes[0];
frmMain.treTreeView.SelectedNode = noes[0];
}
}), new object[] { null });
break;
default:
break;
}
@ -261,6 +291,11 @@ namespace GSDumpGUI
msg.MessageType = MessageType.DebugState;
msg.Parameters.AddRange(wrap.GetGifPackets(dump));
Client.Send(msg);
msg = new TCPMessage();
msg.MessageType = MessageType.Step;
msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket));
Client.Send(msg);
}
break;
case MessageType.GetDebugMode:
@ -275,9 +310,25 @@ namespace GSDumpGUI
msg.MessageType = MessageType.DebugState;
msg.Parameters.AddRange(wrap.GetGifPackets(dump));
Client.Send(msg);
msg = new TCPMessage();
msg.MessageType = MessageType.Step;
msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket));
Client.Send(msg);
}
break;
case MessageType.Step:
wrap.ExternalEvent.WaitOne();
wrap.ExternalEvent.Reset();
wrap.QueueMessage.Enqueue(Mess);
wrap.ThereIsWork = true;
break;
case MessageType.RunToCursor:
wrap.ExternalEvent.WaitOne();
wrap.ExternalEvent.Reset();
wrap.QueueMessage.Enqueue(Mess);
wrap.ThereIsWork = true;
break;
default:
break;
}

View File

@ -410,12 +410,22 @@ namespace GSDumpGUI
private void btnStep_Click(object sender, EventArgs e)
{
MessageBox.Show("Not Implemented");
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.Step;
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
private void btnRunToSelection_Click(object sender, EventArgs e)
{
MessageBox.Show("Not Implemented");
if (treTreeView.SelectedNode != null)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.RunToCursor;
msg.Parameters.Add(Convert.ToInt32(treTreeView.SelectedNode.Text.Split(new string[]{" - "}, StringSplitOptions.None)[0]));
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
else
MessageBox.Show("You have not selected a node to jump to");
}
}
}

View File

@ -51,10 +51,12 @@ namespace GSDumpGUI
private Boolean Running;
public List<TCPMessage> QueueMessage;
public Queue<TCPMessage> QueueMessage;
public Boolean DebugMode;
public GSData CurrentGIFPacket;
public AutoResetEvent Event;
public bool ThereIsWork;
public AutoResetEvent ExternalEvent;
public int RunTo;
static public Boolean IsValidGSDX(String DLL)
{
@ -175,9 +177,9 @@ namespace GSDumpGUI
public unsafe void Run(GSDump dump, int rendererOverride)
{
QueueMessage = new List<TCPMessage>();
QueueMessage = new Queue<TCPMessage>();
Running = true;
Event = new AutoResetEvent(true);
ExternalEvent = new AutoResetEvent(true);
GSinit();
fixed (byte* pointer = dump.Registers)
@ -210,13 +212,76 @@ namespace GSDumpGUI
break;
}
foreach (var itm in dump.Data)
for (int i = 0; i < dump.Data.Count; i++)
{
GSData itm = dump.Data[i];
CurrentGIFPacket = itm;
if (DebugMode)
{
if (RunTo != -1)
{
if (i == RunTo)
{
RunTo = -1;
TCPMessage Msg = new TCPMessage();
Msg.MessageType = MessageType.RunToCursor;
Msg.Parameters.Add(i);
Program.Client.Send(Msg);
ExternalEvent.Set();
}
else
{
Step(itm, pointer);
}
}
else
{
while (!ThereIsWork && Running)
{
NativeMessage message;
while (NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 1))
{
if (!NativeMethods.IsWindowVisible(new IntPtr(HWND)))
{
Running = false;
}
NativeMethods.TranslateMessage(ref message);
NativeMethods.DispatchMessage(ref message);
}
}
ThereIsWork = false;
if (QueueMessage.Count > 0)
{
TCPMessage Mess = QueueMessage.Dequeue();
if (Mess.MessageType == MessageType.Step)
{
Step(itm, pointer);
TCPMessage Msg = new TCPMessage();
Msg.MessageType = MessageType.Step;
Msg.Parameters.Add(i);
Program.Client.Send(Msg);
ExternalEvent.Set();
}
else
if (Mess.MessageType == MessageType.RunToCursor)
{
RunTo = (int)Mess.Parameters[0];
}
}
}
}
else
{
Step(itm, pointer);
}
}
}
GSclose();
GSshutdown();

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
using System.Drawing;
namespace GSDumpGUI
{
@ -39,5 +40,32 @@ namespace GSDumpGUI
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32", CharSet = CharSet.Ansi)]
public extern static bool IsWindowVisible(IntPtr HWND);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PeekMessage(out NativeMessage message, IntPtr hwnd, uint messageFilterMin, uint messageFilterMax, uint flags);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TranslateMessage(ref NativeMessage message);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DispatchMessage(ref NativeMessage message);
}
[StructLayout(LayoutKind.Sequential)]
public struct NativeMessage
{
public IntPtr hWnd;
public uint msg;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public Point p;
}
}

View File

@ -115,6 +115,9 @@ namespace TCPLibrary.MessageBased.Core
GetDebugMode,
SetDebugMode,
DebugState
DebugState,
Step,
RunToCursor
}
}