diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-08 11:22:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-10 06:31:33 +0000 |
commit | 56d071c10ca8016848f1f059aa3eb197fe928844 (patch) | |
tree | 956ba2f8f51a7845c603aa0875e83d40d8938e68 /include/sal | |
parent | 014b9ac2e4ec22a1eed2fde806edd7a840035a45 (diff) |
rename SAL_DEBUG_TRACE to SAL_DEBUG_BACKTRACE
since "trace" is such a generic term, this makes it easier to actually find the feature when you need it.
And add feature to limit stack depth of the reported backtrace.
Change-Id: Iab3e4ceb2e8480e7b5e2b920eb6c5d7631e21c43
Reviewed-on: https://gerrit.libreoffice.org/31752
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/sal')
-rw-r--r-- | include/sal/detail/log.h | 1 | ||||
-rw-r--r-- | include/sal/log.hxx | 24 |
2 files changed, 21 insertions, 4 deletions
diff --git a/include/sal/detail/log.h b/include/sal/detail/log.h index ab9718518646..11ece36c3279 100644 --- a/include/sal/detail/log.h +++ b/include/sal/detail/log.h @@ -52,7 +52,6 @@ extern "C" { enum sal_detail_LogLevel { SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN, - SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE = SAL_MAX_ENUM - 1, SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM }; diff --git a/include/sal/log.hxx b/include/sal/log.hxx index 8b4ef0a51962..4438ec559fae 100644 --- a/include/sal/log.hxx +++ b/include/sal/log.hxx @@ -30,6 +30,10 @@ extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log( enum sal_detail_LogLevel level, char const * area, char const * where, char const * message); +extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log_backtrace( + enum sal_detail_LogLevel level, char const * area, char const * where, + char const * message, int maxNoStackFramesToDisplay); + namespace sal { namespace detail { inline void SAL_CALL log( @@ -343,9 +347,23 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { See @ref sal_log "basic logging functionality" for details. */ -#define SAL_DEBUG_TRACE(stream) \ - SAL_DETAIL_LOG_STREAM( \ - SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE, NULL, NULL, stream) +#define SAL_DEBUG_BACKTRACE(stream, maxNoStackFramesToDisplay) \ + do { \ + if (sizeof ::sal::detail::getResult(::sal::detail::StreamStart() << stream) == 1) \ + { \ + ::sal_detail_log_backtrace( \ + ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, \ + ::sal::detail::unwrapStream( \ + ::sal::detail::StreamStart() << stream)); \ + } else { \ + ::std::ostringstream sal_detail_stream; \ + sal_detail_stream << stream; \ + ::sal::detail::log( \ + ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, sal_detail_stream); \ + } \ + } while (false) + + #endif |