1 //===- Win64EHDumper.h - Win64 EH Printing ----------------------*- 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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H
10 #define LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H
11 
12 #include "llvm/Support/ScopedPrinter.h"
13 #include "llvm/Support/Win64EH.h"
14 
15 namespace llvm {
16 namespace object {
17 class COFFObjectFile;
18 class SymbolRef;
19 struct coff_section;
20 }
21 
22 namespace Win64EH {
23 class Dumper {
24   ScopedPrinter &SW;
25   raw_ostream &OS;
26 
27 public:
28   typedef std::error_code (*SymbolResolver)(const object::coff_section *,
29                                             uint64_t, object::SymbolRef &,
30                                             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(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {}
56 
57   void printData(const Context &Ctx);
58 };
59 }
60 }
61 
62 #endif
63