tools: split out Win64EHDumper from COFFDumper
[oota-llvm.git] / tools / llvm-readobj / Win64EHDumper.h
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
16 #include <functional>
17
18 namespace llvm {
19 namespace object {
20 class COFFObjectFile;
21 class SymbolRef;
22 struct coff_section;
23 }
24
25 namespace Win64EH {
26 class Dumper {
27   StreamWriter &SW;
28   raw_ostream &OS;
29
30 public:
31   typedef std::function<error_code(const object::coff_section *, uint64_t,
32                                    object::SymbolRef &)> SymbolResolver;
33
34   struct Context {
35     const object::COFFObjectFile &COFF;
36     SymbolResolver ResolveSymbol;
37
38     Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver)
39       : COFF(COFF), ResolveSymbol(Resolver) {}
40   };
41
42 private:
43   void printRuntimeFunctionEntry(const Context &Ctx,
44                                  const object::coff_section *Section,
45                                  uint64_t SectionOffset,
46                                  const RuntimeFunction &RF);
47   void printUnwindCode(const UnwindInfo& UI, ArrayRef<UnwindCode> UC);
48   void printUnwindInfo(const Context &Ctx, const object::coff_section *Section,
49                        off_t Offset, const UnwindInfo &UI);
50   void printRuntimeFunction(const Context &Ctx,
51                             const object::coff_section *Section,
52                             uint64_t SectionOffset, const RuntimeFunction &RF);
53
54 public:
55   Dumper(StreamWriter &SW) : SW(SW), OS(SW.getOStream()) {}
56
57   void printData(const Context &Ctx);
58 };
59 }
60 }
61
62 #endif