Symbol.h revision 01e6a58b057676d5dc434876dbb2d54871bb962e
1cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke//===-- Symbol.h ------------------------------------------------*- C++ -*-===// 27a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// 37a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// The LLVM Compiler Infrastructure 47a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// 57a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// This file is distributed under the University of Illinois Open Source 67a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// License. See LICENSE.TXT for details. 77a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell// 87a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell//===----------------------------------------------------------------------===// 97a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 107a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#ifndef liblldb_Symbol_h_ 117a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#define liblldb_Symbol_h_ 127a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 137a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#include "lldb/lldb-private.h" 147a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#include "lldb/Core/AddressRange.h" 157a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#include "lldb/Core/Mangled.h" 167a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#include "lldb/Core/UserID.h" 177a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell#include "lldb/Symbol/SymbolContextScope.h" 180c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaeke 190c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaekenamespace lldb_private { 200c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaeke 21cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaekeclass Symbol : 22cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke public SymbolContextScope 23cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke{ 24cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaekepublic: 25cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke // ObjectFile readers can classify their symbol table entries and searches can be made 26cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke // on specific types where the symbol values will have drastically different meanings 270c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaeke // and sorting requirements. 280c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaeke Symbol(); 290c803894985f80e894b36ad4de58ea4c2e906b07Brian Gaeke 307a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell Symbol (uint32_t symID, 317a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const char *name, 327a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool name_is_mangled, 337a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell lldb::SymbolType type, 347a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool external, 357a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool is_debug, 367a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool is_trampoline, 377a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool is_artificial, 387a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const lldb::SectionSP §ion_sp, 397a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell lldb::addr_t value, 407a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t size, 417a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t flags); 42cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 43cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke Symbol (uint32_t symID, 44cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke const char *name, 457a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool name_is_mangled, 467a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell lldb::SymbolType type, 477a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool external, 4802cef96a2855b1b01b81d4b3429ed5cd707dd899Brian Gaeke bool is_debug, 4902cef96a2855b1b01b81d4b3429ed5cd707dd899Brian Gaeke bool is_trampoline, 5002cef96a2855b1b01b81d4b3429ed5cd707dd899Brian Gaeke bool is_artificial, 517a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const AddressRange &range, 527a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t flags); 537a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 547a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell Symbol (const Symbol& rhs); 557a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 567a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const Symbol& 57cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke operator= (const Symbol& rhs); 58cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 59cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke void 60ff336a4e7f9a71834bb60a540a14dd023e7cbcfdBrian Gaeke Clear(); 61ff336a4e7f9a71834bb60a540a14dd023e7cbcfdBrian Gaeke 62ff336a4e7f9a71834bb60a540a14dd023e7cbcfdBrian Gaeke bool 63ff336a4e7f9a71834bb60a540a14dd023e7cbcfdBrian Gaeke Compare (const ConstString& name, lldb::SymbolType type) const; 64cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 65cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke void 66cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke Dump (Stream *s, Target *target, uint32_t index) const; 677a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 687a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool 697a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell ValueIsAddress() const; 707a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 717a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell //------------------------------------------------------------------ 727a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell // Access the address value. Do NOT hand out the AddressRange as an 737a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell // object as the byte size of the address range may not be filled in 747a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell // and it should be accessed via GetByteSize(). 757a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell //------------------------------------------------------------------ 76cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke Address & 77cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke GetAddress() 78cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke { 79cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke return m_addr_range.GetBaseAddress(); 80cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke } 81cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 82cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke //------------------------------------------------------------------ 83cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke // Access the address value. Do NOT hand out the AddressRange as an 84cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke // object as the byte size of the address range may not be filled in 85cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke // and it should be accessed via GetByteSize(). 869058349aa431ef4cbdea51d30302f88105f61b76Brian Gaeke //------------------------------------------------------------------ 879058349aa431ef4cbdea51d30302f88105f61b76Brian Gaeke const Address & 889058349aa431ef4cbdea51d30302f88105f61b76Brian Gaeke GetAddress() const 897a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 907a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_addr_range.GetBaseAddress(); 917a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 927a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 937a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const ConstString & 947a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetName () const 957a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 967a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_mangled.GetName(); 977a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 987a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 997a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t 1007a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetID() const 1017a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1027a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_uid; 1037a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 104cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 105cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke void 106cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke SetID(uint32_t uid) 107cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke { 108cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke m_uid = uid; 109cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke } 110cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke 111cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke Mangled& 112cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke GetMangled () 113cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke { 114cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke return m_mangled; 115cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke } 1167a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1177a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const Mangled& 1187a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetMangled () const 1197a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1207a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_mangled; 1217a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1227a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1237a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t 1247a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetSiblingIndex () const; 1257a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1267a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell lldb::SymbolType 1277a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetType () const 128cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke { 129cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke return (lldb::SymbolType)m_type; 130cbeedf73d403ca0b65b3d4151b5630c5e335055bBrian Gaeke } 1317a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1327a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell void 1337a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell SetType (lldb::SymbolType type) 1347a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1357a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell m_type = (lldb::SymbolType)type; 1367a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1377a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1387a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell const char * 1397a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetTypeAsString () const; 1407a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1417a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell uint32_t 1427a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetFlags () const 1437a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1447a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_flags; 1457a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1467a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1477a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell void 1487a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell SetFlags (uint32_t flags) 1497a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1507a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell m_flags = flags; 1517a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 152554831c479f75bd6f116045ebc78aad4797715cfBrian Gaeke 153554831c479f75bd6f116045ebc78aad4797715cfBrian Gaeke void 154554831c479f75bd6f116045ebc78aad4797715cfBrian Gaeke GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const; 1557a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1567a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool 1577a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell IsSynthetic () const 1587a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1597a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_is_synthetic; 1607a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1617a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1627a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell void 1637a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell SetIsSynthetic (bool b) 1647a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1657a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell m_is_synthetic = b; 1667a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1677a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1687a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1697a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell bool 1707a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell GetSizeIsSynthesized() const 1717a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1727a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell return m_size_is_synthesized; 1737a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1747a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 1757a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell void 1767a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell SetSizeIsSynthesized(bool b) 1777a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell { 1787a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell m_size_is_synthesized = b; 1797a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell } 1807a73b80b9052136c8cd2234eb3433a07df7cf38eJohn Criswell 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_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