X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fcommon%2Fdali-common.cpp;h=78dd20d65184c84dc7c1ec21fa280768b25e5355;hb=091424324901c46a18959bfc0dd52f7ce8a0a811;hp=9f458b74166efb2674a251e18635196e3e45a1ae;hpb=5cd990ee01591c1f7f6d6aeb4a37a5509982fa21;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 9f458b7..78dd20d 100644 --- a/dali/public-api/common/dali-common.cpp +++ b/dali/public-api/common/dali-common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -22,9 +22,9 @@ #include #include #include -#include #ifndef EMSCRIPTEN // cxxabi not supported +# include # include #endif @@ -33,17 +33,16 @@ // INTERNAL INCLUDES #include -namespace -{ -const int MAX_NUM_STACK_FRAMES = 25; -const size_t C_SYMBOL_LENGTH = 4096; -} - namespace Dali { #if defined(BACKTRACE_ENABLED) +namespace +{ +const int MAX_NUM_STACK_FRAMES = 25; +} + std::string Demangle(const char* symbol) { std::string result; @@ -70,39 +69,46 @@ std::string Demangle(const char* symbol) size_t tokenLength = endOfToken - startOfToken; // Allocate space for symbol - char *mangledSymbol = (char*)malloc(tokenLength+1u); - strncpy(mangledSymbol, startOfToken, tokenLength); - mangledSymbol[tokenLength] = '\0'; - - size_t size; - int 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 - } - else + char *mangledSymbol = reinterpret_cast< char* >( malloc( tokenLength + 1u ) ); + if(mangledSymbol != NULL) { - result = symbol; + strncpy(mangledSymbol, startOfToken, tokenLength); + mangledSymbol[tokenLength] = '\0'; + + size_t size; + int 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 + } + else + { + result = symbol; + } + free(mangledSymbol); } - free(mangledSymbol); } } return result; } -DALI_EXPORT_API DaliException::DaliException(const char *location, const char* condition) -: mLocation(location), mCondition(condition) +DALI_EXPORT_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. // Initial dlog error message is output in DALI_ASSERT_ALWAYS macro // Also output on stderr - fprintf(stderr, "Exception: \n%s\n thrown at %s\nSee dlog for backtrace\n", mCondition.c_str(), mLocation.c_str()); +#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 ); +#endif DALI_LOG_ERROR_NOFN("Backtrace:\n"); @@ -120,20 +126,26 @@ DALI_EXPORT_API DaliException::DaliException(const char *location, const char* c #else // BACKTRACE_ENABLED - -DALI_EXPORT_API DaliException::DaliException(const char *location, const char* condition) -: mLocation(location), mCondition(condition) +DALI_EXPORT_API DaliException::DaliException( const char* location, const char* condition ) +: location( location ), condition( condition ) { - printf("Exception: \n%s\n thrown at %s\nSee dlog for backtrace\n", mCondition.c_str(), mLocation.c_str()); +#if defined(DEBUG_ENABLED) + printf("Exception: \n%s\n thrown at %s\n", condition, location ); +#else + printf("Exception: \n%s\n thrown\n", condition ); +#endif } #endif // BACKTRACE_ENABLED - -DALI_EXPORT_API void DaliAssertMessage(const char* condition, const char* file, int line) +DALI_EXPORT_API void DaliAssertMessage( const char* location, const char* condition ) { - DALI_LOG_ERROR_NOFN( "Assertion (%s) failed in: %s:%d\n", condition, file, line ); +#if defined(DEBUG_ENABLED) + DALI_LOG_ERROR_NOFN( "Assert (%s) failed in: %s\n", condition, location ); +#else + DALI_LOG_ERROR_NOFN( "Assert (%s) failed\n", condition ); +#endif } } // Dali