Kerning.
[oota-llvm.git] / tools / llvm-dwarfdump / llvm-dwarfdump.cpp
index e73300a0cd8d911ed720e23d392e8546716cab7f..34302fa745f1aef2adb42fb84a399bfb429f45da 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/OwningPtr.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/DebugInfo/DIContext.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/RelocVisitor.h"
-#include "llvm/DebugInfo/DIContext.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
@@ -69,100 +69,8 @@ static void DumpInput(const StringRef &Filename) {
   }
 
   OwningPtr<ObjectFile> Obj(ObjectFile::createObjectFile(Buff.take()));
+  OwningPtr<DIContext> dictx(DIContext::getDWARFContext(Obj.get()));
 
-  StringRef DebugInfoSection;
-  RelocAddrMap RelocMap;
-  StringRef DebugAbbrevSection;
-  StringRef DebugLineSection;
-  StringRef DebugArangesSection;
-  StringRef DebugStringSection;
-  StringRef DebugRangesSection;
-
-  error_code ec;
-  for (section_iterator i = Obj->begin_sections(),
-                        e = Obj->end_sections();
-                        i != e; i.increment(ec)) {
-    StringRef name;
-    i->getName(name);
-    StringRef data;
-    i->getContents(data);
-
-    if (name.startswith("__DWARF,"))
-      name = name.substr(8); // Skip "__DWARF," prefix.
-    name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.
-    if (name == "debug_info")
-      DebugInfoSection = data;
-    else if (name == "debug_abbrev")
-      DebugAbbrevSection = data;
-    else if (name == "debug_line")
-      DebugLineSection = data;
-    else if (name == "debug_aranges")
-      DebugArangesSection = data;
-    else if (name == "debug_str")
-      DebugStringSection = data;
-    else if (name == "debug_ranges")
-      DebugRangesSection = data;
-    // Any more debug info sections go here.
-    else
-      continue;
-
-    // TODO: For now only handle relocations for the debug_info section.
-    if (name != "debug_info")
-      continue;
-
-    if (i->begin_relocations() != i->end_relocations()) {
-      uint64_t SectionSize;
-      i->getSize(SectionSize);
-      for (relocation_iterator reloc_i = i->begin_relocations(),
-                               reloc_e = i->end_relocations();
-                               reloc_i != reloc_e; reloc_i.increment(ec)) {
-        uint64_t Address;
-        reloc_i->getAddress(Address);
-        uint64_t Type;
-        reloc_i->getType(Type);
-
-        RelocVisitor V(Obj->getFileFormatName());
-        // The section address is always 0 for debug sections.
-        RelocToApply R(V.visit(Type, *reloc_i));
-        if (V.error()) {
-          SmallString<32> Name;
-          error_code ec(reloc_i->getTypeName(Name));
-          if (ec) {
-            errs() << "Aaaaaa! Nameless relocation! Aaaaaa!\n";
-          }
-          errs() << "error: failed to compute relocation: "
-                 << Name << "\n";
-          continue;
-        }
-
-        if (Address + R.Width > SectionSize) {
-          errs() << "error: " << R.Width << "-byte relocation starting "
-                 << Address << " bytes into section " << name << " which is "
-                 << SectionSize << " bytes long.\n";
-          continue;
-        }
-        if (R.Width > 8) {
-          errs() << "error: can't handle a relocation of more than 8 bytes at "
-                    "a time.\n";
-          continue;
-        }
-        DEBUG(dbgs() << "Writing " << format("%p", R.Value)
-                     << " at " << format("%p", Address)
-                     << " with width " << format("%d", R.Width)
-                     << "\n");
-        RelocMap[Address] = std::make_pair(R.Width, R.Value);
-      }
-    }
-  }
-
-  OwningPtr<DIContext> dictx(DIContext::getDWARFContext(/*FIXME*/true,
-                                                        DebugInfoSection,
-                                                        DebugAbbrevSection,
-                                                        DebugArangesSection,
-                                                        DebugLineSection,
-                                                        DebugStringSection,
-                                                        DebugRangesSection,
-                                                        RelocMap));
   if (Address == -1ULL) {
     outs() << Filename
            << ":\tfile format " << Obj->getFileFormatName() << "\n\n";