Keep original source path and mapped path in LineEntry

Summary:
The "file" variable in a LineEntry was mapped using target.source-map, except when stepping through inlined code. This patch adds a new variable to LineEntry, "original_file", that contains the original file from the debug info. "file" will continue to (possibly) be mapped.

Some code has been changed to use "original_file". This is code dealing with symbols. Code dealing with source files will still use "file". Reviewers, please confirm that these particular changes are correct.

Tests run on Ubuntu 12.04 show no regression.

Reviewers: clayborg, jingham

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D20135

llvm-svn: 269250
This commit is contained in:
Ted Woodward 2016-05-11 22:46:53 +00:00
parent 8c4136b0d8
commit 911d57840a
10 changed files with 57 additions and 33 deletions

View File

@ -167,11 +167,22 @@ struct LineEntry
AddressRange
GetSameLineContiguousAddressRange () const;
//------------------------------------------------------------------
/// Apply file mappings from target.source-map to the LineEntry's file.
///
/// @param[in] target_sp
/// Shared pointer to the target this LineEntry belongs to.
//------------------------------------------------------------------
void
ApplyFileMappings(lldb::TargetSP target_sp);
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
AddressRange range; ///< The section offset address range for this line entry.
FileSpec file;
FileSpec file; ///< The source file, possibly mapped by the target.source-map setting
FileSpec original_file; ///< The original source file, from debug info.
uint32_t line; ///< The source line number, or zero if there is no line number information.
uint16_t column; ///< The column number of the source line, or zero if there is no column information.
uint16_t is_start_of_statement:1, ///< Indicates this entry is the beginning of a statement.

View File

@ -75,6 +75,7 @@ BreakpointResolver::SetSCMatchesByLine (SearchFilter &filter, SymbolContextList
bool first_entry = true;
FileSpec match_file_spec;
FileSpec match_original_file_spec;
uint32_t closest_line_number = UINT32_MAX;
// Pull out the first entry, and all the others that match its file spec, and stuff them in the tmp list.
@ -86,11 +87,13 @@ BreakpointResolver::SetSCMatchesByLine (SearchFilter &filter, SymbolContextList
if (first_entry)
{
match_file_spec = sc.line_entry.file;
match_original_file_spec = sc.line_entry.original_file;
matches = true;
first_entry = false;
}
else
matches = (sc.line_entry.file == match_file_spec);
matches = ((sc.line_entry.file == match_file_spec) ||
(sc.line_entry.original_file == match_original_file_spec));
if (matches)
{

View File

@ -897,7 +897,7 @@ protected:
operator == (const SourceInfo &rhs) const
{
return function == rhs.function &&
line_entry.file == rhs.line_entry.file &&
line_entry.original_file == rhs.line_entry.original_file &&
line_entry.line == rhs.line_entry.line;
}
@ -905,7 +905,7 @@ protected:
operator != (const SourceInfo &rhs) const
{
return function != rhs.function ||
line_entry.file != rhs.line_entry.file ||
line_entry.original_file != rhs.line_entry.original_file ||
line_entry.line != rhs.line_entry.line;
}

View File

@ -43,6 +43,7 @@ LineEntry::LineEntry
) :
range(section_sp, section_offset, byte_size),
file(_file),
original_file(_file),
line(_line),
column(_column),
is_start_of_statement(_is_start_of_statement),
@ -58,6 +59,7 @@ LineEntry::Clear()
{
range.Clear();
file.Clear();
original_file.Clear();
line = LLDB_INVALID_LINE_NUMBER;
column = 0;
is_start_of_statement = 0;
@ -260,7 +262,7 @@ LineEntry::GetSameLineContiguousAddressRange () const
if (next_line_sc.line_entry.IsValid()
&& next_line_sc.line_entry.range.GetByteSize() > 0
&& file == next_line_sc.line_entry.file)
&& original_file == next_line_sc.line_entry.original_file)
{
// Include any line 0 entries - they indicate that this is compiler-generated code
// that does not correspond to user source code.
@ -283,3 +285,15 @@ LineEntry::GetSameLineContiguousAddressRange () const
}
return complete_line_range;
}
void
LineEntry::ApplyFileMappings(lldb::TargetSP target_sp)
{
if (target_sp)
{
// Apply any file remappings to our file
FileSpec new_file_spec;
if (target_sp->GetSourcePathMap().FindFile(original_file, new_file_spec))
file = new_file_spec;
}
}

View File

@ -299,6 +299,7 @@ LineTable::ConvertEntryAtIndexToLineEntry (uint32_t idx, LineEntry &line_entry)
line_entry.range.SetByteSize(0);
line_entry.file = m_comp_unit->GetSupportFiles().GetFileSpecAtIndex (entry.file_idx);
line_entry.original_file = m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx);
line_entry.line = entry.line;
line_entry.column = entry.column;
line_entry.is_start_of_statement = entry.is_start_of_statement;
@ -462,9 +463,9 @@ LineTable::Dump (Stream *s, Target *target, Address::DumpStyle style, Address::D
for (size_t idx = 0; idx < count; ++idx)
{
ConvertEntryAtIndexToLineEntry (idx, line_entry);
line_entry.Dump (s, target, prev_file != line_entry.file, style, fallback_style, show_line_ranges);
line_entry.Dump (s, target, prev_file != line_entry.original_file, style, fallback_style, show_line_ranges);
s->EOL();
prev_file = line_entry.file;
prev_file = line_entry.original_file;
}
}

