Symtab.h revision 020f353bf792f1028e4037ea92d03acc90594c40
1//===-- Symtab.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 11#ifndef liblldb_Symtab_h_ 12#define liblldb_Symtab_h_ 13 14#include <vector> 15 16#include "lldb/lldb-private.h" 17#include "lldb/Core/UniqueCStringMap.h" 18#include "lldb/Symbol/Symbol.h" 19 20namespace lldb_private { 21 22class Symtab 23{ 24public: 25 Symtab(ObjectFile *objfile); 26 ~Symtab(); 27 28 void Reserve (uint32_t count); 29 Symbol * Resize (uint32_t count); 30 uint32_t AddSymbol(const Symbol& symbol); 31 size_t GetNumSymbols() const; 32 void Dump(Stream *s, Process *process) const; 33 void Dump(Stream *s, Process *process, std::vector<uint32_t>& indexes) const; 34 35 Symbol * SymbolAtIndex (uint32_t idx); 36 const Symbol * SymbolAtIndex (uint32_t idx) const; 37 Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx); 38 const Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx) const; 39 uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector<uint32_t>& matches, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; 40 uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector<uint32_t>& matches); 41 uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, std::vector<uint32_t>& matches); 42 uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes); 43 size_t FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes); 44 size_t FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes); 45 Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); 46 Symbol * FindSymbolWithFileAddress (lldb::addr_t file_addr); 47// Symbol * FindSymbolContainingAddress (const Address& value, const uint32_t* indexes, uint32_t num_indexes); 48// Symbol * FindSymbolContainingAddress (const Address& value); 49 Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes); 50 Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr); 51 size_t CalculateSymbolSize (Symbol *symbol); 52 53 void SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const; 54 55 static void DumpSymbolHeader (Stream *s); 56 57protected: 58 typedef std::vector<Symbol> collection; 59 typedef collection::iterator iterator; 60 typedef collection::const_iterator const_iterator; 61 62 static int CompareSymbolValueByIndex (void *thunk, const void *a, const void *b); 63 static int CompareSymbolValueByIndexLinux (const void *a, const void *b, void *thunk); 64 void InitNameIndexes (); 65 void InitAddressIndexes (); 66 67 ObjectFile * m_objfile; 68 collection m_symbols; 69 std::vector<uint32_t> m_addr_indexes; 70 UniqueCStringMap<uint32_t> m_name_to_index; 71 72private: 73 DISALLOW_COPY_AND_ASSIGN (Symtab); 74}; 75 76} // namespace lldb_private 77 78#endif // liblldb_Symtab_h_ 79