/*PGR-GNU***************************************************************** File: assert.cpp Copyright 2015~ Vicky Vergara Copyright 2014 Stephen Woodbridge Mail: project@pgrouting.org ------ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ #include "cpp_common/assert.hpp" #include #include #include #ifdef __GLIBC__ #include #endif #include #include std::string get_backtrace() { #ifdef __GLIBC__ void *trace[16]; int i, trace_size = 0; trace_size = backtrace(trace, 16); char** funcNames = backtrace_symbols(trace, trace_size); std::string message = "\n*** Execution path***\n"; for (i = 0; i < trace_size; ++i) { message += "[bt]" + static_cast(funcNames[i]) + "\n"; } free(funcNames); return message; #else return ""; #endif } std::string get_backtrace(const std::string &msg) { return std::string("\n") + msg + "\n" + get_backtrace(); } const char* AssertFailedException::what() const throw() { return str.c_str(); } AssertFailedException::AssertFailedException(std::string msg) : str(msg) {}