diff options
Diffstat (limited to 'lldb/source/Symbol')
| -rw-r--r-- | lldb/source/Symbol/ObjectFile.cpp | 5 | ||||
| -rw-r--r-- | lldb/source/Symbol/Symbol.cpp | 61 | ||||
| -rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 17 | ||||
| -rw-r--r-- | lldb/source/Symbol/Symtab.cpp | 37 |
4 files changed, 42 insertions, 78 deletions
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 4f02a93de41..a45ef820f0e 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -266,10 +266,9 @@ ObjectFile::GetAddressClass (addr_t file_addr) Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr); if (symbol) { - const AddressRange *range_ptr = symbol->GetAddressRangePtr(); - if (range_ptr) + if (symbol->ValueIsAddress()) { - const SectionSP section_sp (range_ptr->GetBaseAddress().GetSection()); + const SectionSP section_sp (symbol->GetAddress().GetSection()); if (section_sp) { const SectionType section_type = section_sp->GetType(); diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 636670d994f..af7c2d4d527 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -158,28 +158,10 @@ Symbol::Clear() m_addr_range.Clear(); } -AddressRange * -Symbol::GetAddressRangePtr() +bool +Symbol::ValueIsAddress() const { - if (m_addr_range.GetBaseAddress().GetSection()) - { - if (!m_calculated_size) - GetByteSize(); - return &m_addr_range; - } - return NULL; -} - -const AddressRange * -Symbol::GetAddressRangePtr() const -{ - if (m_addr_range.GetBaseAddress().GetSection()) - { - if (!m_calculated_size) - GetByteSize(); - return &m_addr_range; - } - return NULL; + return m_addr_range.GetBaseAddress().GetSection().get() != NULL; } uint32_t @@ -245,8 +227,10 @@ Symbol::Dump(Stream *s, Target *target, uint32_t index) const m_is_external ? 'X' : ' ', GetTypeAsString()); - SectionSP section_sp (m_addr_range.GetBaseAddress().GetSection()); - if (section_sp) + // Make sure the size of the symbol is up to date before dumping + GetByteSize(); + + if (ValueIsAddress()) { if (!m_addr_range.GetBaseAddress().Dump(s, NULL, Address::DumpStyleFileAddress)) s->Printf("%*s", 18, ""); @@ -304,13 +288,6 @@ Symbol::GetPrologueByteSize () return 0; } -void -Symbol::SetValue(addr_t value) -{ - m_addr_range.GetBaseAddress().SetRawAddress(value); -} - - bool Symbol::Compare(const ConstString& name, SymbolType type) const { @@ -365,9 +342,8 @@ Symbol::CalculateSymbolContext (SymbolContext *sc) { // Symbols can reconstruct the symbol and the module in the symbol context sc->symbol = this; - const AddressRange *range = GetAddressRangePtr(); - if (range) - sc->module_sp = range->GetBaseAddress().GetModule(); + if (ValueIsAddress()) + sc->module_sp = GetAddress().GetModule(); else sc->module_sp.reset(); } @@ -375,9 +351,8 @@ Symbol::CalculateSymbolContext (SymbolContext *sc) ModuleSP Symbol::CalculateSymbolContextModule () { - const AddressRange *range = GetAddressRangePtr(); - if (range) - return range->GetBaseAddress().GetModule(); + if (ValueIsAddress()) + return GetAddress().GetModule(); return ModuleSP(); } @@ -392,10 +367,9 @@ void Symbol::DumpSymbolContext (Stream *s) { bool dumped_module = false; - const AddressRange *range = GetAddressRangePtr(); - if (range) - { - ModuleSP module_sp (range->GetBaseAddress().GetModule()); + if (ValueIsAddress()) + { + ModuleSP module_sp (GetAddress().GetModule()); if (module_sp) { dumped_module = true; @@ -416,10 +390,9 @@ Symbol::GetByteSize () const if (byte_size == 0 && !m_calculated_size) { const_cast<Symbol*>(this)->m_calculated_size = true; - const AddressRange *range = GetAddressRangePtr(); - if (range) + if (ValueIsAddress()) { - ModuleSP module_sp (range->GetBaseAddress().GetModule()); + ModuleSP module_sp (GetAddress().GetModule()); if (module_sp) { ObjectFile *objfile = module_sp->GetObjectFile(); @@ -428,7 +401,7 @@ Symbol::GetByteSize () const Symtab *symtab = objfile->GetSymtab(); if (symtab) { - const_cast<AddressRange &>(m_addr_range).SetByteSize(symtab->CalculateSymbolSize (const_cast<Symbol *>(this))); + const_cast<Symbol*>(this)->SetByteSize (symtab->CalculateSymbolSize (const_cast<Symbol *>(this))); byte_size = m_addr_range.GetByteSize(); } } diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 1c764e89ef5..3fff6fbc52c 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -206,9 +206,9 @@ SymbolContext::DumpStopContext symbol->GetMangled().GetName().Dump(s); } - if (addr.IsValid() && symbol->GetAddressRangePtr()) + if (addr.IsValid() && symbol->ValueIsAddress()) { - const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset(); + const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddress().GetOffset(); if (symbol_offset) { dumped_something = true; @@ -431,10 +431,10 @@ SymbolContext::GetAddressRange (uint32_t scope, { if (range_idx == 0) { - const AddressRange *range_ptr = symbol->GetAddressRangePtr(); - if (range_ptr) + if (symbol->ValueIsAddress()) { - range = *range_ptr; + range.GetBaseAddress() = symbol->GetAddress(); + range.SetByteSize (symbol->GetByteSize()); return true; } } @@ -551,7 +551,7 @@ SymbolContext::GetFunctionName (Mangled::NamePreference preference) } return function->GetMangled().GetName(preference); } - else if (symbol && symbol->GetAddressRangePtr()) + else if (symbol && symbol->ValueIsAddress()) { return symbol->GetMangled().GetName(preference); } @@ -934,14 +934,13 @@ SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_in && sc.block == NULL && sc.line_entry.IsValid() == false) { - const AddressRange *symbol_range = sc.symbol->GetAddressRangePtr(); - if (symbol_range) + if (sc.symbol->ValueIsAddress()) { for (pos = m_symbol_contexts.begin(); pos != end; ++pos) { if (pos->function) { - if (pos->function->GetAddressRange().GetBaseAddress() == symbol_range->GetBaseAddress()) + if (pos->function->GetAddressRange().GetBaseAddress() == sc.symbol->GetAddress()) { // Do we already have a function with this symbol? if (pos->symbol == sc.symbol) diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index ea4ff608cb5..dd2a04d1ab2 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -442,15 +442,8 @@ namespace { const std::vector<Symbol>& symbols; SymbolIndexComparator(const std::vector<Symbol>& s) : symbols(s) { } bool operator()(uint32_t index_a, uint32_t index_b) { - addr_t value_a; - addr_t value_b; - if (symbols[index_a].GetValue().GetSection() == symbols[index_b].GetValue().GetSection()) { - value_a = symbols[index_a].GetValue ().GetOffset(); - value_b = symbols[index_b].GetValue ().GetOffset(); - } else { - value_a = symbols[index_a].GetValue ().GetFileAddress(); - value_b = symbols[index_b].GetValue ().GetFileAddress(); - } + addr_t value_a = symbols[index_a].GetAddress().GetFileAddress(); + addr_t value_b = symbols[index_b].GetAddress().GetFileAddress(); if (value_a == value_b) { // The if the values are equal, use the original symbol user ID @@ -741,10 +734,9 @@ SymbolWithFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr) // lldb::Symbol::GetAddressRangePtr() will only return a non NULL address // range if the symbol has a section! - const AddressRange *curr_range = curr_symbol->GetAddressRangePtr(); - if (curr_range) + if (curr_symbol->ValueIsAddress()) { - const addr_t curr_file_addr = curr_range->GetBaseAddress().GetFileAddress(); + const addr_t curr_file_addr = curr_symbol->GetAddress().GetFileAddress(); if (info_file_addr < curr_file_addr) return -1; if (info_file_addr > curr_file_addr) @@ -765,10 +757,9 @@ SymbolWithClosestFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr) return -1; const addr_t info_file_addr = info->file_addr; - const AddressRange *curr_range = symbol->GetAddressRangePtr(); - if (curr_range) + if (symbol->ValueIsAddress()) { - const addr_t curr_file_addr = curr_range->GetBaseAddress().GetFileAddress(); + const addr_t curr_file_addr = symbol->GetAddress().GetFileAddress(); if (info_file_addr < curr_file_addr) return -1; @@ -819,7 +810,7 @@ Symtab::InitAddressIndexes() const_iterator end = m_symbols.end(); for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) { - if (pos->GetAddressRangePtr()) + if (pos->ValueIsAddress()) m_addr_indexes.push_back (std::distance(begin, pos)); } #endif @@ -851,15 +842,18 @@ Symtab::CalculateSymbolSize (Symbol *symbol) // Else if this is an address based symbol, figure out the delta between // it and the next address based symbol - if (symbol->GetAddressRangePtr()) + if (symbol->ValueIsAddress()) { if (!m_addr_indexes_computed) InitAddressIndexes(); const size_t num_addr_indexes = m_addr_indexes.size(); - SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress(this, symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(), &m_addr_indexes.front(), num_addr_indexes); + SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress (this, + symbol->GetAddress().GetFileAddress(), + &m_addr_indexes.front(), + num_addr_indexes); if (info.match_index_ptr != NULL) { - const lldb::addr_t curr_file_addr = symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(); + const lldb::addr_t curr_file_addr = symbol->GetAddress().GetFileAddress(); // We can figure out the address range of all symbols except the // last one by taking the delta between the current symbol and // the next symbol @@ -872,12 +866,11 @@ Symtab::CalculateSymbolSize (Symbol *symbol) if (next_symbol == NULL) break; - assert (next_symbol->GetAddressRangePtr()); - const lldb::addr_t next_file_addr = next_symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(); + const lldb::addr_t next_file_addr = next_symbol->GetAddress().GetFileAddress(); if (next_file_addr > curr_file_addr) { byte_size = next_file_addr - curr_file_addr; - symbol->GetAddressRangePtr()->SetByteSize(byte_size); + symbol->SetByteSize(byte_size); symbol->SetSizeIsSynthesized(true); break; } |

