Conditionally include backtraces in ROCPROFSYS_THROW based on verbosity (#272)
* Conditionally include backtraces in ROCPROFSYS_THROW based on verbosity
Modify ROCPROFSYS_THROW to only include backtraces when:
debug mode is enabled, OR
verbose level is >= 2, OR
running in CI environment
* Fix formatting errors
[ROCm/rocprofiler-systems commit: b0ff07b4fe]
This commit is contained in:
gecommit door
GitHub
bovenliggende
0497b7934f
commit
329183b112
@@ -377,14 +377,21 @@ as_hex<void*>(void*, size_t);
|
||||
if(ROCPROFSYS_UNLIKELY((COND))) \
|
||||
{ \
|
||||
char _msg_buffer[ROCPROFSYS_DEBUG_BUFFER_LEN]; \
|
||||
bool _print_backtrace = ::rocprofsys::get_debug() || \
|
||||
::rocprofsys::get_verbose() >= 2 || \
|
||||
::rocprofsys::get_is_continuous_integration(); \
|
||||
snprintf(_msg_buffer, ROCPROFSYS_DEBUG_BUFFER_LEN, \
|
||||
"[rocprof-sys][%i][%li][%s]%s", ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \
|
||||
ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, ROCPROFSYS_FUNCTION, \
|
||||
::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
|
||||
auto len = strlen(_msg_buffer); \
|
||||
snprintf(_msg_buffer + len, ROCPROFSYS_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \
|
||||
throw ::rocprofsys::exception<TYPE>( \
|
||||
::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \
|
||||
if(!_print_backtrace) \
|
||||
throw ::rocprofsys::exception<TYPE>( \
|
||||
::tim::log::string(::tim::log::color::fatal(), _msg_buffer), false); \
|
||||
else \
|
||||
throw ::rocprofsys::exception<TYPE>( \
|
||||
::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \
|
||||
}
|
||||
|
||||
#define ROCPROFSYS_CONDITIONAL_BASIC_THROW_E(COND, TYPE, ...) \
|
||||
|
||||
@@ -73,6 +73,12 @@ exception<Tp>::exception(const char* _msg)
|
||||
, m_what{ get_backtrace(_msg) }
|
||||
{}
|
||||
|
||||
template <typename Tp>
|
||||
exception<Tp>::exception(const std::string& _msg, bool with_backtrace)
|
||||
: Tp{ _msg }
|
||||
, m_what{ with_backtrace ? get_backtrace(_msg) : strdup(_msg.c_str()) }
|
||||
{}
|
||||
|
||||
template <typename Tp>
|
||||
exception<Tp>::~exception()
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ class exception : public Tp
|
||||
public:
|
||||
explicit exception(const std::string& _msg);
|
||||
explicit exception(const char* _msg);
|
||||
explicit exception(const std::string& _msg, bool with_backtrace);
|
||||
|
||||
~exception() override;
|
||||
|
||||
|
||||
Verwijs in nieuw issue
Block a user