Fix build under OSX with clang. Fixes issue 180.
This commit is contained in:
@ -486,10 +486,11 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
static void printStackTrace(void * trace[], int size, int start=0) {
|
||||
|
||||
static void writeStackTrace(void * trace[], int size, int start, Array<const char *> & lines) {
|
||||
StringBuilder builder(512);
|
||||
char ** string_array = backtrace_symbols(trace, size);
|
||||
|
||||
nvDebug( "\nDumping stacktrace:\n" );
|
||||
for(int i = start; i < size-1; i++ ) {
|
||||
# if NV_CC_GNUC // defined(HAVE_CXXABI_H)
|
||||
// @@ Write a better parser for the possible formats.
|
||||
@ -510,34 +511,48 @@ namespace
|
||||
char * name = abi::__cxa_demangle(begin+1, 0, 0, &stat);
|
||||
if (module == NULL) {
|
||||
if (name == NULL || stat != 0) {
|
||||
nvDebug( " In: '%s'\n", begin+1 );
|
||||
builder.format(" In: '%s'\n", begin+1);
|
||||
}
|
||||
else {
|
||||
nvDebug( " In: '%s'\n", name );
|
||||
builder.format(" In: '%s'\n", name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (name == NULL || stat != 0) {
|
||||
nvDebug( " In: [%s] '%s'\n", module, begin+1 );
|
||||
builder.format(" In: [%s] '%s'\n", module, begin+1);
|
||||
}
|
||||
else {
|
||||
nvDebug( " In: [%s] '%s'\n", module, name );
|
||||
builder.format(" In: [%s] '%s'\n", module, name);
|
||||
}
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
else {
|
||||
nvDebug( " In: '%s'\n", string_array[i] );
|
||||
builder.format(" In: '%s'\n", string_array[i]);
|
||||
}
|
||||
# else
|
||||
nvDebug( " In: '%s'\n", string_array[i] );
|
||||
builder.format(" In: '%s'\n", string_array[i]);
|
||||
# endif
|
||||
lines.append(builder.release());
|
||||
}
|
||||
nvDebug("\n");
|
||||
|
||||
free(string_array);
|
||||
}
|
||||
|
||||
static void printStackTrace(void * trace[], int size, int start=0) {
|
||||
nvDebug( "\nDumping stacktrace:\n" );
|
||||
|
||||
Array<const char *> lines;
|
||||
writeStackTrace(trace, size, 1, lines);
|
||||
|
||||
for (uint i = 0; i < lines.count(); i++) {
|
||||
nvDebug(lines[i]);
|
||||
delete lines[i];
|
||||
}
|
||||
|
||||
nvDebug("\n");
|
||||
}
|
||||
|
||||
#endif // defined(HAVE_EXECINFO_H)
|
||||
|
||||
static void * callerAddress(void * secret)
|
||||
@ -818,6 +833,7 @@ int nvAbort(const char * exp, const char * file, int line, const char * func/*=N
|
||||
// Abnormal termination. Create mini dump and output call stack.
|
||||
void debug::terminate(int code)
|
||||
{
|
||||
#if NV_OS_WIN32
|
||||
EnterCriticalSection(&s_handler_critical_section);
|
||||
|
||||
writeMiniDump(NULL);
|
||||
@ -843,6 +859,7 @@ void debug::terminate(int code)
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&s_handler_critical_section);
|
||||
#endif
|
||||
|
||||
exit(code);
|
||||
}
|
||||
@ -908,6 +925,7 @@ void debug::resetAssertHandler()
|
||||
}
|
||||
|
||||
|
||||
#if NV_OS_WIN32
|
||||
#if USE_SEPARATE_THREAD
|
||||
|
||||
static void initHandlerThread()
|
||||
@ -951,7 +969,8 @@ static void shutHandlerThread() {
|
||||
// @@ Free stuff. Terminate thread.
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USE_SEPARATE_THREAD
|
||||
#endif // NV_OS_WIN32
|
||||
|
||||
|
||||
// Enable signal handler.
|
||||
|
@ -32,21 +32,28 @@
|
||||
#else // NV_NO_ASSERT
|
||||
|
||||
# if NV_CC_MSVC
|
||||
// @@ Does this work in msvc-6 and earlier?
|
||||
// @@ Does this work in msvc-6 and earlier?
|
||||
# define nvDebugBreak() __debugbreak()
|
||||
//# define nvDebugBreak() __asm { int 3 }
|
||||
# elif NV_CC_GNUC && NV_CPU_PPC && NV_OS_DARWIN
|
||||
// @@ Use __builtin_trap() on GCC
|
||||
# define nvDebugBreak() __asm__ volatile ("trap");
|
||||
# elif NV_CC_GNUC && NV_CPU_X86 && NV_OS_DARWIN
|
||||
# define nvDebugBreak() __asm__ volatile ("int3");
|
||||
# elif NV_CC_GNUC && NV_CPU_X86
|
||||
//#define nvDebugBreak() __asm { int 3 }
|
||||
# elif NV_CC_GNUC
|
||||
# define nvDebugBreak() __builtin_trap()
|
||||
# else
|
||||
# error "No nvDebugBreak()!"
|
||||
# endif
|
||||
|
||||
/*
|
||||
# elif NV_CC_GNUC || NV_CPU_PPC && NV_OS_DARWIN
|
||||
// @@ Use __builtin_trap() on GCC
|
||||
# define nvDebugBreak() __asm__ volatile ("trap")
|
||||
# elif (NV_CC_GNUC || NV_CPU_X86 || NV_CPU_X86_64) && NV_OS_DARWIN
|
||||
# define nvDebugBreak() __asm__ volatile ("int3")
|
||||
# elif NV_CC_GNUC || NV_CPU_X86 || NV_CPU_X86_64
|
||||
# define nvDebugBreak() __asm__ ( "int %0" : :"I"(3) )
|
||||
# else
|
||||
# include <signal.h>
|
||||
# define nvDebugBreak() raise(SIGTRAP);
|
||||
// define nvDebugBreak() *((int *)(0)) = 0
|
||||
# define nvDebugBreak() raise(SIGTRAP)
|
||||
# endif
|
||||
*/
|
||||
|
||||
#define nvDebugBreakOnce() \
|
||||
NV_MULTI_LINE_MACRO_BEGIN \
|
||||
|
@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
#define NV_FASTCALL __attribute__((fastcall))
|
||||
#define NV_FORCEINLINE __attribute__((always_inline))
|
||||
#define NV_FORCEINLINE inline __attribute__((always_inline))
|
||||
#define NV_DEPRECATED __attribute__((deprecated))
|
||||
|
||||
#if __GNUC__ > 2
|
||||
|
Reference in New Issue
Block a user