Skip to content

Commit 8e4ad3d

Browse files
committed
Property sheets, configuration simplified
MemLeak build fixed
1 parent be1c910 commit 8e4ad3d

16 files changed

+226
-602
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ x64/*
7373
rpcs3/x64/*
7474
rpcs3-tests/x64/*
7575

76-
.DS_Store
77-
rpcs3/Emu/SysCalls/Modules/prx_*.h
78-
7976
# cmake
8077
Makefile
8178
*CMakeFiles*

Utilities/Thread.cpp

+31-50
Original file line numberDiff line numberDiff line change
@@ -532,50 +532,32 @@ uint64_t* darwin_x64reg(x64_context *context, int reg)
532532
auto *state = &context->uc_mcontext->__ss;
533533
switch(reg)
534534
{
535-
case 0: // RAX
536-
return &state->__rax;
537-
case 1: // RCX
538-
return &state->__rcx;
539-
case 2: // RDX
540-
return &state->__rdx;
541-
case 3: // RBX
542-
return &state->__rbx;
543-
case 4: // RSP
544-
return &state->__rsp;
545-
case 5: // RBP
546-
return &state->__rbp;
547-
case 6: // RSI
548-
return &state->__rsi;
549-
case 7: // RDI
550-
return &state->__rdi;
551-
case 8: // R8
552-
return &state->__r8;
553-
case 9: // R9
554-
return &state->__r9;
555-
case 10: // R10
556-
return &state->__r10;
557-
case 11: // R11
558-
return &state->__r11;
559-
case 12: // R12
560-
return &state->__r12;
561-
case 13: // R13
562-
return &state->__r13;
563-
case 14: // R14
564-
return &state->__r14;
565-
case 15: // R15
566-
return &state->__r15;
567-
case 16: // RIP
568-
return &state->__rip;
569-
default: // FAIL
570-
assert(0);
535+
case 0: return &state->__rax;
536+
case 1: return &state->__rcx;
537+
case 2: return &state->__rdx;
538+
case 3: return &state->__rbx;
539+
case 4: return &state->__rsp;
540+
case 5: return &state->__rbp;
541+
case 6: return &state->__rsi;
542+
case 7: return &state->__rdi;
543+
case 8: return &state->__r8;
544+
case 9: return &state->__r9;
545+
case 10: return &state->__r10;
546+
case 11: return &state->__r11;
547+
case 12: return &state->__r12;
548+
case 13: return &state->__r13;
549+
case 14: return &state->__r14;
550+
case 15: return &state->__r15;
551+
case 16: return &state->__rip;
552+
default:
553+
LOG_ERROR(GENERAL, "Invalid register index: %d", reg);
554+
return nullptr;
571555
}
572556
}
573557

574558
#else
575559

576-
typedef decltype(REG_RIP) reg_table_t;
577-
578-
static const reg_table_t reg_table[17] =
560+
static const decltype(REG_RAX) reg_table[] =
579561
{
580562
REG_RAX, REG_RCX, REG_RDX, REG_RBX, REG_RSP, REG_RBP, REG_RSI, REG_RDI,
581563
REG_R8, REG_R9, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15, REG_RIP
@@ -1139,14 +1121,16 @@ void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp)
11391121
const u64 addr64 = (u64)pExp->ExceptionRecord->ExceptionInformation[1] - (u64)vm::base(0);
11401122
const bool is_writing = pExp->ExceptionRecord->ExceptionInformation[0] != 0;
11411123

1142-
if (u == EXCEPTION_ACCESS_VIOLATION && (u32)addr64 == addr64)
1124+
if (u == EXCEPTION_ACCESS_VIOLATION)
11431125
{
1144-
throw EXCEPTION("Access violation %s location 0x%llx", is_writing ? "writing" : "reading", addr64);
1126+
if ((u32)addr64 == addr64)
1127+
{
1128+
throw EXCEPTION("Access violation %s location 0x%llx", is_writing ? "writing" : "reading", addr64);
1129+
}
1130+
1131+
std::printf("Access violation %s location %p at %p\n", is_writing ? "writing" : "reading", (void*)pExp->ExceptionRecord->ExceptionInformation[1], pExp->ExceptionRecord->ExceptionAddress);
1132+
std::abort();
11451133
}
1146-
1147-
__debugbreak(); // if it reached there, there should probably be a possibility to check the callstack
1148-
1149-
throw EXCEPTION("Fatal error occured %s location %p at %p", is_writing ? "writing" : "reading", pExp->ExceptionRecord->ExceptionInformation[1], pExp->ExceptionRecord->ExceptionAddress);
11501134
}
11511135

11521136
const PVOID exception_handler = (atexit([]{ RemoveVectoredExceptionHandler(exception_handler); }), AddVectoredExceptionHandler(1, [](PEXCEPTION_POINTERS pExp) -> LONG
@@ -1195,7 +1179,8 @@ void signal_handler(int sig, siginfo_t* info, void* uct)
11951179
}
11961180

11971181
// else some fatal error
1198-
exit(EXIT_FAILURE);
1182+
std::printf("Access violation %s location %p at %p\n", is_writing ? "writing" : "reading", info->si_addr, RIP((ucontext_t*)uct));
1183+
std::abort();
11991184
}
12001185

12011186
const int sigaction_result = []() -> int
@@ -1219,10 +1204,6 @@ void thread_ctrl::initialize()
12191204
{
12201205
SetCurrentThreadDebugName(g_tls_this_thread->m_name().c_str());
12211206

1222-
#if defined(_MSC_VER)
1223-
_set_se_translator(_se_translator); // not essential, disable if necessary
1224-
#endif
1225-
12261207
#ifdef _WIN32
12271208
if (!exception_handler || !exception_filter)
12281209
#else

asmjitsrc/asmjit.vcxproj

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
<ConfigurationType>StaticLibrary</ConfigurationType>
8282
<UseDebugLibraries>false</UseDebugLibraries>
8383
<PlatformToolset>v140</PlatformToolset>
84-
<WholeProgramOptimization>true</WholeProgramOptimization>
8584
<CharacterSet>Unicode</CharacterSet>
8685
</PropertyGroup>
8786
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

rpcs3/D3D12GSRender.vcxproj

+13-144
Original file line numberDiff line numberDiff line change
@@ -28,170 +28,39 @@
2828
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
2929
</PropertyGroup>
3030
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
31-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
31+
<PropertyGroup Label="Configuration">
3232
<ConfigurationType>StaticLibrary</ConfigurationType>
33-
<UseDebugLibraries>true</UseDebugLibraries>
34-
<PlatformToolset>v140</PlatformToolset>
35-
<CharacterSet>Unicode</CharacterSet>
36-
</PropertyGroup>
37-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'" Label="Configuration">
38-
<ConfigurationType>StaticLibrary</ConfigurationType>
39-
<UseDebugLibraries>true</UseDebugLibraries>
40-
<PlatformToolset>v140</PlatformToolset>
41-
<CharacterSet>Unicode</CharacterSet>
42-
</PropertyGroup>
43-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'" Label="Configuration">
44-
<ConfigurationType>StaticLibrary</ConfigurationType>
45-
<UseDebugLibraries>true</UseDebugLibraries>
46-
<PlatformToolset>v140</PlatformToolset>
4733
<CharacterSet>Unicode</CharacterSet>
48-
</PropertyGroup>
49-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
50-
<ConfigurationType>StaticLibrary</ConfigurationType>
51-
<UseDebugLibraries>false</UseDebugLibraries>
52-
<PlatformToolset>v140</PlatformToolset>
53-
<WholeProgramOptimization>false</WholeProgramOptimization>
54-
<CharacterSet>Unicode</CharacterSet>
55-
</PropertyGroup>
56-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'" Label="Configuration">
57-
<ConfigurationType>StaticLibrary</ConfigurationType>
58-
<UseDebugLibraries>false</UseDebugLibraries>
5934
<PlatformToolset>v140</PlatformToolset>
60-
<WholeProgramOptimization>false</WholeProgramOptimization>
61-
<CharacterSet>Unicode</CharacterSet>
6235
</PropertyGroup>
6336
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
6437
<ImportGroup Label="ExtensionSettings">
6538
</ImportGroup>
6639
<ImportGroup Label="Shared">
6740
</ImportGroup>
68-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
41+
<ImportGroup Label="PropertySheets">
6942
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
43+
<Import Project="..\rpcs3_default.props" />
44+
</ImportGroup>
45+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
46+
<Import Project="..\rpcs3_debug.props" />
7047
</ImportGroup>
7148
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'" Label="PropertySheets">
72-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
49+
<Import Project="..\rpcs3_debug.props" />
50+
<Import Project="..\rpcs3_memleak.props" />
7351
</ImportGroup>
7452
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'" Label="PropertySheets">
75-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
53+
<Import Project="..\rpcs3_debug.props" />
54+
<Import Project="..\rpcs3_llvm.props" />
7655
</ImportGroup>
7756
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
78-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
<Import Project="..\rpcs3_release.props" />
7958
</ImportGroup>
8059
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'" Label="PropertySheets">
81-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
<Import Project="..\rpcs3_release.props" />
61+
<Import Project="..\rpcs3_llvm.props" />
8262
</ImportGroup>
8363
<PropertyGroup Label="UserMacros" />
84-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
85-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\minidx12\Include;$(IncludePath)</IncludePath>
86-
</PropertyGroup>
87-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">
88-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\minidx12\Include;$(IncludePath)</IncludePath>
89-
</PropertyGroup>
90-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
91-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\minidx12\Include;$(IncludePath)</IncludePath>
92-
</PropertyGroup>
93-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
94-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\minidx12\Include;$(IncludePath)</IncludePath>
95-
</PropertyGroup>
96-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
97-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\minidx12\Include;$(IncludePath)</IncludePath>
98-
</PropertyGroup>
99-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
100-
<ClCompile>
101-
<WarningLevel>Level3</WarningLevel>
102-
<Optimization>Disabled</Optimization>
103-
<SDLCheck>false</SDLCheck>
104-
<PrecompiledHeader>Use</PrecompiledHeader>
105-
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
106-
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>
107-
<PrecompiledHeaderOutputFile>$(Platform)\$(Configuration).pch</PrecompiledHeaderOutputFile>
108-
<ProgramDataBaseFileName>$(Platform)\$(Configuration).pdb</ProgramDataBaseFileName>
109-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
110-
<ExceptionHandling>Async</ExceptionHandling>
111-
</ClCompile>
112-
<Link>
113-
<GenerateDebugInformation>true</GenerateDebugInformation>
114-
</Link>
115-
</ItemDefinitionGroup>
116-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">
117-
<ClCompile>
118-
<WarningLevel>Level3</WarningLevel>
119-
<Optimization>Disabled</Optimization>
120-
<SDLCheck>false</SDLCheck>
121-
<PrecompiledHeader>Use</PrecompiledHeader>
122-
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
123-
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>
124-
<PrecompiledHeaderOutputFile>$(Platform)\$(Configuration).pch</PrecompiledHeaderOutputFile>
125-
<ProgramDataBaseFileName>$(Platform)\$(Configuration).pdb</ProgramDataBaseFileName>
126-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
127-
<ExceptionHandling>Async</ExceptionHandling>
128-
<PreprocessorDefinitions>_UNICODE;UNICODE;MSVC_CRT_MEMLEAK_DETECTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
129-
</ClCompile>
130-
<Link>
131-
<GenerateDebugInformation>true</GenerateDebugInformation>
132-
</Link>
133-
</ItemDefinitionGroup>
134-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
135-
<ClCompile>
136-
<WarningLevel>Level3</WarningLevel>
137-
<Optimization>Disabled</Optimization>
138-
<SDLCheck>false</SDLCheck>
139-
<PrecompiledHeader>Use</PrecompiledHeader>
140-
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
141-
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>
142-
<PrecompiledHeaderOutputFile>$(Platform)\$(Configuration).pch</PrecompiledHeaderOutputFile>
143-
<ProgramDataBaseFileName>$(Platform)\$(Configuration).pdb</ProgramDataBaseFileName>
144-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
145-
<ExceptionHandling>Async</ExceptionHandling>
146-
<PreprocessorDefinitions>_UNICODE;UNICODE;LLVM_AVAILABLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
147-
</ClCompile>
148-
<Link>
149-
<GenerateDebugInformation>true</GenerateDebugInformation>
150-
</Link>
151-
</ItemDefinitionGroup>
152-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
153-
<ClCompile>
154-
<WarningLevel>Level3</WarningLevel>
155-
<Optimization>MaxSpeed</Optimization>
156-
<FunctionLevelLinking>true</FunctionLevelLinking>
157-
<IntrinsicFunctions>true</IntrinsicFunctions>
158-
<SDLCheck>false</SDLCheck>
159-
<PrecompiledHeader>Use</PrecompiledHeader>
160-
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
161-
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>
162-
<PrecompiledHeaderOutputFile>$(Platform)\$(Configuration).pch</PrecompiledHeaderOutputFile>
163-
<ProgramDataBaseFileName>$(Platform)\$(Configuration).pdb</ProgramDataBaseFileName>
164-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
165-
<ExceptionHandling>Async</ExceptionHandling>
166-
</ClCompile>
167-
<Link>
168-
<GenerateDebugInformation>true</GenerateDebugInformation>
169-
<EnableCOMDATFolding>true</EnableCOMDATFolding>
170-
<OptimizeReferences>true</OptimizeReferences>
171-
</Link>
172-
</ItemDefinitionGroup>
173-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
174-
<ClCompile>
175-
<WarningLevel>Level3</WarningLevel>
176-
<Optimization>MaxSpeed</Optimization>
177-
<FunctionLevelLinking>true</FunctionLevelLinking>
178-
<IntrinsicFunctions>true</IntrinsicFunctions>
179-
<SDLCheck>false</SDLCheck>
180-
<PrecompiledHeader>Use</PrecompiledHeader>
181-
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
182-
<AdditionalIncludeDirectories>.;..</AdditionalIncludeDirectories>
183-
<PrecompiledHeaderOutputFile>$(Platform)\$(Configuration).pch</PrecompiledHeaderOutputFile>
184-
<ProgramDataBaseFileName>$(Platform)\$(Configuration).pdb</ProgramDataBaseFileName>
185-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
186-
<ExceptionHandling>Async</ExceptionHandling>
187-
<PreprocessorDefinitions>_UNICODE;UNICODE;LLVM_AVAILABLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
188-
</ClCompile>
189-
<Link>
190-
<GenerateDebugInformation>true</GenerateDebugInformation>
191-
<EnableCOMDATFolding>true</EnableCOMDATFolding>
192-
<OptimizeReferences>true</OptimizeReferences>
193-
</Link>
194-
</ItemDefinitionGroup>
19564
<ItemGroup>
19665
<ClInclude Include="Emu\RSX\D3D12\D3D12Utils.h" />
19766
<ClInclude Include="Emu\RSX\D3D12\D3D12CommonDecompiler.h" />

rpcs3/D3D12GSRender.vcxproj.user

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

rpcs3/Emu/Memory/vm_var.h

+17-7
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ namespace vm
101101
using pointer = _ptr_base<T, const u32>;
102102

103103
public:
104+
// Call the constructor with specified arguments
104105
template<typename... Args, typename = std::enable_if_t<std::is_constructible<T, Args...>::value>> _var_base(Args&&... args)
105106
: pointer(A::alloc(sizeof32(T), alignof32(T)), vm::addr)
106107
{
107-
// Call the constructor with specified arguments
108+
#include "restore_new.h"
108109
new(pointer::get_ptr()) T(std::forward<Args>(args)...);
110+
#include "define_new_memleakdetect.h"
109111
}
110112

111113
_var_base(const _var_base&) = delete; // Delete copy/move constructors and copy/move operators
@@ -131,20 +133,24 @@ namespace vm
131133
u32 m_count;
132134

133135
public:
136+
// Call the default constructor for each element
134137
_var_base(u32 count)
135138
: pointer(A::alloc(sizeof32(T) * count, alignof32(T)), vm::addr)
136139
, m_count(count)
137140
{
138-
// Call the default constructor for each element
141+
#include "restore_new.h"
139142
new(pointer::get_ptr()) T[count]();
143+
#include "define_new_memleakdetect.h"
140144
}
141145

146+
// Call the constructor for each element using [it, it + count)
142147
template<typename T2> _var_base(u32 count, T2 it)
143148
: pointer(A::alloc(sizeof32(T) * count, alignof32(T)), vm::addr)
144149
, m_count(count)
145150
{
146-
// Initialize each element using iterator
147-
std::uninitialized_copy_n<T2>(it, count, const_cast<std::remove_cv_t<T>*>(pointer::get_ptr()));
151+
#include "restore_new.h"
152+
for (u32 i = 0; i < m_count; i++, it++) new(pointer::get_ptr() + i) T(*it);
153+
#include "define_new_memleakdetect.h"
148154
}
149155

150156
_var_base(const _var_base&) = delete; // Delete copy/move constructors and copy/move operators
@@ -180,18 +186,22 @@ namespace vm
180186
using pointer = _ptr_base<T, const u32>;
181187

182188
public:
189+
// Call the default constructor for each element
183190
_var_base()
184191
: pointer(A::alloc(sizeof32(T) * N, alignof32(T)), vm::addr)
185192
{
186-
// Call the default constructor for each element
193+
#include "restore_new.h"
187194
new(pointer::get_ptr()) T[N]();
195+
#include "define_new_memleakdetect.h"
188196
}
189197

198+
// Call the constructor for each element using array
190199
template<typename T2> _var_base(const T2(&array)[N])
191200
: pointer(A::alloc(sizeof32(T) * N, alignof32(T)), vm::addr)
192201
{
193-
// Copy the array
194-
std::uninitialized_copy_n(array + 0, N, const_cast<std::remove_cv_t<T>*>(pointer::get_ptr()));
202+
#include "restore_new.h"
203+
for (u32 i = 0; i < N; i++) new(pointer::get_ptr() + i) T(array[i]);
204+
#include "define_new_memleakdetect.h"
195205
}
196206

197207
_var_base(const _var_base&) = delete; // Delete copy/move constructors and copy/move operators

0 commit comments

Comments
 (0)