Value.h revision 462d4147f3bb9141bf62d904f58a623db00669df
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 eContextTypeOpaqueClangQualType,// void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)") 48 eContextTypeDCRegisterInfo, // lldb::RegisterInfo * 49 eContextTypeDCType, // Type * 50 eContextTypeDCVariable, // Variable * 51 eContextTypeValue // Value * (making this a proxy value. Used when putting locals on the DWARF expression parser stack) 52 }; 53 54 Value(); 55 Value(const Scalar& scalar); 56 Value(int v); 57 Value(unsigned int v); 58 Value(long v); 59 Value(unsigned long v); 60 Value(long long v); 61 Value(unsigned long long v); 62 Value(float v); 63 Value(double v); 64 Value(long double v); 65 Value(const uint8_t *bytes, int len); 66 Value(const Value &v); 67 68 Value * 69 CreateProxy(); 70 71 Value * 72 GetProxyTarget(); 73 74 void * 75 GetClangType(); 76 77 ValueType 78 GetValueType() const; 79 80 lldb::AddressType 81 GetValueAddressType () const; 82 83 ContextType 84 GetContextType() const; 85 86 void 87 SetValueType (ValueType value_type); 88 89 void 90 ClearContext (); 91 92 void 93 SetContext (ContextType context_type, void *p); 94 95 lldb::RegisterInfo * 96 GetRegisterInfo(); 97 98 Type * 99 GetType(); 100 101 Scalar & 102 ResolveValue (ExecutionContext *exe_ctx, clang::ASTContext *ast_context); 103 104 Scalar & 105 GetScalar(); 106 107 void 108 ResizeData(int len); 109 110 bool 111 ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context); 112 113 Variable * 114 GetVariable(); 115 116 void 117 Dump (Stream* strm); 118 119 lldb::Format 120 GetValueDefaultFormat (); 121 122 size_t 123 GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr); 124 125 Error 126 GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context, DataExtractor &data, uint32_t data_offset); 127 128 static const char * 129 GetValueTypeAsCString (ValueType context_type); 130 131 static const char * 132 GetContextTypeAsCString (ContextType context_type); 133 134protected: 135 Scalar m_value; 136 ValueType m_value_type; 137 void * m_context; 138 ContextType m_context_type; 139 DataBufferHeap m_data_buffer; 140}; 141 142class ValueList 143{ 144public: 145 ValueList () {} 146 ValueList (const ValueList &rhs); 147 148 ~ValueList () {} 149 150 const ValueList & operator= (const ValueList &rhs); 151 152 // void InsertValue (Value *value, size_t idx); 153 void PushValue (const Value &value); 154 155 size_t GetSize (); 156 Value *GetValueAtIndex(size_t idx); 157 void Clear(); 158 159protected: 160 161private: 162 typedef std::vector<Value> collection; 163 164 collection m_values; 165}; 166 167} // namespace lldb_private 168 169#endif // liblldb_Value_h_ 170