1 /** \file debug_gtk3.h 2 * \brief Gtk3 port debugging code - header 3 * 4 * \author Bas Wassink <b.wassink@ziggo.nl> 5 */ 6 7 /* 8 * This file is part of VICE, the Versatile Commodore Emulator. 9 * See README for copyright notice. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 * 02111-1307 USA. 25 * 26 */ 27 28 #ifndef VICE_DEBUG_GTK3_H 29 # define VICE_DEBUG_GTK3_H 30 31 # include "vice.h" 32 33 /* HAVE_DEBUG_GTK3UI comes from configure */ 34 # ifdef HAVE_DEBUG_GTK3UI 35 36 # include <glib.h> 37 38 /** \brief Print debugging info on stdout 39 * 40 * Works just like g_print() and printf(), except that every line is prefixed 41 * with "[debug-gtk3] $FILE:$LINE::$FUNC(): ". 42 * This macro outputs a newline. so the user should not provide one in the 43 * message, unless an extra newline is preferred. 44 */ 45 # define debug_gtk3(...) \ 46 g_print("[debug-gtk3] %s:%d::%s(): ", __FILE__, __LINE__, __func__); \ 47 g_print(__VA_ARGS__); \ 48 g_print("\n"); 49 50 # else /* HAVE_DEBUG_GTK3UI */ 51 /** \brief Empty placeholder */ 52 # define debug_gtk3(...) 53 # endif /* HAVE DEBUG_GTK3UI */ 54 55 56 #include <stdlib.h> 57 58 /** \brief Not-implemented message with file, function and lineno, calls exit(1) 59 */ 60 #define NOT_IMPLEMENTED() \ 61 fprintf(stderr, \ 62 "%s:%d: error: function %s() is not implemented yet, exiting\n", \ 63 __FILE__, __LINE__, __func__); \ 64 exit(1) 65 66 67 /** \brief Not-implemented message with file, function and lineno, only warns 68 */ 69 #define NOT_IMPLEMENTED_WARN_ONLY() \ 70 fprintf(stderr, \ 71 "%s:%d: warning: function %s() is not implemented yet, continuing\n", \ 72 __FILE__, __LINE__, __func__) 73 74 75 /** \brief Not-implemented message, shown at most X times 76 * 77 * This macro limits the number of 'not implemented' messages appearing on 78 * stderr, so the terminal debug output doesn't get flooded. 79 * 80 * Usage: declare a `static int foo_msgs` somewhere and then in the function you 81 * want to limit the number of messages it spits out, use this macro: 82 * NOT_IMPLEMENTED_WARN_X_TIMES(foo_msgs, 5); (warn 5 times at most) 83 * 84 * \param[in,out] C counter variable (int) 85 * \param[in] X maximum number of times to show the warning (int) 86 */ 87 #define NOT_IMPLEMENTED_WARN_X_TIMES(C, X) \ 88 if ((C)++ < (X)) { \ 89 fprintf(stderr, \ 90 "%s:%d: warning function %s() is not implemented yet, " \ 91 "warning %d/%d\n", \ 92 __FILE__, __LINE__, __func__, (C), (X)); \ 93 } 94 95 96 /** \brief Incomplete implementation message, only warns 97 */ 98 #define INCOMPLETE_IMPLEMENTATION() \ 99 fprintf(stderr, \ 100 "%s:%d: warning: function %s() is not fully implemented yet, continuing\n", \ 101 __FILE__, __LINE__, __func__) 102 103 104 /** \brief Temporary implementation message, only warns 105 */ 106 #define TEMPORARY_IMPLEMENTATION() \ 107 fprintf(stderr, \ 108 "%s:%d: warning: function %s() contains a temporary implementation, continuing\n", \ 109 __FILE__, __LINE__, __func__) 110 111 112 113 #endif /* VICE_DEBUG_GTK3_H */ 114