Move -dwarf-version to an MC level command line option so it's
[oota-llvm.git] / tools / llvm-readobj / ARMWinEHPrinter.h
1 //===--- ARMWinEHPrinter.h - Windows on ARM Unwind Information Printer ----===//
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_READOBJ_ARMWINEHPRINTER_H
11 #define LLVM_READOBJ_ARMWINEHPRINTER_H
12
13 #include "StreamWriter.h"
14 #include "llvm/Object/COFF.h"
15 #include "llvm/Support/ErrorOr.h"
16
17 namespace llvm {
18 namespace ARM {
19 namespace WinEH {
20 class RuntimeFunction;
21
22 class Decoder {
23   static const size_t PDataEntrySize;
24
25   StreamWriter &SW;
26   raw_ostream &OS;
27
28   struct RingEntry {
29     uint8_t Mask;
30     uint8_t Value;
31     bool (Decoder::*Routine)(const support::ulittle8_t *, unsigned &, unsigned,
32                              bool);
33   };
34   static const RingEntry Ring[];
35
36   bool opcode_0xxxxxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
37                        unsigned Length, bool Prologue);
38   bool opcode_10Lxxxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
39                        unsigned Length, bool Prologue);
40   bool opcode_1100xxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
41                        unsigned Length, bool Prologue);
42   bool opcode_11010Lxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
43                        unsigned Length, bool Prologue);
44   bool opcode_11011Lxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
45                        unsigned Length, bool Prologue);
46   bool opcode_11100xxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
47                        unsigned Length, bool Prologue);
48   bool opcode_111010xx(const support::ulittle8_t *Opcodes, unsigned &Offset,
49                        unsigned Length, bool Prologue);
50   bool opcode_1110110L(const support::ulittle8_t *Opcodes, unsigned &Offset,
51                        unsigned Length, bool Prologue);
52   bool opcode_11101110(const support::ulittle8_t *Opcodes, unsigned &Offset,
53                        unsigned Length, bool Prologue);
54   bool opcode_11101111(const support::ulittle8_t *Opcodes, unsigned &Offset,
55                        unsigned Length, bool Prologue);
56   bool opcode_11110101(const support::ulittle8_t *Opcodes, unsigned &Offset,
57                        unsigned Length, bool Prologue);
58   bool opcode_11110110(const support::ulittle8_t *Opcodes, unsigned &Offset,
59                        unsigned Length, bool Prologue);
60   bool opcode_11110111(const support::ulittle8_t *Opcodes, unsigned &Offset,
61                        unsigned Length, bool Prologue);
62   bool opcode_11111000(const support::ulittle8_t *Opcodes, unsigned &Offset,
63                        unsigned Length, bool Prologue);
64   bool opcode_11111001(const support::ulittle8_t *Opcodes, unsigned &Offset,
65                        unsigned Length, bool Prologue);
66   bool opcode_11111010(const support::ulittle8_t *Opcodes, unsigned &Offset,
67                        unsigned Length, bool Prologue);
68   bool opcode_11111011(const support::ulittle8_t *Opcodes, unsigned &Offset,
69                        unsigned Length, bool Prologue);
70   bool opcode_11111100(const support::ulittle8_t *Opcodes, unsigned &Offset,
71                        unsigned Length, bool Prologue);
72   bool opcode_11111101(const support::ulittle8_t *Opcodes, unsigned &Offset,
73                        unsigned Length, bool Prologue);
74   bool opcode_11111110(const support::ulittle8_t *Opcodes, unsigned &Offset,
75                        unsigned Length, bool Prologue);
76   bool opcode_11111111(const support::ulittle8_t *Opcodes, unsigned &Offset,
77                        unsigned Length, bool Prologue);
78
79   void decodeOpcodes(ArrayRef<support::ulittle8_t> Opcodes, unsigned Offset,
80                      bool Prologue);
81
82   void printRegisters(const std::pair<uint16_t, uint32_t> &RegisterMask);
83
84   ErrorOr<object::SectionRef>
85   getSectionContaining(const object::COFFObjectFile &COFF, uint64_t Address);
86
87   ErrorOr<object::SymbolRef>
88   getSymbol(const object::COFFObjectFile &COFF, uint64_t Address,
89             bool FunctionOnly = false);
90
91   ErrorOr<object::SymbolRef>
92   getRelocatedSymbol(const object::COFFObjectFile &COFF,
93                      const object::SectionRef &Section, uint64_t Offset);
94
95   bool dumpXDataRecord(const object::COFFObjectFile &COFF,
96                        const object::SectionRef &Section,
97                        uint64_t FunctionAddress, uint64_t VA);
98   bool dumpUnpackedEntry(const object::COFFObjectFile &COFF,
99                          const object::SectionRef Section, uint64_t Offset,
100                          unsigned Index, const RuntimeFunction &Entry);
101   bool dumpPackedEntry(const object::COFFObjectFile &COFF,
102                        const object::SectionRef Section, uint64_t Offset,
103                        unsigned Index, const RuntimeFunction &Entry);
104   bool dumpProcedureDataEntry(const object::COFFObjectFile &COFF,
105                               const object::SectionRef Section, unsigned Entry,
106                               ArrayRef<uint8_t> Contents);
107   void dumpProcedureData(const object::COFFObjectFile &COFF,
108                          const object::SectionRef Section);
109
110 public:
111   Decoder(StreamWriter &SW) : SW(SW), OS(SW.getOStream()) {}
112   std::error_code dumpProcedureData(const object::COFFObjectFile &COFF);
113 };
114 }
115 }
116 }
117
118 #endif
119