Output current function in assert diagnostics (#2665)
This commit is contained in:
parent
67fb5cc21d
commit
15eebb1ca6
2 changed files with 9 additions and 5 deletions
|
@ -108,9 +108,11 @@ void nano::move_all_files_to_dir (boost::filesystem::path const & from, boost::f
|
|||
/*
|
||||
* Backing code for "release_assert" & "debug_assert", which are macros
|
||||
*/
|
||||
void assert_internal (const char * check_expr, const char * file, unsigned int line, bool is_release_assert)
|
||||
void assert_internal (const char * check_expr, const char * func, const char * file, unsigned int line, bool is_release_assert)
|
||||
{
|
||||
std::cerr << "Assertion (" << check_expr << ") failed " << file << ":" << line << "\n\n";
|
||||
std::cerr << "Assertion (" << check_expr << ") failed\n"
|
||||
<< func << "\n"
|
||||
<< file << ":" << line << "\n\n";
|
||||
|
||||
// Output stack trace to cerr
|
||||
auto backtrace_str = nano::generate_stacktrace ();
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <nano/lib/locks.hpp>
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
@ -20,13 +22,13 @@ namespace system
|
|||
}
|
||||
}
|
||||
|
||||
void assert_internal (const char * check_expr, const char * file, unsigned int line, bool is_release_assert);
|
||||
#define release_assert(check) check ? (void)0 : assert_internal (#check, __FILE__, __LINE__, true)
|
||||
void assert_internal (const char * check_expr, const char * func, const char * file, unsigned int line, bool is_release_assert);
|
||||
#define release_assert(check) check ? (void)0 : assert_internal (#check, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, true)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define debug_assert(check) (void)0
|
||||
#else
|
||||
#define debug_assert(check) check ? (void)0 : assert_internal (#check, __FILE__, __LINE__, false)
|
||||
#define debug_assert(check) check ? (void)0 : assert_internal (#check, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, false)
|
||||
#endif
|
||||
|
||||
namespace nano
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue