22 : m_comp_unit(comp_unit), m_entries() {}
25 std::vector<std::unique_ptr<LineSequence>> &&sequences)
26 : m_comp_unit(comp_unit), m_entries() {
27 LineTable::Entry::LessThanBinaryPredicate less_than_bp(
this);
28 llvm::stable_sort(sequences, less_than_bp);
29 for (
const auto &sequence : sequences) {
40 uint16_t column, uint16_t file_idx,
41 bool is_start_of_statement,
42 bool is_start_of_basic_block,
43 bool is_prologue_end,
bool is_epilogue_begin,
44 bool is_terminal_entry) {
45 Entry entry(file_addr, line, column, file_idx, is_start_of_statement,
46 is_start_of_basic_block, is_prologue_end, is_epilogue_begin,
49 LineTable::Entry::LessThanBinaryPredicate less_than_bp(
this);
50 entry_collection::iterator pos =
51 llvm::upper_bound(
m_entries, entry, less_than_bp);
66 return std::make_unique<LineTable::LineSequenceImpl>();
71 uint16_t column, uint16_t file_idx,
bool is_start_of_statement,
72 bool is_start_of_basic_block,
bool is_prologue_end,
bool is_epilogue_begin,
73 bool is_terminal_entry) {
74 assert(sequence !=
nullptr);
76 Entry entry(file_addr, line, column, file_idx, is_start_of_statement,
77 is_start_of_basic_block, is_prologue_end, is_epilogue_begin,
89 if (!entries.empty() && entries.back().file_addr == file_addr) {
100 entries.back() = entry;
102 entries.push_back(entry);
106 assert(sequence !=
nullptr);
115 !Entry::EntryAddressLessThan(entry,
m_entries.back())) {
122 entry_collection::iterator begin_pos =
m_entries.begin();
123 entry_collection::iterator end_pos =
m_entries.end();
124 LineTable::Entry::LessThanBinaryPredicate less_than_bp(
this);
125 entry_collection::iterator pos =
126 upper_bound(begin_pos, end_pos, entry, less_than_bp);
129 if (pos != begin_pos) {
130 while (pos < end_pos && !((pos - 1)->is_terminal_entry))
137 if (pos != begin_pos) {
138 entry_collection::iterator prev_pos = pos - 1;
139 assert(prev_pos->is_terminal_entry);
145LineTable::Entry::LessThanBinaryPredicate::LessThanBinaryPredicate(
147 : m_line_table(line_table) {}
149bool LineTable::Entry::LessThanBinaryPredicate::
151#define LT_COMPARE(a, b) \
169bool LineTable::Entry::LessThanBinaryPredicate::
170operator()(
const std::unique_ptr<LineSequence> &sequence_a,
171 const std::unique_ptr<LineSequence> &sequence_b)
const {
174 return (*
this)(seq_a->m_entries.front(), seq_b->m_entries.front());
190 uint32_t *index_ptr) {
191 if (index_ptr !=
nullptr)
194 bool success =
false;
200 entry_collection::const_iterator begin_pos =
m_entries.begin();
201 entry_collection::const_iterator end_pos =
m_entries.end();
202 entry_collection::const_iterator pos = lower_bound(
203 begin_pos, end_pos, search_entry, Entry::EntryAddressLessThan);
204 if (pos != end_pos) {
205 if (pos != begin_pos) {
206 if (pos->file_addr != search_entry.
file_addr)
208 else if (pos->file_addr == search_entry.
file_addr) {
212 if (pos->is_terminal_entry) {
217 if (pos != end_pos) {
218 if (pos->file_addr != search_entry.
file_addr)
223 if (pos != end_pos) {
226 while (pos != begin_pos) {
227 entry_collection::const_iterator prev_pos = pos - 1;
228 if (prev_pos->file_addr == search_entry.
file_addr &&
229 prev_pos->is_terminal_entry ==
false)
248 if (pos != end_pos && pos->is_terminal_entry ==
false) {
249 uint32_t match_idx = std::distance(begin_pos, pos);
251 if (index_ptr !=
nullptr && success)
252 *index_ptr = match_idx;
277 if (!module_sp->ResolveFileAddress(
file_addr,
306 uint32_t start_idx, uint32_t
file_idx,
308 auto file_idx_matcher = [](uint32_t file_index, uint16_t entry_file_idx) {
309 return file_index == entry_file_idx;
311 return FindLineEntryIndexByFileIndexImpl<uint32_t>(
313 start_idx,
file_idx, src_location_spec, line_entry_ptr, file_idx_matcher);
317 uint32_t start_idx,
const std::vector<uint32_t> &
file_idx,
319 auto file_idx_matcher = [](
const std::vector<uint32_t> &file_indexes,
320 uint16_t entry_file_idx) {
321 return llvm::is_contained(file_indexes, entry_file_idx);
324 return FindLineEntryIndexByFileIndexImpl<std::vector<uint32_t>>(
325 start_idx,
file_idx, src_location_spec, line_entry_ptr, file_idx_matcher);
334 size_t num_added = 0;
339 for (
size_t idx = 0; idx < count; ++idx) {
361 for (
size_t idx = 0; idx < count; ++idx) {
364 style, fallback_style, show_line_ranges);
374 for (
size_t idx = 0; idx < count; ++idx) {
385 const size_t initial_count = file_ranges.
GetSize();
390 for (
size_t idx = 0; idx < count; ++idx) {
396 file_ranges.
Append(range);
403 return file_ranges.
GetSize() - initial_count;
414 bool prev_entry_was_linked =
false;
415 bool range_changed =
false;
416 for (
size_t idx = 0; idx < count; ++idx) {
421 entry.
file_addr - (end_sequence ? 1 : 0);
422 if (file_range_entry ==
nullptr ||
423 !file_range_entry->
Contains(lookup_file_addr)) {
424 prev_file_range_entry = file_range_entry;
426 range_changed =
true;
432 bool terminate_previous_entry =
false;
433 if (file_range_entry) {
434 entry_linked_file_addr = entry.
file_addr -
436 file_range_entry->
data;
439 if (range_changed && prev_file_range_entry) {
440 prev_end_entry_linked_file_addr =
444 if (prev_end_entry_linked_file_addr != entry_linked_file_addr)
445 terminate_previous_entry = prev_entry_was_linked;
447 }
else if (prev_entry_was_linked) {
452 !sequence.
m_entries.back().is_terminal_entry) {
453 terminate_previous_entry =
true;
457 if (terminate_previous_entry && !sequence.
m_entries.empty()) {
462 prev_end_entry_linked_file_addr =
466 sequence.
m_entries.back().file_addr = prev_end_entry_linked_file_addr;
467 sequence.
m_entries.back().is_terminal_entry =
true;
470 line_table_up->InsertSequence(&sequence);
475 if (file_range_entry) {
479 sequence.
m_entries.back().file_addr = entry_linked_file_addr;
485 sequence.
m_entries.back().is_terminal_entry) {
486 line_table_up->InsertSequence(&sequence);
488 prev_entry_was_linked =
false;
490 prev_entry_was_linked = file_range_entry !=
nullptr;
493 range_changed =
false;
495 if (line_table_up->m_entries.empty())
497 return line_table_up.release();
Address & GetBaseAddress()
Get accessor for the base address of the range.
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
A section + offset based address class.
DumpStyle
Dump styles allow the Address::Dump(Stream *,DumpStyle) const function to display Address contents in...
bool Slide(int64_t offset)
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
A class that describes a compilation unit.
const SupportFileList & GetSupportFiles()
Get the compile unit's support file list.
An abstract base class used during symbol table creation.
entry_collection m_entries
The collection of line entries in this sequence.
CompileUnit * m_comp_unit
The compile unit that this line table belongs to.
void Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges)
Dump all line entries in this line table to the stream s.
size_t FindLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list)
static std::unique_ptr< LineSequence > CreateLineSequenceContainer()
void InsertLineEntry(lldb::addr_t file_addr, uint32_t line, uint16_t column, uint16_t file_idx, bool is_start_of_statement, bool is_start_of_basic_block, bool is_prologue_end, bool is_epilogue_begin, bool is_terminal_entry)
Adds a new line entry to this line table.
bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr=nullptr)
Find a line entry that contains the section offset address so_addr.
std::vector< Entry > entry_collection
The collection type for the line entries.
static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr, uint32_t line, uint16_t column, uint16_t file_idx, bool is_start_of_statement, bool is_start_of_basic_block, bool is_prologue_end, bool is_epilogue_begin, bool is_terminal_entry)
void InsertSequence(LineSequence *sequence)
uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx, const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr)
Find a line entry index that has a matching file index and source line number.
LineTable(CompileUnit *comp_unit)
Construct with compile unit.
bool ConvertEntryAtIndexToLineEntry(uint32_t idx, LineEntry &line_entry)
LineTable * LinkLineTable(const FileRangeMap &file_range_map)
entry_collection m_entries
The collection of line entries in this line table.
void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level)
size_t GetContiguousFileAddressRanges(FileAddressRanges &file_ranges, bool append)
Gets all contiguous file address ranges for the entire line table.
bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry)
Get the line entry from the line table at index idx.
uint32_t GetSize() const
Gets the size of the line table in number of line table entries.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Entry * FindEntryThatContains(B addr)
void Append(const Entry &entry)
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
A stream class that can stream formatted output to a file.
size_t EOL()
Output and End of Line character to the stream.
lldb::SupportFileSP GetSupportFileAtIndex(size_t idx) const
Defines a list of symbol context objects.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void Clear()
Clear the object's state.
Defines a symbol context baton that can be handed other debug core functions.
LineEntry line_entry
The LineEntry for a given query.
#define UNUSED_IF_ASSERT_DISABLED(x)
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::SupportFile > SupportFileSP
std::shared_ptr< lldb_private::Module > ModuleSP
A line table entry class.
uint16_t column
The column number of the source line, or zero if there is no column information.
uint16_t is_epilogue_begin
Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakp...
void Clear()
Clear the object's state.
bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const
Dump a description of this object to a Stream.
lldb::SupportFileSP original_file_sp
The original source file, from debug info.
AddressRange range
The section offset address range for this line entry.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const
uint16_t is_start_of_basic_block
Indicates this entry is the beginning of a basic block.
uint16_t is_prologue_end
Indicates this entry is one (of possibly many) where execution should be suspended for an entry break...
lldb::SupportFileSP file_sp
The source file, possibly mapped by the target.source-map setting.
uint16_t is_terminal_entry
Indicates this entry is that of the first byte after the end of a sequence of target machine instruct...
uint16_t is_start_of_statement
Indicates this entry is the beginning of a statement.
uint32_t is_start_of_statement
Indicates this entry is the beginning of a statement.
uint32_t is_epilogue_begin
Indicates this entry is one (of possibly many) where execution should be suspended for an exit breakp...
uint32_t is_terminal_entry
Indicates this entry is that of the first byte after the end of a sequence of target machine instruct...
uint32_t is_prologue_end
Indicates this entry is one (of possibly many) where execution should be suspended for an entry break...
uint16_t file_idx
The file index into CompileUnit's file table, or zero if there is no file information.
lldb::addr_t file_addr
The file address for this line entry.
uint32_t is_start_of_basic_block
Indicates this entry is the beginning of a basic block.
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.
bool Contains(BaseType r) const
BaseType GetRangeBase() const
void SetRangeEnd(BaseType end)
void SetRangeBase(BaseType b)
Set the start value for the range, and keep the same size.
BaseType GetRangeEnd() const