tools: avoid use of std::function
[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 namespace llvm {
17 namespace object {
18 class COFFObjectFile;
19 class SymbolRef;
20 struct coff_section;
21 }
22
23 namespace Win64EH {
24 class Dumper {
25   StreamWriter &SW;
26   raw_ostream &OS;
27
28 public:
29   typedef error_code (*SymbolResolver)(const object::coff_section *, uint64_t,
30                                        object::SymbolRef &, void *);
31
32   struct Context {
33     const object::COFFObjectFile &COFF;
34     SymbolResolver ResolveSymbol;
35     void *UserData;
36
37     Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver,
38             void *UserData)
39       : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {}
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