Add thread list to debugger

This commit is contained in:
Kingcom 2014-08-22 16:11:16 +02:00
parent 5f7a3a8ca9
commit 1e3e5c92a8
4 changed files with 161 additions and 9 deletions

View File

@ -410,14 +410,6 @@ void BreakpointList::removeBreakpoint(int itemIndex)
}
}
void BreakpointList::postEvent(wxEventType type, int value)
{
wxCommandEvent event( type, GetId() );
event.SetEventObject(this);
event.SetInt(value);
wxPostEvent(this,event);
}
void BreakpointList::onPopupClick(wxCommandEvent& evt)
{
int index = GetFirstSelected();
@ -475,3 +467,135 @@ void BreakpointList::onDoubleClick(int itemIndex, const wxPoint& point)
{
gotoBreakpointAddress(itemIndex);
}
//
// ThreadList
//
enum { TL_TID, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT };
GenericListViewColumn threadColumns[TL_COLUMNCOUNT] = {
{ L"TID", 0.08f },
{ L"PC", 0.21f },
{ L"Entry Point", 0.21f },
{ L"Priority", 0.08f },
{ L"State", 0.21f },
{ L"Wait type", 0.21f },
};
ThreadList::ThreadList(wxWindow* parent, DebugInterface* _cpu)
: GenericListView(parent,threadColumns,TL_COLUMNCOUNT), cpu(_cpu)
{
#ifdef __linux__
// On linux wx failed to resize properly the page. I don't know why so for the moment I just create a static size page
// Far from ideal but at least I can use the memory window!
this->SetSize(wxSize(1000, 200));
#endif
}
void ThreadList::reloadThreads()
{
threads = getEEThreads();
update();
}
int ThreadList::getRowCount()
{
return threads.size();
}
wxString ThreadList::getColumnText(int item, int col) const
{
if (item < 0 || item >= (int)threads.size())
return L"";
FastFormatUnicode dest;
const EEThread& thread = threads[item];
switch (col)
{
case TL_TID:
dest.Write("%d",thread.tid);
break;
case TL_PROGRAMCOUNTER:
if (thread.data.status == THS_RUN)
dest.Write("0x%08X", cpu->getPC());
else
dest.Write("0x%08X", thread.data.entry);
break;
case TL_ENTRYPOINT:
dest.Write("0x%08X", thread.data.entry_init);
break;
case TL_PRIORITY:
dest.Write("0x%02X", thread.data.currentPriority);
break;
case TL_STATE:
switch (thread.data.status)
{
case THS_BAD:
dest.Write("Bad");
break;
case THS_RUN:
dest.Write("Running");
break;
case THS_READY:
dest.Write("Ready");
break;
case THS_WAIT:
dest.Write("Waiting");
break;
case THS_SUSPEND:
dest.Write("Suspended");
break;
case THS_WAIT_SUSPEND:
dest.Write("Waiting/Suspended");
break;
case THS_DORMANT:
dest.Write("Dormant");
break;
}
break;
case TL_WAITTYPE:
switch (thread.data.waitType)
{
case WAIT_NONE:
dest.Write("None");
break;
case WAIT_WAKEUP_REQ:
dest.Write("Wakeup request");
break;
case WAIT_SEMA:
dest.Write("Semaphore");
break;
}
break;
default:
return L"Invalid";
}
return dest;
}
void ThreadList::onDoubleClick(int itemIndex, const wxPoint& point)
{
if (itemIndex < 0 || itemIndex >= (int)threads.size())
return;
const EEThread& thread = threads[itemIndex];
switch (thread.data.status)
{
case THS_DORMANT:
case THS_BAD:
postEvent(debEVT_GOTOINDISASM,thread.data.entry_init);
break;
case THS_RUN:
postEvent(debEVT_GOTOINDISASM,cpu->getPC());
break;
default:
postEvent(debEVT_GOTOINDISASM,thread.data.entry);
break;
}
}

View File

@ -17,6 +17,7 @@
#include <wx/listctrl.h>
#include "DebugTools/DebugInterface.h"
#include "DebugTools/Breakpoints.h"
#include "DebugTools/BiosDebugData.h"
#include "CtrlDisassemblyView.h"
struct GenericListViewColumn
@ -74,7 +75,6 @@ private:
void toggleEnabled(int itemIndex);
void gotoBreakpointAddress(int itemIndex);
void removeBreakpoint(int itemIndex);
void postEvent(wxEventType type, int value);
void showMenu(const wxPoint& pos);
std::vector<BreakPoint> displayedBreakPoints_;
@ -82,3 +82,19 @@ private:
DebugInterface* cpu;
CtrlDisassemblyView* disasm;
};
class ThreadList: public GenericListView
{
public:
ThreadList(wxWindow* parent, DebugInterface* _cpu);
void reloadThreads();
protected:
void onPopupClick(wxCommandEvent& evt);
virtual wxString getColumnText(int row, int col) const;
virtual int getRowCount();
virtual void onDoubleClick(int itemIndex, const wxPoint& point);
private:
DebugInterface* cpu;
std::vector<EEThread> threads;
};

View File

@ -107,6 +107,13 @@ CpuTabPage::CpuTabPage(wxWindow* parent, DebugInterface* _cpu)
breakpointList = new BreakpointList(bottomTabs,cpu,disassembly);
bottomTabs->AddPage(breakpointList,L"Breakpoints");
threadList = NULL;
if (cpu == &r5900Debug)
{
threadList = new ThreadList(bottomTabs,cpu);
bottomTabs->AddPage(threadList,L"Threads");
}
mainSizer->Add(bottomTabs,1,wxEXPAND);
@ -162,6 +169,10 @@ void CpuTabPage::setBottomTabPage(wxWindow* win)
void CpuTabPage::update()
{
breakpointList->reloadBreakpoints();
if (threadList != NULL)
threadList->reloadThreads();
Refresh();
}

View File

@ -59,6 +59,7 @@ private:
wxNotebook* leftTabs;
BreakpointList* breakpointList;
wxStaticText* cyclesText;
ThreadList* threadList;
u32 lastCycles;
};