27 llvm::stable_sort(sequences, less_than_bp);
28 for (
const Sequence &seq : sequences) {
38 uint16_t column, uint16_t file_idx,
39 bool is_start_of_statement,
40 bool is_start_of_basic_block,
41 bool is_prologue_end,
bool is_epilogue_begin,
42 bool is_terminal_entry) {
43 Entry entry(file_addr, line, column, file_idx, is_start_of_statement,
44 is_start_of_basic_block, is_prologue_end, is_epilogue_begin,
48 entry_collection::iterator pos =
49 llvm::upper_bound(
m_entries, entry, less_than_bp);
61 uint16_t file_idx,
bool is_start_of_statement,
bool is_start_of_basic_block,
62 bool is_prologue_end,
bool is_epilogue_begin,
bool is_terminal_entry) {
63 Entry entry(file_addr, line, column, file_idx, is_start_of_statement,
64 is_start_of_basic_block, is_prologue_end, is_epilogue_begin,
76 if (!entries.empty() && entries.back().file_addr == file_addr) {
87 entries.back() = entry;
89 entries.push_back(entry);
100 !Entry::EntryAddressLessThan(entry,
m_entries.back())) {
107 entry_collection::iterator begin_pos =
m_entries.begin();
108 entry_collection::iterator end_pos =
m_entries.end();
110 entry_collection::iterator pos =
111 std::upper_bound(begin_pos, end_pos, entry, less_than_bp);
114 if (pos != begin_pos) {
115 while (pos < end_pos && !((pos - 1)->is_terminal_entry))
122 if (pos != begin_pos) {
123 entry_collection::iterator prev_pos = pos - 1;
124 assert(prev_pos->is_terminal_entry);
131 const Entry &b)
const {
132#define LT_COMPARE(a, b) \
179 llvm::upper_bound(
m_entries, search_entry, Entry::EntryAddressLessThan);
181 if (pos !=
m_entries.begin() && !std::prev(pos)->is_terminal_entry)
184 return std::distance(
m_entries.begin(), pos);
187std::pair<uint32_t, uint32_t>
191 return {first, first};
202 search_entry, Entry::EntryAddressLessThan);
204 pos->is_terminal_entry)
207 return {first, std::distance(
m_entries.begin(), pos)};
212 uint32_t *index_ptr) {
213 if (index_ptr !=
nullptr)
221 if (
m_entries[idx].file_addr > file_addr)
225 if (index_ptr !=
nullptr && success)
247 if (!module_sp->ResolveFileAddress(file_addr,
276 uint32_t start_idx, uint32_t file_idx,
278 auto file_idx_matcher = [](uint32_t file_index, uint16_t entry_file_idx) {
279 return file_index == entry_file_idx;
283 start_idx, file_idx, src_location_spec, line_entry_ptr, file_idx_matcher);
287 uint32_t start_idx,
const std::vector<uint32_t> &file_idx,
289 auto file_idx_matcher = [](
const std::vector<uint32_t> &file_indexes,
290 uint16_t entry_file_idx) {
291 return llvm::is_contained(file_indexes, entry_file_idx);
295 start_idx, file_idx, src_location_spec, line_entry_ptr, file_idx_matcher);
304 size_t num_added = 0;
309 for (
size_t idx = 0; idx < count; ++idx) {
315 if (
m_entries[idx].file_idx == file_idx) {
331 for (
size_t idx = 0; idx < count; ++idx) {
334 style, fallback_style, show_line_ranges);
344 for (
size_t idx = 0; idx < count; ++idx) {
355 const size_t initial_count = file_ranges.
GetSize();
360 for (
size_t idx = 0; idx < count; ++idx) {
366 file_ranges.
Append(range);
373 return file_ranges.
GetSize() - initial_count;
384 bool prev_entry_was_linked =
false;
385 bool range_changed =
false;
386 for (
size_t idx = 0; idx < count; ++idx) {
391 entry.
file_addr - (end_sequence ? 1 : 0);
392 if (file_range_entry ==
nullptr ||
393 !file_range_entry->
Contains(lookup_file_addr)) {
394 prev_file_range_entry = file_range_entry;
396 range_changed =
true;
402 bool terminate_previous_entry =
false;
403 if (file_range_entry) {
404 entry_linked_file_addr = entry.
file_addr -
406 file_range_entry->
data;
409 if (range_changed && prev_file_range_entry) {
410 prev_end_entry_linked_file_addr =
414 if (prev_end_entry_linked_file_addr != entry_linked_file_addr)
415 terminate_previous_entry = prev_entry_was_linked;
417 }
else if (prev_entry_was_linked) {
422 !sequence.
m_entries.back().is_terminal_entry) {
423 terminate_previous_entry =
true;
427 if (terminate_previous_entry && !sequence.
m_entries.empty()) {
432 prev_end_entry_linked_file_addr =
436 sequence.
m_entries.back().file_addr = prev_end_entry_linked_file_addr;
437 sequence.
m_entries.back().is_terminal_entry =
true;
440 line_table_up->InsertSequence(std::move(sequence));
444 if (file_range_entry) {
448 sequence.
m_entries.back().file_addr = entry_linked_file_addr;
454 sequence.
m_entries.back().is_terminal_entry) {
455 line_table_up->InsertSequence(std::move(sequence));
456 prev_entry_was_linked =
false;
458 prev_entry_was_linked = file_range_entry !=
nullptr;
461 range_changed =
false;
463 if (line_table_up->m_entries.empty())
465 return line_table_up.release();
A section + offset based address range class.
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.
lldb::addr_t GetByteSize() const
Get 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.
bool operator()(const LineTable::Entry &, const LineTable::Entry &) const
std::vector< Entry > m_entries
CompileUnit * m_comp_unit
The compile unit that this line table belongs to.
std::pair< uint32_t, uint32_t > GetLineEntryIndexRange(const AddressRange &range) const
Returns the (half-open) range of line entry indexes which overlap the given address range.
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 void AppendLineEntryToSequence(Sequence &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 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.
uint32_t FindLineEntryIndexByFileIndexImpl(uint32_t start_idx, T file_idx, const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr, std::function< bool(T, uint16_t)> file_idx_matcher)
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.
uint32_t lower_bound(const Address &so_addr) const
Returns the index of the first line entry which ends after the given address (i.e....
LineTable(CompileUnit *comp_unit)
Construct with compile unit.
bool ConvertEntryAtIndexToLineEntry(uint32_t idx, LineEntry &line_entry)
RangeDataVector< lldb::addr_t, lldb::addr_t, lldb::addr_t > FileRangeMap
LineTable * LinkLineTable(const FileRangeMap &file_range_map)
void InsertSequence(Sequence sequence)
lldb_private::RangeVector< lldb::addr_t, lldb::addr_t, 32 > FileAddressRanges
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.
RangeData< lldb::addr_t, lldb::addr_t, lldb::addr_t > Entry
Entry * FindEntryThatContains(B addr)
void Append(const Entry &entry)
Range< lldb::addr_t, lldb::addr_t > 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.
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