diff tools/obj2yaml/obj2yaml.cpp @ 148:63bd29f05246

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 19:46:37 +0900
parents c2174574ed3a
children
line wrap: on
line diff
--- a/tools/obj2yaml/obj2yaml.cpp	Sun Dec 23 19:23:36 2018 +0900
+++ b/tools/obj2yaml/obj2yaml.cpp	Wed Aug 14 19:46:37 2019 +0900
@@ -1,33 +1,36 @@
 //===------ utils/obj2yaml.cpp - obj2yaml conversion tool -------*- C++ -*-===//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 
+#include "obj2yaml.h"
 #include "Error.h"
-#include "obj2yaml.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/COFF.h"
+#include "llvm/Object/Minidump.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/PrettyStackTrace.h"
-#include "llvm/Support/Signals.h"
+#include "llvm/Support/InitLLVM.h"
 
 using namespace llvm;
 using namespace llvm::object;
 
-static std::error_code dumpObject(const ObjectFile &Obj) {
+static Error dumpObject(const ObjectFile &Obj) {
   if (Obj.isCOFF())
-    return coff2yaml(outs(), cast<COFFObjectFile>(Obj));
+    return errorCodeToError(coff2yaml(outs(), cast<COFFObjectFile>(Obj)));
+
+  if (Obj.isXCOFF())
+    return errorCodeToError(xcoff2yaml(outs(), cast<XCOFFObjectFile>(Obj)));
+
   if (Obj.isELF())
     return elf2yaml(outs(), Obj);
+
   if (Obj.isWasm())
-    return wasm2yaml(outs(), cast<WasmObjectFile>(Obj));
+    return errorCodeToError(wasm2yaml(outs(), cast<WasmObjectFile>(Obj)));
 
-  return obj2yaml_error::unsupported_obj_file_format;
+  return errorCodeToError(obj2yaml_error::unsupported_obj_file_format);
 }
 
 static Error dumpInput(StringRef File) {
@@ -42,7 +45,9 @@
     return errorCodeToError(macho2yaml(outs(), Binary));
   // TODO: If this is an archive, then burst it and dump each entry
   if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary))
-    return errorCodeToError(dumpObject(*Obj));
+    return dumpObject(*Obj);
+  if (MinidumpFile *Minidump = dyn_cast<MinidumpFile>(&Binary))
+    return minidump2yaml(outs(), *Minidump);
 
   return Error::success();
 }
@@ -52,7 +57,7 @@
     Input = "<stdin>";
   std::string ErrMsg;
   raw_string_ostream OS(ErrMsg);
-  logAllUnhandledErrors(std::move(Err), OS, "");
+  logAllUnhandledErrors(std::move(Err), OS);
   OS.flush();
   errs() << "Error reading file: " << Input << ": " << ErrMsg;
   errs().flush();
@@ -62,10 +67,8 @@
                                    cl::init("-"));
 
 int main(int argc, char *argv[]) {
+  InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
-  sys::PrintStackTraceOnErrorSignal(argv[0]);
-  PrettyStackTraceProgram X(argc, argv);
-  llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
 
   if (Error Err = dumpInput(InputFilename)) {
     reportError(InputFilename, std::move(Err));