1//===------ utils/obj2yaml.hpp - obj2yaml conversion tool -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7// This file declares some helper routines, and also the format-specific
8// writers. To add a new format, add the declaration here, and, in a separate
9// source file, implement it.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_TOOLS_OBJ2YAML_OBJ2YAML_H
13#define LLVM_TOOLS_OBJ2YAML_OBJ2YAML_H
14
15#include "llvm/Object/COFF.h"
16#include "llvm/Object/GOFFObjectFile.h"
17#include "llvm/Object/Minidump.h"
18#include "llvm/Object/Wasm.h"
19#include "llvm/Object/XCOFFObjectFile.h"
20#include "llvm/Support/MemoryBufferRef.h"
21#include "llvm/Support/raw_ostream.h"
22#include <system_error>
23
24enum RawSegments : unsigned { none = 0, data = 1, linkedit = 1 << 1 };
25std::error_code coff2yaml(llvm::raw_ostream &Out,
26 const llvm::object::COFFObjectFile &Obj);
27llvm::Error elf2yaml(llvm::raw_ostream &Out,
28 const llvm::object::ObjectFile &Obj);
29llvm::Error goff2yaml(llvm::raw_ostream &Out,
30 const llvm::object::GOFFObjectFile &Obj);
31llvm::Error macho2yaml(llvm::raw_ostream &Out, const llvm::object::Binary &Obj,
32 unsigned RawSegments);
33llvm::Error minidump2yaml(llvm::raw_ostream &Out,
34 const llvm::object::MinidumpFile &Obj);
35llvm::Error xcoff2yaml(llvm::raw_ostream &Out,
36 const llvm::object::XCOFFObjectFile &Obj);
37std::error_code wasm2yaml(llvm::raw_ostream &Out,
38 const llvm::object::WasmObjectFile &Obj);
39llvm::Error archive2yaml(llvm::raw_ostream &Out, llvm::MemoryBufferRef Source);
40llvm::Error offload2yaml(llvm::raw_ostream &Out, llvm::MemoryBufferRef Source);
41llvm::Error dxcontainer2yaml(llvm::raw_ostream &Out,
42 llvm::MemoryBufferRef Source);
43
44// Forward decls for dwarf2yaml
45namespace llvm {
46class DWARFContext;
47namespace DWARFYAML {
48struct Data;
49}
50} // namespace llvm
51
52llvm::Error dumpDebugAbbrev(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
53llvm::Error dumpDebugAddr(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
54llvm::Error dumpDebugARanges(llvm::DWARFContext &DCtx,
55 llvm::DWARFYAML::Data &Y);
56void dumpDebugPubSections(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
57void dumpDebugInfo(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
58void dumpDebugLines(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
59llvm::Error dumpDebugRanges(llvm::DWARFContext &DCtx, llvm::DWARFYAML::Data &Y);
60llvm::Error dumpDebugStrings(llvm::DWARFContext &DCtx,
61 llvm::DWARFYAML::Data &Y);
62
63#endif
64