summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
blob: c4ae8e8e44b3ec89ab1192c533121c4e244efc12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//===-- MICmnLLDBDebugSessionInfoVarObj.h -----------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#pragma once

// Third Party Headers:
#include <map>
#include "lldb/API/SBValue.h"

// In-house headers:
#include "MIUtilString.h"

//++ ============================================================================
// Details: MI debug session variable object. The static functionality in *this
//          class manages a map container of *these variable objects.
//--
class CMICmnLLDBDebugSessionInfoVarObj
{
    // Enums:
  public:
    //++ ----------------------------------------------------------------------
    // Details: Enumeration of a variable type that is not a composite type
    //--
    enum varFormat_e
    {
        // CODETAG_SESSIONINFO_VARFORMAT_ENUM
        // *** Order is import here ***
        eVarFormat_Invalid = 0,
        eVarFormat_Binary,
        eVarFormat_Octal,
        eVarFormat_Decimal,
        eVarFormat_Hex,
        eVarFormat_Natural,
        eVarFormat_count // Always last one
    };

    //++ ----------------------------------------------------------------------
    // Details: Enumeration of a variable type by composite or internal type
    //--
    enum varType_e
    {
        eVarType_InValid = 0,
        eVarType_Composite, // i.e. struct
        eVarType_Internal,  // i.e. int
        eVarType_count      // Always last one
    };

    // Statics:
  public:
    static varFormat_e GetVarFormatForString(const CMIUtilString &vrStrFormat);
    static varFormat_e GetVarFormatForChar(char vcFormat);
    static CMIUtilString GetValueStringFormatted(const lldb::SBValue &vrValue, const varFormat_e veVarFormat);
    static void VarObjAdd(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj);
    static void VarObjDelete(const CMIUtilString &vrVarName);
    static bool VarObjGet(const CMIUtilString &vrVarName, CMICmnLLDBDebugSessionInfoVarObj &vrwVarObj);
    static void VarObjUpdate(const CMICmnLLDBDebugSessionInfoVarObj &vrVarObj);
    static void VarObjIdInc();
    static MIuint VarObjIdGet();
    static void VarObjIdResetToZero();
    static void VarObjClear();
    static void VarObjSetFormat(varFormat_e eDefaultFormat);

    // Methods:
  public:
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj();
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
                                                const lldb::SBValue &vrValue);
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMIUtilString &vrStrNameReal, const CMIUtilString &vrStrName,
                                                const lldb::SBValue &vrValue, const CMIUtilString &vrStrVarObjParentName);
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(CMICmnLLDBDebugSessionInfoVarObj &vrOther);
    /* ctor */ CMICmnLLDBDebugSessionInfoVarObj(CMICmnLLDBDebugSessionInfoVarObj &&vrOther);
    //
    CMICmnLLDBDebugSessionInfoVarObj &operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
    CMICmnLLDBDebugSessionInfoVarObj &operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther);
    //
    const CMIUtilString &GetName() const;
    const CMIUtilString &GetNameReal() const;
    const CMIUtilString &GetValueFormatted() const;
    lldb::SBValue &GetValue();
    const lldb::SBValue &GetValue() const;
    varType_e GetType() const;
    bool SetVarFormat(const varFormat_e veVarFormat);
    const CMIUtilString &GetVarParentName() const;
    void UpdateValue();

    // Overridden:
  public:
    // From CMICmnBase
    /* dtor */ virtual ~CMICmnLLDBDebugSessionInfoVarObj();

    // Typedefs:
  private:
    typedef std::map<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj> MapKeyToVarObj_t;
    typedef std::pair<CMIUtilString, CMICmnLLDBDebugSessionInfoVarObj> MapPairKeyToVarObj_t;

    // Statics:
  private:
    static CMIUtilString GetStringFormatted(const MIuint64 vnValue, const char *vpStrValueNatural, varFormat_e veVarFormat);

    // Methods:
  private:
    bool CopyOther(const CMICmnLLDBDebugSessionInfoVarObj &vrOther);
    bool MoveOther(CMICmnLLDBDebugSessionInfoVarObj &vrwOther);

    // Attributes:
  private:
    static const char *ms_aVarFormatStrings[];
    static const char *ms_aVarFormatChars[];
    static MapKeyToVarObj_t ms_mapVarIdToVarObj;
    static MIuint ms_nVarUniqueId;
    static varFormat_e ms_eDefaultFormat;    // overrides "natural" format
    //
    // *** Update the copy move constructors and assignment operator ***
    varFormat_e m_eVarFormat;
    varType_e m_eVarType;
    CMIUtilString m_strName;
    lldb::SBValue m_SBValue;
    CMIUtilString m_strNameReal;
    CMIUtilString m_strFormattedValue;
    CMIUtilString m_strVarObjParentName;
    // *** Update the copy move constructors and assignment operator ***
};
OpenPOWER on IntegriCloud