]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnLLDBDebugSessionInfoVarObj.h
1 //===-- MICmnLLDBDebugSessionInfoVarObj.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 // Third Party Headers:
12 #include "lldb/API/SBValue.h"
13 #include <map>
14
15 // In-house headers:
16 #include "MIUtilString.h"
17
18 //++
19 //============================================================================
20 // Details: MI debug session variable object. The static functionality in *this
21 //          class manages a map container of *these variable objects.
22 //--
23 class CMICmnLLDBDebugSessionInfoVarObj {
24   // Enums:
25 public:
26   //++ ----------------------------------------------------------------------
27   // Details: Enumeration of a variable type that is not a composite type
28   //--
29   enum varFormat_e {
30     // CODETAG_SESSIONINFO_VARFORMAT_ENUM
31     // *** Order is import here ***
32     eVarFormat_Invalid = 0,
33     eVarFormat_Binary,
34     eVarFormat_Octal,
35     eVarFormat_Decimal,
36     eVarFormat_Hex,
37     eVarFormat_Natural,
38     eVarFormat_count // Always last one
39   };
40
41   //++ ----------------------------------------------------------------------
42   // Details: Enumeration of a variable type by composite or internal type
43   //--
44   enum varType_e {
45     eVarType_InValid = 0,
46     eVarType_Composite, // i.e. struct
47     eVarType_Internal,  // i.e. int
48     eVarType_count      // Always last one
49   };
50
51   // Statics:
52 public:
53   static varFormat_e GetVarFormatForString(const CMIUtilString &vrStrFormat);
54   static varFormat_e GetVarFormatForChar(char vcFormat);
55   static CMIUtilString GetValueStringFormatted(const lldb::SBValue &vrValue,
56                                                const varFormat_e veVarFormat);
57   static void VarObjAdd(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj);
58   static void VarObjDelete(const CMIUtilString &vrVarName);
59   static bool VarObjGet(const CMIUtilString &vrVarName,
60                         CMICmnLLDBDebugSessionInfoVarObj &vrwVarObj);
61   static void VarObjUpdate(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj);
62   static void VarObjIdInc();
63   static MIuint VarObjIdGet();
64   static void VarObjIdResetToZero();
65   static void VarObjClear();
66   static void VarObjSetFormat(varFormat_e eDefaultFormat);
67
68   // Methods:
69 public:
70   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj();
71   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(
72       const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
73       const lldb::SBValue &vrValue);
74   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(
75       const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
76       const lldb::SBValue &vrValue, const CMIUtilString &vrStrVarObjParentName);
77   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(
78       const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
79   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(
80       CMICmnLLDBDebugSessionInfoVarObj &vrOther);
81   /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(
82       CMICmnLLDBDebugSessionInfoVarObj &&vrOther);
83   //
84   CMICmnLLDBDebugSessionInfoVarObj &
85   operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
86   CMICmnLLDBDebugSessionInfoVarObj &
87   operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther);
88   //
89   const CMIUtilString &GetName() const;
90   const CMIUtilString &GetNameReal() const;
91   const CMIUtilString &GetValueFormatted() const;
92   lldb::SBValue &GetValue();
93   const lldb::SBValue &GetValue() const;
94   varType_e GetType() const;
95   bool SetVarFormat(const varFormat_e veVarFormat);
96   const CMIUtilString &GetVarParentName() const;
97   void UpdateValue();
98
99   // Overridden:
100 public:
101   // From CMICmnBase
102   /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj();
103
104   // Typedefs:
105 private:
106   typedef std::map<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj>
107       MapKeyToVarObj_t;
108   typedef std::pair<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj>
109       MapPairKeyToVarObj_t;
110
111   // Statics:
112 private:
113   static CMIUtilString GetStringFormatted(const MIuint64 vnValue,
114                                           const char *vpStrValueNatural,
115                                           varFormat_e veVarFormat);
116
117   // Methods:
118 private:
119   bool CopyOther(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
120   bool MoveOther(CMICmnLLDBDebugSessionInfoVarObj &vrwOther);
121
122   // Attributes:
123 private:
124   static const char *ms_aVarFormatStrings[];
125   static const char *ms_aVarFormatChars[];
126   static MapKeyToVarObj_t ms_mapVarIdToVarObj;
127   static MIuint ms_nVarUniqueId;
128   static varFormat_e ms_eDefaultFormat; // overrides "natural" format
129   //
130   // *** Update the copy move constructors and assignment operator ***
131   varFormat_e m_eVarFormat;
132   varType_e m_eVarType;
133   CMIUtilString m_strName;
134   lldb::SBValue m_SBValue;
135   CMIUtilString m_strNameReal;
136   CMIUtilString m_strFormattedValue;
137   CMIUtilString m_strVarObjParentName;
138   // *** Update the copy move constructors and assignment operator ***
139 };