mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 14:46:49 +01:00
Core/CPUThreadGuard: Fetch System from Guard.
This commit is contained in:
parent
31d33d0efd
commit
3006c23c85
@ -8,6 +8,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
#include "Common/Event.h"
|
#include "Common/Event.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "Core/Debugger/PPCDebugInterface.h"
|
#include "Core/Debugger/PPCDebugInterface.h"
|
||||||
#include "Core/HW/CPU.h"
|
#include "Core/HW/CPU.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
@ -122,14 +123,14 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins
|
|||||||
return tmp_attributes;
|
return tmp_attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceOutput CodeTrace::SaveCurrentInstruction(const Core::CPUThreadGuard* guard) const
|
TraceOutput CodeTrace::SaveCurrentInstruction(const Core::CPUThreadGuard& guard) const
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& ppc_state = system.GetPPCState();
|
auto& ppc_state = system.GetPPCState();
|
||||||
|
|
||||||
// Quickly save instruction and memory target for fast logging.
|
// Quickly save instruction and memory target for fast logging.
|
||||||
TraceOutput output;
|
TraceOutput output;
|
||||||
const std::string instr = PowerPC::debug_interface.Disassemble(guard, ppc_state.pc);
|
const std::string instr = PowerPC::debug_interface.Disassemble(&guard, ppc_state.pc);
|
||||||
output.instruction = instr;
|
output.instruction = instr;
|
||||||
output.address = ppc_state.pc;
|
output.address = ppc_state.pc;
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
|
|||||||
if (m_recording)
|
if (m_recording)
|
||||||
return results;
|
return results;
|
||||||
|
|
||||||
TraceOutput pc_instr = SaveCurrentInstruction(&guard);
|
TraceOutput pc_instr = SaveCurrentInstruction(guard);
|
||||||
const InstructionAttributes instr = GetInstructionAttributes(pc_instr);
|
const InstructionAttributes instr = GetInstructionAttributes(pc_instr);
|
||||||
|
|
||||||
// Not an instruction we should start autostepping from (ie branches).
|
// Not an instruction we should start autostepping from (ie branches).
|
||||||
@ -199,7 +200,7 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
|
|||||||
{
|
{
|
||||||
PowerPC::SingleStep();
|
PowerPC::SingleStep();
|
||||||
|
|
||||||
pc_instr = SaveCurrentInstruction(&guard);
|
pc_instr = SaveCurrentInstruction(guard);
|
||||||
hit = TraceLogic(pc_instr);
|
hit = TraceLogic(pc_instr);
|
||||||
results.count += 1;
|
results.count += 1;
|
||||||
} while (clock::now() < timeout && hit < stop_condition &&
|
} while (clock::now() < timeout && hit < stop_condition &&
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
InstructionAttributes GetInstructionAttributes(const TraceOutput& line) const;
|
InstructionAttributes GetInstructionAttributes(const TraceOutput& line) const;
|
||||||
TraceOutput SaveCurrentInstruction(const Core::CPUThreadGuard* guard) const;
|
TraceOutput SaveCurrentInstruction(const Core::CPUThreadGuard& guard) const;
|
||||||
HitType TraceLogic(const TraceOutput& current_instr, bool first_hit = false);
|
HitType TraceLogic(const TraceOutput& current_instr, bool first_hit = false);
|
||||||
|
|
||||||
bool m_recording = false;
|
bool m_recording = false;
|
||||||
|
@ -116,6 +116,8 @@ public:
|
|||||||
CPUThreadGuard& operator=(const CPUThreadGuard&) = delete;
|
CPUThreadGuard& operator=(const CPUThreadGuard&) = delete;
|
||||||
CPUThreadGuard& operator=(CPUThreadGuard&&) = delete;
|
CPUThreadGuard& operator=(CPUThreadGuard&&) = delete;
|
||||||
|
|
||||||
|
Core::System& GetSystem() const { return m_system; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
const bool m_was_cpu_thread;
|
const bool m_was_cpu_thread;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Common/BitUtils.h"
|
#include "Common/BitUtils.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "Core/HW/DSP.h"
|
#include "Core/HW/DSP.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/PowerPC/MMU.h"
|
#include "Core/PowerPC/MMU.h"
|
||||||
@ -125,7 +126,7 @@ struct EffectiveAddressSpaceAccessors : Accessors
|
|||||||
bool Matches(const Core::CPUThreadGuard& guard, u32 haystack_start, const u8* needle_start,
|
bool Matches(const Core::CPUThreadGuard& guard, u32 haystack_start, const u8* needle_start,
|
||||||
std::size_t needle_size) const
|
std::size_t needle_size) const
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
u32 page_base = haystack_start & 0xfffff000;
|
u32 page_base = haystack_start & 0xfffff000;
|
||||||
@ -212,13 +213,13 @@ struct AuxiliaryAddressSpaceAccessors : Accessors
|
|||||||
}
|
}
|
||||||
u8 ReadU8(const Core::CPUThreadGuard& guard, u32 address) const override
|
u8 ReadU8(const Core::CPUThreadGuard& guard, u32 address) const override
|
||||||
{
|
{
|
||||||
const u8* base = Core::System::GetInstance().GetDSP().GetARAMPtr();
|
const u8* base = guard.GetSystem().GetDSP().GetARAMPtr();
|
||||||
return base[address];
|
return base[address];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteU8(const Core::CPUThreadGuard& guard, u32 address, u8 value) override
|
void WriteU8(const Core::CPUThreadGuard& guard, u32 address, u8 value) override
|
||||||
{
|
{
|
||||||
u8* base = Core::System::GetInstance().GetDSP().GetARAMPtr();
|
u8* base = guard.GetSystem().GetDSP().GetARAMPtr();
|
||||||
base[address] = value;
|
base[address] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "Core/HW/CPU.h"
|
#include "Core/HW/CPU.h"
|
||||||
#include "Core/HW/GPFifo.h"
|
#include "Core/HW/GPFifo.h"
|
||||||
#include "Core/HW/MMIO.h"
|
#include "Core/HW/MMIO.h"
|
||||||
@ -524,7 +525,7 @@ TryReadInstResult TryReadInstruction(u32 address)
|
|||||||
|
|
||||||
u32 HostRead_Instruction(const Core::CPUThreadGuard& guard, const u32 address)
|
u32 HostRead_Instruction(const Core::CPUThreadGuard& guard, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
return ReadFromHardware<XCheckTLBFlag::OpcodeNoException, u32>(system, memory, address);
|
return ReadFromHardware<XCheckTLBFlag::OpcodeNoException, u32>(system, memory, address);
|
||||||
}
|
}
|
||||||
@ -536,7 +537,7 @@ std::optional<ReadResult<u32>> HostTryReadInstruction(const Core::CPUThreadGuard
|
|||||||
if (!HostIsInstructionRAMAddress(guard, address, space))
|
if (!HostIsInstructionRAMAddress(guard, address, space))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
switch (space)
|
switch (space)
|
||||||
@ -660,7 +661,7 @@ static std::optional<ReadResult<T>> HostTryReadUX(const Core::CPUThreadGuard& gu
|
|||||||
if (!HostIsRAMAddress(guard, address, space))
|
if (!HostIsRAMAddress(guard, address, space))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
switch (space)
|
switch (space)
|
||||||
@ -795,28 +796,28 @@ void Write_F64(const double var, const u32 address)
|
|||||||
|
|
||||||
u8 HostRead_U8(const Core::CPUThreadGuard& guard, const u32 address)
|
u8 HostRead_U8(const Core::CPUThreadGuard& guard, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
return ReadFromHardware<XCheckTLBFlag::NoException, u8>(system, memory, address);
|
return ReadFromHardware<XCheckTLBFlag::NoException, u8>(system, memory, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 HostRead_U16(const Core::CPUThreadGuard& guard, const u32 address)
|
u16 HostRead_U16(const Core::CPUThreadGuard& guard, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
return ReadFromHardware<XCheckTLBFlag::NoException, u16>(system, memory, address);
|
return ReadFromHardware<XCheckTLBFlag::NoException, u16>(system, memory, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 HostRead_U32(const Core::CPUThreadGuard& guard, const u32 address)
|
u32 HostRead_U32(const Core::CPUThreadGuard& guard, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
return ReadFromHardware<XCheckTLBFlag::NoException, u32>(system, memory, address);
|
return ReadFromHardware<XCheckTLBFlag::NoException, u32>(system, memory, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 HostRead_U64(const Core::CPUThreadGuard& guard, const u32 address)
|
u64 HostRead_U64(const Core::CPUThreadGuard& guard, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
return ReadFromHardware<XCheckTLBFlag::NoException, u64>(system, memory, address);
|
return ReadFromHardware<XCheckTLBFlag::NoException, u64>(system, memory, address);
|
||||||
}
|
}
|
||||||
@ -837,28 +838,28 @@ double HostRead_F64(const Core::CPUThreadGuard& guard, const u32 address)
|
|||||||
|
|
||||||
void HostWrite_U8(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
void HostWrite_U8(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 1);
|
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostWrite_U16(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
void HostWrite_U16(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 2);
|
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostWrite_U32(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
void HostWrite_U32(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 4);
|
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostWrite_U64(const Core::CPUThreadGuard& guard, const u64 var, const u32 address)
|
void HostWrite_U64(const Core::CPUThreadGuard& guard, const u64 var, const u32 address)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, static_cast<u32>(var >> 32),
|
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, static_cast<u32>(var >> 32),
|
||||||
4);
|
4);
|
||||||
@ -887,7 +888,7 @@ static std::optional<WriteResult> HostTryWriteUX(const Core::CPUThreadGuard& gua
|
|||||||
if (!HostIsRAMAddress(guard, address, space))
|
if (!HostIsRAMAddress(guard, address, space))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
switch (space)
|
switch (space)
|
||||||
@ -1041,7 +1042,7 @@ static bool IsRAMAddress(Memory::MemoryManager& memory, u32 address, bool transl
|
|||||||
|
|
||||||
bool HostIsRAMAddress(const Core::CPUThreadGuard& guard, u32 address, RequestedAddressSpace space)
|
bool HostIsRAMAddress(const Core::CPUThreadGuard& guard, u32 address, RequestedAddressSpace space)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
switch (space)
|
switch (space)
|
||||||
@ -1067,7 +1068,7 @@ bool HostIsInstructionRAMAddress(const Core::CPUThreadGuard& guard, u32 address,
|
|||||||
if (address & 3)
|
if (address & 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = guard.GetSystem();
|
||||||
auto& memory = system.GetMemory();
|
auto& memory = system.GetMemory();
|
||||||
|
|
||||||
switch (space)
|
switch (space)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user