2 #ifndef _GLIBMM_DEBUG_H
3 #define _GLIBMM_DEBUG_H
7 /* Copyright 2002 The gtkmm Development Team
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <glib/gmacros.h>
25 #include <glibmmconfig.h>
27 // Some stuff that's useful when debugging gtkmm internals:
29 #ifdef GLIBMM_DEBUG_REFCOUNTING
31 #include <glib/gmessages.h>
33 /* We can't use G_GNUC_PRETTY_FUNCTION because it's always disabled in C++,
34 * even though __PRETTY_FUNCTION__ works fine in C++ as well if you use it
35 * right (i.e. concatenation with string literals isn't allowed).
38 #define GLIBMM_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
40 #define GLIBMM_GNUC_PRETTY_FUNCTION ""
43 #define GLIBMM_DEBUG_REFERENCE(cppInstance, cInstance) \
45 void *const cppInstance__ = (void*) (cppInstance); \
46 void *const cInstance__ = (void*) (cInstance); \
49 "file %s: line %d (%s):\n" \
50 "ref: C++ instance: %p; C instance: %p, ref_count = %u, type = %s\n", \
53 GLIBMM_GNUC_PRETTY_FUNCTION, \
56 G_OBJECT(cInstance__)->ref_count, \
57 G_OBJECT_TYPE_NAME(cInstance__)); \
60 #define GLIBMM_DEBUG_UNREFERENCE(cppInstance, cInstance) \
62 void *const cppInstance__ = (void*) (cppInstance); \
63 void *const cInstance__ = (void*) (cInstance); \
66 "file %s: line %d (%s):\n" \
67 "unref: C++ instance: %p; C instance: %p, ref_count = %u, type = %s\n", \
70 GLIBMM_GNUC_PRETTY_FUNCTION, \
73 G_OBJECT(cInstance__)->ref_count, \
74 G_OBJECT_TYPE_NAME(cInstance__)); \
79 #define GLIBMM_DEBUG_REFERENCE(cppInstance,cInstance) G_STMT_START{ (void)0; }G_STMT_END
80 #define GLIBMM_DEBUG_UNREFERENCE(cppInstance,cInstance) G_STMT_START{ (void)0; }G_STMT_END
82 #endif /* GLIBMM_DEBUG_REFCOUNTING */
84 #endif /* _GLIBMM_DEBUG_H */