2013-04-17 22:43:11 -04:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include <cstdlib>
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/Common.h"
|
|
|
|
#include "Common/FileUtil.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-07-08 14:29:26 +02:00
|
|
|
#include "Core/Core.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/Tracer.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
namespace Core {
|
2009-02-20 22:04:52 +00:00
|
|
|
|
2014-07-08 15:58:25 +02:00
|
|
|
static File::IOFile tracefile;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-07-08 15:58:25 +02:00
|
|
|
static bool bReadTrace = false;
|
|
|
|
static bool bWriteTrace = false;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
void StartTrace(bool write)
|
|
|
|
{
|
|
|
|
if (write)
|
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
tracefile.Open("L:\\trace.dat", "wb");
|
2008-12-08 05:30:24 +00:00
|
|
|
bReadTrace = false;
|
|
|
|
bWriteTrace = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
tracefile.Open("L:\\trace.dat", "rb");
|
2008-12-08 05:30:24 +00:00
|
|
|
bReadTrace = true;
|
|
|
|
bWriteTrace = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopTrace()
|
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
tracefile.Close();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
static int stateSize = 32*4;// + 32*16 + 6*4;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
int SyncTrace()
|
|
|
|
{
|
|
|
|
if (bWriteTrace)
|
|
|
|
{
|
2011-03-11 10:21:46 +00:00
|
|
|
tracefile.WriteBytes(&PowerPC::ppcState, stateSize);
|
|
|
|
tracefile.Flush();
|
2008-12-08 05:30:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (bReadTrace)
|
|
|
|
{
|
|
|
|
PowerPC::PowerPCState state;
|
2011-03-11 10:21:46 +00:00
|
|
|
if (!tracefile.ReadBytes(&state, stateSize))
|
2008-12-08 05:30:24 +00:00
|
|
|
return 1;
|
2011-03-11 10:21:46 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
bool difference = false;
|
|
|
|
for (int i=0; i<32; i++)
|
|
|
|
{
|
|
|
|
if (PowerPC::ppcState.gpr[i] != state.gpr[i])
|
|
|
|
{
|
2009-05-01 15:17:03 +00:00
|
|
|
DEBUG_LOG(POWERPC, "DIFFERENCE - r%i (local %08x, remote %08x)", i, PowerPC::ppcState.gpr[i], state.gpr[i]);
|
2008-12-08 05:30:24 +00:00
|
|
|
difference = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
for (int i=0; i<32; i++)
|
|
|
|
{
|
|
|
|
for (int j=0; j<2; j++)
|
|
|
|
{
|
|
|
|
if (PowerPC::ppcState.ps[i][j] != state.ps[i][j])
|
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - ps%i_%i (local %f, remote %f)", i, j, PowerPC::ppcState.ps[i][j], state.ps[i][j]);
|
|
|
|
difference = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
/*
|
2008-12-15 19:40:12 +00:00
|
|
|
if (GetCR() != state.cr)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - CR (local %08x, remote %08x)", PowerPC::ppcState.cr, state.cr);
|
|
|
|
difference = true;
|
|
|
|
}
|
|
|
|
if (PowerPC::ppcState.pc != state.pc)
|
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - PC (local %08x, remote %08x)", PowerPC::ppcState.pc, state.pc);
|
|
|
|
difference = true;
|
|
|
|
}
|
2013-04-16 23:14:36 -04:00
|
|
|
if (PowerPC::ppcState.npc != state.npc)
|
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - NPC (local %08x, remote %08x)", PowerPC::ppcState.npc, state.npc);
|
|
|
|
difference = true;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
if (PowerPC::ppcState.msr != state.msr)
|
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - MSR (local %08x, remote %08x)", PowerPC::ppcState.msr, state.msr);
|
|
|
|
difference = true;
|
|
|
|
}
|
|
|
|
if (PowerPC::ppcState.fpscr != state.fpscr)
|
|
|
|
{
|
|
|
|
LOG(GEKKO, "DIFFERENCE - FPSCR (local %08x, remote %08x)", PowerPC::ppcState.fpscr, state.fpscr);
|
|
|
|
difference = true;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (difference)
|
|
|
|
{
|
|
|
|
Host_UpdateLogDisplay();
|
|
|
|
//Also show drec compare window here
|
|
|
|
//CDynaViewDlg::Show(true);
|
|
|
|
//CDynaViewDlg::ViewAddr(m_BlockStart);
|
|
|
|
//CDynaViewDlg::Show(true);
|
|
|
|
//PanicAlert("Hang on");
|
|
|
|
//Sleep(INFINITE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
//LOG(GEKKO, "No difference!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
} // end of namespace Core
|