1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef _ANDROID_UTILS_DEBUG_H 13 #define _ANDROID_UTILS_DEBUG_H 14 15 #include <stdarg.h> 16 17 #define VERBOSE_TAG_LIST \ 18 _VERBOSE_TAG(init, "emulator initialization") \ 19 _VERBOSE_TAG(console, "control console") \ 20 _VERBOSE_TAG(modem, "emulated GSM modem") \ 21 _VERBOSE_TAG(radio, "emulated GSM AT Command channel") \ 22 _VERBOSE_TAG(keys, "key bindings & presses") \ 23 _VERBOSE_TAG(slirp, "internal router/firewall") \ 24 _VERBOSE_TAG(timezone, "host timezone detection" ) \ 25 _VERBOSE_TAG(socket, "network sockets") \ 26 _VERBOSE_TAG(proxy, "network proxy support") \ 27 _VERBOSE_TAG(audio, "audio sub-system") \ 28 _VERBOSE_TAG(audioin, "audio input backend") \ 29 _VERBOSE_TAG(audioout, "audio output backend") \ 30 _VERBOSE_TAG(surface, "video surface support") \ 31 _VERBOSE_TAG(qemud, "qemud multiplexer daemon") \ 32 _VERBOSE_TAG(gps, "emulated GPS") \ 33 _VERBOSE_TAG(nand_limits, "nand/flash read/write thresholding") \ 34 _VERBOSE_TAG(hw_control, "emulated power/flashlight/led/vibrator") \ 35 _VERBOSE_TAG(avd_config, "android virtual device configuration") \ 36 _VERBOSE_TAG(sensors, "emulated sensors") \ 37 38 #define _VERBOSE_TAG(x,y) VERBOSE_##x, 39 typedef enum { 40 VERBOSE_TAG_LIST 41 VERBOSE_MAX /* do not remove */ 42 } VerboseTag; 43 #undef _VERBOSE_TAG 44 45 /* defined in android_main.c */ 46 extern unsigned long android_verbose; 47 48 #define VERBOSE_ENABLE(tag) \ 49 android_verbose |= (1 << VERBOSE_##tag) 50 51 #define VERBOSE_DISABLE(tag) \ 52 android_verbose &= (1 << VERBOSE_##tag) 53 54 #define VERBOSE_CHECK(tag) \ 55 ((android_verbose & (1 << VERBOSE_##tag)) != 0) 56 57 #define VERBOSE_CHECK_ANY() \ 58 (android_verbose != 0) 59 60 #define VERBOSE_PRINT(tag,...) \ 61 do { if (VERBOSE_CHECK(tag)) dprint(__VA_ARGS__); } while (0) 62 63 /** DEBUG TRACE SUPPORT 64 ** 65 ** debug messages can be sent by calling these function 66 ** 67 ** 'dprint' prints the message, then appends a '\n\ 68 ** 'dprintn' simply prints the message as is 69 ** 'dprintnv' allows you to use a va_list argument 70 ** 'dwarning' prints a warning message, then appends a '\n' 71 ** 'derror' prints a severe error message, then appends a '\n' 72 */ 73 74 extern void dprint( const char* format, ... ); 75 extern void dprintn( const char* format, ... ); 76 extern void dprintnv( const char* format, va_list args ); 77 extern void dwarning( const char* format, ... ); 78 extern void derror( const char* format, ... ); 79 80 /** STDOUT/STDERR REDIRECTION 81 ** 82 ** allows you to shut temporarily shutdown stdout/stderr 83 ** this is useful to get rid of debug messages from ALSA and esd 84 ** on Linux. 85 **/ 86 87 extern void stdio_disable( void ); 88 extern void stdio_enable( void ); 89 90 /* */ 91 92 #endif /* _ANDROID_UTILS_DEBUG_H */ 93