Permalink
Browse files

Debugger: Add debug interfaces for threads.

This way we can switch context.
  • Loading branch information...
unknownbrackets committed May 10, 2018
1 parent 3193772 commit 5670fc03ae00b817ff0f6a87bb683812df8f7917
View
@@ -553,6 +553,7 @@
<ClInclude Include="Debugger\WebSocket\LogBroadcaster.h" />
<ClInclude Include="Debugger\WebSocket\SteppingBroadcaster.h" />
<ClInclude Include="FileSystems\BlobFileSystem.h" />
<ClInclude Include="HLE\KernelThreadDebugInterface.h" />
<ClInclude Include="HLE\KUBridge.h" />
<ClInclude Include="HLE\sceUsbCam.h" />
<ClInclude Include="MIPS\IR\IRFrontend.h" />
@@ -1337,6 +1337,9 @@
<ClInclude Include="Debugger\WebSocket\BreakpointSubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
<ClInclude Include="HLE\KernelThreadDebugInterface.h">
<Filter>HLE\Kernel</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
@@ -236,7 +236,7 @@ std::vector<BranchLine> DisassemblyManager::getBranchLines(u32 start, u32 size)
return result;
}
void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLineInfo& dest)
void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLineInfo &dest, DebugInterface *cpuDebug)
{
// This is here really to avoid lock ordering issues.
auto memLock = Memory::Lock();
@@ -250,7 +250,7 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin
if (it != entries.end()) {
DisassemblyEntry *entry = it->second;
if (entry->disassemble(address, dest, insertSymbols))
if (entry->disassemble(address, dest, insertSymbols, cpuDebug))
return;
}
@@ -432,14 +432,14 @@ u32 DisassemblyFunction::getLineAddress(int line)
return lineAddresses[line];
}
bool DisassemblyFunction::disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols)
bool DisassemblyFunction::disassemble(u32 address, DisassemblyLineInfo &dest, bool insertSymbols, DebugInterface *cpuDebug)
{
std::lock_guard<std::recursive_mutex> guard(lock_);
auto it = findDisassemblyEntry(entries,address,false);
if (it == entries.end())
return false;
return it->second->disassemble(address,dest,insertSymbols);
return it->second->disassemble(address, dest, insertSymbols, cpuDebug);
}
void DisassemblyFunction::getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest)
@@ -720,16 +720,19 @@ void DisassemblyFunction::clear()
hash = 0;
}
bool DisassemblyOpcode::disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols)
bool DisassemblyOpcode::disassemble(u32 address, DisassemblyLineInfo &dest, bool insertSymbols, DebugInterface *cpuDebug)
{
if (!cpuDebug)
cpuDebug = DisassemblyManager::getCpu();
char opcode[64],arguments[256];
const char *dizz = DisassemblyManager::getCpu()->disasm(address,4);
const char *dizz = cpuDebug->disasm(address, 4);
parseDisasm(dizz,opcode,arguments,insertSymbols);
dest.type = DISTYPE_OPCODE;
dest.name = opcode;
dest.params = arguments;
dest.totalSize = 4;
dest.info = MIPSAnalyst::GetOpcodeInfo(DisassemblyManager::getCpu(),address);
dest.info = MIPSAnalyst::GetOpcodeInfo(cpuDebug, address);
return true;
}
@@ -789,11 +792,14 @@ void DisassemblyMacro::setMacroMemory(std::string _name, u32 _immediate, u8 _rt,
numOpcodes = 2;
}
bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols)
bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo &dest, bool insertSymbols, DebugInterface *cpuDebug)
{
if (!cpuDebug)
cpuDebug = DisassemblyManager::getCpu();
char buffer[64];
dest.type = DISTYPE_MACRO;
dest.info = MIPSAnalyst::GetOpcodeInfo(DisassemblyManager::getCpu(),address);
dest.info = MIPSAnalyst::GetOpcodeInfo(cpuDebug, address);
std::string addressSymbol;
switch (type)
@@ -802,11 +808,10 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool
dest.name = name;
addressSymbol = g_symbolMap->GetLabelString(immediate);
if (!addressSymbol.empty() && insertSymbols)
{
sprintf(buffer,"%s,%s",DisassemblyManager::getCpu()->GetRegName(0,rt),addressSymbol.c_str());
if (!addressSymbol.empty() && insertSymbols) {
sprintf(buffer, "%s,%s", cpuDebug->GetRegName(0, rt), addressSymbol.c_str());
} else {
sprintf(buffer,"%s,0x%08X",DisassemblyManager::getCpu()->GetRegName(0,rt),immediate);
sprintf(buffer, "%s,0x%08X", cpuDebug->GetRegName(0, rt), immediate);
}
dest.params = buffer;
@@ -818,11 +823,10 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool
dest.name = name;
addressSymbol = g_symbolMap->GetLabelString(immediate);
if (!addressSymbol.empty() && insertSymbols)
{
sprintf(buffer,"%s,%s",DisassemblyManager::getCpu()->GetRegName(0,rt),addressSymbol.c_str());
if (!addressSymbol.empty() && insertSymbols) {
sprintf(buffer, "%s,%s", cpuDebug->GetRegName(0, rt), addressSymbol.c_str());
} else {
sprintf(buffer,"%s,0x%08X",DisassemblyManager::getCpu()->GetRegName(0,rt),immediate);
sprintf(buffer, "%s,0x%08X", cpuDebug->GetRegName(0, rt), immediate);
}
dest.params = buffer;
@@ -867,7 +871,7 @@ void DisassemblyData::recheck()
}
}
bool DisassemblyData::disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols)
bool DisassemblyData::disassemble(u32 address, DisassemblyLineInfo &dest, bool insertSymbols, DebugInterface *cpuDebug)
{
dest.type = DISTYPE_DATA;
@@ -1065,7 +1069,7 @@ DisassemblyComment::DisassemblyComment(u32 _address, u32 _size, std::string _nam
}
bool DisassemblyComment::disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols)
bool DisassemblyComment::disassemble(u32 address, DisassemblyLineInfo &dest, bool insertSymbols, DebugInterface *cpuDebug)
{
dest.type = DISTYPE_OTHER;
dest.name = name;
@@ -63,7 +63,7 @@ class DisassemblyEntry
virtual int getLineNum(u32 address, bool findStart) = 0;
virtual u32 getLineAddress(int line) = 0;
virtual u32 getTotalSize() = 0;
virtual bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) = 0;
virtual bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) = 0;
virtual void getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest) { };
};
@@ -77,7 +77,7 @@ class DisassemblyFunction: public DisassemblyEntry
int getLineNum(u32 address, bool findStart) override;
u32 getLineAddress(int line) override;
u32 getTotalSize() override { return size; };
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) override;
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) override;
void getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest) override;
private:
@@ -105,7 +105,7 @@ class DisassemblyOpcode: public DisassemblyEntry
int getLineNum(u32 address, bool findStart) override { return (address - this->address) / 4; };
u32 getLineAddress(int line) override { return address + line * 4; };
u32 getTotalSize() override { return num * 4; };
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) override;
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) override;
void getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest) override;
private:
@@ -128,7 +128,7 @@ class DisassemblyMacro: public DisassemblyEntry
int getLineNum(u32 address, bool findStart) override { return 0; };
u32 getLineAddress(int line) override { return address; };
u32 getTotalSize() override { return numOpcodes * 4; };
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) override;
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) override;
private:
enum MacroType { MACRO_LI, MACRO_MEMORYIMM };
@@ -153,7 +153,7 @@ class DisassemblyData: public DisassemblyEntry
int getLineNum(u32 address, bool findStart) override;
u32 getLineAddress(int line) override { return lineAddresses[line]; };
u32 getTotalSize() override { return size; };
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) override;
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) override;
private:
void createLines();
@@ -185,7 +185,7 @@ class DisassemblyComment: public DisassemblyEntry
int getLineNum(u32 address, bool findStart) override { return 0; };
u32 getLineAddress(int line) override { return address; };
u32 getTotalSize() override { return size; };
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) override;
bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols, DebugInterface *cpuDebug) override;
private:
u32 address;
@@ -205,7 +205,7 @@ class DisassemblyManager
void setCpu(DebugInterface* _cpu) { cpu = _cpu; };
void setMaxParamChars(int num) { maxParamChars = num; clear(); };
void getLine(u32 address, bool insertSymbols, DisassemblyLineInfo& dest);
void getLine(u32 address, bool insertSymbols, DisassemblyLineInfo &dest, DebugInterface *cpuDebug = nullptr);
void analyze(u32 address, u32 size);
std::vector<BranchLine> getBranchLines(u32 start, u32 size);
Oops, something went wrong.

0 comments on commit 5670fc0

Please sign in to comment.