From: Heeyong Song Date: Wed, 17 Nov 2021 07:00:04 +0000 (+0900) Subject: Add DaliPrintBackTrace for common X-Git-Tag: dali_2.3.2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db8a79a6645dcf76ccfdc0f3985bf30126c34828;p=platform%2Fcore%2Fuifw%2Fdali-core.git Add DaliPrintBackTrace for common Change-Id: Ieb24205ccdc75d3b9a4ac3e7b44166503a472d80 --- diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index 0baf3ec..64aa025 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -15,6 +15,7 @@ SET(TC_SOURCES utc-Dali-BaseHandle.cpp utc-Dali-CameraActor.cpp utc-Dali-CircularQueue.cpp + utc-Dali-Common.cpp utc-Dali-ConditionalWait.cpp utc-Dali-ConnectionTracker.cpp utc-Dali-Constrainer.cpp diff --git a/automated-tests/src/dali/utc-Dali-Common.cpp b/automated-tests/src/dali/utc-Dali-Common.cpp new file mode 100644 index 0000000..e4a0870 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Common.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include + +using namespace Dali; + +void utc_dali_common_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_common_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliCommonPrintBackTrace(void) +{ + TestApplication application; + tet_infoline("Testing Dali::DaliPrintBackTrace"); + + try + { + Dali::DaliPrintBackTrace(); + tet_result(TET_PASS); + } + catch(...) + { + tet_result(TET_FAIL); + } + + END_TEST; +} diff --git a/dali/public-api/common/dali-common.cpp b/dali/public-api/common/dali-common.cpp index 486606a..87dfa7f 100644 --- a/dali/public-api/common/dali-common.cpp +++ b/dali/public-api/common/dali-common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -124,6 +124,21 @@ DALI_CORE_API DaliException::DaliException(const char* location, const char* con free(symbols); } +DALI_CORE_API void DaliPrintBackTrace() +{ + 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++) + { + std::string demangled_symbol = Demangle(symbols[i]); + 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) @@ -137,6 +152,10 @@ DALI_CORE_API DaliException::DaliException(const char* location, const char* con #endif } +DALI_CORE_API void DaliPrintBackTrace() +{ +} + #endif // BACKTRACE_ENABLED DALI_CORE_API void DaliAssertMessage(const char* location, const char* condition) diff --git a/dali/public-api/common/dali-common.h b/dali/public-api/common/dali-common.h index a32e4a8..d703cd6 100644 --- a/dali/public-api/common/dali-common.h +++ b/dali/public-api/common/dali-common.h @@ -2,7 +2,7 @@ #define DALI_COMMON_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -119,6 +119,14 @@ namespace Dali DALI_CORE_API void DaliAssertMessage(const char* location, const char* condition); /** + * @brief Print backtrace log if required. + * @note Do nothing if ENABLE_BACKTRACE option off. + * + * @SINCE_2_3.2 + */ +DALI_CORE_API void DaliPrintBackTrace(); + +/** * @brief Exception class for Dali Core library - Raised by assertions in codebase. * @SINCE_1_0.0 */