1 //===-- 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 #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: 18 class CMICmnLog; 19 20 //++ 21 //============================================================================ 22 // Details: MI debugging aid utility class. 23 //-- 24 class CMIUtilDebug { 25 // Statics: 26 public: 27 static void WaitForDbgAttachInfinteLoop(); 28 29 // Methods: 30 public: 31 /* ctor */ CMIUtilDebug(); 32 33 // Overrideable: 34 public: 35 // From CMICmnBase 36 /* dtor */ virtual ~CMIUtilDebug(); 37 }; 38 39 //++ 40 //============================================================================ 41 // Details: MI debug utility class. Used to indicate the current function 42 // depth in the call stack. It uses the CMIlCmnLog logger to output 43 // the current fn trace information. 44 // Use macro MI_TRACEFN( "Some fn name" ) and implement the scope of 45 // the functions you wish to build up a trace off. 46 // Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on 47 // tracing code. 48 //-- 49 class CMIUtilDebugFnTrace { 50 // Methods: 51 public: 52 /* ctor */ CMIUtilDebugFnTrace(const CMIUtilString &vFnName); 53 54 // Overrideable: 55 public: 56 // From CMICmnBase 57 /* dtor */ virtual ~CMIUtilDebugFnTrace(); 58 59 // Attributes: 60 private: 61 const CMIUtilString m_strFnName; 62 63 static CMICmnLog &ms_rLog; 64 static MIuint ms_fnDepthCnt; // Increment count as fn depth increases, 65 // decrement count as fn stack pops off 66 }; 67 68 //++ 69 //============================================================================ 70 // Details: Take the given text and send it to the server's Logger to output to 71 // the 72 // trace file. 73 // Type: Compile preprocess. 74 // Args: x - (R) Message (may be seen by user). 75 //-- 76 #ifdef MI_USE_DEBUG_TRACE_FN 77 #define MI_TRACEFN(x) CMIUtilDebugFnTrace __MITrace(x) 78 #else 79 #define MI_TRACEFN(x) 80 #endif // MI_USE_DEBUG_TRACE_FN 81