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