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