portable debugbreak

ευχαριστώ ροδάκινε

Co-Authored-By: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com>
This commit is contained in:
georgemoralis 2023-07-24 13:05:57 +03:00
parent 947603e0e2
commit 2b9aaff641
6 changed files with 39 additions and 30 deletions

View File

@ -34,7 +34,7 @@ add_executable(shadps4
src/Core/Memory.h src/Core/Memory.h
src/Core/PS4/Linker.cpp src/Core/PS4/Linker.cpp
src/Core/PS4/Linker.h src/Core/PS4/Linker.h
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Util/StringUtil.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h") "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Util/StringUtil.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/Debug.h")
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
target_link_libraries(shadps4 PUBLIC fmt spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY}) target_link_libraries(shadps4 PUBLIC fmt spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY})

View File

@ -1,5 +1,6 @@
#include "ThreadManagement.h" #include "ThreadManagement.h"
#include "../ErrorCodes.h" #include "../ErrorCodes.h"
#include "../../../../Debug.h"
namespace HLE::Libs::LibKernel::ThreadManagement namespace HLE::Libs::LibKernel::ThreadManagement
{ {
@ -50,7 +51,7 @@ int scePthreadAttrSetdetachstate(ScePthreadAttr* attr, int detachstate) {
case 0: pstate = PTHREAD_CREATE_JOINABLE; break; case 0: pstate = PTHREAD_CREATE_JOINABLE; break;
case 1: pstate = PTHREAD_CREATE_DETACHED; break; case 1: pstate = PTHREAD_CREATE_DETACHED; break;
default: default:
__debugbreak(); //unknown state BREAKPOINT(); // unknown state
} }
int result = pthread_attr_setdetachstate(&(*attr)->pth_attr, pstate); int result = pthread_attr_setdetachstate(&(*attr)->pth_attr, pstate);
@ -73,7 +74,7 @@ int scePthreadAttrSetinheritsched(ScePthreadAttr* attr, int inheritSched) {
switch (inheritSched) { switch (inheritSched) {
case 0: pinherit_sched = PTHREAD_EXPLICIT_SCHED; break; case 0: pinherit_sched = PTHREAD_EXPLICIT_SCHED; break;
case 4: pinherit_sched = PTHREAD_INHERIT_SCHED; break; case 4: pinherit_sched = PTHREAD_INHERIT_SCHED; break;
default: __debugbreak(); // unknown inheritSched default: BREAKPOINT(); // unknown inheritSched
} }
int result = pthread_attr_setinheritsched(&(*attr)->pth_attr, pinherit_sched); int result = pthread_attr_setinheritsched(&(*attr)->pth_attr, pinherit_sched);
@ -115,7 +116,7 @@ int scePthreadAttrSetschedpolicy(ScePthreadAttr* attr, int policy) {
if (policy!= SCHED_OTHER) if (policy!= SCHED_OTHER)
{ {
__debugbreak();//invest if policy is other and if winpthreadlibrary support it BREAKPOINT(); // invest if policy is other and if winpthreadlibrary support it
} }
(*attr)->policy = policy; (*attr)->policy = policy;

View File

@ -1,6 +1,7 @@
#include "LibC.h" #include "LibC.h"
#include "Libs.h" #include "Libs.h"
#include "../Loader/Elf.h" #include "../Loader/Elf.h"
#include "../../../Debug.h"
namespace HLE::Libs::LibC { namespace HLE::Libs::LibC {
@ -13,13 +14,13 @@ namespace HLE::Libs::LibC {
int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object) int PS4_SYSV_ABI __cxa_guard_acquire(u64* guard_object)
{ {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int PS4_SYSV_ABI __cxa_guard_release(u64* guard_object) int PS4_SYSV_ABI __cxa_guard_release(u64* guard_object)
{ {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
@ -31,18 +32,16 @@ namespace HLE::Libs::LibC {
return ::memcpy(dest, src, n); return ::memcpy(dest, src, n);
} }
static PS4_SYSV_ABI void catchReturnFromMain(int status) static PS4_SYSV_ABI void catchReturnFromMain(int status) { BREAKPOINT();
{ __debugbreak();
} }
static PS4_SYSV_ABI void exit(int code) static PS4_SYSV_ABI void exit(int code) { BREAKPOINT();
{ __debugbreak();
} }
static PS4_SYSV_ABI int atexit(void (*func)()) static PS4_SYSV_ABI int atexit(void (*func)())
{ {
int rt = ::atexit(func); int rt = ::atexit(func);
if (rt != 0) if (rt != 0)
{ {
__debugbreak(); BREAKPOINT();
} }
return rt; return rt;
} }

View File

@ -1,6 +1,7 @@
#include "../Loader/Elf.h" #include "../Loader/Elf.h"
#include "LibKernel.h" #include "LibKernel.h"
#include "Libs.h" #include "Libs.h"
#include "../../../Debug.h"
namespace HLE::Libs::LibKernel { namespace HLE::Libs::LibKernel {
@ -8,39 +9,39 @@ namespace HLE::Libs::LibKernel {
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(off_t searchStart, off_t searchEnd, size_t len, size_t alignment, int memoryType, int PS4_SYSV_ABI sceKernelAllocateDirectMemory(off_t searchStart, off_t searchEnd, size_t len, size_t alignment, int memoryType,
off_t* physAddrOut) { off_t* physAddrOut) {
__debugbreak(); BREAKPOINT();
return 0; // OK return 0; // OK
} }
size_t PS4_SYSV_ABI sceKernelGetDirectMemorySize() { size_t PS4_SYSV_ABI sceKernelGetDirectMemorySize() {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, size_t len, int prot, int flags, off_t directMemoryStart, size_t alignment) { int32_t PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, size_t len, int prot, int flags, off_t directMemoryStart, size_t alignment) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len) { int32_t PS4_SYSV_ABI sceKernelReleaseDirectMemory(off_t start, size_t len) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int PS4_SYSV_ABI sceKernelCreateEqueue(/* SceKernelEqueue* eq*/ int eq, const char* name) int PS4_SYSV_ABI sceKernelCreateEqueue(/* SceKernelEqueue* eq*/ int eq, const char* name)
{ {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/) int PS4_SYSV_ABI sceKernelWaitEqueue(/*SceKernelEqueue eq, SceKernelEvent* ev,*/ int num, int* out /*, SceKernelUseconds* timo*/)
{ {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int PS4_SYSV_ABI sceKernelIsNeoMode() int PS4_SYSV_ABI sceKernelIsNeoMode()
{ {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
static PS4_SYSV_ABI void stack_chk_fail() { __debugbreak(); static PS4_SYSV_ABI void stack_chk_fail() { BREAKPOINT();
} }
void LibKernel_Register(SymbolsResolver* sym) { void LibKernel_Register(SymbolsResolver* sym) {
//obj //obj

View File

@ -1,39 +1,40 @@
#include "LibSceVideoOut.h" #include "LibSceVideoOut.h"
#include "Libs.h" #include "Libs.h"
#include "../Loader/Elf.h" #include "../Loader/Elf.h"
#include "../../../Debug.h"
namespace HLE::Libs::LibSceVideoOut { namespace HLE::Libs::LibSceVideoOut {
int32_t PS4_SYSV_ABI sceVideoOutGetFlipStatus(int32_t handle /*, SceVideoOutFlipStatus* status*/) { int32_t PS4_SYSV_ABI sceVideoOutGetFlipStatus(int32_t handle /*, SceVideoOutFlipStatus* status*/) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex, int32_t flipMode, int64_t flipArg) { int32_t PS4_SYSV_ABI sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex, int32_t flipMode, int64_t flipArg) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex, void* const* addresses, int32_t bufferNum /*, int32_t PS4_SYSV_ABI sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex, void* const* addresses, int32_t bufferNum /*,
const SceVideoOutBufferAttribute* attribute*/) { const SceVideoOutBufferAttribute* attribute*/) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceVideoOutAddFlipEvent(/*SceKernelEqueue eq,*/ int32_t handle, void* udata) { int32_t PS4_SYSV_ABI sceVideoOutAddFlipEvent(/*SceKernelEqueue eq,*/ int32_t handle, void* udata) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceVideoOutSetFlipRate(int32_t handle, int32_t rate) { int32_t PS4_SYSV_ABI sceVideoOutSetFlipRate(int32_t handle, int32_t rate) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(/* SceVideoOutBufferAttribute* attribute,*/ uint32_t pixelFormat, uint32_t tilingMode, void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(/* SceVideoOutBufferAttribute* attribute,*/ uint32_t pixelFormat, uint32_t tilingMode,
uint32_t aspectRatio, uint32_t aspectRatio,
uint32_t width, uint32_t height, uint32_t pitchInPixel) uint32_t width, uint32_t height, uint32_t pitchInPixel)
{ {
__debugbreak(); BREAKPOINT();
} }
int32_t PS4_SYSV_ABI sceVideoOutGetResolutionStatus(int32_t handle /*, SceVideoOutResolutionStatus* status*/) { int32_t PS4_SYSV_ABI sceVideoOutGetResolutionStatus(int32_t handle /*, SceVideoOutResolutionStatus* status*/) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
@ -42,15 +43,15 @@ namespace HLE::Libs::LibSceVideoOut {
{ {
if (busType != 0) if (busType != 0)
{ {
__debugbreak(); BREAKPOINT();
} }
if (index != 0) if (index != 0)
{ {
__debugbreak(); BREAKPOINT();
} }
if (param != nullptr) if (param != nullptr)
{ {
__debugbreak(); BREAKPOINT();
} }
for (;;) { for (;;) {
printf("videoopen\n"); printf("videoopen\n");
@ -58,7 +59,7 @@ namespace HLE::Libs::LibSceVideoOut {
return 0; return 0;
} }
int32_t PS4_SYSV_ABI sceVideoOutIsFlipPending(int32_t handle) { int32_t PS4_SYSV_ABI sceVideoOutIsFlipPending(int32_t handle) {
__debugbreak(); BREAKPOINT();
return 0; return 0;
} }
void LibSceVideoOut_Register(SymbolsResolver* sym) void LibSceVideoOut_Register(SymbolsResolver* sym)

7
src/Debug.h Normal file
View File

@ -0,0 +1,7 @@
#ifdef _MSC_VER
#define BREAKPOINT __debugbreak
#elif defined(__GNUC__)
#define BREAKPOINT __builtin_trap
#else
#error What the fuck is this compiler
#endif