17f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//===- Win64EHDumper.h - Win64 EH Printing ----------------------*- C++ -*-===//
27f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//
37f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//                     The LLVM Compiler Infrastructure
47f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//
57f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project// This file is distributed under the University of Illinois Open Source
67f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project// License. See LICENSE.TXT for details.
77f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//
87f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project//===----------------------------------------------------------------------===//
97f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#ifndef LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H
117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#define LLVM_TOOLS_LLVM_READOBJ_WIN64EHDUMPER_H
127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "llvm/Support/ScopedPrinter.h"
147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "llvm/Support/Win64EH.h"
157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectnamespace llvm {
177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectnamespace object {
187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectclass COFFObjectFile;
197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectclass SymbolRef;
207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectstruct coff_section;
217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectnamespace Win64EH {
247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectclass Dumper {
257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  ScopedPrinter &SW;
267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  raw_ostream &OS;
277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectpublic:
297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  typedef std::error_code (*SymbolResolver)(const object::coff_section *,
307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                                            uint64_t, object::SymbolRef &,
317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                                            void *);
327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  struct Context {
347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project    const object::COFFObjectFile &COFF;
357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project    SymbolResolver ResolveSymbol;
367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project    void *UserData;
377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project    Context(const object::COFFObjectFile &COFF, SymbolResolver Resolver,
397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project            void *UserData)
407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project      : COFF(COFF), ResolveSymbol(Resolver), UserData(UserData) {}
417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  };
427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectprivate:
447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  void printRuntimeFunctionEntry(const Context &Ctx,
457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                                 const object::coff_section *Section,
467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                                 uint64_t SectionOffset,
477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                                 const RuntimeFunction &RF);
487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  void printUnwindCode(const UnwindInfo& UI, ArrayRef<UnwindCode> UC);
497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  void printUnwindInfo(const Context &Ctx, const object::coff_section *Section,
507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                       off_t Offset, const UnwindInfo &UI);
517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  void printRuntimeFunction(const Context &Ctx,
527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                            const object::coff_section *Section,
537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                            uint64_t SectionOffset, const RuntimeFunction &RF);
547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectpublic:
567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  Dumper(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {}
577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  void printData(const Context &Ctx);
597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project};
607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#endif
647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project