Index: include/lldb/Symbol/LineEntry.h =================================================================== --- include/lldb/Symbol/LineEntry.h +++ include/lldb/Symbol/LineEntry.h @@ -168,10 +168,21 @@ 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. Index: source/Breakpoint/BreakpointResolver.cpp =================================================================== --- source/Breakpoint/BreakpointResolver.cpp +++ source/Breakpoint/BreakpointResolver.cpp @@ -75,6 +75,7 @@ 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 @@ 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) { Index: source/Commands/CommandObjectSource.cpp =================================================================== --- source/Commands/CommandObjectSource.cpp +++ source/Commands/CommandObjectSource.cpp @@ -897,7 +897,7 @@ 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 @@ 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; } Index: source/Symbol/LineEntry.cpp =================================================================== --- source/Symbol/LineEntry.cpp +++ source/Symbol/LineEntry.cpp @@ -43,6 +43,7 @@ ) : 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 @@ { range.Clear(); file.Clear(); + original_file.Clear(); line = LLDB_INVALID_LINE_NUMBER; column = 0; is_start_of_statement = 0; @@ -260,7 +262,7 @@ 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 @@ } 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; + } +} Index: source/Symbol/LineTable.cpp =================================================================== --- source/Symbol/LineTable.cpp +++ source/Symbol/LineTable.cpp @@ -299,6 +299,7 @@ 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 @@ 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; } } Index: source/Symbol/SymbolContext.cpp =================================================================== --- source/Symbol/SymbolContext.cpp +++ source/Symbol/SymbolContext.cpp @@ -595,6 +595,7 @@ 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; Index: source/Target/StackFrame.cpp =================================================================== --- source/Target/StackFrame.cpp +++ source/Target/StackFrame.cpp @@ -490,14 +490,7 @@ 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); } } } Index: source/Target/StackFrameList.cpp =================================================================== --- source/Target/StackFrameList.cpp +++ source/Target/StackFrameList.cpp @@ -350,6 +350,7 @@ 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 @@ // 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 @@ 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); Index: source/Target/ThreadPlanStepOverRange.cpp =================================================================== --- source/Target/ThreadPlanStepOverRange.cpp +++ source/Target/ThreadPlanStepOverRange.cpp @@ -232,7 +232,7 @@ 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 @@ // some code fragment by using #include 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 @@ 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; Index: source/Target/ThreadPlanStepRange.cpp =================================================================== --- source/Target/ThreadPlanStepRange.cpp +++ source/Target/ThreadPlanStepRange.cpp @@ -155,7 +155,7 @@ 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) {