Value.h revision 2bc9eb3ba78efc64a273729b480bafc3bbaa433a
1//===-- Value.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#ifndef liblldb_Value_h_ 11#define liblldb_Value_h_ 12 13// C Includes 14// C++ Includes 15#include <vector> 16// Other libraries and framework includes 17// Project includes 18#include "lldb/lldb-private.h" 19#include "lldb/Core/ClangForward.h" 20#include "lldb/Core/DataBufferHeap.h" 21#include "lldb/Core/Error.h" 22#include "lldb/Core/Scalar.h" 23 24namespace lldb_private { 25 26class Value 27{ 28public: 29 30 // Values Less than zero are an error, greater than or equal to zero 31 // returns what the Scalar result is. 32 enum ValueType 33 { 34 // m_value contains... 35 // ============================ 36 eValueTypeScalar, // raw scalar value 37 eValueTypeFileAddress, // file address value 38 eValueTypeLoadAddress, // load address value 39 eValueTypeHostAddress // host address value (for memory in the process that is using liblldb) 40 }; 41 42 enum ContextType // Type that describes Value::m_context 43 { 44 // m_context contains... 45 // ==================== 46 eContextTypeInvalid, // undefined 47 eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)") 48 eContextTypeRegisterInfo, // RegisterInfo * 49 eContextTypeLLDBType, // lldb_private::Type * 50 eContextTypeVariable // lldb_private::Variable * 51 }; 52 53 Value(); 54 Value(const Scalar& scalar); 55 Value(const uint8_t *bytes, int len); 56 Value(const Value &rhs); 57 58 Value & 59 operator=(const Value &rhs); 60 61 lldb::clang_type_t 62 GetClangType(); 63 64 ValueType 65 GetValueType() const; 66 67 AddressType 68 GetValueAddressType () const; 69 70 ContextType 71 GetContextType() const 72 { 73 return m_context_type; 74 } 75 76 void 77 SetValueType (ValueType value_type) 78 { 79 m_value_type = value_type; 80 } 81 82 void 83 ClearContext () 84 { 85 m_context = NULL; 86 m_context_type = eContextTypeInvalid; 87 } 88 89 void 90 SetContext (ContextType context_type, void *p) 91 { 92 m_context_type = context_type; 93 m_context = p; 94 } 95 96 RegisterInfo * 97 GetRegisterInfo(); 98 99 Type * 100 GetType(); 101 102 Scalar & 103 ResolveValue (ExecutionContext *exe_ctx, clang::ASTContext *ast_context); 104 105 Scalar & 106 GetScalar() 107 { 108 return m_value; 109 } 110 111 void 112 ResizeData(int len); 113 114 bool 115 ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context); 116 117 Variable * 118 GetVariable(); 119 120 void 121 Dump (Stream* strm); 122 123 lldb::Format 124 GetValueDefaultFormat (); 125 126 size_t 127 GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr); 128 129 Error 130 GetValueAsData (ExecutionContext *exe_ctx, 131 clang::ASTContext *ast_context, 132 DataExtractor &data, 133 uint32_t data_offset, 134 Module *module); // Can be NULL 135 136 static const char * 137 GetValueTypeAsCString (ValueType context_type); 138 139 static const char * 140 GetContextTypeAsCString (ContextType context_type); 141 142 bool 143 GetData (DataExtractor &data); 144 145protected: 146 Scalar m_value; 147 ValueType m_value_type; 148 void * m_context; 149 ContextType m_context_type; 150 DataBufferHeap m_data_buffer; 151}; 152 153class ValueList 154{ 155public: 156 ValueList () : 157 m_values() 158 { 159 } 160 161 ValueList (const ValueList &rhs); 162 163 ~ValueList () 164 { 165 } 166 167 const ValueList & operator= (const ValueList &rhs); 168 169 // void InsertValue (Value *value, size_t idx); 170 void PushValue (const Value &value); 171 172 size_t GetSize (); 173 Value *GetValueAtIndex(size_t idx); 174 void Clear(); 175 176protected: 177 178private: 179 typedef std::vector<Value> collection; 180 181 collection m_values; 182}; 183 184} // namespace lldb_private 185 186#endif // liblldb_Value_h_ 187