Split symbol support for ELF and Linux.
llvm-svn: 185366
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 905b6cb..ee447a1 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -16,6 +16,7 @@
#include "lldb/Symbol/Symtab.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Symbol/SymbolVendor.h"
using namespace lldb;
using namespace lldb_private;
@@ -288,22 +289,59 @@
m_type_data_resolved = true;
ModuleSP module_sp (m_addr_range.GetBaseAddress().GetModule());
SymbolContext sc;
- if (module_sp && module_sp->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
- eSymbolContextLineEntry,
- sc))
+ if (module_sp)
{
- m_type_data = sc.line_entry.range.GetByteSize();
- // Sanity check - this may be a function in the middle of code that has debug information, but
- // not for this symbol. So the line entries surrounding us won't lie inside our function.
- // In that case, the line entry will be bigger than we are, so we do that quick check and
- // if that is true, we just return 0.
- if (m_type_data >= m_addr_range.GetByteSize())
+ uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
+ eSymbolContextLineEntry,
+ sc);
+ if (resolved_flags & eSymbolContextLineEntry)
+ {
+ // Default to the end of the first line entry.
+ m_type_data = sc.line_entry.range.GetByteSize();
+
+ // Set address for next line.
+ Address addr (m_addr_range.GetBaseAddress());
+ addr.Slide (m_type_data);
+
+ // Check the first few instructions and look for one that has a line number that is
+ // different than the first entry. This is also done in Function::GetPrologueByteSize().
+ uint16_t total_offset = m_type_data;
+ for (int idx = 0; idx < 6; ++idx)
+ {
+ SymbolContext sc_temp;
+ resolved_flags = module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextLineEntry, sc_temp);
+ // Make sure we got line number information...
+ if (!(resolved_flags & eSymbolContextLineEntry))
+ break;
+
+ // If this line number is different than our first one, use it and we're done.
+ if (sc_temp.line_entry.line != sc.line_entry.line)
+ {
+ m_type_data = total_offset;
+ break;
+ }
+
+ // Slide addr up to the next line address.
+ addr.Slide (sc_temp.line_entry.range.GetByteSize());
+ total_offset += sc_temp.line_entry.range.GetByteSize();
+ // If we've gone too far, bail out.
+ if (total_offset >= m_addr_range.GetByteSize())
+ break;
+ }
+
+ // Sanity check - this may be a function in the middle of code that has debug information, but
+ // not for this symbol. So the line entries surrounding us won't lie inside our function.
+ // In that case, the line entry will be bigger than we are, so we do that quick check and
+ // if that is true, we just return 0.
+ if (m_type_data >= m_addr_range.GetByteSize())
+ m_type_data = 0;
+ }
+ else
+ {
+ // TODO: expose something in Process to figure out the
+ // size of a function prologue.
m_type_data = 0;
- }
- else
- {
- // TODO: expose something in Process to figure out the
- // size of a function prologue.
+ }
}
}
return m_type_data;
@@ -418,10 +456,10 @@
ModuleSP module_sp (GetAddress().GetModule());
if (module_sp)
{
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile)
+ SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
+ if (sym_vendor)
{
- Symtab *symtab = objfile->GetSymtab();
+ Symtab *symtab = sym_vendor->GetSymtab();
if (symtab)
{
const_cast<Symbol*>(this)->SetByteSize (symtab->CalculateSymbolSize (const_cast<Symbol *>(this)));