3 * Utility macros and functions for debugging. */
6 * GiNaC Copyright (C) 1999-2022 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef GINAC_MOD_GCD_DEBUG_H
24 #define GINAC_MOD_GCD_DEBUG_H
33 #define DEBUG_PREFIX __func__ << ':' << __LINE__ << ": "
34 #define EXCEPTION_PREFIX std::string(__func__) + std::string(": ") +
36 #define Dout2(stream, msg) \
38 stream << DEBUG_PREFIX << msg << std::endl << std::flush; \
40 #define Dout(msg) Dout2(std::cout, msg)
42 #define bug3_on(condition, the_exception, msg) \
44 if (unlikely(condition)) { \
45 std::ostringstream err_stream; \
46 Dout2(err_stream, "BUG: " << msg); \
47 throw the_exception(err_stream.str()); \
51 #define bug_on(condition, msg) bug3_on(condition, std::logic_error, msg)
53 #endif // ndef GINAC_MOD_GCD_DEBUG_H