Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lldb/include/lldb/Symbol/LineEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "lldb/Core/AddressRange.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SupportFile.h"
#include "lldb/lldb-private.h"

namespace lldb_private {
Expand Down Expand Up @@ -133,7 +134,8 @@ struct LineEntry {
AddressRange range; ///< The section offset address range for this line entry.
FileSpec file; ///< The source file, possibly mapped by the target.source-map
///setting
FileSpec original_file; ///< The original source file, from debug info.
lldb::SupportFileSP
original_file_sp; ///< The original source file, from debug info.
uint32_t line = LLDB_INVALID_LINE_NUMBER; ///< The source line number, or zero
///< if there is no line number
/// information.
Expand Down
3 changes: 2 additions & 1 deletion lldb/include/lldb/Utility/FileSpecList.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SupportFile.h"
#include "lldb/lldb-forward.h"

#include <cstddef>
#include <vector>
Expand Down Expand Up @@ -40,7 +41,7 @@ class SupportFileList {
bool AppendIfUnique(const FileSpec &file);
size_t GetSize() const { return m_files.size(); }
const FileSpec &GetFileSpecAtIndex(size_t idx) const;
std::shared_ptr<SupportFile> GetSupportFileAtIndex(size_t idx) const;
lldb::SupportFileSP GetSupportFileAtIndex(size_t idx) const;
size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const;
/// Find a compatible file index.
///
Expand Down
5 changes: 4 additions & 1 deletion lldb/include/lldb/Utility/SupportFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace lldb_private {
/// file yet. This also stores an optional checksum of the on-disk content.
class SupportFile {
public:
SupportFile() : m_file_spec(), m_checksum() {}
SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {}
SupportFile(const FileSpec &spec, const Checksum &checksum)
: m_file_spec(spec), m_checksum(checksum) {}
Expand All @@ -29,10 +30,12 @@ class SupportFile {

virtual ~SupportFile() = default;

bool operator==(const SupportFile &other) {
bool operator==(const SupportFile &other) const {
return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum;
}

bool operator!=(const SupportFile &other) const { return !(*this == other); }

/// Return the file name only. Useful for resolving breakpoints by file name.
const FileSpec &GetSpecOnly() const { return m_file_spec; };

Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class StringList;
class StringTableReader;
class StructuredDataImpl;
class StructuredDataPlugin;
class SupportFile;
class Symbol;
class SymbolContext;
class SymbolContextList;
Expand Down Expand Up @@ -462,6 +463,7 @@ typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP;
typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP;
typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren>
ScriptedSyntheticChildrenSP;
typedef std::shared_ptr<lldb_private::SupportFile> SupportFileSP;
typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP;
typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP;
typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Breakpoint/BreakpointResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ void BreakpointResolver::SetSCMatchesByLine(
auto worklist_begin = std::partition(
all_scs.begin(), all_scs.end(), [&](const SymbolContext &sc) {
if (sc.line_entry.file == match.line_entry.file ||
sc.line_entry.original_file == match.line_entry.original_file) {
*sc.line_entry.original_file_sp ==
*match.line_entry.original_file_sp) {
// When a match is found, keep track of the smallest line number.
closest_line = std::min(closest_line, sc.line_entry.line);
return false;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,13 @@ class CommandObjectSourceList : public CommandObjectParsed {

bool operator==(const SourceInfo &rhs) const {
return function == rhs.function &&
line_entry.original_file == rhs.line_entry.original_file &&
*line_entry.original_file_sp == *rhs.line_entry.original_file_sp &&
line_entry.line == rhs.line_entry.line;
}

bool operator!=(const SourceInfo &rhs) const {
return function != rhs.function ||
line_entry.original_file != rhs.line_entry.original_file ||
*line_entry.original_file_sp != *rhs.line_entry.original_file_sp ||
line_entry.line != rhs.line_entry.line;
}

Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Core/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Disassembler::GetFunctionDeclLineEntry(const SymbolContext &sc) {
sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line);

if (func_decl_file != prologue_end_line.file &&
func_decl_file != prologue_end_line.original_file)
func_decl_file != prologue_end_line.original_file_sp->GetSpecOnly())
return {};

SourceLine decl_line;
Expand Down Expand Up @@ -407,7 +407,8 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
sc.function->GetStartLineSourceInfo(func_decl_file,
func_decl_line);
if (func_decl_file == prologue_end_line.file ||
func_decl_file == prologue_end_line.original_file) {
func_decl_file ==
prologue_end_line.original_file_sp->GetSpecOnly()) {
// Add all the lines between the function declaration and
// the first non-prologue source line to the list of lines
// to print.
Expand Down
10 changes: 5 additions & 5 deletions lldb/source/Symbol/LineEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LineEntry::LineEntry()
void LineEntry::Clear() {
range.Clear();
file.Clear();
original_file.Clear();
original_file_sp = std::make_shared<SupportFile>();
line = LLDB_INVALID_LINE_NUMBER;
column = 0;
is_start_of_statement = 0;
Expand Down Expand Up @@ -182,7 +182,7 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange(
// different file / line number.
AddressRange complete_line_range = range;
auto symbol_context_scope = lldb::eSymbolContextLineEntry;
Declaration start_call_site(original_file, line);
Declaration start_call_site(original_file_sp->GetSpecOnly(), line);
if (include_inlined_functions)
symbol_context_scope |= lldb::eSymbolContextBlock;

Expand All @@ -196,7 +196,7 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange(
next_line_sc.line_entry.range.GetByteSize() == 0)
break;

if (original_file == next_line_sc.line_entry.original_file &&
if (*original_file_sp == *next_line_sc.line_entry.original_file_sp &&
(next_line_sc.line_entry.line == 0 ||
line == next_line_sc.line_entry.line)) {
// Include any line 0 entries - they indicate that this is compiler-
Expand Down Expand Up @@ -240,8 +240,8 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange(
void LineEntry::ApplyFileMappings(lldb::TargetSP target_sp) {
if (target_sp) {
// Apply any file remappings to our file.
if (auto new_file_spec =
target_sp->GetSourcePathMap().FindFile(original_file))
if (auto new_file_spec = target_sp->GetSourcePathMap().FindFile(
original_file_sp->GetSpecOnly()))
file = *new_file_spec;
}
}
12 changes: 6 additions & 6 deletions lldb/source/Symbol/LineTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx,

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.original_file_sp =
m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx);
line_entry.line = entry.line;
line_entry.column = entry.column;
line_entry.is_start_of_statement = entry.is_start_of_statement;
Expand Down Expand Up @@ -357,13 +357,13 @@ void LineTable::Dump(Stream *s, Target *target, Address::DumpStyle style,
Address::DumpStyle fallback_style, bool show_line_ranges) {
const size_t count = m_entries.size();
LineEntry line_entry;
FileSpec prev_file;
SupportFileSP prev_file;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

for (size_t idx = 0; idx < count; ++idx) {
ConvertEntryAtIndexToLineEntry(idx, line_entry);
line_entry.Dump(s, target, prev_file != line_entry.original_file, style,
fallback_style, show_line_ranges);
line_entry.Dump(s, target, *prev_file != *line_entry.original_file_sp,
style, fallback_style, show_line_ranges);
s->EOL();
prev_file = line_entry.original_file;
prev_file = line_entry.original_file_sp;
}
}

Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Symbol/SymbolContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,9 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
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.original_file_sp =
std::make_shared<SupportFile>(
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 =
Expand Down
12 changes: 6 additions & 6 deletions lldb/source/Target/ThreadPlanStepOverRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
StackFrameSP frame_sp = thread.GetStackFrameAtIndex(0);
sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
if (sc.line_entry.IsValid()) {
if (sc.line_entry.original_file !=
m_addr_context.line_entry.original_file &&
if (*sc.line_entry.original_file_sp !=
*m_addr_context.line_entry.original_file_sp &&
sc.comp_unit == m_addr_context.comp_unit &&
sc.function == m_addr_context.function) {
// Okay, find the next occurrence of this file in the line table:
Expand All @@ -244,8 +244,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
LineEntry prev_line_entry;
if (line_table->GetLineEntryAtIndex(entry_idx - 1,
prev_line_entry) &&
prev_line_entry.original_file ==
line_entry.original_file) {
*prev_line_entry.original_file_sp ==
*line_entry.original_file_sp) {
SymbolContext prev_sc;
Address prev_address =
prev_line_entry.range.GetBaseAddress();
Expand Down Expand Up @@ -279,8 +279,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
if (next_line_function != m_addr_context.function)
break;

if (next_line_entry.original_file ==
m_addr_context.line_entry.original_file) {
if (*next_line_entry.original_file_sp ==
*m_addr_context.line_entry.original_file_sp) {
const bool abort_other_plans = false;
const RunMode stop_other_threads = RunMode::eAllThreads;
lldb::addr_t cur_pc = thread.GetStackFrameAtIndex(0)
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/ThreadPlanStepRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ bool ThreadPlanStepRange::InRange() {
frame->GetSymbolContext(eSymbolContextEverything));
if (m_addr_context.line_entry.IsValid() &&
new_context.line_entry.IsValid()) {
if (m_addr_context.line_entry.original_file ==
new_context.line_entry.original_file) {
if (*m_addr_context.line_entry.original_file_sp ==
*new_context.line_entry.original_file_sp) {
if (m_addr_context.line_entry.line == new_context.line_entry.line) {
m_addr_context = new_context;
const bool include_inlined_functions =
Expand Down