Common: Move OSThreads into core
Common shouldn't be depending on APIs in Core (in this, case depending on the PowerPC namespace). Because of the poor separation here, this moves OSThread functionality into core, so that it resolves the implicit dependency on core.
This commit is contained in:
parent
7e197186b9
commit
57534777d4
|
@ -34,8 +34,6 @@ add_library(common
|
||||||
Crypto/ec.h
|
Crypto/ec.h
|
||||||
Debug/MemoryPatches.cpp
|
Debug/MemoryPatches.cpp
|
||||||
Debug/MemoryPatches.h
|
Debug/MemoryPatches.h
|
||||||
Debug/OSThread.cpp
|
|
||||||
Debug/OSThread.h
|
|
||||||
Debug/Threads.h
|
Debug/Threads.h
|
||||||
Debug/Watches.cpp
|
Debug/Watches.cpp
|
||||||
Debug/Watches.h
|
Debug/Watches.h
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
<ClInclude Include="CPUDetect.h" />
|
<ClInclude Include="CPUDetect.h" />
|
||||||
<ClInclude Include="DebugInterface.h" />
|
<ClInclude Include="DebugInterface.h" />
|
||||||
<ClInclude Include="Debug\MemoryPatches.h" />
|
<ClInclude Include="Debug\MemoryPatches.h" />
|
||||||
<ClInclude Include="Debug\OSThread.h" />
|
|
||||||
<ClInclude Include="Debug\Threads.h" />
|
<ClInclude Include="Debug\Threads.h" />
|
||||||
<ClInclude Include="Debug\Watches.h" />
|
<ClInclude Include="Debug\Watches.h" />
|
||||||
<ClInclude Include="DynamicLibrary.h" />
|
<ClInclude Include="DynamicLibrary.h" />
|
||||||
|
@ -191,7 +190,6 @@
|
||||||
<ClCompile Include="Config\ConfigInfo.cpp" />
|
<ClCompile Include="Config\ConfigInfo.cpp" />
|
||||||
<ClCompile Include="Config\Layer.cpp" />
|
<ClCompile Include="Config\Layer.cpp" />
|
||||||
<ClCompile Include="Debug\MemoryPatches.cpp" />
|
<ClCompile Include="Debug\MemoryPatches.cpp" />
|
||||||
<ClCompile Include="Debug\OSThread.cpp" />
|
|
||||||
<ClCompile Include="Debug\Watches.cpp" />
|
<ClCompile Include="Debug\Watches.cpp" />
|
||||||
<ClCompile Include="DynamicLibrary.cpp" />
|
<ClCompile Include="DynamicLibrary.cpp" />
|
||||||
<ClCompile Include="ENetUtil.cpp" />
|
<ClCompile Include="ENetUtil.cpp" />
|
||||||
|
|
|
@ -273,9 +273,6 @@
|
||||||
<ClInclude Include="Debug\MemoryPatches.h">
|
<ClInclude Include="Debug\MemoryPatches.h">
|
||||||
<Filter>Debug</Filter>
|
<Filter>Debug</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Debug\OSThread.h">
|
|
||||||
<Filter>Debug</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Debug\Threads.h">
|
<ClInclude Include="Debug\Threads.h">
|
||||||
<Filter>Debug</Filter>
|
<Filter>Debug</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -365,9 +362,6 @@
|
||||||
<ClCompile Include="Debug\MemoryPatches.cpp">
|
<ClCompile Include="Debug\MemoryPatches.cpp">
|
||||||
<Filter>Debug</Filter>
|
<Filter>Debug</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Debug\OSThread.cpp">
|
|
||||||
<Filter>Debug</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="GL\GLContext.cpp">
|
<ClCompile Include="GL\GLContext.cpp">
|
||||||
<Filter>GL\GLInterface</Filter>
|
<Filter>GL\GLInterface</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -80,6 +80,8 @@ add_library(core
|
||||||
Debugger/Dump.cpp
|
Debugger/Dump.cpp
|
||||||
Debugger/Dump.h
|
Debugger/Dump.h
|
||||||
Debugger/GCELF.h
|
Debugger/GCELF.h
|
||||||
|
Debugger/OSThread.cpp
|
||||||
|
Debugger/OSThread.h
|
||||||
Debugger/PPCDebugInterface.cpp
|
Debugger/PPCDebugInterface.cpp
|
||||||
Debugger/PPCDebugInterface.h
|
Debugger/PPCDebugInterface.h
|
||||||
Debugger/RSO.cpp
|
Debugger/RSO.cpp
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
<ClCompile Include="CoreTiming.cpp" />
|
<ClCompile Include="CoreTiming.cpp" />
|
||||||
<ClCompile Include="Debugger\Debugger_SymbolMap.cpp" />
|
<ClCompile Include="Debugger\Debugger_SymbolMap.cpp" />
|
||||||
<ClCompile Include="Debugger\Dump.cpp" />
|
<ClCompile Include="Debugger\Dump.cpp" />
|
||||||
|
<ClCompile Include="Debugger\OSThread.cpp" />
|
||||||
<ClCompile Include="Debugger\PPCDebugInterface.cpp" />
|
<ClCompile Include="Debugger\PPCDebugInterface.cpp" />
|
||||||
<ClCompile Include="Debugger\RSO.cpp" />
|
<ClCompile Include="Debugger\RSO.cpp" />
|
||||||
<ClCompile Include="DSPEmulator.cpp" />
|
<ClCompile Include="DSPEmulator.cpp" />
|
||||||
|
@ -399,6 +400,7 @@
|
||||||
<ClInclude Include="Debugger\Debugger_SymbolMap.h" />
|
<ClInclude Include="Debugger\Debugger_SymbolMap.h" />
|
||||||
<ClInclude Include="Debugger\Dump.h" />
|
<ClInclude Include="Debugger\Dump.h" />
|
||||||
<ClInclude Include="Debugger\GCELF.h" />
|
<ClInclude Include="Debugger\GCELF.h" />
|
||||||
|
<ClInclude Include="Debugger\OSThread.h" />
|
||||||
<ClInclude Include="Debugger\PPCDebugInterface.h" />
|
<ClInclude Include="Debugger\PPCDebugInterface.h" />
|
||||||
<ClInclude Include="Debugger\RSO.h" />
|
<ClInclude Include="Debugger\RSO.h" />
|
||||||
<ClInclude Include="DSPEmulator.h" />
|
<ClInclude Include="DSPEmulator.h" />
|
||||||
|
|
|
@ -217,6 +217,9 @@
|
||||||
<ClCompile Include="Debugger\Dump.cpp">
|
<ClCompile Include="Debugger\Dump.cpp">
|
||||||
<Filter>Debugger</Filter>
|
<Filter>Debugger</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Debugger\OSThread.cpp">
|
||||||
|
<Filter>Debugger</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="Debugger\PPCDebugInterface.cpp">
|
<ClCompile Include="Debugger\PPCDebugInterface.cpp">
|
||||||
<Filter>Debugger</Filter>
|
<Filter>Debugger</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1050,6 +1053,9 @@
|
||||||
<ClInclude Include="Debugger\GCELF.h">
|
<ClInclude Include="Debugger\GCELF.h">
|
||||||
<Filter>Debugger</Filter>
|
<Filter>Debugger</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Debugger\OSThread.h">
|
||||||
|
<Filter>Debugger</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="Debugger\PPCDebugInterface.h">
|
<ClInclude Include="Debugger\PPCDebugInterface.h">
|
||||||
<Filter>Debugger</Filter>
|
<Filter>Debugger</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -2,20 +2,22 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "Common/Debug/OSThread.h"
|
#include "Core/Debugger/OSThread.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "Core/PowerPC/MMU.h"
|
#include "Core/PowerPC/MMU.h"
|
||||||
|
|
||||||
|
namespace Core::Debug
|
||||||
|
{
|
||||||
// Context offsets based on the following functions:
|
// Context offsets based on the following functions:
|
||||||
// - OSSaveContext
|
// - OSSaveContext
|
||||||
// - OSSaveFPUContext
|
// - OSSaveFPUContext
|
||||||
// - OSDumpContext
|
// - OSDumpContext
|
||||||
// - OSClearContext
|
// - OSClearContext
|
||||||
// - OSExceptionVector
|
// - OSExceptionVector
|
||||||
void Common::Debug::OSContext::Read(u32 addr)
|
void OSContext::Read(u32 addr)
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < gpr.size(); i++)
|
for (std::size_t i = 0; i < gpr.size(); i++)
|
||||||
gpr[i] = PowerPC::HostRead_U32(addr + u32(i * sizeof(int)));
|
gpr[i] = PowerPC::HostRead_U32(addr + u32(i * sizeof(int)));
|
||||||
|
@ -41,7 +43,7 @@ void Common::Debug::OSContext::Read(u32 addr)
|
||||||
// - OSInitMutex
|
// - OSInitMutex
|
||||||
// - OSLockMutex
|
// - OSLockMutex
|
||||||
// - __OSUnlockAllMutex
|
// - __OSUnlockAllMutex
|
||||||
void Common::Debug::OSMutex::Read(u32 addr)
|
void OSMutex::Read(u32 addr)
|
||||||
{
|
{
|
||||||
thread_queue.head = PowerPC::HostRead_U32(addr);
|
thread_queue.head = PowerPC::HostRead_U32(addr);
|
||||||
thread_queue.tail = PowerPC::HostRead_U32(addr + 0x4);
|
thread_queue.tail = PowerPC::HostRead_U32(addr + 0x4);
|
||||||
|
@ -63,7 +65,7 @@ void Common::Debug::OSMutex::Read(u32 addr)
|
||||||
// - __OSThreadInit
|
// - __OSThreadInit
|
||||||
// - OSSetThreadSpecific
|
// - OSSetThreadSpecific
|
||||||
// - SOInit (for errno)
|
// - SOInit (for errno)
|
||||||
void Common::Debug::OSThread::Read(u32 addr)
|
void OSThread::Read(u32 addr)
|
||||||
{
|
{
|
||||||
context.Read(addr);
|
context.Read(addr);
|
||||||
state = PowerPC::HostRead_U16(addr + 0x2c8);
|
state = PowerPC::HostRead_U16(addr + 0x2c8);
|
||||||
|
@ -94,25 +96,25 @@ void Common::Debug::OSThread::Read(u32 addr)
|
||||||
specific[1] = PowerPC::HostRead_U32(addr + 0x314);
|
specific[1] = PowerPC::HostRead_U32(addr + 0x314);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Common::Debug::OSThread::IsValid() const
|
bool OSThread::IsValid() const
|
||||||
{
|
{
|
||||||
return PowerPC::HostIsRAMAddress(stack_end) && PowerPC::HostRead_U32(stack_end) == STACK_MAGIC;
|
return PowerPC::HostIsRAMAddress(stack_end) && PowerPC::HostRead_U32(stack_end) == STACK_MAGIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Debug::OSThreadView::OSThreadView(u32 addr)
|
OSThreadView::OSThreadView(u32 addr)
|
||||||
{
|
{
|
||||||
m_address = addr;
|
m_address = addr;
|
||||||
m_thread.Read(addr);
|
m_thread.Read(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::Debug::OSThread& Common::Debug::OSThreadView::Data() const
|
const OSThread& OSThreadView::Data() const
|
||||||
{
|
{
|
||||||
return m_thread;
|
return m_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Debug::PartialContext Common::Debug::OSThreadView::GetContext() const
|
Common::Debug::PartialContext OSThreadView::GetContext() const
|
||||||
{
|
{
|
||||||
PartialContext context;
|
Common::Debug::PartialContext context;
|
||||||
|
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return context;
|
return context;
|
||||||
|
@ -134,57 +136,57 @@ Common::Debug::PartialContext Common::Debug::OSThreadView::GetContext() const
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Common::Debug::OSThreadView::GetAddress() const
|
u32 OSThreadView::GetAddress() const
|
||||||
{
|
{
|
||||||
return m_address;
|
return m_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 Common::Debug::OSThreadView::GetState() const
|
u16 OSThreadView::GetState() const
|
||||||
{
|
{
|
||||||
return m_thread.state;
|
return m_thread.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Common::Debug::OSThreadView::IsSuspended() const
|
bool OSThreadView::IsSuspended() const
|
||||||
{
|
{
|
||||||
return m_thread.suspend > 0;
|
return m_thread.suspend > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Common::Debug::OSThreadView::IsDetached() const
|
bool OSThreadView::IsDetached() const
|
||||||
{
|
{
|
||||||
return m_thread.is_detached != 0;
|
return m_thread.is_detached != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Common::Debug::OSThreadView::GetBasePriority() const
|
s32 OSThreadView::GetBasePriority() const
|
||||||
{
|
{
|
||||||
return m_thread.base_priority;
|
return m_thread.base_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Common::Debug::OSThreadView::GetEffectivePriority() const
|
s32 OSThreadView::GetEffectivePriority() const
|
||||||
{
|
{
|
||||||
return m_thread.effective_priority;
|
return m_thread.effective_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Common::Debug::OSThreadView::GetStackStart() const
|
u32 OSThreadView::GetStackStart() const
|
||||||
{
|
{
|
||||||
return m_thread.stack_addr;
|
return m_thread.stack_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Common::Debug::OSThreadView::GetStackEnd() const
|
u32 OSThreadView::GetStackEnd() const
|
||||||
{
|
{
|
||||||
return m_thread.stack_end;
|
return m_thread.stack_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Common::Debug::OSThreadView::GetStackSize() const
|
std::size_t OSThreadView::GetStackSize() const
|
||||||
{
|
{
|
||||||
return GetStackStart() - GetStackEnd();
|
return GetStackStart() - GetStackEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Common::Debug::OSThreadView::GetErrno() const
|
s32 OSThreadView::GetErrno() const
|
||||||
{
|
{
|
||||||
return m_thread.error;
|
return m_thread.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Common::Debug::OSThreadView::GetSpecific() const
|
std::string OSThreadView::GetSpecific() const
|
||||||
{
|
{
|
||||||
std::string specific;
|
std::string specific;
|
||||||
|
|
||||||
|
@ -198,7 +200,9 @@ std::string Common::Debug::OSThreadView::GetSpecific() const
|
||||||
return specific;
|
return specific;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Common::Debug::OSThreadView::IsValid() const
|
bool OSThreadView::IsValid() const
|
||||||
{
|
{
|
||||||
return m_thread.IsValid();
|
return m_thread.IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Core::Debug
|
|
@ -11,7 +11,7 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Debug/Threads.h"
|
#include "Common/Debug/Threads.h"
|
||||||
|
|
||||||
namespace Common::Debug
|
namespace Core::Debug
|
||||||
{
|
{
|
||||||
template <class C>
|
template <class C>
|
||||||
struct OSQueue
|
struct OSQueue
|
||||||
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
const OSThread& Data() const;
|
const OSThread& Data() const;
|
||||||
|
|
||||||
PartialContext GetContext() const override;
|
Common::Debug::PartialContext GetContext() const override;
|
||||||
u32 GetAddress() const override;
|
u32 GetAddress() const override;
|
||||||
u16 GetState() const override;
|
u16 GetState() const override;
|
||||||
bool IsSuspended() const override;
|
bool IsSuspended() const override;
|
||||||
|
@ -151,4 +151,4 @@ private:
|
||||||
OSThread m_thread;
|
OSThread m_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common::Debug
|
} // namespace Core::Debug
|
|
@ -11,10 +11,10 @@
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "Common/Align.h"
|
#include "Common/Align.h"
|
||||||
#include "Common/Debug/OSThread.h"
|
|
||||||
#include "Common/GekkoDisassembler.h"
|
#include "Common/GekkoDisassembler.h"
|
||||||
|
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/Debugger/OSThread.h"
|
||||||
#include "Core/HW/DSP.h"
|
#include "Core/HW/DSP.h"
|
||||||
#include "Core/PowerPC/MMU.h"
|
#include "Core/PowerPC/MMU.h"
|
||||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||||
|
@ -176,14 +176,14 @@ Common::Debug::Threads PPCDebugInterface::GetThreads() const
|
||||||
if (!PowerPC::HostIsRAMAddress(active_queue_head))
|
if (!PowerPC::HostIsRAMAddress(active_queue_head))
|
||||||
return threads;
|
return threads;
|
||||||
|
|
||||||
auto active_thread = std::make_unique<Common::Debug::OSThreadView>(active_queue_head);
|
auto active_thread = std::make_unique<Core::Debug::OSThreadView>(active_queue_head);
|
||||||
if (!active_thread->IsValid())
|
if (!active_thread->IsValid())
|
||||||
return threads;
|
return threads;
|
||||||
|
|
||||||
const auto insert_threads = [&threads](u32 addr, auto get_next_addr) {
|
const auto insert_threads = [&threads](u32 addr, auto get_next_addr) {
|
||||||
while (addr != 0 && PowerPC::HostIsRAMAddress(addr))
|
while (addr != 0 && PowerPC::HostIsRAMAddress(addr))
|
||||||
{
|
{
|
||||||
auto thread = std::make_unique<Common::Debug::OSThreadView>(addr);
|
auto thread = std::make_unique<Core::Debug::OSThreadView>(addr);
|
||||||
if (!thread->IsValid())
|
if (!thread->IsValid())
|
||||||
break;
|
break;
|
||||||
addr = get_next_addr(*thread);
|
addr = get_next_addr(*thread);
|
||||||
|
|
Loading…
Reference in New Issue