Symbol.h revision 12bec71b323dc520f0e985a86e09c4712559e115
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 18namespace lldb_private { 19 20class Symbol : 21 public UserID // Used to uniquely identify this symbol in its symbol table 22{ 23public: 24 // ObjectFile readers can classify their symbol table entries and searches can be made 25 // on specific types where the symbol values will have drastically different meanings 26 // and sorting requirements. 27 Symbol(); 28 29 Symbol (lldb::user_id_t symID, 30 const char *name, 31 bool name_is_mangled, 32 lldb::SymbolType type, 33 bool external, 34 bool is_debug, 35 bool is_trampoline, 36 bool is_artificial, 37 const Section* section, 38 lldb::addr_t value, 39 uint32_t size, 40 uint32_t flags); 41 42 Symbol (lldb::user_id_t symID, 43 const char *name, 44 bool name_is_mangled, 45 lldb::SymbolType type, 46 bool external, 47 bool is_debug, 48 bool is_trampoline, 49 bool is_artificial, 50 const AddressRange &range, 51 uint32_t flags); 52 53 Symbol (const Symbol& rhs); 54 55 const Symbol& 56 operator= (const Symbol& rhs); 57 58 bool 59 Compare (const ConstString& name, lldb::SymbolType type) const; 60 61 void 62 Dump (Stream *s, Process *process, uint32_t index) const; 63 64 AddressRange * 65 GetAddressRangePtr (); 66 67 const AddressRange * 68 GetAddressRangePtr () const; 69 70 AddressRange & 71 GetAddressRangeRef() { return m_addr_range; } 72 73 const AddressRange & 74 GetAddressRangeRef() const { return m_addr_range; } 75 76 Mangled& 77 GetMangled () { return m_mangled; } 78 79 const Mangled& 80 GetMangled () const { return m_mangled; } 81 82 bool 83 GetSizeIsSibling () const { return m_size_is_sibling; } 84 85 bool 86 GetSizeIsSynthesized() const { return m_size_is_synthesized; } 87 88 uint32_t 89 GetSiblingIndex () const; 90 91 uint32_t 92 GetByteSize () const { return m_addr_range.GetByteSize(); } 93 94 lldb::SymbolType 95 GetType () const { return m_type; } 96 97 void 98 SetType (lldb::SymbolType type) { m_type = type; } 99 100 const char * 101 GetTypeAsString () const; 102 103 uint32_t 104 GetFlags () const { return m_flags; } 105 106 void 107 SetFlags (uint32_t flags) { m_flags = flags; } 108 109 void 110 GetDescription (Stream *s, lldb::DescriptionLevel level, Process *process) const; 111 112 Function * 113 GetFunction (); 114 115 Address & 116 GetValue () { return m_addr_range.GetBaseAddress(); } 117 118 const Address & 119 GetValue () const { return m_addr_range.GetBaseAddress(); } 120 121 bool 122 IsSynthetic () const { return m_is_synthetic; } 123 124 void 125 SetIsSynthetic (bool b) { m_is_synthetic = b; } 126 127 void 128 SetSizeIsSynthesized(bool b) { m_size_is_synthesized = b; } 129 130 bool 131 IsDebug () const { return m_is_debug; } 132 133 void 134 SetDebug (bool b) { m_is_debug = b; } 135 136 bool 137 IsExternal () const { return m_is_external; } 138 139 void 140 SetExternal (bool b) { m_is_external = b; } 141 142 bool 143 IsTrampoline () const; 144 145 void 146 SetByteSize (uint32_t size) { m_addr_range.SetByteSize(size); } 147 148 void 149 SetSizeIsSibling (bool b) { m_size_is_sibling = b; } 150 151 void 152 SetValue (Address &value) { m_addr_range.GetBaseAddress() = value; } 153 154 void 155 SetValue (const AddressRange &range) { m_addr_range = range; } 156 157 void 158 SetValue (lldb::addr_t value); 159 160 // If m_type is "Code" or "Function" then this will return the prologue size 161 // in bytes, else it will return zero. 162 uint32_t 163 GetPrologueByteSize (); 164 165protected: 166 167 Mangled m_mangled; // uniqued symbol name/mangled name pair 168 lldb::SymbolType m_type; // symbol type 169 uint16_t m_type_data; // data specific to m_type 170 uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated 171 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. 172 m_is_debug:1, // non-zero if this symbol is debug information in a symbol 173 m_is_external:1, // non-zero if this symbol is globally visible 174 m_size_is_sibling:1, // m_size contains the index of this symbol's sibling 175 m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next 176 m_searched_for_function:1;// non-zero if we have looked for the function associated with this symbol already. 177 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) 178 uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these 179 Function * m_function; 180}; 181 182} // namespace lldb_private 183 184#endif // liblldb_Symbol_h_ 185