1*0b57cec5SDimitry Andric //===- Win64EHDumper.h - Win64 EH Printing ----------------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #ifndef LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H 10*0b57cec5SDimitry Andric #define LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric #include "llvm/Support/ScopedPrinter.h" 13*0b57cec5SDimitry Andric #include "llvm/Support/Win64EH.h" 14*0b57cec5SDimitry Andric 15*0b57cec5SDimitry Andric namespace llvm { 16*0b57cec5SDimitry Andric namespace object { 17*0b57cec5SDimitry Andric class COFFObjectFile; 18*0b57cec5SDimitry Andric class SymbolRef; 19*0b57cec5SDimitry Andric struct coff_section; 20*0b57cec5SDimitry Andric } 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric namespace Win64EH { 23*0b57cec5SDimitry Andric class Dumper { 24*0b57cec5SDimitry Andric ScopedPrinter &SW; 25*0b57cec5SDimitry Andric raw_ostream &OS; 26*0b57cec5SDimitry Andric 27*0b57cec5SDimitry Andric public: 28*0b57cec5SDimitry Andric typedef std::error_code (*SymbolResolver)(const object::coff_section *, 29*0b57cec5SDimitry Andric uint64_t, object::SymbolRef &, 30*0b57cec5SDimitry Andric void *); 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric struct Context { 33*0b57cec5SDimitry Andric const object::COFFObjectFile &COFF; 34*0b57cec5SDimitry Andric SymbolResolver ResolveSymbol; 35*0b57cec5SDimitry Andric void *UserData; 36*0b57cec5SDimitry Andric ContextContext37*0b57cec5SDimitry Andric Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver, 38*0b57cec5SDimitry Andric void *UserData) 39*0b57cec5SDimitry Andric : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {} 40*0b57cec5SDimitry Andric }; 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric private: 43*0b57cec5SDimitry Andric void printRuntimeFunctionEntry(const Context &Ctx, 44*0b57cec5SDimitry Andric const object::coff_section *Section, 45*0b57cec5SDimitry Andric uint64_t SectionOffset, 46*0b57cec5SDimitry Andric const RuntimeFunction &RF); 47*0b57cec5SDimitry Andric void printUnwindCode(const UnwindInfo& UI, ArrayRef<UnwindCode> UC); 48*0b57cec5SDimitry Andric void printUnwindInfo(const Context &Ctx, const object::coff_section *Section, 49*0b57cec5SDimitry Andric off_t Offset, const UnwindInfo &UI); 50*0b57cec5SDimitry Andric void printRuntimeFunction(const Context &Ctx, 51*0b57cec5SDimitry Andric const object::coff_section *Section, 52*0b57cec5SDimitry Andric uint64_t SectionOffset, const RuntimeFunction &RF); 53*0b57cec5SDimitry Andric 54*0b57cec5SDimitry Andric public: Dumper(ScopedPrinter & SW)55*0b57cec5SDimitry Andric Dumper(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {} 56*0b57cec5SDimitry Andric 57*0b57cec5SDimitry Andric void printData(const Context &Ctx); 58*0b57cec5SDimitry Andric }; 59*0b57cec5SDimitry Andric } 60*0b57cec5SDimitry Andric } 61*0b57cec5SDimitry Andric 62*0b57cec5SDimitry Andric #endif 63