[Lldb-commits] [lldb] r171548 - in /lldb/trunk: include/lldb/Symbol/LineTable.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/LineTable.cpp
Andrew Kaylor
andrew.kaylor at intel.com
Fri Jan 4 14:57:56 PST 2013
Author: akaylor
Date: Fri Jan 4 16:57:56 2013
New Revision: 171548
URL: http://llvm.org/viewvc/llvm-project?rev=171548&view=rev
Log:
Handle the case of unordered sequences in a DWARF line table.
Modified:
lldb/trunk/include/lldb/Symbol/LineTable.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/LineTable.cpp
Modified: lldb/trunk/include/lldb/Symbol/LineTable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=171548&r1=171547&r2=171548&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/LineTable.h (original)
+++ lldb/trunk/include/lldb/Symbol/LineTable.h Fri Jan 4 16:57:56 2013
@@ -21,6 +21,25 @@
namespace lldb_private {
//----------------------------------------------------------------------
+/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h"
+/// @brief An abstract base class used during symbol table creation.
+//----------------------------------------------------------------------
+class LineSequence
+{
+public:
+ LineSequence ();
+
+ virtual
+ ~LineSequence() {}
+
+ virtual void
+ Clear() = 0;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN (LineSequence);
+};
+
+//----------------------------------------------------------------------
/// @class LineTable LineTable.h "lldb/Symbol/LineTable.h"
/// @brief A line table class.
//----------------------------------------------------------------------
@@ -54,19 +73,6 @@
// void
// AddLineEntry (const LineEntry& line_entry);
- // Called when you can guarantee the addresses are in increasing order
- void
- AppendLineEntry (const lldb::SectionSP& section_sp,
- lldb::addr_t section_offset,
- 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);
-
// Called when you can't guarantee the addresses are in increasing order
void
InsertLineEntry (const lldb::SectionSP& section_sp,
@@ -80,6 +86,29 @@
bool is_epilogue_begin,
bool is_terminal_entry);
+ // Used to instantiate the LineSequence helper classw
+ LineSequence*
+ CreateLineSequenceContainer ();
+
+ // Append an entry to a caller-provided collection that will later be
+ // inserted in this line table.
+ void
+ AppendLineEntryToSequence (LineSequence* sequence,
+ const lldb::SectionSP& section_sp,
+ lldb::addr_t section_offset,
+ 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);
+
+ // Insert a sequence of entries into this line table.
+ void
+ InsertSequence (LineSequence* sequence);
+
//------------------------------------------------------------------
/// Dump all line entries in this line table to the stream \a s.
///
@@ -351,15 +380,35 @@
//------------------------------------------------------------------
// Types
//------------------------------------------------------------------
- typedef std::vector<lldb_private::Section*> section_collection; ///< The collection type for the line entries.
- typedef std::vector<Entry> entry_collection; ///< The collection type for the line entries.
+ typedef std::vector<lldb_private::Section*> section_collection; ///< The collection type for the sections.
+ typedef std::vector<Entry> entry_collection; ///< The collection type for the line entries.
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
- CompileUnit* m_comp_unit; ///< The compile unit that this line table belongs to.
+ CompileUnit* m_comp_unit; ///< The compile unit that this line table belongs to.
SectionList m_section_list; ///< The list of sections that at least one of the line entries exists in.
entry_collection m_entries; ///< The collection of line entries in this line table.
+ //------------------------------------------------------------------
+ // Helper class
+ //------------------------------------------------------------------
+ class LineSequenceImpl : public LineSequence
+ {
+ public:
+ LineSequenceImpl() :
+ LineSequence()
+ {}
+
+ virtual
+ ~LineSequenceImpl()
+ {}
+
+ virtual void
+ Clear();
+
+ entry_collection m_seq_entries; ///< The collection of line entries in this sequence.
+ };
+
bool
ConvertEntryAtIndexToLineEntry (uint32_t idx, LineEntry &line_entry);
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=171548&r1=171547&r2=171548&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Jan 4 16:57:56 2013
@@ -991,6 +991,7 @@
DWARFDebugLine::Row prev_row;
SectionSP prev_section_sp;
SectionSP curr_section_sp;
+ llvm::OwningPtr<LineSequence> curr_sequence_ap;
};
//----------------------------------------------------------------------
@@ -1137,20 +1138,36 @@
// We are not in an object file that contains DWARF for an
// N_OSO, this is just a normal DWARF file. The DWARF spec
// guarantees that the addresses will be in increasing order
- // so, since we store line tables in file address order, we
- // can always just append the line entry without needing to
- // search for the correct insertion point (we don't need to
- // use LineEntry::InsertLineEntry()).
- line_table->AppendLineEntry (info->curr_section_sp,
- curr_line_section_offset,
- state.line,
- state.column,
- state.file,
- state.is_stmt,
- state.basic_block,
- state.prologue_end,
- state.epilogue_begin,
- state.end_sequence);
+ // for a sequence, but the line table for a single compile unit
+ // may contain multiple sequences so we append entries to the
+ // current sequence until we find its end, then we merge the
+ // sequence into the main line table collection.
+
+ // If this is our first time here, we need to create a
+ // sequence container.
+ if (!info->curr_sequence_ap)
+ {
+ info->curr_sequence_ap.reset(line_table->CreateLineSequenceContainer());
+ assert(info->curr_sequence_ap);
+ }
+ line_table->AppendLineEntryToSequence(info->curr_sequence_ap.get(),
+ info->curr_section_sp,
+ curr_line_section_offset,
+ state.line,
+ state.column,
+ state.file,
+ state.is_stmt,
+ state.basic_block,
+ state.prologue_end,
+ state.epilogue_begin,
+ state.end_sequence);
+ if (state.end_sequence)
+ {
+ // First, put the current sequence into the line table.
+ line_table->InsertSequence(info->curr_sequence_ap.get());
+ // Then, empty it to prepare for the next sequence.
+ info->curr_sequence_ap->Clear();
+ }
}
}
@@ -1186,7 +1203,8 @@
false,
DWARFDebugLine::Row(),
SectionSP(),
- SectionSP()
+ SectionSP(),
+ llvm::OwningPtr<LineSequence>()
};
uint32_t offset = cu_line_offset;
DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info);
Modified: lldb/trunk/source/Symbol/LineTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=171548&r1=171547&r2=171548&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LineTable.cpp (original)
+++ lldb/trunk/source/Symbol/LineTable.cpp Fri Jan 4 16:57:56 2013
@@ -34,34 +34,6 @@
{
}
-//void
-//LineTable::AddLineEntry(const LineEntry& entry)
-//{
-// // Do a binary search for the correct entry and insert it
-// m_line_entries.insert(std::upper_bound(m_line_entries.begin(), m_line_entries.end(), entry), entry);
-//}
-
-void
-LineTable::AppendLineEntry
-(
- const lldb::SectionSP& section_sp,
- lldb::addr_t section_offset,
- 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
-)
-{
- uint32_t sect_idx = m_section_list.AddUniqueSection (section_sp);
- Entry entry(sect_idx, section_offset, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry);
- m_entries.push_back (entry);
-}
-
-
void
LineTable::InsertLineEntry
(
@@ -106,6 +78,80 @@
// Dump (&s, Address::DumpStyleFileAddress);
}
+LineSequence::LineSequence()
+{
+}
+
+void
+LineTable::LineSequenceImpl::Clear()
+{
+ m_seq_entries.clear();
+}
+
+LineSequence* LineTable::CreateLineSequenceContainer ()
+{
+ return new LineTable::LineSequenceImpl();
+}
+
+void
+LineTable::AppendLineEntryToSequence
+(
+ LineSequence* sequence,
+ const SectionSP& section_sp,
+ lldb::addr_t section_offset,
+ 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
+)
+{
+ assert(sequence != NULL);
+ LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence);
+ uint32_t sect_idx = m_section_list.AddUniqueSection (section_sp);
+ Entry entry(sect_idx, section_offset, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry);
+ seq->m_seq_entries.push_back (entry);
+}
+
+void
+LineTable::InsertSequence (LineSequence* sequence)
+{
+ assert(sequence != NULL);
+ LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence);
+ if (seq->m_seq_entries.empty())
+ return;
+ Entry& entry = seq->m_seq_entries.front();
+
+ // If the first entry address in this sequence is greater than or equal to
+ // the address of the last item in our entry collection, just append.
+ if (m_entries.empty() || !Entry::EntryAddressLessThan(entry, m_entries.back()))
+ {
+ m_entries.insert(m_entries.end(),
+ seq->m_seq_entries.begin(),
+ seq->m_seq_entries.end());
+ return;
+ }
+
+ // Otherwise, find where this belongs in the collection
+ entry_collection::iterator begin_pos = m_entries.begin();
+ entry_collection::iterator end_pos = m_entries.end();
+ LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+ entry_collection::iterator pos = upper_bound(begin_pos, end_pos, entry, less_than_bp);
+#ifdef LLDB_CONFIGURATION_DEBUG
+ // If we aren't inserting at the beginning, the previous entry should
+ // terminate a sequence.
+ if (pos != begin_pos)
+ {
+ entry_collection::iterator prev_pos = pos - 1;
+ assert(prev_pos->is_terminal_entry);
+ }
+#endif
+ m_entries.insert(pos, seq->m_seq_entries.begin(), seq->m_seq_entries.end());
+}
+
//----------------------------------------------------------------------
LineTable::Entry::LessThanBinaryPredicate::LessThanBinaryPredicate(LineTable *line_table) :
m_line_table (line_table)
More information about the lldb-commits
mailing list