forked from OSchip/llvm-project
Symbol prologue code checks if funciton lines up with symbol and uses function prologue code with line info if so.
Differential Revision: http://llvm-reviews.chandlerc.com/D1082 llvm-svn: 185553
This commit is contained in:
parent
8490bbd16b
commit
bf43d1ad26
|
@ -14,6 +14,7 @@
|
||||||
#include "lldb/Core/Stream.h"
|
#include "lldb/Core/Stream.h"
|
||||||
#include "lldb/Symbol/ObjectFile.h"
|
#include "lldb/Symbol/ObjectFile.h"
|
||||||
#include "lldb/Symbol/Symtab.h"
|
#include "lldb/Symbol/Symtab.h"
|
||||||
|
#include "lldb/Symbol/Function.h"
|
||||||
#include "lldb/Target/Process.h"
|
#include "lldb/Target/Process.h"
|
||||||
#include "lldb/Target/Target.h"
|
#include "lldb/Target/Target.h"
|
||||||
#include "lldb/Symbol/SymbolVendor.h"
|
#include "lldb/Symbol/SymbolVendor.h"
|
||||||
|
@ -287,60 +288,72 @@ Symbol::GetPrologueByteSize ()
|
||||||
if (!m_type_data_resolved)
|
if (!m_type_data_resolved)
|
||||||
{
|
{
|
||||||
m_type_data_resolved = true;
|
m_type_data_resolved = true;
|
||||||
ModuleSP module_sp (m_addr_range.GetBaseAddress().GetModule());
|
|
||||||
SymbolContext sc;
|
const Address &base_address = m_addr_range.GetBaseAddress();
|
||||||
if (module_sp)
|
Function *function = base_address.CalculateSymbolContextFunction();
|
||||||
|
if (function)
|
||||||
{
|
{
|
||||||
uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
|
// Functions have line entries which can also potentially have end of prologue information.
|
||||||
eSymbolContextLineEntry,
|
// So if this symbol points to a function, use the prologue information from there.
|
||||||
sc);
|
m_type_data = function->GetPrologueByteSize();
|
||||||
if (resolved_flags & eSymbolContextLineEntry)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModuleSP module_sp (base_address.GetModule());
|
||||||
|
SymbolContext sc;
|
||||||
|
if (module_sp)
|
||||||
{
|
{
|
||||||
// Default to the end of the first line entry.
|
uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress (base_address,
|
||||||
m_type_data = sc.line_entry.range.GetByteSize();
|
eSymbolContextLineEntry,
|
||||||
|
sc);
|
||||||
// Set address for next line.
|
if (resolved_flags & eSymbolContextLineEntry)
|
||||||
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;
|
// Default to the end of the first line entry.
|
||||||
resolved_flags = module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextLineEntry, sc_temp);
|
m_type_data = sc.line_entry.range.GetByteSize();
|
||||||
// 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.
|
// Set address for next line.
|
||||||
if (sc_temp.line_entry.line != sc.line_entry.line)
|
Address addr (base_address);
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
m_type_data = total_offset;
|
SymbolContext sc_temp;
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slide addr up to the next line address.
|
// Sanity check - this may be a function in the middle of code that has debug information, but
|
||||||
addr.Slide (sc_temp.line_entry.range.GetByteSize());
|
// not for this symbol. So the line entries surrounding us won't lie inside our function.
|
||||||
total_offset += sc_temp.line_entry.range.GetByteSize();
|
// In that case, the line entry will be bigger than we are, so we do that quick check and
|
||||||
// If we've gone too far, bail out.
|
// if that is true, we just return 0.
|
||||||
if (total_offset >= m_addr_range.GetByteSize())
|
if (m_type_data >= m_addr_range.GetByteSize())
|
||||||
break;
|
m_type_data = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// 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.
|
// TODO: expose something in Process to figure out the
|
||||||
// In that case, the line entry will be bigger than we are, so we do that quick check and
|
// size of a function prologue.
|
||||||
// if that is true, we just return 0.
|
|
||||||
if (m_type_data >= m_addr_range.GetByteSize())
|
|
||||||
m_type_data = 0;
|
m_type_data = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: expose something in Process to figure out the
|
|
||||||
// size of a function prologue.
|
|
||||||
m_type_data = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue