blob: a49fd9a868ec747cc97a7143a44c6781c1c4b760 [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
Deepak Panickal6f9c4682014-05-16 10:51:01 +000010#pragma once
11
12#define MI_USE_DEBUG_TRACE_FN // Undefine to compile out fn trace code
13
14// In-house headers:
15#include "MIUtilString.h"
16
17// Declarations:
18class CMICmnLog;
19
Kate Stoneb9c1b512016-09-06 20:57:50 +000020//++
21//============================================================================
Zachary Turner1d6af022014-11-17 18:06:21 +000022// Details: MI debugging aid utility class.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000023//--
Kate Stoneb9c1b512016-09-06 20:57:50 +000024class CMIUtilDebug {
25 // Statics:
26public:
27 static void ShowDlgWaitForDbgAttach();
28 static void WaitForDbgAttachInfinteLoop();
Deepak Panickal6f9c4682014-05-16 10:51:01 +000029
Kate Stoneb9c1b512016-09-06 20:57:50 +000030 // Methods:
31public:
32 /* ctor */ CMIUtilDebug();
Zachary Turner1d6af022014-11-17 18:06:21 +000033
Kate Stoneb9c1b512016-09-06 20:57:50 +000034 // Overrideable:
35public:
36 // From CMICmnBase
37 /* dtor */ virtual ~CMIUtilDebug();
Deepak Panickal6f9c4682014-05-16 10:51:01 +000038};
39
Kate Stoneb9c1b512016-09-06 20:57:50 +000040//++
41//============================================================================
Zachary Turner1d6af022014-11-17 18:06:21 +000042// Details: MI debug utility class. Used to indicate the current function
43// depth in the call stack. It uses the CMIlCmnLog logger to output
44// the current fn trace information.
45// Use macro MI_TRACEFN( "Some fn name" ) and implement the scope of
46// the functions you wish to build up a trace off.
47// Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on
48// tracing code.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000049//--
Kate Stoneb9c1b512016-09-06 20:57:50 +000050class CMIUtilDebugFnTrace {
51 // Methods:
52public:
53 /* ctor */ CMIUtilDebugFnTrace(const CMIUtilString &vFnName);
Deepak Panickal6f9c4682014-05-16 10:51:01 +000054
Kate Stoneb9c1b512016-09-06 20:57:50 +000055 // Overrideable:
56public:
57 // From CMICmnBase
58 /* dtor */ virtual ~CMIUtilDebugFnTrace();
Deepak Panickal6f9c4682014-05-16 10:51:01 +000059
Kate Stoneb9c1b512016-09-06 20:57:50 +000060 // Attributes:
61private:
62 const CMIUtilString m_strFnName;
Zachary Turner1d6af022014-11-17 18:06:21 +000063
Kate Stoneb9c1b512016-09-06 20:57:50 +000064 static CMICmnLog &ms_rLog;
65 static MIuint ms_fnDepthCnt; // Increment count as fn depth increases,
66 // decrement count as fn stack pops off
Deepak Panickal6f9c4682014-05-16 10:51:01 +000067};
68
Kate Stoneb9c1b512016-09-06 20:57:50 +000069//++
70//============================================================================
71// Details: Take the given text and send it to the server's Logger to output to
72// the
Zachary Turner1d6af022014-11-17 18:06:21 +000073// trace file.
74// Type: Compile preprocess.
75// Args: x - (R) Message (may be seen by user).
Deepak Panickal6f9c4682014-05-16 10:51:01 +000076//--
77#ifdef MI_USE_DEBUG_TRACE_FN
Zachary Turner1d6af022014-11-17 18:06:21 +000078#define MI_TRACEFN(x) CMIUtilDebugFnTrace __MITrace(x)
Deepak Panickal6f9c4682014-05-16 10:51:01 +000079#else
Zachary Turner1d6af022014-11-17 18:06:21 +000080#define MI_TRACEFN(x)
Deepak Panickal6f9c4682014-05-16 10:51:01 +000081#endif // MI_USE_DEBUG_TRACE_FN