mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Initial code for the tracer + fixed the file locations
This commit is contained in:
parent
34f113207d
commit
854579a97b
@ -583,7 +583,6 @@
|
||||
<ClCompile Include="KeyMap.cpp" />
|
||||
<ClCompile Include="KeyMapDefaults.cpp" />
|
||||
<ClCompile Include="MemFault.cpp" />
|
||||
<ClCompile Include="MIPSTracer.cpp" />
|
||||
<ClCompile Include="MIPS\ARM64\Arm64IRAsm.cpp" />
|
||||
<ClCompile Include="MIPS\ARM64\Arm64IRCompALU.cpp" />
|
||||
<ClCompile Include="MIPS\ARM64\Arm64IRCompBranch.cpp" />
|
||||
@ -993,6 +992,7 @@
|
||||
<ClCompile Include="MIPS\MIPSIntVFPU.cpp" />
|
||||
<ClCompile Include="MIPS\MIPSTables.cpp" />
|
||||
<ClCompile Include="MIPS\MIPSVFPUUtils.cpp" />
|
||||
<ClCompile Include="MIPS\MIPSTracer.cpp" />
|
||||
<ClCompile Include="MIPS\MIPS\MipsJit.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@ -1194,7 +1194,6 @@
|
||||
<ClInclude Include="KeyMap.h" />
|
||||
<ClInclude Include="KeyMapDefaults.h" />
|
||||
<ClInclude Include="MemFault.h" />
|
||||
<ClInclude Include="MIPSTracer.h" />
|
||||
<ClInclude Include="MIPS\ARM64\Arm64IRJit.h" />
|
||||
<ClInclude Include="MIPS\ARM64\Arm64IRRegCache.h" />
|
||||
<ClInclude Include="MIPS\fake\FakeJit.h" />
|
||||
@ -1408,6 +1407,7 @@
|
||||
<ClInclude Include="MIPS\MIPSIntVFPU.h" />
|
||||
<ClInclude Include="MIPS\MIPSTables.h" />
|
||||
<ClInclude Include="MIPS\MIPSVFPUUtils.h" />
|
||||
<ClInclude Include="MIPS\MIPSTracer.h" />
|
||||
<ClInclude Include="MIPS\MIPS\MipsJit.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
@ -123,6 +123,9 @@
|
||||
<ClCompile Include="MIPS\MIPSVFPUUtils.cpp">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MIPS\MIPSTracer.cpp">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MIPS\MIPSAnalyst.cpp">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClCompile>
|
||||
@ -1315,9 +1318,6 @@
|
||||
<ClCompile Include="HLE\AtracCtx2.cpp">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MIPSTracer.cpp">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@ -1350,6 +1350,9 @@
|
||||
<ClInclude Include="MIPS\MIPSVFPUUtils.h">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MIPS\MIPSTracer.h">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MIPS\MIPSAnalyst.h">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClInclude>
|
||||
@ -2109,9 +2112,6 @@
|
||||
<ClInclude Include="HLE\AtracCtx2.h">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MIPSTracer.h">
|
||||
<Filter>MIPS</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE.TXT" />
|
||||
|
41
Core/MIPS/MIPSTracer.cpp
Normal file
41
Core/MIPS/MIPSTracer.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2024- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Core/MIPS/MIPSTracer.h"
|
||||
|
||||
#include <cstring> // for std::memcpy
|
||||
#include "Core/MIPS/MIPSTables.h" // for MIPSDisAsm
|
||||
|
||||
|
||||
bool TraceBlockStorage::push_block(u32* instructions, u32 size) {
|
||||
if (cur_offset + size >= raw_instructions.size()) {
|
||||
return false;
|
||||
}
|
||||
std::memcpy(cur_data_ptr, instructions, size);
|
||||
cur_offset += size;
|
||||
cur_data_ptr += size;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TraceBlockStorage::initialize(u32 capacity) {
|
||||
raw_instructions.resize(capacity);
|
||||
cur_offset = 0;
|
||||
cur_data_ptr = raw_instructions.data();
|
||||
}
|
||||
|
||||
|
||||
MIPSTracer mipsTracer;
|
138
Core/MIPS/MIPSTracer.h
Normal file
138
Core/MIPS/MIPSTracer.h
Normal file
@ -0,0 +1,138 @@
|
||||
// Copyright (c) 2024- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Opcode.h"
|
||||
|
||||
|
||||
|
||||
struct TraceBlockInfo {
|
||||
u32 virt_address;
|
||||
u32 size;
|
||||
u32 storage_index;
|
||||
};
|
||||
|
||||
struct TraceBlockStorage {
|
||||
std::vector<u32> raw_instructions;
|
||||
u32 cur_offset;
|
||||
u32* cur_data_ptr;
|
||||
|
||||
TraceBlockStorage(u32 capacity):
|
||||
raw_instructions(capacity, 0),
|
||||
cur_offset(0),
|
||||
cur_data_ptr(raw_instructions.data())
|
||||
{}
|
||||
|
||||
TraceBlockStorage(): raw_instructions(), cur_offset(0), cur_data_ptr(nullptr) {}
|
||||
|
||||
bool push_block(u32* instructions, u32 size);
|
||||
|
||||
void initialize(u32 capacity);
|
||||
|
||||
Memory::Opcode operator[](u32 index) {
|
||||
return Memory::Opcode(raw_instructions[index]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct CyclicBuffer {
|
||||
std::vector<T> buffer;
|
||||
u32 current_index;
|
||||
bool overflow;
|
||||
|
||||
explicit CyclicBuffer(u32 capacity) : buffer(capacity, T()), current_index(0), overflow(false) {}
|
||||
|
||||
CyclicBuffer(): buffer(), current_index(0), overflow(false) {}
|
||||
|
||||
void push_back(const T& value);
|
||||
void push_back(T&& value);
|
||||
|
||||
void clear();
|
||||
void resize(u32 new_capacity);
|
||||
|
||||
std::vector<T> get_content() const;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> CyclicBuffer<T>::get_content() const {
|
||||
if (!overflow) {
|
||||
return std::vector<T>(buffer.begin(), buffer.begin() + current_index);
|
||||
}
|
||||
|
||||
std::vector<T> ans;
|
||||
ans.reserve(buffer.size());
|
||||
std::copy(buffer.begin() + current_index, buffer.end(), std::back_inserter(ans));
|
||||
std::copy(buffer.begin(), buffer.begin() + current_index, std::back_inserter(ans));
|
||||
return ans;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CyclicBuffer<T>::push_back(const T& value) {
|
||||
buffer[current_index] = value;
|
||||
++current_index;
|
||||
if (current_index == buffer.size()) {
|
||||
current_index = 0;
|
||||
overflow = true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CyclicBuffer<T>::push_back(T&& value) {
|
||||
buffer[current_index] = std::move(value);
|
||||
++current_index;
|
||||
if (current_index == buffer.size()) {
|
||||
current_index = 0;
|
||||
overflow = true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CyclicBuffer<T>::clear() {
|
||||
buffer.clear();
|
||||
current_index = 0;
|
||||
overflow = false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CyclicBuffer<T>::resize(u32 new_capacity) {
|
||||
buffer.resize(new_capacity);
|
||||
}
|
||||
|
||||
struct MIPSTracer {
|
||||
std::vector<TraceBlockInfo> trace_info;
|
||||
|
||||
// The trace might be very big, in that case I don't mind losing the oldest entries.
|
||||
CyclicBuffer<u32> executed_blocks;
|
||||
|
||||
std::unordered_map<u64, u32> hash_to_index;
|
||||
|
||||
TraceBlockStorage storage;
|
||||
|
||||
std::string logging_path;
|
||||
|
||||
MIPSTracer(): trace_info(), executed_blocks(), hash_to_index(), storage(), logging_path() {}
|
||||
};
|
||||
|
||||
extern MIPSTracer mipsTracer;
|
@ -1 +0,0 @@
|
||||
#pragma once
|
Loading…
Reference in New Issue
Block a user