diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-04-02 11:58:37 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-04-02 11:58:37 +0000 |
| commit | 3cee663e71f6d90ed48eeb5e37de70d14b661eab (patch) | |
| tree | a5449caea1fa4dcf9a12013f0f1ff8688af77655 /llvm/tools/obj2yaml | |
| parent | 07ef786652e7bd2236733a1d209f4f485901eda6 (diff) | |
| download | bcm5719-llvm-3cee663e71f6d90ed48eeb5e37de70d14b661eab.tar.gz bcm5719-llvm-3cee663e71f6d90ed48eeb5e37de70d14b661eab.zip | |
Add minidump support to obj2yaml
Summary:
This patch adds the code needed to parse a minidump file into the
MinidumpYAML model, and the necessary glue code so that obj2yaml can
recognise the minidump files and process them.
Reviewers: jhenderson, zturner, clayborg
Subscribers: mgorny, lldb-commits, amccarth, markmentovai, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59634
llvm-svn: 357469
Diffstat (limited to 'llvm/tools/obj2yaml')
| -rw-r--r-- | llvm/tools/obj2yaml/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | llvm/tools/obj2yaml/minidump2yaml.cpp | 24 | ||||
| -rw-r--r-- | llvm/tools/obj2yaml/obj2yaml.cpp | 3 | ||||
| -rw-r--r-- | llvm/tools/obj2yaml/obj2yaml.h | 3 |
4 files changed, 31 insertions, 0 deletions
diff --git a/llvm/tools/obj2yaml/CMakeLists.txt b/llvm/tools/obj2yaml/CMakeLists.txt index c59fe650952..5bac7c02465 100644 --- a/llvm/tools/obj2yaml/CMakeLists.txt +++ b/llvm/tools/obj2yaml/CMakeLists.txt @@ -13,6 +13,7 @@ add_llvm_tool(obj2yaml dwarf2yaml.cpp elf2yaml.cpp macho2yaml.cpp + minidump2yaml.cpp wasm2yaml.cpp Error.cpp ) diff --git a/llvm/tools/obj2yaml/minidump2yaml.cpp b/llvm/tools/obj2yaml/minidump2yaml.cpp new file mode 100644 index 00000000000..50c883edb27 --- /dev/null +++ b/llvm/tools/obj2yaml/minidump2yaml.cpp @@ -0,0 +1,24 @@ +//===- minidump2yaml.cpp - Minidump to yaml conversion tool -----*- C++ -*-===// +// +// 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 "Error.h" +#include "obj2yaml.h" +#include "llvm/Object/Minidump.h" +#include "llvm/ObjectYAML/MinidumpYAML.h" +#include "llvm/Support/YAMLTraits.h" + +using namespace llvm; + +Error minidump2yaml(raw_ostream &Out, const object::MinidumpFile &Obj) { + auto ExpectedObject = MinidumpYAML::Object::create(Obj); + if (!ExpectedObject) + return ExpectedObject.takeError(); + yaml::Output Output(Out); + Output << *ExpectedObject; + return llvm::Error::success(); +} diff --git a/llvm/tools/obj2yaml/obj2yaml.cpp b/llvm/tools/obj2yaml/obj2yaml.cpp index 1350970096f..9ae861dd13e 100644 --- a/llvm/tools/obj2yaml/obj2yaml.cpp +++ b/llvm/tools/obj2yaml/obj2yaml.cpp @@ -10,6 +10,7 @@ #include "Error.h" #include "llvm/Object/Archive.h" #include "llvm/Object/COFF.h" +#include "llvm/Object/Minidump.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/InitLLVM.h" @@ -40,6 +41,8 @@ static Error dumpInput(StringRef File) { // TODO: If this is an archive, then burst it and dump each entry if (ObjectFile *Obj = dyn_cast<ObjectFile>(&Binary)) return errorCodeToError(dumpObject(*Obj)); + if (MinidumpFile *Minidump = dyn_cast<MinidumpFile>(&Binary)) + return minidump2yaml(outs(), *Minidump); return Error::success(); } diff --git a/llvm/tools/obj2yaml/obj2yaml.h b/llvm/tools/obj2yaml/obj2yaml.h index c7c4956d6bf..c34a6814c5e 100644 --- a/llvm/tools/obj2yaml/obj2yaml.h +++ b/llvm/tools/obj2yaml/obj2yaml.h @@ -13,6 +13,7 @@ #define LLVM_TOOLS_OBJ2YAML_OBJ2YAML_H #include "llvm/Object/COFF.h" +#include "llvm/Object/Minidump.h" #include "llvm/Object/Wasm.h" #include "llvm/Support/raw_ostream.h" #include <system_error> @@ -23,6 +24,8 @@ std::error_code elf2yaml(llvm::raw_ostream &Out, const llvm::object::ObjectFile &Obj); std::error_code macho2yaml(llvm::raw_ostream &Out, const llvm::object::Binary &Obj); +llvm::Error minidump2yaml(llvm::raw_ostream &Out, + const llvm::object::MinidumpFile &Obj); std::error_code wasm2yaml(llvm::raw_ostream &Out, const llvm::object::WasmObjectFile &Obj); |

