X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fcommon%2Fdali-common.cpp;h=218f08448382b80218b42f3e44a35979b89e45ce;hb=2b6582355a641702eca8c919a6eb97e0c42bddf6;hp=42d13311ab3d85a32d820d6607e0be65bbb39345;hpb=646f736e77b085c86e982c0d1d4b895c2a431330;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/common/dali-common.cpp b/dali/public-api/common/dali-common.cpp index 42d1331..218f084 100644 --- a/dali/public-api/common/dali-common.cpp +++ b/dali/public-api/common/dali-common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,17 @@ // EXTERNAL INCLUDES #include -#include #include +#include + +#define BACKTRACE_ENABLED +#if defined(BACKTRACE_ENABLED) +#if defined(__GLIBC__) #include +#endif #include - +#endif #include // INTERNAL INCLUDES @@ -33,7 +38,6 @@ namespace Dali { - #if defined(BACKTRACE_ENABLED) namespace @@ -51,9 +55,9 @@ std::string Demangle(const char* symbol) if(openParen != NULL) { const char* startOfToken = openParen + 1; - const char* plus = strchr(startOfToken, '+'); - const char* closeParen = strchr(startOfToken, ')'); - const char* endOfToken = NULL; + const char* plus = strchr(startOfToken, '+'); + const char* closeParen = strchr(startOfToken, ')'); + const char* endOfToken = NULL; if(plus != NULL) { endOfToken = plus; @@ -67,17 +71,17 @@ std::string Demangle(const char* symbol) size_t tokenLength = endOfToken - startOfToken; // Allocate space for symbol - char *mangledSymbol = reinterpret_cast< char* >( malloc( tokenLength + 1u ) ); + char* mangledSymbol = reinterpret_cast(malloc(tokenLength + 1u)); if(mangledSymbol != NULL) { strncpy(mangledSymbol, startOfToken, tokenLength); mangledSymbol[tokenLength] = '\0'; - size_t size; - int32_t status; - char* demangled=NULL; - demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status ); - if( demangled != NULL ) + size_t size; + int32_t status; + char* demangled = NULL; + demangled = abi::__cxa_demangle(mangledSymbol, NULL, &size, &status); + if(demangled != NULL) { result = demangled; free(demangled); // demangle() allocates returned string, so free it @@ -94,8 +98,9 @@ std::string Demangle(const char* symbol) return result; } -DALI_CORE_API DaliException::DaliException( const char* location, const char* condition ) -: location( location ), condition( condition ) +DALI_CORE_API DaliException::DaliException(const char* location, const char* condition) +: location(location), + condition(condition) { // Note, if a memory error has occured, then the backtrace won't work - backtrace_symbols relies on // allocating memory. @@ -105,45 +110,44 @@ DALI_CORE_API DaliException::DaliException( const char* location, const char* co #if defined(DEBUG_ENABLED) fprintf(stderr, "Exception: \n%s\n thrown at %s\nSee dlog for backtrace\n", condition, location); #else - fprintf(stderr, "Exception: \n%s\n thrown\nSee dlog for backtrace\n", condition ); + fprintf(stderr, "Exception: \n%s\n thrown\nSee dlog for backtrace\n", condition); #endif DALI_LOG_ERROR_NOFN("Backtrace:\n"); - void* frameArray[MAX_NUM_STACK_FRAMES]; - int32_t nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES); - char** symbols = backtrace_symbols(frameArray, nSize); - for(int32_t i=1; i< nSize; i++) + void* frameArray[MAX_NUM_STACK_FRAMES]; + int32_t nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES); + char** symbols = backtrace_symbols(frameArray, nSize); + for(int32_t i = 1; i < nSize; i++) { std::string demangled_symbol = Demangle(symbols[i]); - DALI_LOG_ERROR_NOFN("[%02d] %s\n", i, demangled_symbol.c_str() ); + DALI_LOG_ERROR_NOFN("[%02d] %s\n", i, demangled_symbol.c_str()); } free(symbols); } - #else // BACKTRACE_ENABLED -DALI_CORE_API DaliException::DaliException( const char* location, const char* condition ) -: location( location ), condition( condition ) +DALI_CORE_API DaliException::DaliException(const char* location, const char* condition) +: location(location), + condition(condition) { #if defined(DEBUG_ENABLED) - printf("Exception: \n%s\n thrown at %s\n", condition, location ); + printf("Exception: \n%s\n thrown at %s\n", condition, location); #else - printf("Exception: \n%s\n thrown\n", condition ); + printf("Exception: \n%s\n thrown\n", condition); #endif } - #endif // BACKTRACE_ENABLED -DALI_CORE_API void DaliAssertMessage( const char* location, const char* condition ) +DALI_CORE_API void DaliAssertMessage(const char* location, const char* condition) { #if defined(DEBUG_ENABLED) - DALI_LOG_ERROR_NOFN( "Assert (%s) failed in: %s\n", condition, location ); + DALI_LOG_ERROR_NOFN("Assert (%s) failed in: %s\n", condition, location); #else - DALI_LOG_ERROR_NOFN( "Assert (%s) failed\n", condition ); + DALI_LOG_ERROR_NOFN("Assert (%s) failed\n", condition); #endif } -} // Dali +} // namespace Dali