summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARFDebugAbbrev.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-09-13 19:42:23 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-09-13 19:42:23 +0000
commitaa2f78f5e6cf071a335f7a05ca48cf4df385a172 (patch)
treed452ecb21885103e72ca6a8df7d7b78abfadeb5a /llvm/lib/DebugInfo/DWARFDebugAbbrev.h
parent88a1d9fc0043f23fe8722cf0949335f41b123f19 (diff)
downloadbcm5719-llvm-aa2f78f5e6cf071a335f7a05ca48cf4df385a172.tar.gz
bcm5719-llvm-aa2f78f5e6cf071a335f7a05ca48cf4df385a172.zip
Sketch out a DWARF parser.
This introduces a new library to LLVM: libDebugInfo. It will provide debug information parsing to LLVM. Much of the design and some of the code is taken from the LLDB project. It also contains an llvm-dwarfdump tool that can dump the abbrevs and DIEs from an object file. It can be used to write tests for DWARF input and output easily. llvm-svn: 139627
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFDebugAbbrev.h')
-rw-r--r--llvm/lib/DebugInfo/DWARFDebugAbbrev.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARFDebugAbbrev.h b/llvm/lib/DebugInfo/DWARFDebugAbbrev.h
new file mode 100644
index 00000000000..eaa79a10144
--- /dev/null
+++ b/llvm/lib/DebugInfo/DWARFDebugAbbrev.h
@@ -0,0 +1,71 @@
+//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
+#define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
+
+#include "DWARFAbbreviationDeclaration.h"
+#include <list>
+#include <map>
+#include <vector>
+
+namespace llvm {
+
+typedef std::vector<DWARFAbbreviationDeclaration>
+ DWARFAbbreviationDeclarationColl;
+typedef DWARFAbbreviationDeclarationColl::iterator
+ DWARFAbbreviationDeclarationCollIter;
+typedef DWARFAbbreviationDeclarationColl::const_iterator
+ DWARFAbbreviationDeclarationCollConstIter;
+
+class DWARFAbbreviationDeclarationSet {
+ uint64_t Offset;
+ uint32_t IdxOffset;
+ std::vector<DWARFAbbreviationDeclaration> Decls;
+ public:
+ DWARFAbbreviationDeclarationSet()
+ : Offset(0), IdxOffset(0) {}
+
+ DWARFAbbreviationDeclarationSet(uint64_t offset, uint32_t idxOffset)
+ : Offset(offset), IdxOffset(idxOffset) {}
+
+ void clear() {
+ IdxOffset = 0;
+ Decls.clear();
+ }
+ uint64_t getOffset() const { return Offset; }
+ void dump(raw_ostream &OS) const;
+ bool extract(DataExtractor data, uint32_t* offset_ptr);
+
+ const DWARFAbbreviationDeclaration *
+ getAbbreviationDeclaration(uint32_t abbrCode) const;
+};
+
+typedef std::map<uint64_t, DWARFAbbreviationDeclarationSet>
+ DWARFAbbreviationDeclarationCollMap;
+typedef DWARFAbbreviationDeclarationCollMap::iterator
+ DWARFAbbreviationDeclarationCollMapIter;
+typedef DWARFAbbreviationDeclarationCollMap::const_iterator
+ DWARFAbbreviationDeclarationCollMapConstIter;
+
+class DWARFDebugAbbrev {
+public:
+ DWARFDebugAbbrev();
+ const DWARFAbbreviationDeclarationSet *
+ getAbbreviationDeclarationSet(uint64_t cu_abbr_offset) const;
+ void dump(raw_ostream &OS) const;
+ void parse(DataExtractor data);
+protected:
+ DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
+ mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
+};
+
+}
+
+#endif
OpenPOWER on IntegriCloud