Exemple #1
0
void DebuggerPanel::HandleCommand(wxCommandEvent& event)
{
	PPCThread* thr = (PPCThread*)event.GetClientData();

	switch(event.GetId())
	{
	case DID_CREATE_THREAD:
		m_nb->AddPage(new InterpreterDisAsmFrame(m_nb, thr), thr->GetFName());
	break;

	case DID_REMOVE_THREAD:
		for(uint i=0; i<m_nb->GetPageCount(); ++i)
		{
			InterpreterDisAsmFrame* page = (InterpreterDisAsmFrame*)m_nb->GetPage(i);

			if(page->CPU.GetId() == thr->GetId())
			{
				m_nb->DeletePage(i);
				break;
			}
		}
	break;
	}

	event.Skip();
}
void PPCThreadManager::RemoveThread(const u32 id)
{
	std::lock_guard<std::mutex> lock(m_mtx_thread);

	for(u32 i=0; i<m_threads.GetCount(); ++i)
	{
		if(m_threads[i].m_wait_thread_id == id)
		{
			m_threads[i].Wait(false);
			m_threads[i].m_wait_thread_id = -1;
		}

		if(m_threads[i].GetId() != id) continue;

		PPCThread* thr = &m_threads[i];
		wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr);
		if(thr->IsAlive())
		{
			thr->Close();
		}
		else
		{
			thr->Close();
			delete thr;
		}


		m_threads.RemoveFAt(i);
		i--;
	}

	Emu.GetIdManager().RemoveID(id, false);
	Emu.CheckStatus();
}
Exemple #3
0
PPUThread& GetCurrentPPUThread()
{
	PPCThread* thread = GetCurrentPPCThread();

	if(!thread || thread->GetType() != CPU_THREAD_PPU) throw std::string("GetCurrentPPUThread: bad thread");

	return *(PPUThread*)thread;
}
Exemple #4
0
int sys_process_is_stack(u32 p)
{
	PPCThread* CPU = GetCurrentPPCThread();
	if (p >= CPU->GetStackAddr() && p <= CPU->GetStackAddr() + CPU->GetStackSize())
		return 1;

	return 0;
}
Exemple #5
0
SPUThread& GetCurrentSPUThread()
{
	PPCThread* thread = GetCurrentPPCThread();

	if(!thread || (thread->GetType() != CPU_THREAD_SPU && thread->GetType() != CPU_THREAD_RAW_SPU))
	{
		throw wxString("GetCurrentSPUThread: bad thread");
	}

	return *(SPUThread*)thread;
}
Exemple #6
0
int sys_ppu_thread_stop(u32 thread_id)
{
	sysPrxForUser.Warning("sys_ppu_thread_stop(thread_id=%d)", thread_id);

	PPCThread* thr = Emu.GetCPU().GetThread(thread_id);
	if(!thr) return CELL_ESRCH;

	thr->Stop();

	return CELL_OK;
}
Exemple #7
0
int sys_ppu_thread_set_priority(u32 thread_id, int prio)
{
	sysPrxForUser.Warning("sys_ppu_thread_set_priority(thread_id=%d, prio=%d)", thread_id, prio);

	PPCThread* thr = Emu.GetCPU().GetThread(thread_id);
	if(!thr) return CELL_ESRCH;

	thr->SetPrio(prio);

	return CELL_OK;
}
Exemple #8
0
int sys_ppu_thread_get_priority(u32 thread_id, u32 prio_addr)
{
	sysPrxForUser.Log("sys_ppu_thread_get_priority(thread_id=%d, prio_addr=0x%x)", thread_id, prio_addr);

	PPCThread* thr = Emu.GetCPU().GetThread(thread_id);
	if(!thr) return CELL_ESRCH;
	if(!Memory.IsGoodAddr(prio_addr)) return CELL_EFAULT;

	Memory.Write32(prio_addr, thr->GetPrio());

	return CELL_OK;
}
Exemple #9
0
//181
int sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type)
{
	sc_spu.Warning("sys_spu_thread_write_ls(id=0x%x, address=0x%x, value=0x%llx, type=0x%x)",
		id, address, value, type);

	PPCThread* thr = Emu.GetCPU().GetThread(id);

	if(!thr || thr->GetType() == PPC_THREAD_PPU)
	{
		return CELL_ESRCH;
	}

	(*(SPUThread*)thr).WriteLS64(address, value);

	return CELL_OK;
}
Exemple #10
0
//190
int sys_spu_thread_write_spu_mb(u32 id, u32 value)
{
	sc_spu.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x)", id, value);

	PPCThread* thr = Emu.GetCPU().GetThread(id);

	if(!thr || !thr->GetType() == PPC_THREAD_PPU)
	{
		return CELL_ESRCH;
	}

	if(!(*(SPUThread*)thr).mfc.SPU_In_MBox.Push(value))
	{
		ConLog.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x): used all mbox items.");
		return CELL_EBUSY; //?
	}

	return CELL_OK;
}
Exemple #11
0
//182
int sys_spu_thread_read_ls(u32 id, u32 address, u32 value_addr, u32 type)
{
	sc_spu.Warning("sys_spu_thread_read_ls(id=0x%x, address=0x%x, value_addr=0x%x, type=0x%x)",
		id, address, value_addr, type);

	PPCThread* thr = Emu.GetCPU().GetThread(id);

	if(!thr || thr->GetType() == PPC_THREAD_PPU)
	{
		return CELL_ESRCH;
	}

	if(!(*(SPUThread*)thr).IsGoodLSA(address))
	{
		return CELL_EFAULT;
	}

	Memory.Write64(value_addr, (*(SPUThread*)thr).ReadLS64(address));

	return CELL_OK;
}
Exemple #12
0
//166
int sys_spu_thread_set_argument(u32 id, u32 arg_addr)
{
	sc_spu.Warning("sys_spu_thread_set_argument(id=0x%x, arg_addr=0x%x)", id, arg_addr);
	PPCThread* thr = Emu.GetCPU().GetThread(id);

	if(!thr || thr->GetType() == PPC_THREAD_PPU)
	{
		return CELL_ESRCH;
	}

	if(!Memory.IsGoodAddr(arg_addr, sizeof(sys_spu_thread_argument)))
	{
		return CELL_EFAULT;
	}

	auto& arg = (sys_spu_thread_argument&)Memory[arg_addr];
	thr->SetArg(0, re(arg.arg1));
	thr->SetArg(1, re(arg.arg2));
	thr->SetArg(2, re(arg.arg3));
	thr->SetArg(3, re(arg.arg4));

	return CELL_OK;
}
void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
{
	PPCThread* thr = (PPCThread*)event.GetClientData();
	event.Skip();

	if(!thr)
	{
		switch(event.GetId())
		{
		case DID_STOPPED_EMU:
			UpdateUnitList();
		break;

		case DID_PAUSED_EMU:
			//DoUpdate();
		break;
		}
	}
	else if(CPU && thr->GetId() == CPU->GetId())
	{
		switch(event.GetId())
		{
		case DID_PAUSE_THREAD:
			m_btn_run->Disable();
			m_btn_step->Disable();
			m_btn_pause->Disable();
		break;

		case DID_PAUSED_THREAD:
			m_btn_run->Enable();
			m_btn_step->Enable();
			m_btn_pause->Disable();
			DoUpdate();
		break;

		case DID_START_THREAD:
		case DID_EXEC_THREAD:
		case DID_RESUME_THREAD:
			m_btn_run->Disable();
			m_btn_step->Disable();
			m_btn_pause->Enable();
		break;

		case DID_REMOVE_THREAD:
		case DID_STOP_THREAD:
			m_btn_run->Disable();
			m_btn_step->Disable();
			m_btn_pause->Disable();

			if(event.GetId() == DID_REMOVE_THREAD)
			{
				//m_choice_units->SetSelection(-1);
				//wxCommandEvent event;
				//event.SetInt(-1);
				//event.SetClientData(nullptr);
				//OnSelectUnit(event);
				UpdateUnitList();
				//DoUpdate();
			}
		break;
		}
	}
	else
	{
		switch(event.GetId())
		{
		case DID_CREATE_THREAD:
			UpdateUnitList();
			if(m_choice_units->GetSelection() == -1)
			{
				//m_choice_units->SetSelection(0);
				//wxCommandEvent event;
				//event.SetInt(0);
				//event.SetClientData(&Emu.GetCPU().GetThreads()[0]);
				//OnSelectUnit(event);
			}
		break;

		case DID_REMOVED_THREAD:
			UpdateUnitList();
		break;
		}
	}
}