Author: ted Date: Wed May 11 17:46:53 2016 New Revision: 269250 URL: http://llvm.org/viewvc/llvm-project?rev=269250&view=rev Log: 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 Modified: lldb/trunk/include/lldb/Symbol/LineEntry.h lldb/trunk/source/Breakpoint/BreakpointResolver.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Symbol/LineEntry.cpp lldb/trunk/source/Symbol/LineTable.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/StackFrameList.cpp lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp Modified: lldb/trunk/include/lldb/Symbol/LineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineEntry.h?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineEntry.h (original) +++ lldb/trunk/include/lldb/Symbol/LineEntry.h Wed May 11 17:46:53 2016 @@ -168,10 +168,21 @@ struct LineEntry 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. Modified: lldb/trunk/source/Breakpoint/BreakpointResolver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolver.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolver.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolver.cpp Wed May 11 17:46:53 2016 @@ -75,6 +75,7 @@ BreakpointResolver::SetSCMatchesByLine ( 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 ( 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) { Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed May 11 17:46:53 2016 @@ -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; } Modified: lldb/trunk/source/Symbol/LineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineEntry.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineEntry.cpp (original) +++ lldb/trunk/source/Symbol/LineEntry.cpp Wed May 11 17:46:53 2016 @@ -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::GetSameLineContiguousAddressR 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::GetSameLineContiguousAddressR } 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; + } +} Modified: lldb/trunk/source/Symbol/LineTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineTable.cpp (original) +++ lldb/trunk/source/Symbol/LineTable.cpp Wed May 11 17:46:53 2016 @@ -299,6 +299,7 @@ LineTable::ConvertEntryAtIndexToLineEntr 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 *targ 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; } } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Wed May 11 17:46:53 2016 @@ -595,6 +595,7 @@ SymbolContext::GetParentOfInlinedScope ( 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; Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Wed May 11 17:46:53 2016 @@ -490,14 +490,7 @@ StackFrame::GetSymbolContext (uint32_t r 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); } } } Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Wed May 11 17:46:53 2016 @@ -350,6 +350,7 @@ StackFrameList::GetFramesUpTo(uint32_t e 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 e // 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 e 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); Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Wed May 11 17:46:53 2016 @@ -232,7 +232,7 @@ ThreadPlanStepOverRange::ShouldStop (Eve 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 (Eve // 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 (Eve 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; Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=269250&r1=269249&r2=269250&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Wed May 11 17:46:53 2016 @@ -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) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits