aboutsummaryrefslogtreecommitdiffstats
path: root/memcheck/memcheck_logging.h
blob: 94a3c09366b79e34b1256701812abe322ac7b2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Copyright (C) 2007-2010 The Android Open Source Project
**
** This software is licensed under the terms of the GNU General Public
** License version 2, as published by the Free Software Foundation, and
** may be copied, distributed, and modified under those terms.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
*/

/*
 * Contains declarations of logging macros used in memchecker framework.
 */

#ifndef QEMU_MEMCHECK_MEMCHECK_LOGGING_H
#define QEMU_MEMCHECK_MEMCHECK_LOGGING_H

#include "qemu-common.h"
#include "android/utils/debug.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Prints debug message under the 'memcheck' tag. */
#define MD(...)  VERBOSE_PRINT(memcheck, __VA_ARGS__)

/* Prints an error message under the 'memcheck' tag. */
#define ME(...)  \
    do { if (VERBOSE_CHECK(memcheck)) derror(__VA_ARGS__); } while (0)

// =============================================================================
// Tracing flags (see trace_flags declared in memcheck.c), and macros
// =============================================================================

/* Enables fork() tracing. */
#define TRACE_PROC_FORK_ENABLED                 0x00000001
/* Enables clone() tracing. */
#define TRACE_PROC_CLONE_ENABLED                0x00000002
/* Enables new PID allocation tracing. */
#define TRACE_PROC_NEW_PID_ENABLED              0x00000004
/* Enables guest process starting tracing. */
#define TRACE_PROC_START_ENABLED                0x00000008
/* Enables guest process exiting tracing. */
#define TRACE_PROC_EXIT_ENABLED                 0x00000010
/* Enables libc.so initialization tracing. */
#define TRACE_PROC_LIBC_INIT_ENABLED            0x00000020
/* Enables leaking tracing. */
#define TRACE_CHECK_LEAK_ENABLED                0x00000040
/* Enables invalid pointer access tracing. */
#define TRACE_CHECK_INVALID_PTR_ENABLED         0x00000080
/* Enables reading violations tracing. */
#define TRACE_CHECK_READ_VIOLATION_ENABLED      0x00000100
/* Enables writing violations tracing. */
#define TRACE_CHECK_WRITE_VIOLATION_ENABLED     0x00000200
/* Enables module mapping tracing. */
#define TRACE_PROC_MMAP_ENABLED                 0x00000400
/* All tracing flags combined. */
#define TRACE_ALL_ENABLED   (TRACE_PROC_FORK_ENABLED                | \
                             TRACE_PROC_CLONE_ENABLED               | \
                             TRACE_PROC_NEW_PID_ENABLED             | \
                             TRACE_PROC_START_ENABLED               | \
                             TRACE_PROC_LIBC_INIT_ENABLED           | \
                             TRACE_PROC_EXIT_ENABLED                | \
                             TRACE_CHECK_INVALID_PTR_ENABLED        | \
                             TRACE_CHECK_READ_VIOLATION_ENABLED     | \
                             TRACE_CHECK_WRITE_VIOLATION_ENABLED    | \
                             TRACE_PROC_MMAP_ENABLED                | \
                             TRACE_CHECK_LEAK_ENABLED)

/* Prints a trace to the stdout. */
#define T(level, ...)                                   \
    do {                                                \
        if (trace_flags & TRACE_##level##_ENABLED) {    \
            printf(__VA_ARGS__);                        \
        }                                               \
    } while (0)

/* Set of tracing flags (declared in memchek.c). */
extern uint32_t trace_flags;

#ifdef __cplusplus
};  /* end of extern "C" */
#endif

#endif  // QEMU_MEMCHECK_MEMCHECK_LOGGING_H