]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MIUtilDebug.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MIUtilDebug.h
1 //===-- MIUtilDebug.h -------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #pragma once
10
11 #define MI_USE_DEBUG_TRACE_FN // Undefine to compile out fn trace code
12
13 // In-house headers:
14 #include "MIUtilString.h"
15
16 // Declarations:
17 class CMICmnLog;
18
19 //++
20 //============================================================================
21 // Details: MI debugging aid utility class.
22 //--
23 class CMIUtilDebug {
24   // Statics:
25 public:
26   static void WaitForDbgAttachInfinteLoop();
27
28   // Methods:
29 public:
30   /* ctor */ CMIUtilDebug();
31
32   // Overrideable:
33 public:
34   // From CMICmnBase
35   /* dtor */ virtual ~CMIUtilDebug();
36 };
37
38 //++
39 //============================================================================
40 // Details: MI debug utility class. Used to indicate the current function
41 //          depth in the call stack. It uses the CMIlCmnLog logger to output
42 //          the current fn trace information.
43 //          Use macro MI_TRACEFN( "Some fn name" ) and implement the scope of
44 //          the functions you wish to build up a trace off.
45 //          Use preprocessor definition MI_USE_DEBUG_TRACE_FN to turn off or on
46 //          tracing code.
47 //--
48 class CMIUtilDebugFnTrace {
49   // Methods:
50 public:
51   /* ctor */ CMIUtilDebugFnTrace(const CMIUtilString &vFnName);
52
53   // Overrideable:
54 public:
55   // From CMICmnBase
56   /* dtor */ virtual ~CMIUtilDebugFnTrace();
57
58   // Attributes:
59 private:
60   const CMIUtilString m_strFnName;
61
62   static CMICmnLog &ms_rLog;
63   static MIuint ms_fnDepthCnt; // Increment count as fn depth increases,
64                                // decrement count as fn stack pops off
65 };
66
67 //++
68 //============================================================================
69 // Details: Take the given text and send it to the server's Logger to output to
70 // the
71 //          trace file.
72 // Type:    Compile preprocess.
73 // Args:    x   - (R) Message (may be seen by user).
74 //--
75 #ifdef MI_USE_DEBUG_TRACE_FN
76 #define MI_TRACEFN(x) CMIUtilDebugFnTrace __MITrace(x)
77 #else
78 #define MI_TRACEFN(x)
79 #endif // MI_USE_DEBUG_TRACE_FN