summaryrefslogtreecommitdiff
path: root/avstream/avscamera/sys/Dbg.h
blob: b0bc6e80091434eac612c21fc6e5b4b20d4cff91 (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
/**************************************************************************

    AVStream Camera Sample

    Copyright (c) 2014, Microsoft Corporation.

    File:

        Dbg.h

    Abstract:

        Debug definitions.

    History:

        created 2/18/2015

**************************************************************************/

#pragma once

#define DEBUGLVL_VERBOSE 2
#define DEBUGLVL_TERSE 1
#define DEBUGLVL_ERROR 0

const int DebugLevel = DEBUGLVL_TERSE;

#if (DBG)
#define _DbgPrintF(lvl, strings) \
{ \
    if (lvl <= DebugLevel) {\
        DbgPrint(STR_MODULENAME);\
        DbgPrint##strings;\
        DbgPrint("\n");\
        if ((lvl) == DEBUGLVL_ERROR) {\
            NT_ASSERT(0);\
        } \
    }\
}
#else // !DBG
#define _DbgPrintF(lvl, strings)
#endif // !DBG

//  This is for debug output; but we're going to leave it in the
//  driver for now.  We can always turn off the Windbg output at
//  the debugger.
//  Enable via debugger: ed Kd_IHVSTREAMING_Mask 0xFFFFFFFF
#define ENABLE_TRACING  1
#if ENABLE_TRACING

#define DBG_OUT( FMT, ... ) \
    { \
        LARGE_INTEGER   SysTime; \
        LARGE_INTEGER   LocalTime; \
        TIME_FIELDS     TimeFields; \
        \
        KeQuerySystemTimePrecise( &SysTime ); \
        ExSystemTimeToLocalTime( &SysTime, &LocalTime ); \
        RtlTimeToTimeFields( &LocalTime, &TimeFields ); \
        DbgPrintEx( DPFLTR_IHVSTREAMING_ID, DPFLTR_MASK|DPFLTR_TRACE_LEVEL, \
        "%02d:%02d:%02d.%03d [%p] " ## FMT ## "\n", \
        TimeFields.Hour, TimeFields.Minute, TimeFields.Second, TimeFields.Milliseconds, \
        KeGetCurrentThread(), __VA_ARGS__ ); \
    }

#define DBG_ENTER( FMT, ... ) \
    DBG_OUT( "Entering: " __FUNCTION__ ## FMT, __VA_ARGS__ );

#define DBG_LEAVE( FMT, ... ) \
    DBG_OUT( " Leaving: " __FUNCTION__ ## FMT, __VA_ARGS__ );

#define DBG_TRACE( FMT, ... ) \
    DBG_OUT( "      In: " __FUNCTION__ ## " " ## FMT, __VA_ARGS__ );

#else // !ENABLE_TRACING  
#define DBG_ENTER( ... )
#define DBG_LEAVE( ... )
#define DBG_TRACE( ... )
#endif // !ENABLE_TRACING