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