mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
use sys/ucontext.h everywhere instead
This commit is contained in:
parent
cf1dc90a06
commit
f3198c31c3
@ -109,7 +109,6 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
|
|||||||
#define CC_BUILD_GLMODERN
|
#define CC_BUILD_GLMODERN
|
||||||
#define CC_BUILD_GLES
|
#define CC_BUILD_GLES
|
||||||
#define CC_BUILD_EGL
|
#define CC_BUILD_EGL
|
||||||
#define CC_BUILD_UNWIND
|
|
||||||
#define CC_BUILD_TOUCH
|
#define CC_BUILD_TOUCH
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define CC_BUILD_LINUX
|
#define CC_BUILD_LINUX
|
||||||
|
72
src/Logger.c
72
src/Logger.c
@ -7,34 +7,28 @@
|
|||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#ifdef CC_BUILD_WEB
|
#if defined CC_BUILD_WEB
|
||||||
#undef CC_BUILD_POSIX /* Can't see native CPU state with javascript */
|
/* Can't see native CPU state with javascript */
|
||||||
#endif
|
#undef CC_BUILD_POSIX
|
||||||
#ifdef CC_BUILD_WIN
|
#elif defined CC_BUILD_WIN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define NOSERVICE
|
#define NOSERVICE
|
||||||
#define NOMCX
|
#define NOMCX
|
||||||
#define NOIME
|
#define NOIME
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <imagehlp.h>
|
#include <imagehlp.h>
|
||||||
#endif
|
#elif defined CC_BUILD_OPENBSD
|
||||||
|
|
||||||
/* POSIX can be shared between unix-ish systems */
|
|
||||||
/* NOTE: Android's bionic libc doesn't provide backtrace (execinfo.h) */
|
|
||||||
#ifdef CC_BUILD_POSIX
|
|
||||||
#if defined CC_BUILD_OPENBSD
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
/* OpenBSD doesn't provide ucontext.h */
|
/* OpenBSD doesn't provide sys/ucontext.h */
|
||||||
#elif defined CC_BUILD_LINUX || defined CC_BUILD_ANDROID
|
#elif defined CC_BUILD_LINUX || defined CC_BUILD_ANDROID
|
||||||
/* Need to define this to get REG_ constants */
|
/* Need to define this to get REG_ constants */
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
#include <ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#undef __USE_GNU
|
#undef __USE_GNU
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#else
|
#elif defined CC_BUILD_POSIX
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -317,35 +311,6 @@ void Logger_Backtrace(String* trace, void* ctx) {
|
|||||||
}
|
}
|
||||||
String_AppendConst(trace, _NL);
|
String_AppendConst(trace, _NL);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_UNWIND
|
|
||||||
#include <unwind.h>
|
|
||||||
#define __USE_GNU
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#undef __USE_GNU
|
|
||||||
|
|
||||||
static _Unwind_Reason_Code Logger_DumpFrame(struct _Unwind_Context* ctx, void* arg) {
|
|
||||||
String str; char strBuffer[384];
|
|
||||||
uintptr_t addr;
|
|
||||||
Dl_info s;
|
|
||||||
|
|
||||||
addr = _Unwind_GetIP(ctx);
|
|
||||||
String_InitArray(str, strBuffer);
|
|
||||||
if (!addr) return _URC_END_OF_STACK;
|
|
||||||
|
|
||||||
s.dli_sname = NULL;
|
|
||||||
s.dli_fname = NULL;
|
|
||||||
dladdr((void*)addr, &s);
|
|
||||||
|
|
||||||
Logger_PrintFrame(&str, addr, (uintptr_t)s.dli_saddr, s.dli_sname, s.dli_fname);
|
|
||||||
String_AppendString((String*)arg, &str);
|
|
||||||
Logger_Log(&str);
|
|
||||||
return _URC_NO_REASON;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger_Backtrace(String* trace, void* ctx) {
|
|
||||||
_Unwind_Backtrace(Logger_DumpFrame, trace);
|
|
||||||
String_AppendConst(trace, _NL);
|
|
||||||
}
|
|
||||||
#elif defined CC_BUILD_POSIX
|
#elif defined CC_BUILD_POSIX
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
@ -365,7 +330,24 @@ static void Logger_DumpFrame(String* trace, void* addr) {
|
|||||||
Logger_Log(&str);
|
Logger_Log(&str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CC_BUILD_OSX
|
#if defined CC_BUILD_ANDROID
|
||||||
|
/* android's bionic libc doesn't provide backtrace (execinfo.h) */
|
||||||
|
#include <unwind.h>
|
||||||
|
|
||||||
|
static _Unwind_Reason_Code Logger_DumpFrame(struct _Unwind_Context* ctx, void* arg) {
|
||||||
|
uintptr_t addr = _Unwind_GetIP(ctx);
|
||||||
|
if (!addr) return _URC_END_OF_STACK;
|
||||||
|
|
||||||
|
Logger_DumpFrame((String*)arg, (void*)addr);
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger_Backtrace(String* trace, void* ctx) {
|
||||||
|
_Unwind_Backtrace(Logger_DumpFrame, trace);
|
||||||
|
String_AppendConst(trace, _NL);
|
||||||
|
}
|
||||||
|
#elif defined CC_BUILD_OSX
|
||||||
|
/* backtrace is only available on OSX since 10.5 */
|
||||||
void Logger_Backtrace(String* trace, void* ctx) {
|
void Logger_Backtrace(String* trace, void* ctx) {
|
||||||
void* addrs[40];
|
void* addrs[40];
|
||||||
unsigned i, frames;
|
unsigned i, frames;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user