Symbol.h revision 36da2aa6dc5ad9994b638ed09eb81c44cc05540b
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 lldb::addr_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 () const 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 (lldb::addr_t size) 213 { 214 m_calculated_size = size > 0; 215 m_addr_range.SetByteSize(size); 216 } 217 218 bool 219 GetSizeIsSibling () const 220 { 221 return m_size_is_sibling; 222 } 223 224 void 225 SetSizeIsSibling (bool b) 226 { 227 m_size_is_sibling = b; 228 } 229 230// void 231// SetValue (Address &value) 232// { 233// m_addr_range.GetBaseAddress() = value; 234// } 235// 236// void 237// SetValue (const AddressRange &range) 238// { 239// m_addr_range = range; 240// } 241// 242// void 243// SetValue (lldb::addr_t value); 244// { 245// m_addr_range.GetBaseAddress().SetRawAddress(value); 246// } 247 248 // If m_type is "Code" or "Function" then this will return the prologue size 249 // in bytes, else it will return zero. 250 uint32_t 251 GetPrologueByteSize (); 252 253 bool 254 GetDemangledNameIsSynthesized() const 255 { 256 return m_demangled_is_synthesized; 257 } 258 void 259 SetDemangledNameIsSynthesized(bool b) 260 { 261 m_demangled_is_synthesized = b; 262 } 263 264 //------------------------------------------------------------------ 265 /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) 266 /// 267 /// @see SymbolContextScope 268 //------------------------------------------------------------------ 269 virtual void 270 CalculateSymbolContext (SymbolContext *sc); 271 272 virtual lldb::ModuleSP 273 CalculateSymbolContextModule (); 274 275 virtual Symbol * 276 CalculateSymbolContextSymbol (); 277 278 //------------------------------------------------------------------ 279 /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) 280 /// 281 /// @see SymbolContextScope 282 //------------------------------------------------------------------ 283 virtual void 284 DumpSymbolContext (Stream *s); 285 286protected: 287 288 uint32_t m_uid; // User ID (usually the original symbol table index) 289 Mangled m_mangled; // uniqued symbol name/mangled name pair 290 uint16_t m_type_data; // data specific to m_type 291 uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated 292 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. 293 m_is_debug:1, // non-zero if this symbol is debug information in a symbol 294 m_is_external:1, // non-zero if this symbol is globally visible 295 m_size_is_sibling:1, // m_size contains the index of this symbol's sibling 296 m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next 297 m_calculated_size:1, 298 m_demangled_is_synthesized:1, // The demangled name was created should not be used for expressions or other lookups 299 m_type:8; 300 uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these 301 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) 302}; 303 304} // namespace lldb_private 305 306#endif // liblldb_Symbol_h_ 307