mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 07:49:57 -04:00
Try to better support non glibc systems
This commit is contained in:
parent
08e5d21d4b
commit
c9b1c04924
3
.github/workflows/build_mac32.yml
vendored
3
.github/workflows/build_mac32.yml
vendored
@ -13,9 +13,6 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
env:
|
|
||||||
GHCR_ACCESS_KEY: ${{ secrets.GHCR_ACCESS_KEY }}
|
|
||||||
if: ${{ env.GHCR_ACCESS_KEY != '' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/classicube/minimal-osxcross:latest
|
image: ghcr.io/classicube/minimal-osxcross:latest
|
||||||
|
45
src/Logger.c
45
src/Logger.c
@ -340,21 +340,7 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|||||||
String_AppendConst(trace, _NL);
|
String_AppendConst(trace, _NL);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_ANDROID
|
#elif defined CC_BUILD_ANDROID
|
||||||
/* android's bionic libc doesn't provide backtrace (execinfo.h) */
|
#define CC_BACKTRACE_UNWIND
|
||||||
#include <unwind.h>
|
|
||||||
|
|
||||||
static _Unwind_Reason_Code UnwindFrame(struct _Unwind_Context* ctx, void* arg) {
|
|
||||||
cc_uintptr addr = _Unwind_GetIP(ctx);
|
|
||||||
if (!addr) return _URC_END_OF_STACK;
|
|
||||||
|
|
||||||
DumpFrame((cc_string*)arg, (void*)addr);
|
|
||||||
return _URC_NO_REASON;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|
||||||
_Unwind_Backtrace(UnwindFrame, trace);
|
|
||||||
String_AppendConst(trace, _NL);
|
|
||||||
}
|
|
||||||
#elif defined CC_BUILD_DARWIN
|
#elif defined CC_BUILD_DARWIN
|
||||||
/* backtrace is only available on macOS since 10.5 */
|
/* backtrace is only available on macOS since 10.5 */
|
||||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||||
@ -368,7 +354,8 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|||||||
/* Skip frames don't want to include in backtrace */
|
/* Skip frames don't want to include in backtrace */
|
||||||
/* frame 0 = thread_stack_pcs */
|
/* frame 0 = thread_stack_pcs */
|
||||||
/* frame 1 = Logger_Backtrace */
|
/* frame 1 = Logger_Backtrace */
|
||||||
for (i = 2; i < frames; i++) {
|
for (i = 2; i < frames; i++)
|
||||||
|
{
|
||||||
DumpFrame(trace, addrs[i]);
|
DumpFrame(trace, addrs[i]);
|
||||||
}
|
}
|
||||||
String_AppendConst(trace, _NL);
|
String_AppendConst(trace, _NL);
|
||||||
@ -385,17 +372,21 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|||||||
}
|
}
|
||||||
#elif defined CC_BACKTRACE_BUILTIN
|
#elif defined CC_BACKTRACE_BUILTIN
|
||||||
/* Implemented later at end of the file */
|
/* Implemented later at end of the file */
|
||||||
#elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2
|
#elif defined CC_BUILD_POSIX && defined _GLIBC_
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||||
void* addrs[MAX_BACKTRACE_FRAMES];
|
void* addrs[MAX_BACKTRACE_FRAMES];
|
||||||
int i, frames = backtrace(addrs, MAX_BACKTRACE_FRAMES);
|
int i, frames = backtrace(addrs, MAX_BACKTRACE_FRAMES);
|
||||||
|
|
||||||
for (i = 0; i < frames; i++) {
|
for (i = 0; i < frames; i++)
|
||||||
|
{
|
||||||
DumpFrame(trace, addrs[i]);
|
DumpFrame(trace, addrs[i]);
|
||||||
}
|
}
|
||||||
String_AppendConst(trace, _NL);
|
String_AppendConst(trace, _NL);
|
||||||
}
|
}
|
||||||
|
#elif defined CC_BUILD_POSIX
|
||||||
|
/* musl etc - rely on unwind from GCC instead */
|
||||||
|
#define CC_BACKTRACE_UNWIND
|
||||||
#else
|
#else
|
||||||
void Logger_Backtrace(cc_string* trace, void* ctx) { }
|
void Logger_Backtrace(cc_string* trace, void* ctx) { }
|
||||||
#endif
|
#endif
|
||||||
@ -1298,6 +1289,24 @@ void Logger_FailToStart(const char* raw_msg) {
|
|||||||
Process_Exit(1);
|
Process_Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined CC_BACKTRACE_UNWIND
|
||||||
|
#include <unwind.h>
|
||||||
|
|
||||||
|
static _Unwind_Reason_Code UnwindFrame(struct _Unwind_Context* ctx, void* arg) {
|
||||||
|
cc_uintptr addr = _Unwind_GetIP(ctx);
|
||||||
|
if (!addr) return _URC_END_OF_STACK;
|
||||||
|
|
||||||
|
DumpFrame((cc_string*)arg, (void*)addr);
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||||
|
_Unwind_Backtrace(UnwindFrame, trace);
|
||||||
|
String_AppendConst(trace, _NL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined CC_BACKTRACE_BUILTIN
|
#if defined CC_BACKTRACE_BUILTIN
|
||||||
static CC_NOINLINE void* GetReturnAddress(int level) {
|
static CC_NOINLINE void* GetReturnAddress(int level) {
|
||||||
/* "... a value of 0 yields the return address of the current function, a value of 1 yields the return address of the caller of the current function" */
|
/* "... a value of 0 yields the return address of the current function, a value of 1 yields the return address of the caller of the current function" */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user