blob: b163b05f5de5b22c1dfa04075566dfef1c6fe49f [file] [log] [blame]
Deepak Panickal6f9c4682014-05-16 10:51:01 +00001//===-- MIUtilDebug.h -------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//++
11// File: MIUtilDebug.h
12//
13// Overview: CMIUtilDebug interface.
14//
15// Environment: Compilers: Visual C++ 12.
16// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17// Libraries: See MIReadmetxt.
18//
19// Copyright: None.
20//--
21
22#pragma once
23
24#define MI_USE_DEBUG_TRACE_FN // Undefine to compile out fn trace code
25
26// In-house headers:
27#include "MIUtilString.h"
28
29// Declarations:
30class CMICmnLog;
31
32//++ ============================================================================
33// Details: MI debugging aid utility class.
34// Gotchas: None.
35// Authors:
36// Changes: None.
37//--
38class CMIUtilDebug
39{
40// Statics:
41public:
42 static void ShowDlgWaitForDbgAttach( void );
43 static void WaitForDbgAttachInfinteLoop( void );
44
45// Methods:
46public:
47 /* ctor */ CMIUtilDebug( void );
48
49// Overrideable:
50public:
51 // From CMICmnBase
52 /* dtor */ virtual ~CMIUtilDebug( void );
53};
54
55//++ ============================================================================
56// Details: MI debug utility class. Used to indicate the current function
57// depth in the call stack. It uses the CMIlCmnLog logger to output
58// the current fn trace information.
59// Use macro MI_TRACEFN( "Some fn name" ) and implement the scope of
60// the functions you wish to build up a trace off.
61// Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on
62// tracing code.
63// Gotchas: None.
64// Authors: Illya Rudkin 07/03/2014.
65// Changes: None.
66//--
67class CMIUtilDebugFnTrace
68{
69// Methods:
70public:
71 /* ctor */ CMIUtilDebugFnTrace( const CMIUtilString & vFnName );
72
73// Overrideable:
74public:
75 // From CMICmnBase
76 /* dtor */ virtual ~CMIUtilDebugFnTrace( void );
77
78// Attributes:
79private:
80 const CMIUtilString m_strFnName;
81
82 static CMICmnLog & ms_rLog;
83 static MIuint ms_fnDepthCnt; // Increment count as fn depth increases, decrement count as fn stack pops off
84};
85
86//++ ============================================================================
87// Details: Take the given text and send it to the server's Logger to output to the
88// trace file.
89// Type: Compile preprocess.
90// Args: x - (R) Message (may be seen by user).
91//--
92#ifdef MI_USE_DEBUG_TRACE_FN
93#define MI_TRACEFN( x ) CMIUtilDebugFnTrace __MITrace( x )
94#else
95#define MI_TRACEFN( x )
96#endif // MI_USE_DEBUG_TRACE_FN