00001 /** 00002 * This file is part of alarmd 00003 * 00004 * Contact Person: David Weinehall <david.weinehall@nokia.com> 00005 * 00006 * Copyright (C) 2006 Nokia Corporation 00007 * alarmd and libalarm are free software; you can redistribute them 00008 * and/or modify them under the terms of the GNU Lesser General Public 00009 * License version 2.1 as published by the Free Software Foundation. 00010 * 00011 * alarmd and libalarm are distributed in the hope that they will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this software; if not, write to the Free 00018 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00019 * 02110-1301 USA 00020 */ 00021 00022 #ifndef _DEBUG_H_ 00023 #define _DEBUG_H_ 00024 00025 /** 00026 * SECTION:debug 00027 * @short_description: Debugging macros & functions. 00028 * 00029 * Alarmd internal debugging macros & functions. 00030 **/ 00031 00032 #ifdef DEBUG_FUNC 00033 /** 00034 * ENTER_FUNC: 00035 * 00036 * Indicates that we're entering a function. 00037 * Displays a message and increments the indentation in the 00038 * debugging output. 00039 **/ 00040 #define ENTER_FUNC enter_func(__FUNCTION__) 00041 00042 /** 00043 * LEAVE_FUNC: 00044 * 00045 * Indicates that we're leaving a function. 00046 * Displays a message and decrements the indentation in the debugging output. 00047 **/ 00048 #define LEAVE_FUNC leave_func(__FUNCTION__) 00049 00050 /** 00051 * DEBUG: 00052 * 00053 * Writes a debug message to stdout with the current indentation level. 00054 **/ 00055 #define DEBUG(...) dbg(__FUNCTION__, __VA_ARGS__) 00056 00057 #else 00058 00059 #define ENTER_FUNC 00060 #define LEAVE_FUNC 00061 #define DEBUG(...) 00062 00063 #endif 00064 00065 /** 00066 * enter_func: 00067 * @name: Name of function being entered. 00068 * 00069 * Should be called as #ENTER_FUNC at start of a function. 00070 **/ 00071 void enter_func(const char *name); 00072 00073 /** 00074 * leave_func: 00075 * @name: Name of function being entered. 00076 * 00077 * Should be called as #LEAVE_FUNC at the end of a function. 00078 **/ 00079 void leave_func(const char *name); 00080 00081 /** 00082 * dbg: 00083 * @func: Name of function writing debug info. 00084 * @format: Format for the message being printed (printf like). 00085 * @...: Values to fill into the format string. 00086 * 00087 * Writes a debug message; should be used through #DEBUG macro. 00088 **/ 00089 void dbg(const char *func, const char *format, ...); 00090 00091 #endif