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 13 #pragma once 14 15 #include <stdarg.h> 16 #include <stdbool.h> 17 #include <stdint.h> 18 19 #include "android/utils/compiler.h" 20 21 ANDROID_BEGIN_HEADER 22 23 #define VERBOSE_TAG_LIST \ 24 _VERBOSE_TAG(init, "emulator initialization") \ 25 _VERBOSE_TAG(console, "control console") \ 26 _VERBOSE_TAG(modem, "emulated GSM modem") \ 27 _VERBOSE_TAG(radio, "emulated GSM AT Command channel") \ 28 _VERBOSE_TAG(keys, "key bindings & presses") \ 29 _VERBOSE_TAG(events, "events sent to the emulator") \ 30 _VERBOSE_TAG(slirp, "internal router/firewall") \ 31 _VERBOSE_TAG(timezone, "host timezone detection") \ 32 _VERBOSE_TAG(socket, "network sockets") \ 33 _VERBOSE_TAG(proxy, "network proxy support") \ 34 _VERBOSE_TAG(audio, "audio sub-system") \ 35 _VERBOSE_TAG(audioin, "audio input backend") \ 36 _VERBOSE_TAG(audioout, "audio output backend") \ 37 _VERBOSE_TAG(surface, "video surface support") \ 38 _VERBOSE_TAG(qemud, "qemud multiplexer daemon") \ 39 _VERBOSE_TAG(gps, "emulated GPS") \ 40 _VERBOSE_TAG(nand_limits, "nand/flash read/write thresholding") \ 41 _VERBOSE_TAG(hw_control, "emulated power/flashlight/led/vibrator") \ 42 _VERBOSE_TAG(avd_config, "android virtual device configuration") \ 43 _VERBOSE_TAG(sensors, "emulated sensors") \ 44 _VERBOSE_TAG(memcheck, "memory checker") \ 45 _VERBOSE_TAG(camera, "camera") \ 46 _VERBOSE_TAG(adevice, "android device connected via port forwarding") \ 47 _VERBOSE_TAG(sensors_port, "sensors emulator connected to android device") \ 48 _VERBOSE_TAG(mtport, "multi-touch emulator connected to android device") \ 49 _VERBOSE_TAG(mtscreen, "multi-touch screen emulation") \ 50 _VERBOSE_TAG(gles, "hardware OpenGLES emulation") \ 51 _VERBOSE_TAG(gles1emu, "emulated GLESv1 renderer") \ 52 _VERBOSE_TAG(adbserver, "ADB server") \ 53 _VERBOSE_TAG(adbclient, "ADB QEMU client") \ 54 _VERBOSE_TAG(adb, "ADB debugger") \ 55 _VERBOSE_TAG(asconnector, "Asynchronous socket connector") \ 56 _VERBOSE_TAG(asyncsocket, "Asynchronous socket") \ 57 _VERBOSE_TAG(sdkctlsocket, "Socket tethering to SdkControl server") \ 58 _VERBOSE_TAG(updater, "Update checker") \ 59 _VERBOSE_TAG(metrics, "Metrics reporting") \ 60 _VERBOSE_TAG(rotation, "Device rotation debugging") \ 61 _VERBOSE_TAG(goldfishsync, "Goldfish Sync Device") \ 62 _VERBOSE_TAG(syncthreads, "HostGPU Sync Threads") \ 63 _VERBOSE_TAG(memory, "Memory Usage Report") \ 64 _VERBOSE_TAG(car, "Emulated car data") \ 65 _VERBOSE_TAG(record, "Screen recording") \ 66 _VERBOSE_TAG(snapshot, "Snapshots") \ 67 _VERBOSE_TAG(virtualscene, "Virtual scene rendering") \ 68 _VERBOSE_TAG(automation, "Automation") \ 69 _VERBOSE_TAG(offworld, "Offworld") \ 70 71 #define _VERBOSE_TAG(x,y) VERBOSE_##x, 72 typedef enum { 73 VERBOSE_TAG_LIST 74 VERBOSE_MAX /* do not remove */ 75 } VerboseTag; 76 #undef _VERBOSE_TAG 77 78 extern uint64_t android_verbose; 79 80 // Enable/disable verbose logs from the base/* family. 81 extern void base_enable_verbose_logs(); 82 extern void base_disable_verbose_logs(); 83 84 #define VERBOSE_ENABLE(tag) \ 85 android_verbose |= (1ULL << VERBOSE_##tag) 86 87 #define VERBOSE_DISABLE(tag) \ 88 android_verbose &= (1ULL << VERBOSE_##tag) 89 90 #define VERBOSE_CHECK(tag) \ 91 ((android_verbose & (1ULL << VERBOSE_##tag)) != 0) 92 93 #define VERBOSE_CHECK_ANY() \ 94 (android_verbose != 0) 95 96 #define VERBOSE_PRINT(tag,...) \ 97 do { if (VERBOSE_CHECK(tag)) dprint(__VA_ARGS__); } while (0) 98 99 // This omits the "emulator: " prefix. 100 #define VERBOSE_DPRINT(tag,format,...) \ 101 do { if (VERBOSE_CHECK(tag)) { \ 102 dprintn(format "\n", \ 103 ##__VA_ARGS__); } } while(0) 104 105 #define VERBOSE_FUNCTION_PRINT(tag,format,...) \ 106 do { if (VERBOSE_CHECK(tag)) \ 107 dprintn("emulator: %s: " format "\n", \ 108 __func__, ##__VA_ARGS__); } while(0) 109 110 // This omits the "emulator: " prefix. 111 #define VERBOSE_FUNCTION_DPRINT(tag,format,...) \ 112 do { if (VERBOSE_CHECK(tag)) \ 113 dprintn("%s: " format "\n", \ 114 __func__, ##__VA_ARGS__); } while(0) 115 116 #define VERBOSE_TID_PRINT(tag,...) \ 117 do { if (VERBOSE_CHECK(tag)) \ 118 android_tid_function_print(true, NULL, __VA_ARGS__); \ 119 } while (0) 120 121 // This omits the "emulator: " prefix. 122 #define VERBOSE_TID_DPRINT(tag,...) \ 123 do { if (VERBOSE_CHECK(tag)) \ 124 android_tid_function_print(false, NULL, __VA_ARGS__); } \ 125 while (0) 126 127 #define VERBOSE_TID_FUNCTION_PRINT(tag,...) \ 128 do { if (VERBOSE_CHECK(tag)) \ 129 android_tid_function_print(true, __func__, __VA_ARGS__); } \ 130 while (0) 131 132 // This omits the "emulator: " prefix. 133 #define VERBOSE_TID_FUNCTION_DPRINT(tag,...) \ 134 do { if (VERBOSE_CHECK(tag)) \ 135 android_tid_function_print(false, __func__, __VA_ARGS__); } \ 136 while (0) 137 138 /** DEBUG TRACE SUPPORT 139 ** 140 ** Debug messages can be sent by calling these functions: 141 ** 142 ** 'dprint' prints "emulator: ", the message, then appends a '\n' 143 ** 'dprintn' prints the message as is 144 ** 'dprintnv' is 'dprintn' but allows you to use a va_list argument 145 ** 'dwarning' prints "emulator: WARNING: ", then appends a '\n' 146 ** 'derror' prints "emulator: ERROR: ", then appends a '\n' 147 */ 148 149 extern void dprint( const char* format, ... ); 150 extern void dprintn( const char* format, ... ); 151 extern void dprintnv( const char* format, va_list args ); 152 extern void dwarning( const char* format, ... ); 153 extern void derror( const char* format, ... ); 154 155 /** MULTITHREADED DEBUG TRACING 156 ** 157 ** 'android_tid_function_print' is for tracing in multi-threaded situations. 158 ** It prints "emulator: " or not (depending on |use_emulator_prefix|), 159 ** the thread id, a function name (|function|), the message, and finally '\n'. 160 */ 161 extern void android_tid_function_print(bool use_emulator_prefix, 162 const char* function, 163 const char* format, ... ); 164 165 /** STDOUT/STDERR REDIRECTION 166 ** 167 ** allows you to shut temporarily shutdown stdout/stderr 168 ** this is useful to get rid of debug messages from ALSA and esd 169 ** on Linux. 170 **/ 171 172 extern void stdio_disable( void ); 173 extern void stdio_enable( void ); 174 175 ANDROID_END_HEADER 176