Home | History | Annotate | Download | only in utils
      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 #include "android/utils/compiler.h"
     18 
     19 ANDROID_BEGIN_HEADER
     20 
     21 #define  VERBOSE_TAG_LIST    \
     22     _VERBOSE_TAG(init,         "emulator initialization")  \
     23     _VERBOSE_TAG(console,      "control console")  \
     24     _VERBOSE_TAG(modem,        "emulated GSM modem")  \
     25     _VERBOSE_TAG(radio,        "emulated GSM AT Command channel") \
     26     _VERBOSE_TAG(keys,         "key bindings & presses") \
     27     _VERBOSE_TAG(slirp,        "internal router/firewall") \
     28     _VERBOSE_TAG(timezone,     "host timezone detection" ) \
     29     _VERBOSE_TAG(socket,       "network sockets") \
     30     _VERBOSE_TAG(proxy,        "network proxy support") \
     31     _VERBOSE_TAG(audio,        "audio sub-system") \
     32     _VERBOSE_TAG(audioin,      "audio input backend") \
     33     _VERBOSE_TAG(audioout,     "audio output backend") \
     34     _VERBOSE_TAG(surface,      "video surface support") \
     35     _VERBOSE_TAG(qemud,        "qemud multiplexer daemon") \
     36     _VERBOSE_TAG(gps,          "emulated GPS") \
     37     _VERBOSE_TAG(nand_limits,  "nand/flash read/write thresholding") \
     38     _VERBOSE_TAG(hw_control,   "emulated power/flashlight/led/vibrator") \
     39     _VERBOSE_TAG(avd_config,   "android virtual device configuration") \
     40     _VERBOSE_TAG(sensors,      "emulated sensors") \
     41     _VERBOSE_TAG(memcheck,     "memory checker") \
     42     _VERBOSE_TAG(camera,       "camera") \
     43     _VERBOSE_TAG(adevice,      "android device connected via port forwarding") \
     44     _VERBOSE_TAG(sensors_port, "sensors emulator connected to android device") \
     45     _VERBOSE_TAG(mtport,       "multi-touch emulator connected to android device") \
     46     _VERBOSE_TAG(mtscreen,     "multi-touch screen emulation") \
     47     _VERBOSE_TAG(gles,         "hardware OpenGLES emulation") \
     48     _VERBOSE_TAG(adbserver,    "ADB server") \
     49     _VERBOSE_TAG(adbclient,    "ADB QEMU client") \
     50     _VERBOSE_TAG(adb,          "ADB debugger") \
     51     _VERBOSE_TAG(asconnector,  "Asynchronous socket connector") \
     52     _VERBOSE_TAG(asyncsocket,  "Asynchronous socket") \
     53     _VERBOSE_TAG(sdkctlsocket, "Socket tethering to SdkControl server") \
     54 
     55 #define  _VERBOSE_TAG(x,y)  VERBOSE_##x,
     56 typedef enum {
     57     VERBOSE_TAG_LIST
     58     VERBOSE_MAX  /* do not remove */
     59 } VerboseTag;
     60 #undef  _VERBOSE_TAG
     61 
     62 extern unsigned long  android_verbose;
     63 
     64 #define  VERBOSE_ENABLE(tag)    \
     65     android_verbose |= (1 << VERBOSE_##tag)
     66 
     67 #define  VERBOSE_DISABLE(tag)   \
     68     android_verbose &= (1 << VERBOSE_##tag)
     69 
     70 #define  VERBOSE_CHECK(tag)    \
     71     ((android_verbose & (1 << VERBOSE_##tag)) != 0)
     72 
     73 #define  VERBOSE_CHECK_ANY()    \
     74     (android_verbose != 0)
     75 
     76 #define  VERBOSE_PRINT(tag,...)  \
     77     do { if (VERBOSE_CHECK(tag)) dprint(__VA_ARGS__); } while (0)
     78 
     79 /** DEBUG TRACE SUPPORT
     80  **
     81  ** debug messages can be sent by calling these function
     82  **
     83  ** 'dprint' prints the message, then appends a '\n\
     84  ** 'dprintn' simply prints the message as is
     85  ** 'dprintnv' allows you to use a va_list argument
     86  ** 'dwarning' prints a warning message, then appends a '\n'
     87  ** 'derror' prints a severe error message, then appends a '\n'
     88  */
     89 
     90 extern void   dprint( const char*  format, ... );
     91 extern void   dprintn( const char*  format, ... );
     92 extern void   dprintnv( const char*  format, va_list  args );
     93 extern void   dwarning( const char*  format, ... );
     94 extern void   derror( const char*  format, ... );
     95 
     96 /** STDOUT/STDERR REDIRECTION
     97  **
     98  ** allows you to shut temporarily shutdown stdout/stderr
     99  ** this is useful to get rid of debug messages from ALSA and esd
    100  ** on Linux.
    101  **/
    102 
    103 extern void  stdio_disable( void );
    104 extern void  stdio_enable( void );
    105 
    106 ANDROID_END_HEADER
    107 
    108 #endif /* _ANDROID_UTILS_DEBUG_H */
    109