1 /* Copyright (C) 2007-2010 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 /* 14 * Contains declarations of logging macros used in memchecker framework. 15 */ 16 17 #ifndef QEMU_MEMCHECK_MEMCHECK_LOGGING_H 18 #define QEMU_MEMCHECK_MEMCHECK_LOGGING_H 19 20 /* This file should compile iff qemu is built with memory checking 21 * configuration turned on. */ 22 #ifndef CONFIG_MEMCHECK 23 #error CONFIG_MEMCHECK is not defined. 24 #endif // CONFIG_MEMCHECK 25 26 #include "qemu-common.h" 27 #include "android/utils/debug.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* Prints debug message under the 'memcheck' tag. */ 34 #define MD(...) VERBOSE_PRINT(memcheck, __VA_ARGS__) 35 36 /* Prints an error message under the 'memcheck' tag. */ 37 #define ME(...) \ 38 do { if (VERBOSE_CHECK(memcheck)) derror(__VA_ARGS__); } while (0) 39 40 // ============================================================================= 41 // Tracing flags (see trace_flags declared in memcheck.c), and macros 42 // ============================================================================= 43 44 /* Enables fork() tracing. */ 45 #define TRACE_PROC_FORK_ENABLED 0x00000001 46 /* Enables clone() tracing. */ 47 #define TRACE_PROC_CLONE_ENABLED 0x00000002 48 /* Enables new PID allocation tracing. */ 49 #define TRACE_PROC_NEW_PID_ENABLED 0x00000004 50 /* Enables guest process starting tracing. */ 51 #define TRACE_PROC_START_ENABLED 0x00000008 52 /* Enables guest process exiting tracing. */ 53 #define TRACE_PROC_EXIT_ENABLED 0x00000010 54 /* Enables libc.so initialization tracing. */ 55 #define TRACE_PROC_LIBC_INIT_ENABLED 0x00000020 56 /* Enables leaking tracing. */ 57 #define TRACE_CHECK_LEAK_ENABLED 0x00000040 58 /* Enables invalid pointer access tracing. */ 59 #define TRACE_CHECK_INVALID_PTR_ENABLED 0x00000080 60 /* Enables reading violations tracing. */ 61 #define TRACE_CHECK_READ_VIOLATION_ENABLED 0x00000100 62 /* Enables writing violations tracing. */ 63 #define TRACE_CHECK_WRITE_VIOLATION_ENABLED 0x00000200 64 /* Enables module mapping tracing. */ 65 #define TRACE_PROC_MMAP_ENABLED 0x00000400 66 /* All tracing flags combined. */ 67 #define TRACE_ALL_ENABLED (TRACE_PROC_FORK_ENABLED | \ 68 TRACE_PROC_CLONE_ENABLED | \ 69 TRACE_PROC_NEW_PID_ENABLED | \ 70 TRACE_PROC_START_ENABLED | \ 71 TRACE_PROC_LIBC_INIT_ENABLED | \ 72 TRACE_PROC_EXIT_ENABLED | \ 73 TRACE_CHECK_INVALID_PTR_ENABLED | \ 74 TRACE_CHECK_READ_VIOLATION_ENABLED | \ 75 TRACE_CHECK_WRITE_VIOLATION_ENABLED | \ 76 TRACE_PROC_MMAP_ENABLED | \ 77 TRACE_CHECK_LEAK_ENABLED) 78 79 /* Prints a trace to the stdout. */ 80 #define T(level, ...) \ 81 do { \ 82 if (trace_flags & TRACE_##level##_ENABLED) { \ 83 printf(__VA_ARGS__); \ 84 } \ 85 } while (0) 86 87 /* Set of tracing flags (declared in memchek.c). */ 88 extern uint32_t trace_flags; 89 90 #ifdef __cplusplus 91 }; /* end of extern "C" */ 92 #endif 93 94 #endif // QEMU_MEMCHECK_MEMCHECK_LOGGING_H 95