summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARFDebugLine.h
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-04-30 00:09:19 +0000
committerAlexey Samsonov <samsonov@google.com>2014-04-30 00:09:19 +0000
commit110d595d48033ab2c7dfba0efe833ccc4faf7d6f (patch)
treefaecc4bff99f8a346fa51a88dea5439bce378292 /llvm/lib/DebugInfo/DWARFDebugLine.h
parentfb693085683836d52d7edec3de7a13dd77926ea7 (diff)
downloadbcm5719-llvm-110d595d48033ab2c7dfba0efe833ccc4faf7d6f.tar.gz
bcm5719-llvm-110d595d48033ab2c7dfba0efe833ccc4faf7d6f.zip
[DWARF parser] Cleanup code in DWARFDebugLine.
Streamline parsing and dumping line tables: Prefer composition to multiple inheritance in DWARFDebugLine::ParsingState. Get rid of the weird concept of "DumpingState" structure. was: DWARFDebugLine::DumpingState state(OS); DWARFDebugLine::parseStatementTable(..., state); now: DWARFDebugLine::LineTable LineTable; LineTable.parse(...); LineTable.dump(OS); No functionality change. llvm-svn: 207599
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFDebugLine.h')
-rw-r--r--llvm/lib/DebugInfo/DWARFDebugLine.h54
1 files changed, 19 insertions, 35 deletions
diff --git a/llvm/lib/DebugInfo/DWARFDebugLine.h b/llvm/lib/DebugInfo/DWARFDebugLine.h
index ec73970f0f0..0b3e267c2f8 100644
--- a/llvm/lib/DebugInfo/DWARFDebugLine.h
+++ b/llvm/lib/DebugInfo/DWARFDebugLine.h
@@ -185,6 +185,10 @@ public:
void dump(raw_ostream &OS) const;
void clear();
+ /// Parse prologue and all rows.
+ bool parse(DataExtractor debug_line_data, const RelocAddrMap *RMap,
+ uint32_t *offset_ptr);
+
struct Prologue Prologue;
typedef std::vector<Row> RowVector;
typedef RowVector::const_iterator RowIter;
@@ -194,46 +198,26 @@ public:
SequenceVector Sequences;
};
- struct State : public Row, public Sequence, public LineTable {
- // Special row codes.
- enum {
- StartParsingLineTable = 0,
- DoneParsingLineTable = -1
- };
-
- State() : row(StartParsingLineTable) {}
- virtual ~State();
-
- virtual void appendRowToMatrix(uint32_t offset);
- virtual void finalize();
- virtual void reset() {
- Row::reset(Prologue.DefaultIsStmt);
- Sequence::reset();
- }
-
- // The row number that starts at zero for the prologue, and increases for
- // each row added to the matrix.
- unsigned row;
- };
-
- struct DumpingState : public State {
- DumpingState(raw_ostream &OS) : OS(OS) {}
- virtual ~DumpingState();
- void finalize() override;
- private:
- raw_ostream &OS;
- };
-
- /// Parse a single line table (prologue and all rows).
- static bool parseStatementTable(DataExtractor debug_line_data,
- const RelocAddrMap *RMap,
- uint32_t *offset_ptr, State &state);
-
const LineTable *getLineTable(uint32_t offset) const;
const LineTable *getOrParseLineTable(DataExtractor debug_line_data,
uint32_t offset);
private:
+ struct ParsingState {
+ ParsingState(struct LineTable *LT);
+
+ void resetRowAndSequence();
+ void appendRowToMatrix(uint32_t offset);
+
+ // Line table we're currently parsing.
+ struct LineTable *LineTable;
+ // The row number that starts at zero for the prologue, and increases for
+ // each row added to the matrix.
+ unsigned RowNumber;
+ struct Row Row;
+ struct Sequence Sequence;
+ };
+
typedef std::map<uint32_t, LineTable> LineTableMapTy;
typedef LineTableMapTy::iterator LineTableIter;
typedef LineTableMapTy::const_iterator LineTableConstIter;
OpenPOWER on IntegriCloud