Symbol.h revision 0c31d3d3a4a1d00d53346d8a23b0519f47e55d1f
1//===-- Symbol.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_Symbol_h_ 11#define liblldb_Symbol_h_ 12 13#include "lldb/lldb-private.h" 14#include "lldb/Core/AddressRange.h" 15#include "lldb/Core/Mangled.h" 16#include "lldb/Core/UserID.h" 17#include "lldb/Symbol/SymbolContextScope.h" 18 19namespace lldb_private { 20 21class Symbol : 22 public SymbolContextScope 23{ 24public: 25 // ObjectFile readers can classify their symbol table entries and searches can be made 26 // on specific types where the symbol values will have drastically different meanings 27 // and sorting requirements. 28 Symbol(); 29 30 Symbol (uint32_t symID, 31 const char *name, 32 bool name_is_mangled, 33 lldb::SymbolType type, 34 bool external, 35 bool is_debug, 36 bool is_trampoline, 37 bool is_artificial, 38 const lldb::SectionSP §ion_sp, 39 lldb::addr_t value, 40 uint32_t size, 41 uint32_t flags); 42 43 Symbol (uint32_t symID, 44 const char *name, 45 bool name_is_mangled, 46 lldb::SymbolType type, 47 bool external, 48 bool is_debug, 49 bool is_trampoline, 50 bool is_artificial, 51 const AddressRange &range, 52 uint32_t flags); 53 54 Symbol (const Symbol& rhs); 55 56 const Symbol& 57 operator= (const Symbol& rhs); 58 59 void 60 Clear(); 61 62 bool 63 Compare (const ConstString& name, lldb::SymbolType type) const; 64 65 void 66 Dump (Stream *s, Target *target, uint32_t index) const; 67 68 bool 69 ValueIsAddress() const; 70 71 //------------------------------------------------------------------ 72 // Access the address value. Do NOT hand out the AddressRange as an 73 // object as the byte size of the address range may not be filled in 74 // and it should be accessed via GetByteSize(). 75 //------------------------------------------------------------------ 76 Address & 77 GetAddress() 78 { 79 return m_addr_range.GetBaseAddress(); 80 } 81 82 //------------------------------------------------------------------ 83 // Access the address value. Do NOT hand out the AddressRange as an 84 // object as the byte size of the address range may not be filled in 85 // and it should be accessed via GetByteSize(). 86 //------------------------------------------------------------------ 87 const Address & 88 GetAddress() const 89 { 90 return m_addr_range.GetBaseAddress(); 91 } 92 93 const ConstString & 94 GetName () 95 { 96 return m_mangled.GetName(); 97 } 98 99 uint32_t 100 GetID() const 101 { 102 return m_uid; 103 } 104 105 void 106 SetID(uint32_t uid) 107 { 108 m_uid = uid; 109 } 110 111 Mangled& 112 GetMangled () 113 { 114 return m_mangled; 115 } 116 117 const Mangled& 118 GetMangled () const 119 { 120 return m_mangled; 121 } 122 123 uint32_t 124 GetSiblingIndex () const; 125 126 lldb::SymbolType 127 GetType () const 128 { 129 return (lldb::SymbolType)m_type; 130 } 131 132 void 133 SetType (lldb::SymbolType type) 134 { 135 m_type = (lldb::SymbolType)type; 136 } 137 138 const char * 139 GetTypeAsString () const; 140 141 uint32_t 142 GetFlags () const 143 { 144 return m_flags; 145 } 146 147 void 148 SetFlags (uint32_t flags) 149 { 150 m_flags = flags; 151 } 152 153 void 154 GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const; 155 156 bool 157 IsSynthetic () const 158 { 159 return m_is_synthetic; 160 } 161 162 void 163 SetIsSynthetic (bool b) 164 { 165 m_is_synthetic = b; 166 } 167 168 169 bool 170 GetSizeIsSynthesized() const 171 { 172 return m_size_is_synthesized; 173 } 174 175 void 176 SetSizeIsSynthesized(bool b) 177 { 178 m_size_is_synthesized = b; 179 } 180 181 bool 182 IsDebug () const 183 { 184 return m_is_debug; 185 } 186 187 void 188 SetDebug (bool b) 189 { 190 m_is_debug = b; 191 } 192 193 bool 194 IsExternal () const 195 { 196 return m_is_external; 197 } 198 199 void 200 SetExternal (bool b) 201 { 202 m_is_external = b; 203 } 204 205 bool 206 IsTrampoline () const; 207 208 lldb::addr_t 209 GetByteSize () const; 210 211 void 212 SetByteSize (uint32_t size) 213 { 214 m_addr_range.SetByteSize(size); 215 } 216 217 bool 218 GetSizeIsSibling () const 219 { 220 return m_size_is_sibling; 221 } 222 223 void 224 SetSizeIsSibling (bool b) 225 { 226 m_size_is_sibling = b; 227 } 228 229// void 230// SetValue (Address &value) 231// { 232// m_addr_range.GetBaseAddress() = value; 233// } 234// 235// void 236// SetValue (const AddressRange &range) 237// { 238// m_addr_range = range; 239// } 240// 241// void 242// SetValue (lldb::addr_t value); 243// { 244// m_addr_range.GetBaseAddress().SetRawAddress(value); 245// } 246 247 // If m_type is "Code" or "Function" then this will return the prologue size 248 // in bytes, else it will return zero. 249 uint32_t 250 GetPrologueByteSize (); 251 252 //------------------------------------------------------------------ 253 /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) 254 /// 255 /// @see SymbolContextScope 256 //------------------------------------------------------------------ 257 virtual void 258 CalculateSymbolContext (SymbolContext *sc); 259 260 virtual lldb::ModuleSP 261 CalculateSymbolContextModule (); 262 263 virtual Symbol * 264 CalculateSymbolContextSymbol (); 265 266 //------------------------------------------------------------------ 267 /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) 268 /// 269 /// @see SymbolContextScope 270 //------------------------------------------------------------------ 271 virtual void 272 DumpSymbolContext (Stream *s); 273 274protected: 275 276 uint32_t m_uid; // User ID (usually the original symbol table index) 277 Mangled m_mangled; // uniqued symbol name/mangled name pair 278 uint16_t m_type_data; // data specific to m_type 279 uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated 280 m_is_synthetic:1, // non-zero if this symbol is not actually in the symbol table, but synthesized from other info in the object file. 281 m_is_debug:1, // non-zero if this symbol is debug information in a symbol 282 m_is_external:1, // non-zero if this symbol is globally visible 283 m_size_is_sibling:1, // m_size contains the index of this symbol's sibling 284 m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next 285 m_calculated_size:1, 286 m_type:8; 287 uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these 288 AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any) 289}; 290 291} // namespace lldb_private 292 293#endif // liblldb_Symbol_h_ 294