| Vladimir Chtchetkine | 5389aa1 | 2010-02-16 10:38:35 -0800 | [diff] [blame] | 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 | |
| Vladimir Chtchetkine | 5389aa1 | 2010-02-16 10:38:35 -0800 | [diff] [blame] | 20 | #include "qemu-common.h" |
| 21 | #include "android/utils/debug.h" |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | /* Prints debug message under the 'memcheck' tag. */ |
| 28 | #define MD(...) VERBOSE_PRINT(memcheck, __VA_ARGS__) |
| 29 | |
| 30 | /* Prints an error message under the 'memcheck' tag. */ |
| 31 | #define ME(...) \ |
| 32 | do { if (VERBOSE_CHECK(memcheck)) derror(__VA_ARGS__); } while (0) |
| 33 | |
| 34 | // ============================================================================= |
| 35 | // Tracing flags (see trace_flags declared in memcheck.c), and macros |
| 36 | // ============================================================================= |
| 37 | |
| 38 | /* Enables fork() tracing. */ |
| 39 | #define TRACE_PROC_FORK_ENABLED 0x00000001 |
| 40 | /* Enables clone() tracing. */ |
| 41 | #define TRACE_PROC_CLONE_ENABLED 0x00000002 |
| 42 | /* Enables new PID allocation tracing. */ |
| 43 | #define TRACE_PROC_NEW_PID_ENABLED 0x00000004 |
| 44 | /* Enables guest process starting tracing. */ |
| 45 | #define TRACE_PROC_START_ENABLED 0x00000008 |
| 46 | /* Enables guest process exiting tracing. */ |
| 47 | #define TRACE_PROC_EXIT_ENABLED 0x00000010 |
| 48 | /* Enables libc.so initialization tracing. */ |
| 49 | #define TRACE_PROC_LIBC_INIT_ENABLED 0x00000020 |
| 50 | /* Enables leaking tracing. */ |
| 51 | #define TRACE_CHECK_LEAK_ENABLED 0x00000040 |
| 52 | /* Enables invalid pointer access tracing. */ |
| 53 | #define TRACE_CHECK_INVALID_PTR_ENABLED 0x00000080 |
| 54 | /* Enables reading violations tracing. */ |
| 55 | #define TRACE_CHECK_READ_VIOLATION_ENABLED 0x00000100 |
| 56 | /* Enables writing violations tracing. */ |
| 57 | #define TRACE_CHECK_WRITE_VIOLATION_ENABLED 0x00000200 |
| 58 | /* Enables module mapping tracing. */ |
| 59 | #define TRACE_PROC_MMAP_ENABLED 0x00000400 |
| 60 | /* All tracing flags combined. */ |
| 61 | #define TRACE_ALL_ENABLED (TRACE_PROC_FORK_ENABLED | \ |
| 62 | TRACE_PROC_CLONE_ENABLED | \ |
| 63 | TRACE_PROC_NEW_PID_ENABLED | \ |
| 64 | TRACE_PROC_START_ENABLED | \ |
| 65 | TRACE_PROC_LIBC_INIT_ENABLED | \ |
| 66 | TRACE_PROC_EXIT_ENABLED | \ |
| 67 | TRACE_CHECK_INVALID_PTR_ENABLED | \ |
| 68 | TRACE_CHECK_READ_VIOLATION_ENABLED | \ |
| 69 | TRACE_CHECK_WRITE_VIOLATION_ENABLED | \ |
| 70 | TRACE_PROC_MMAP_ENABLED | \ |
| 71 | TRACE_CHECK_LEAK_ENABLED) |
| 72 | |
| 73 | /* Prints a trace to the stdout. */ |
| 74 | #define T(level, ...) \ |
| 75 | do { \ |
| 76 | if (trace_flags & TRACE_##level##_ENABLED) { \ |
| 77 | printf(__VA_ARGS__); \ |
| 78 | } \ |
| 79 | } while (0) |
| 80 | |
| 81 | /* Set of tracing flags (declared in memchek.c). */ |
| 82 | extern uint32_t trace_flags; |
| 83 | |
| 84 | #ifdef __cplusplus |
| 85 | }; /* end of extern "C" */ |
| 86 | #endif |
| 87 | |
| 88 | #endif // QEMU_MEMCHECK_MEMCHECK_LOGGING_H |