Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 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 | |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 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 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 20 | //++ |
| 21 | //============================================================================ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 22 | // Details: MI debugging aid utility class. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 23 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 24 | class CMIUtilDebug { |
| 25 | // Statics: |
| 26 | public: |
| 27 | static void ShowDlgWaitForDbgAttach(); |
| 28 | static void WaitForDbgAttachInfinteLoop(); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 29 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 30 | // Methods: |
| 31 | public: |
| 32 | /* ctor */ CMIUtilDebug(); |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 33 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | // Overrideable: |
| 35 | public: |
| 36 | // From CMICmnBase |
| 37 | /* dtor */ virtual ~CMIUtilDebug(); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 40 | //++ |
| 41 | //============================================================================ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 42 | // 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 Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 49 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | class CMIUtilDebugFnTrace { |
| 51 | // Methods: |
| 52 | public: |
| 53 | /* ctor */ CMIUtilDebugFnTrace(const CMIUtilString &vFnName); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 54 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | // Overrideable: |
| 56 | public: |
| 57 | // From CMICmnBase |
| 58 | /* dtor */ virtual ~CMIUtilDebugFnTrace(); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 59 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | // Attributes: |
| 61 | private: |
| 62 | const CMIUtilString m_strFnName; |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 63 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 64 | static CMICmnLog &ms_rLog; |
| 65 | static MIuint ms_fnDepthCnt; // Increment count as fn depth increases, |
| 66 | // decrement count as fn stack pops off |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 69 | //++ |
| 70 | //============================================================================ |
| 71 | // Details: Take the given text and send it to the server's Logger to output to |
| 72 | // the |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 73 | // trace file. |
| 74 | // Type: Compile preprocess. |
| 75 | // Args: x - (R) Message (may be seen by user). |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 76 | //-- |
| 77 | #ifdef MI_USE_DEBUG_TRACE_FN |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 78 | #define MI_TRACEFN(x) CMIUtilDebugFnTrace __MITrace(x) |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 79 | #else |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 80 | #define MI_TRACEFN(x) |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 81 | #endif // MI_USE_DEBUG_TRACE_FN |