Fixed minor Debugger errors.

This commit is contained in:
DH 2013-10-06 18:05:58 +03:00
parent 8259006bc3
commit 64cd9746b8
5 changed files with 32 additions and 46 deletions

View File

@ -8,7 +8,7 @@ PPCThread* GetCurrentPPCThread()
} }
PPCThread::PPCThread(PPCThreadType type) PPCThread::PPCThread(PPCThreadType type)
: ThreadBase(true, "PPCThread") : ThreadBase(false, "PPCThread")
, m_type(type) , m_type(type)
, DisAsmFrame(nullptr) , DisAsmFrame(nullptr)
, m_dec(nullptr) , m_dec(nullptr)
@ -124,6 +124,11 @@ bool PPCThread::Sync()
int PPCThread::ThreadStatus() int PPCThread::ThreadStatus()
{ {
if(m_is_step)
{
return PPCThread_Step;
}
if(Emu.IsStopped()) if(Emu.IsStopped())
{ {
return PPCThread_Stopped; return PPCThread_Stopped;
@ -277,6 +282,7 @@ void PPCThread::Stop()
void PPCThread::Exec() void PPCThread::Exec()
{ {
m_is_step = false;
wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this); wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this);
ThreadBase::Start(); ThreadBase::Start();
//std::thread thr(std::bind(std::mem_fn(&PPCThread::Task), this)); //std::thread thr(std::bind(std::mem_fn(&PPCThread::Task), this));
@ -284,8 +290,12 @@ void PPCThread::Exec()
void PPCThread::ExecOnce() void PPCThread::ExecOnce()
{ {
DoCode(Memory.Read32(m_offset + PC)); m_is_step = true;
NextPc(); wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this);
ThreadBase::Start();
if(!ThreadBase::Wait()) while(m_is_step) Sleep(1);
wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, this);
wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
} }
void PPCThread::Task() void PPCThread::Task()
@ -323,6 +333,12 @@ void PPCThread::Task()
DoCode(Memory.Read32(m_offset + PC)); DoCode(Memory.Read32(m_offset + PC));
NextPc(); NextPc();
if(status == PPCThread_Step)
{
m_is_step = false;
break;
}
for(uint i=0; i<bp.GetCount(); ++i) for(uint i=0; i<bp.GetCount(); ++i)
{ {
if(bp[i] == m_offset + PC) if(bp[i] == m_offset + PC)

View File

@ -17,6 +17,7 @@ enum PPCThreadStatus
PPCThread_Stopped, PPCThread_Stopped,
PPCThread_Sleeping, PPCThread_Sleeping,
PPCThread_Break, PPCThread_Break,
PPCThread_Step,
}; };
class PPCThread : public ThreadBase class PPCThread : public ThreadBase
@ -36,6 +37,7 @@ protected:
u64 m_offset; u64 m_offset;
u32 m_exit_status; u32 m_exit_status;
bool m_free_data; bool m_free_data;
bool m_is_step;
public: public:
u64 stack_size; u64 stack_size;

View File

@ -90,10 +90,10 @@ void InstructionEditorDialog::updatePreview(wxCommandEvent& event)
unsigned long opcode; unsigned long opcode;
if (t2_instr->GetValue().ToULong(&opcode, 16)) if (t2_instr->GetValue().ToULong(&opcode, 16))
{ {
disasm->dump_pc = pc;
decoder->Decode((u32)opcode); decoder->Decode((u32)opcode);
wxString preview = disasm->last_opcode; wxString preview = disasm->last_opcode;
while (preview[0] != ':') preview.Remove(0,1); preview.Remove(0, preview.Find(':') + 1);
preview.Remove(0,1);
t3_preview->SetLabel(preview); t3_preview->SetLabel(preview);
} }
else else

View File

@ -13,7 +13,6 @@ u64 InterpreterDisAsmFrame::CentrePc(const u64 pc) const
InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent) InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(500, 700), wxTAB_TRAVERSAL) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(500, 700), wxTAB_TRAVERSAL)
, ThreadBase(false, "DisAsmFrame Thread")
, PC(0) , PC(0)
, CPU(nullptr) , CPU(nullptr)
, m_item_count(30) , m_item_count(30)
@ -84,7 +83,6 @@ InterpreterDisAsmFrame::InterpreterDisAsmFrame(wxWindow* parent)
InterpreterDisAsmFrame::~InterpreterDisAsmFrame() InterpreterDisAsmFrame::~InterpreterDisAsmFrame()
{ {
ThreadBase::Stop();
} }
void InterpreterDisAsmFrame::UpdateUnitList() void InterpreterDisAsmFrame::UpdateUnitList()
@ -443,13 +441,17 @@ void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event)) void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
{ {
ThreadBase::Start(); if(CPU) CPU->ExecOnce();
} }
void InterpreterDisAsmFrame::InstrKey(wxListEvent& event) void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)
{ {
long i = m_list->GetFirstSelected(); long i = m_list->GetFirstSelected();
if(i < 0 || !CPU) return; if(i < 0 || !CPU)
{
event.Skip();
return;
}
const u64 start_pc = PC - m_item_count*4; const u64 start_pc = PC - m_item_count*4;
const u64 pc = start_pc + i*4; const u64 pc = start_pc + i*4;
@ -465,6 +467,8 @@ void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)
DoUpdate(); DoUpdate();
return; return;
} }
event.Skip();
} }
void InterpreterDisAsmFrame::DClick(wxListEvent& event) void InterpreterDisAsmFrame::DClick(wxListEvent& event)
@ -530,35 +534,3 @@ bool InterpreterDisAsmFrame::RemoveBreakPoint(u64 pc)
return false; return false;
} }
void InterpreterDisAsmFrame::Task()
{
if(!CPU) return;
wxGetApp().SendDbgCommand(DID_RESUME_THREAD, CPU);
wxGetApp().SendDbgCommand(DID_RESUMED_THREAD, CPU);
bool dump_status = dump_enable;
//CPU.InitTls();
try
{
do
{
CPU->ExecOnce();
}
while(CPU->IsRunning() && Emu.IsRunning() && !TestDestroy() && !IsBreakPoint(CPU->PC) && dump_status == dump_enable);
}
catch(const wxString& e)
{
ConLog.Error(e);
}
catch(...)
{
ConLog.Error("Unhandled exception.");
}
//CPU.FreeTls();
wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, CPU);
wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, CPU);
}

View File

@ -5,9 +5,7 @@
#include "Emu/Cell/SPUDecoder.h" #include "Emu/Cell/SPUDecoder.h"
#include "Emu/Cell/SPUDisAsm.h" #include "Emu/Cell/SPUDisAsm.h"
class InterpreterDisAsmFrame class InterpreterDisAsmFrame : public wxPanel
: public wxPanel
, public ThreadBase
{ {
wxListView* m_list; wxListView* m_list;
PPC_DisAsm* disasm; PPC_DisAsm* disasm;
@ -53,6 +51,4 @@ public:
bool IsBreakPoint(u64 pc); bool IsBreakPoint(u64 pc);
void AddBreakPoint(u64 pc); void AddBreakPoint(u64 pc);
bool RemoveBreakPoint(u64 pc); bool RemoveBreakPoint(u64 pc);
virtual void Task();
}; };