View File

@ -595,6 +595,7 @@ SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc,
next_frame_pc = range.GetBaseAddress();
next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile();
next_frame_sc.line_entry.original_file = curr_inlined_block_inlined_info->GetCallSite().GetFile();
next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine();
next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn();
return true;

View File

@ -490,14 +490,7 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope)
if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid())
{
m_sc.line_entry = sc.line_entry;
if (m_sc.target_sp)
{
// Be sure to apply and file remappings to our file and line
// entries when handing out a line entry
FileSpec new_file_spec;
if (m_sc.target_sp->GetSourcePathMap().FindFile (m_sc.line_entry.file, new_file_spec))
m_sc.line_entry.file = new_file_spec;
}
m_sc.line_entry.ApplyFileMappings(m_sc.target_sp);
}
}
}

View File

@ -350,6 +350,7 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
if (unwind_block)
{
Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
TargetSP target_sp = m_thread.CalculateTarget();
// Be sure to adjust the frame address to match the address
// that was used to lookup the symbol context above. If we are
// in the first concrete frame, then we lookup using the current
@ -362,9 +363,8 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
// If curr_frame_address points to the first address in a section then after
// adjustment it will point to an other section. In that case resolve the
// address again to the correct section plus offset form.
TargetSP target = m_thread.CalculateTarget();
addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target_sp.get(), eAddressClassCode);
curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target_sp.get(), eAddressClassCode);
}
else
{
@ -377,17 +377,18 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
{
StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
m_frames.size(),
idx,
unwind_frame_sp->GetRegisterContextSP (),
cfa,
next_frame_address,
&next_frame_sc));
m_frames.push_back (frame_sp);
unwind_sc = next_frame_sc;
curr_frame_address = next_frame_address;
next_frame_sc.line_entry.ApplyFileMappings(target_sp);
StackFrameSP frame_sp(new StackFrame(m_thread.shared_from_this(),
m_frames.size(),
idx,
unwind_frame_sp->GetRegisterContextSP (),
cfa,
next_frame_address,
&next_frame_sc));
m_frames.push_back (frame_sp);
unwind_sc = next_frame_sc;
curr_frame_address = next_frame_address;
}
}
} while (m_frames.size() - 1 < end_idx);

View File

@ -232,7 +232,7 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
sc = frame_sp->GetSymbolContext (eSymbolContextEverything);
if (sc.line_entry.IsValid())
{
if (sc.line_entry.file != m_addr_context.line_entry.file
if (sc.line_entry.original_file != m_addr_context.line_entry.original_file
&& sc.comp_unit == m_addr_context.comp_unit
&& sc.function == m_addr_context.function)
{
@ -256,7 +256,7 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
// some code fragment by using #include <source-fragment.c> directly.
LineEntry prev_line_entry;
if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry)
&& prev_line_entry.file == line_entry.file)
&& prev_line_entry.original_file == line_entry.original_file)
{
SymbolContext prev_sc;
Address prev_address = prev_line_entry.range.GetBaseAddress();
@ -289,7 +289,7 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
if (next_line_function != m_addr_context.function)
break;
if (next_line_entry.file == m_addr_context.line_entry.file)
if (next_line_entry.original_file == m_addr_context.line_entry.original_file)
{
const bool abort_other_plans = false;
const RunMode stop_other_threads = RunMode::eAllThreads;

View File

@ -155,7 +155,7 @@ ThreadPlanStepRange::InRange ()
SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything));
if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid())
{
if (m_addr_context.line_entry.file == new_context.line_entry.file)
if (m_addr_context.line_entry.original_file == new_context.line_entry.original_file)
{
if (m_addr_context.line_entry.line == new_context.line_entry.line)
{