1//===- Win64EHDumper.h - Win64 EH Printing ----------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_TOOLS_READOBJ_WIN64EHPRINTER_H
11#define LLVM_TOOLS_READOBJ_WIN64EHPRINTER_H
12
13#include "StreamWriter.h"
14#include "llvm/Support/Win64EH.h"
15
16namespace llvm {
17namespace object {
18class COFFObjectFile;
19class SymbolRef;
20struct coff_section;
21}
22
23namespace Win64EH {
24class Dumper {
25  StreamWriter &SW;
26  raw_ostream &OS;
27
28public:
29  typedef std::error_code (*SymbolResolver)(const object::coff_section *,
30                                            uint64_t, object::SymbolRef &,
31                                            void *);
32
33  struct Context {
34    const object::COFFObjectFile &COFF;
35    SymbolResolver ResolveSymbol;
36    void *UserData;
37
38    Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver,
39            void *UserData)
40      : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {}
41  };
42
43private:
44  void printRuntimeFunctionEntry(const Context &Ctx,
45                                 const object::coff_section *Section,
46                                 uint64_t SectionOffset,
47                                 const RuntimeFunction &RF);
48  void printUnwindCode(const UnwindInfo& UI, ArrayRef<UnwindCode> UC);
49  void printUnwindInfo(const Context &Ctx, const object::coff_section *Section,
50                       off_t Offset, const UnwindInfo &UI);
51  void printRuntimeFunction(const Context &Ctx,
52                            const object::coff_section *Section,
53                            uint64_t SectionOffset, const RuntimeFunction &RF);
54
55public:
56  Dumper(StreamWriter &SW) : SW(SW), OS(SW.getOStream()) {}
57
58  void printData(const Context &Ctx);
59};
60}
61}
62
63#endif
64