Beispiel #1
0
void CPUThread::Task()
{
	//ConLog.Write("%s enter", CPUThread::GetFName());

	const Array<u64>& bp = Emu.GetBreakPoints();

	try
	{
		for(uint i=0; i<bp.GetCount(); ++i)
		{
			if(bp[i] == m_offset + PC)
			{
				Emu.Pause();
				break;
			}
		}

		while(true)
		{
			int status = ThreadStatus();

			if(status == CPUThread_Stopped || status == CPUThread_Break)
			{
				break;
			}

			if(status == CPUThread_Sleeping)
			{
				Sleep(1);
				continue;
			}

			NextPc(m_dec->DecodeMemory(PC + m_offset));

			if(status == CPUThread_Step)
			{
				m_is_step = false;
				break;
			}

			for(uint i=0; i<bp.GetCount(); ++i)
			{
				if(bp[i] == m_offset + PC)
				{
					Emu.Pause();
					break;
				}
			}
		}
	}
	catch(const wxString& e)
	{
		ConLog.Error("Exception: %s", e);
	}
	catch(const char* e)
	{
		ConLog.Error("Exception: %s", e);
	}

	//ConLog.Write("%s leave", CPUThread::GetFName());

	if(m_free_data)
		free(this);
}
Beispiel #2
0
void RawSPUThread::Task()
{
	if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", PPCThread::GetFName().c_str());

	const Array<u64>& bp = Emu.GetBreakPoints();

	try
	{
		for(uint i=0; i<bp.GetCount(); ++i)
		{
			if(bp[i] == m_offset + PC)
			{
				Emu.Pause();
				break;
			}
		}

		bool is_last_paused = true;

		while(true)
		{
			int status = ThreadStatus();

			if(status == CPUThread_Stopped || status == CPUThread_Break)
			{
				break;
			}

			if(status == CPUThread_Sleeping)
			{
				Sleep(1);
				continue;
			}

			//dmac.DoCmd();

			if(SPU.RunCntl.GetValue() != SPU_RUNCNTL_RUNNABLE)
			{
				if(!is_last_paused)
				{
					is_last_paused = true;
					SPU.NPC.SetValue(PC);
					SPU.Status.SetValue(SPU_STATUS_WAITING_FOR_CHANNEL);
				}

				Sleep(1);
				continue;
			}

			if(is_last_paused)
			{
				is_last_paused = false;
				PC = SPU.NPC.GetValue();
				SPU.Status.SetValue(SPU_STATUS_RUNNING);
				ConLog.Warning("Starting RawSPU...");
			}

			Step();
			NextPc(m_dec->DecodeMemory(PC + m_offset));

			if(status == CPUThread_Step)
			{
				m_is_step = false;
				continue;
			}

			for(uint i=0; i<bp.GetCount(); ++i)
			{
				if(bp[i] == PC)
				{
					Emu.Pause();
					continue;
				}
			}
		}
	}
	catch(const std::string& e)
	{
		ConLog.Error("Exception: %s", e.c_str());
	}
	catch(const char* e)
	{
		ConLog.Error("Exception: %s", e);
	}

	if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", PPCThread::GetFName().c_str());
}
Beispiel #3
0
void CPUThread::Task()
{
	if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", CPUThread::GetFName().wx_str());

	const Array<u64>& bp = Emu.GetBreakPoints();

	try
	{
		for(uint i=0; i<bp.GetCount(); ++i)
		{
			if(bp[i] == m_offset + PC)
			{
				Emu.Pause();
				break;
			}
		}

		while(true)
		{
			int status = ThreadStatus();

			if(status == CPUThread_Stopped || status == CPUThread_Break)
			{
				break;
			}

			if(status == CPUThread_Sleeping)
			{
				Sleep(1);
				continue;
			}

			Step();
			NextPc(m_dec->DecodeMemory(PC + m_offset));

			if(status == CPUThread_Step)
			{
				m_is_step = false;
				break;
			}

			for(uint i=0; i<bp.GetCount(); ++i)
			{
				if(bp[i] == PC)
				{
					Emu.Pause();
					break;
				}
			}
		}
	}
	catch(const wxString& e)
	{
		ConLog.Error("Exception: %s", e.wx_str());
	}
	catch(const char* e)
	{
		ConLog.Error("Exception: %s", wxString(e).wx_str());
	}
	catch(int exitcode)
	{
		ConLog.Success("Exit Code: %d", exitcode);
	}

	if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", CPUThread::GetFName().wx_str());
}
Beispiel #4
0
void CPUThread::Task()
{
	if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s enter", CPUThread::GetFName().c_str());

	const std::vector<u64>& bp = Emu.GetBreakPoints();

	for (uint i = 0; i<bp.size(); ++i)
	{
		if (bp[i] == m_offset + PC)
		{
			Emu.Pause();
			break;
		}
	}

	std::vector<u32> trace;

	while (true)
	{
		int status = ThreadStatus();

		if (status == CPUThread_Stopped || status == CPUThread_Break)
		{
			break;
		}

		if (status == CPUThread_Sleeping)
		{
			std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
			continue;
		}

		Step();
		//if (m_trace_enabled)
		//trace.push_back(PC);
		NextPc(m_dec->DecodeMemory(PC + m_offset));

		if (status == CPUThread_Step)
		{
			m_is_step = false;
			break;
		}

		for (uint i = 0; i < bp.size(); ++i)
		{
			if (bp[i] == PC)
			{
				Emu.Pause();
				break;
			}
		}
	}

	if (trace.size())
	{
		LOG_NOTICE(GENERAL, "Trace begin (%d elements)", trace.size());

		u32 start = trace[0], prev = trace[0] - 4;

		for (auto& v : trace) //LOG_NOTICE(GENERAL, "PC = 0x%x", v);
		{
			if (v - prev != 4 && v - prev != 2)
			{
				LOG_NOTICE(GENERAL, "Trace: 0x%08x .. 0x%08x", start, prev);
				start = v;
			}
			prev = v;
		}

		LOG_NOTICE(GENERAL, "Trace end: 0x%08x .. 0x%08x", start, prev);
	}

	if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s leave", CPUThread::GetFName().c_str());
}
Beispiel #5
0
void CPUThread::Task()
{
	if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s enter", CPUThread::GetFName().c_str());

	const std::vector<u64>& bp = Emu.GetBreakPoints();

	for (uint i = 0; i<bp.size(); ++i)
	{
		if (bp[i] == m_offset + PC)
		{
			Emu.Pause();
			break;
		}
	}

	std::vector<u32> trace;

#ifdef _WIN32
	auto old_se_translator = _set_se_translator(_se_translator);
#else
	// TODO: linux version
#endif

	try
	{
		while (true)
		{
			int status = ThreadStatus();

			if (status == CPUThread_Stopped || status == CPUThread_Break)
			{
				break;
			}

			if (status == CPUThread_Sleeping)
			{
				std::this_thread::sleep_for(std::chrono::milliseconds(1));
				continue;
			}

			Step();
			//if (m_trace_enabled) trace.push_back(PC);
			NextPc(m_dec->DecodeMemory(PC + m_offset));

			if (status == CPUThread_Step)
			{
				m_is_step = false;
				break;
			}

			for (uint i = 0; i < bp.size(); ++i)
			{
				if (bp[i] == PC)
				{
					Emu.Pause();
					break;
				}
			}
		}
	}
	catch (const std::string& e)
	{
		LOG_ERROR(GENERAL, "Exception: %s", e.c_str());
		Emu.Pause();
	}
	catch (const char* e)
	{
		LOG_ERROR(GENERAL, "Exception: %s", e);
		Emu.Pause();
	}

#ifdef _WIN32
	_set_se_translator(old_se_translator);
#else
	// TODO: linux version
#endif

	if (trace.size())
	{
		LOG_NOTICE(GENERAL, "Trace begin (%d elements)", trace.size());

		u32 start = trace[0], prev = trace[0] - 4;

		for (auto& v : trace) //LOG_NOTICE(GENERAL, "PC = 0x%x", v);
		{
			if (v - prev != 4)
			{
				LOG_NOTICE(GENERAL, "Trace: 0x%08x .. 0x%08x", start, prev);
				start = v;
			}
			prev = v;
		}

		LOG_NOTICE(GENERAL, "Trace end: 0x%08x .. 0x%08x", start, prev);
	}


	if (Ini.HLELogging.GetValue()) LOG_NOTICE(GENERAL, "%s leave", CPUThread::GetFName().c_str());
}
Beispiel #6
0
/// Puts the current thread in the wait state for the given type
void WaitCurrentThread(WaitType wait_type, Handle wait_handle) {
    Thread* thread = GetCurrentThread();
    thread->wait_type = wait_type;
    thread->wait_handle = wait_handle;
    ChangeThreadState(thread, ThreadStatus(THREADSTATUS_WAIT | (thread->status & THREADSTATUS_SUSPEND)));
}
Beispiel #7
0
void CPUThread::Task()
{
	if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s enter", CPUThread::GetFName().c_str());

	const std::vector<u64>& bp = Emu.GetBreakPoints();

	for (uint i = 0; i<bp.size(); ++i)
	{
		if (bp[i] == m_offset + PC)
		{
			Emu.Pause();
			break;
		}
	}

	std::vector<u64> trace;

#ifdef _WIN32
	_set_se_translator(_se_translator);
#else
	// TODO: linux version
#endif

	while (true)
	{
		int status = ThreadStatus();

		if (status == CPUThread_Stopped || status == CPUThread_Break)
		{
			break;
		}

		if (status == CPUThread_Sleeping)
		{
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
			continue;
		}

		Step();
		//if (PC - 0x13ED4 < 0x288) trace.push_back(PC);
		NextPc(m_dec->DecodeMemory(PC + m_offset));

		if (status == CPUThread_Step)
		{
			m_is_step = false;
			break;
		}

		for (uint i = 0; i < bp.size(); ++i)
		{
			if (bp[i] == PC)
			{
				Emu.Pause();
				break;
			}
		}
	}

	for (auto& v : trace) LOG_NOTICE(PPU, "PC = 0x%llx", v);

	if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s leave", CPUThread::GetFName().c_str());
}