mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #271 from Kingcom/Threads
Add threads list to debugger
This commit is contained in:
commit
ec7fb80a5b
|
@ -267,7 +267,8 @@ set(pcsx2DebugToolsSources
|
|||
DebugTools/DisR3000A.cpp
|
||||
DebugTools/DisR5900asm.cpp
|
||||
DebugTools/DisVU0Micro.cpp
|
||||
DebugTools/DisVU1Micro.cpp)
|
||||
DebugTools/DisVU1Micro.cpp
|
||||
DebugTools/BiosDebugData.cpp)
|
||||
|
||||
# DebugTools headers
|
||||
set(pcsx2DebugToolsHeaders
|
||||
|
@ -282,7 +283,8 @@ set(pcsx2DebugToolsHeaders
|
|||
DebugTools/Debug.h
|
||||
DebugTools/DisASm.h
|
||||
DebugTools/DisVUmicro.h
|
||||
DebugTools/DisVUops.h)
|
||||
DebugTools/DisVUops.h
|
||||
DebugTools/BiosDebugData.h)
|
||||
|
||||
# gui sources
|
||||
set(pcsx2GuiSources
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "BiosDebugData.h"
|
||||
#include "../Memory.h"
|
||||
|
||||
std::vector<EEThread> getEEThreads()
|
||||
{
|
||||
std::vector<EEThread> threads;
|
||||
|
||||
if (CurrentBiosInformation == NULL)
|
||||
return threads;
|
||||
|
||||
u32 start = CurrentBiosInformation->threadListAddr & 0x3fffff;
|
||||
for (int tid = 0; tid < 256; tid++)
|
||||
{
|
||||
EEThread thread;
|
||||
|
||||
EEInternalThread* internal = (EEInternalThread*) PSM(start+tid*sizeof(EEInternalThread));
|
||||
if (internal->status != THS_BAD)
|
||||
{
|
||||
thread.tid = tid;
|
||||
thread.data = *internal;
|
||||
threads.push_back(thread);
|
||||
}
|
||||
}
|
||||
|
||||
return threads;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#include "Pcsx2Types.h"
|
||||
#include "../ps2/BiosTools.h"
|
||||
|
||||
struct EEInternalThread { // internal struct
|
||||
u32 prev;
|
||||
u32 next;
|
||||
int status;
|
||||
u32 entry;
|
||||
u32 stack;
|
||||
u32 gpReg;
|
||||
short currentPriority;
|
||||
short initPriority;
|
||||
int waitType;
|
||||
int semaId;
|
||||
int wakeupCount;
|
||||
int attr;
|
||||
int option;
|
||||
u32 entry_init;
|
||||
int argc;
|
||||
u32 argstring;
|
||||
u32 stack_bottom; //FIXME
|
||||
int stackSize;
|
||||
u32 root;
|
||||
u32 heap_base;
|
||||
};
|
||||
|
||||
enum {
|
||||
THS_BAD = 0x00,
|
||||
THS_RUN = 0x01,
|
||||
THS_READY = 0x02,
|
||||
THS_WAIT = 0x04,
|
||||
THS_SUSPEND = 0x08,
|
||||
THS_WAIT_SUSPEND = 0x0C,
|
||||
THS_DORMANT = 0x10,
|
||||
};
|
||||
|
||||
enum {
|
||||
WAIT_NONE = 0,
|
||||
WAIT_WAKEUP_REQ = 1,
|
||||
WAIT_SEMA = 2,
|
||||
};
|
||||
|
||||
struct EEThread
|
||||
{
|
||||
u32 tid;
|
||||
EEInternalThread data;
|
||||
};
|
||||
|
||||
std::vector<EEThread> getEEThreads();
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
wxNotebook* leftTabs;
|
||||
BreakpointList* breakpointList;
|
||||
wxStaticText* cyclesText;
|
||||
ThreadList* threadList;
|
||||
u32 lastCycles;
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,13 @@ static_assert( sizeof(romdir) == DIRENTRY_SIZE, "romdir struct not packed to 16
|
|||
u32 BiosVersion;
|
||||
u32 BiosChecksum;
|
||||
wxString BiosDescription;
|
||||
const BiosDebugInformation* CurrentBiosInformation;
|
||||
|
||||
const BiosDebugInformation biosVersions[] = {
|
||||
// USA v02.00(14/06/2004) Console
|
||||
{ 0x00000200, 0xD778DB8D, 0x8001a640 },
|
||||
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Exception::BiosLoadFailed (implementations)
|
||||
|
@ -271,6 +277,16 @@ void LoadBIOS()
|
|||
LoadExtraRom( L"rom1", eeMem->ROM1 );
|
||||
LoadExtraRom( L"rom2", eeMem->ROM2 );
|
||||
LoadExtraRom( L"erom", eeMem->EROM );
|
||||
|
||||
CurrentBiosInformation = NULL;
|
||||
for (int i = 0; i < sizeof(biosVersions)/sizeof(biosVersions[0]); i++)
|
||||
{
|
||||
if (biosVersions[i].biosChecksum == BiosChecksum && biosVersions[i].biosVersion == BiosVersion)
|
||||
{
|
||||
CurrentBiosInformation = &biosVersions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception::BadStream& ex)
|
||||
{
|
||||
|
|
|
@ -28,9 +28,17 @@ namespace Exception
|
|||
};
|
||||
}
|
||||
|
||||
struct BiosDebugInformation
|
||||
{
|
||||
u32 biosVersion;
|
||||
u32 biosChecksum;
|
||||
u32 threadListAddr;
|
||||
};
|
||||
|
||||
extern u32 BiosVersion; // Used by CDVD
|
||||
extern u32 BiosChecksum;
|
||||
extern wxString BiosDescription;
|
||||
extern const BiosDebugInformation* CurrentBiosInformation;
|
||||
|
||||
extern void LoadBIOS();
|
||||
extern bool IsBIOS(const wxString& filename, wxString& description);
|
||||
|
|
|
@ -426,6 +426,7 @@
|
|||
<ClCompile Include="..\..\DebugTools\Breakpoints.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DebugInterface.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DisassemblyManager.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\ExpressionParser.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MIPSAnalyst.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp" />
|
||||
|
@ -712,6 +713,7 @@
|
|||
<ClInclude Include="..\..\DebugTools\Breakpoints.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DebugInterface.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DisassemblyManager.h" />
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h" />
|
||||
<ClInclude Include="..\..\DebugTools\ExpressionParser.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MIPSAnalyst.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h" />
|
||||
|
|
|
@ -820,6 +820,9 @@
|
|||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DebugTools\MipsAssemblerTables.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1236,6 +1239,9 @@
|
|||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DebugTools\MipsAssemblerTables.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -411,6 +411,7 @@
|
|||
<ClCompile Include="..\..\DebugTools\Breakpoints.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DebugInterface.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DisassemblyManager.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\ExpressionParser.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MIPSAnalyst.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp" />
|
||||
|
@ -698,6 +699,7 @@
|
|||
<ClInclude Include="..\..\DebugTools\Breakpoints.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DebugInterface.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DisassemblyManager.h" />
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h" />
|
||||
<ClInclude Include="..\..\DebugTools\ExpressionParser.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MIPSAnalyst.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h" />
|
||||
|
|
|
@ -835,6 +835,9 @@
|
|||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DebugTools\MipsAssemblerTables.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1251,6 +1254,9 @@
|
|||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DebugTools\MipsAssemblerTables.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -411,6 +411,7 @@
|
|||
<ClCompile Include="..\..\DebugTools\Breakpoints.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DebugInterface.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\DisassemblyManager.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\ExpressionParser.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MIPSAnalyst.cpp" />
|
||||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp" />
|
||||
|
@ -698,6 +699,7 @@
|
|||
<ClInclude Include="..\..\DebugTools\Breakpoints.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DebugInterface.h" />
|
||||
<ClInclude Include="..\..\DebugTools\DisassemblyManager.h" />
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h" />
|
||||
<ClInclude Include="..\..\DebugTools\ExpressionParser.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MIPSAnalyst.h" />
|
||||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h" />
|
||||
|
@ -938,4 +940,4 @@
|
|||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -850,6 +850,9 @@
|
|||
<ClCompile Include="..\..\DebugTools\MipsAssembler.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DebugTools\BiosDebugData.cpp">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Patch.h">
|
||||
|
@ -1263,6 +1266,9 @@
|
|||
<ClInclude Include="..\..\DebugTools\MipsAssembler.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DebugTools\BiosDebugData.h">
|
||||
<Filter>System\Ps2\Debug</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\3rdparty\wxWidgets\include\wx\msw\wx.rc">
|
||||
|
@ -1345,4 +1351,4 @@
|
|||
<Filter>AppHost\Resources</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
Loading…
Reference in New Issue