Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | 00e08fc | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H |
| 11 | #define LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 12 | |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 13 | #include "llvm/Support/ScopedPrinter.h" |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 14 | #include "llvm/Support/Win64EH.h" |
| 15 | |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 16 | namespace llvm { |
| 17 | namespace object { |
| 18 | class COFFObjectFile; |
| 19 | class SymbolRef; |
| 20 | struct coff_section; |
| 21 | } |
| 22 | |
| 23 | namespace Win64EH { |
| 24 | class Dumper { |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 25 | ScopedPrinter &SW; |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 26 | raw_ostream &OS; |
| 27 | |
| 28 | public: |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 29 | typedef std::error_code (*SymbolResolver)(const object::coff_section *, |
| 30 | uint64_t, object::SymbolRef &, |
| 31 | void *); |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 32 | |
| 33 | struct Context { |
| 34 | const object::COFFObjectFile &COFF; |
| 35 | SymbolResolver ResolveSymbol; |
Saleem Abdulrasool | d29bdc7 | 2014-05-25 21:37:59 +0000 | [diff] [blame] | 36 | void *UserData; |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 37 | |
Saleem Abdulrasool | d29bdc7 | 2014-05-25 21:37:59 +0000 | [diff] [blame] | 38 | Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver, |
| 39 | void *UserData) |
| 40 | : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {} |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | private: |
| 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 | |
| 55 | public: |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 56 | Dumper(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {} |
Saleem Abdulrasool | b6a667f | 2014-05-25 20:26:45 +0000 | [diff] [blame] | 57 | |
| 58 | void printData(const Context &Ctx); |
| 59 | }; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | #endif |