Route diagnostic hooks through platform services

This commit is contained in:
2026-06-03 05:12:00 +02:00
parent e152616d7f
commit 6652127545
8 changed files with 69 additions and 21 deletions

View File

@@ -79,24 +79,12 @@ bool App::clipboard_set_text(const std::string& s)
void App::stacktrace()
{
#if __OSX__
NSString* callstack = [[NSThread callStackSymbols] componentsJoinedByString:@"\n"];
LOG("callstack:\n%s", [callstack cStringUsingEncoding:NSUTF8StringEncoding]);
#endif
active_platform_services().log_stacktrace();
}
void App::crash_test()
{
#ifdef __IOS__
[ios_view crash];
#elif __OSX__
[osx_view hockeyapp_crash];
#elif defined(_WIN32)
__debugbreak();
#elif defined(__ANDROID__)
int *x = nullptr; *x = 42;
LOG("%d", *x);
#endif
active_platform_services().trigger_crash_test();
}
void App::tick(float dt)

View File

@@ -22,6 +22,8 @@ public:
virtual ~PlatformServices() = default;
[[nodiscard]] virtual PlatformStoragePaths prepare_storage_paths() = 0;
virtual void log_stacktrace() = 0;
virtual void trigger_crash_test() = 0;
[[nodiscard]] virtual std::string clipboard_text() = 0;
[[nodiscard]] virtual bool set_clipboard_text(std::string_view text) = 0;
virtual void set_cursor_visible(bool visible) = 0;

View File

@@ -101,6 +101,26 @@ public:
#endif
}
void log_stacktrace() override
{
#if defined(__OSX__)
NSString* callstack = [[NSThread callStackSymbols] componentsJoinedByString:@"\n"];
LOG("callstack:\n%s", [callstack cStringUsingEncoding:NSUTF8StringEncoding]);
#endif
}
void trigger_crash_test() override
{
#ifdef __IOS__
[App::I->ios_view crash];
#elif __OSX__
[App::I->osx_view hockeyapp_crash];
#elif defined(__ANDROID__)
int *x = nullptr; *x = 42;
LOG("%d", *x);
#endif
}
[[nodiscard]] std::string clipboard_text() override
{
#if __IOS__

View File

@@ -195,6 +195,15 @@ public:
};
}
void log_stacktrace() override
{
}
void trigger_crash_test() override
{
__debugbreak();
}
[[nodiscard]] std::string clipboard_text() override
{
return ::clipboard_text();