1 //===-- MICmnLLDBDebugSessionInfoVarObj.h -----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
11 // Third Party Headers:
12 #include "lldb/API/SBValue.h"
16 #include "MIUtilString.h"
19 //============================================================================
20 // Details: MI debug session variable object. The static functionality in *this
21 // class manages a map container of *these variable objects.
23 class CMICmnLLDBDebugSessionInfoVarObj {
26 //++ ----------------------------------------------------------------------
27 // Details: Enumeration of a variable type that is not a composite type
30 // CODETAG_SESSIONINFO_VARFORMAT_ENUM
31 // *** Order is import here ***
32 eVarFormat_Invalid = 0,
38 eVarFormat_count // Always last one
41 //++ ----------------------------------------------------------------------
42 // Details: Enumeration of a variable type by composite or internal type
46 eVarType_Composite, // i.e. struct
47 eVarType_Internal, // i.e. int
48 eVarType_count // Always last one
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);
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);
84 CMICmnLLDBDebugSessionInfoVarObj &
85 operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
86 CMICmnLLDBDebugSessionInfoVarObj &
87 operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther);
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;
102 /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj();
106 typedef std::map<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj>
108 typedef std::pair<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj>
109 MapPairKeyToVarObj_t;
113 static CMIUtilString GetStringFormatted(const MIuint64 vnValue,
114 const char *vpStrValueNatural,
115 varFormat_e veVarFormat);
119 bool CopyOther(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
120 bool MoveOther(CMICmnLLDBDebugSessionInfoVarObj &vrwOther);
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
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 ***