1
//! \file
2
/*
3
**  Copyright (C) - Triton
4
**
5
**  This program is under the terms of the Apache License 2.0.
6
*/
7

8
#ifndef TRITON_EXCEPTIONS_H
9
#define TRITON_EXCEPTIONS_H
10

11
#include <exception>
12
#include <string>
13

14
#include <triton/dllexport.hpp>
15
#include <triton/tritonTypes.hpp>
16

17

18

19
//! The Triton namespace
20
namespace triton {
21
/*!
22
 *  \addtogroup triton
23
 *  @{
24
 */
25

26
  //! The Exceptions namespace
27
  namespace exceptions {
28
  /*!
29
   *  \ingroup triton
30
   *  \addtogroup exceptions
31
   *  @{
32
   */
33

34
    /*! \class Exception
35
     *  \brief The root class of all exceptions. */
36
    class Exception : public std::exception {
37
      protected:
38
        //! Defines the exception message.
39
        std::string message;
40

41
      public:
42
        //! Constructor.
43 1
        TRITON_EXPORT Exception(const char* message) {
44 1
          this->message = std::string(message);
45 1
        };
46

47
        //! Constructor.
48 0
        TRITON_EXPORT Exception(const std::string& message) {
49 0
          this->message = message;
50 0
        };
51

52
        //! Destructor.
53 1
        TRITON_EXPORT virtual ~Exception() throw() {
54 1
        };
55

56
        //! Returns the exception message.
57 1
        TRITON_EXPORT const char* what() const throw () {
58 1
          return this->message.c_str();
59
        };
60
    };
61

62

63
    /*! \class Engines
64
     *  \brief The exception class used by all engines. */
65 1
    class Engines : public triton::exceptions::Exception {
66
      public:
67
        //! Constructor.
68 1
        TRITON_EXPORT Engines(const char* message) : triton::exceptions::Exception(message) {};
69

70
        //! Constructor.
71 0
        TRITON_EXPORT Engines(const std::string& message) : triton::exceptions::Exception(message) {};
72
    };
73

74

75
    /*! \class SymbolicEngine
76
     *  \brief The exception class used by the symbolic engine. */
77 1
    class SymbolicEngine : public triton::exceptions::Engines {
78
      public:
79
        //! Constructor.
80 1
        TRITON_EXPORT SymbolicEngine(const char* message) : triton::exceptions::Engines(message) {};
81

82
        //! Constructor.
83
        TRITON_EXPORT SymbolicEngine(const std::string& message) : triton::exceptions::Engines(message) {};
84
    };
85

86

87
    /*! \class SymbolicExpression
88
     *  \brief The exception class used by symbolic expressions. */
89 0
    class SymbolicExpression : public triton::exceptions::SymbolicEngine {
90
      public:
91
        //! Constructor.
92 0
        TRITON_EXPORT SymbolicExpression(const char* message) : triton::exceptions::SymbolicEngine(message) {};
93

94
        //! Constructor.
95
        TRITON_EXPORT SymbolicExpression(const std::string& message) : triton::exceptions::SymbolicEngine(message) {};
96
    };
97

98

99
    /*! \class SymbolicSimplification
100
     *  \brief The exception class used by symbolic simplifications. */
101 0
    class SymbolicSimplification : public triton::exceptions::SymbolicEngine {
102
      public:
103
        //! Constructor.
104 0
        TRITON_EXPORT SymbolicSimplification(const char* message) : triton::exceptions::SymbolicEngine(message) {};
105

106
        //! Constructor.
107
        TRITON_EXPORT SymbolicSimplification(const std::string& message) : triton::exceptions::SymbolicEngine(message) {};
108
    };
109

110

111
    /*! \class SymbolicVariable
112
     *  \brief The exception class used by symbolic variables. */
113 0
    class SymbolicVariable : public triton::exceptions::SymbolicEngine {
114
      public:
115
        //! Constructor.
116 0
        TRITON_EXPORT SymbolicVariable(const char* message) : triton::exceptions::SymbolicEngine(message) {};
117

118
        //! Constructor.
119
        TRITON_EXPORT SymbolicVariable(const std::string& message) : triton::exceptions::SymbolicEngine(message) {};
120
    };
121

122

123
    /*! \class PathConstraint
124
     *  \brief The exception class used by path constraints. */
125 0
    class PathConstraint : public triton::exceptions::SymbolicEngine {
126
      public:
127
        //! Constructor.
128 0
        TRITON_EXPORT PathConstraint(const char* message) : triton::exceptions::SymbolicEngine(message) {};
129

130
        //! Constructor.
131
        TRITON_EXPORT PathConstraint(const std::string& message) : triton::exceptions::SymbolicEngine(message) {};
132
    };
133

134

135
    /*! \class PathManager
136
     *  \brief The exception class used by the path manager. */
137 0
    class PathManager : public triton::exceptions::SymbolicEngine {
138
      public:
139
        //! Constructor.
140 0
        TRITON_EXPORT PathManager(const char* message) : triton::exceptions::SymbolicEngine(message) {};
141

142
        //! Constructor.
143
        TRITON_EXPORT PathManager(const std::string& message) : triton::exceptions::SymbolicEngine(message) {};
144
    };
145

146

147
    /*! \class TaintEngine
148
     *  \brief The exception class used by the taint engine. */
149 0
    class TaintEngine : public triton::exceptions::Engines {
150
      public:
151
        //! Constructor.
152 0
        TRITON_EXPORT TaintEngine(const char* message) : triton::exceptions::Engines(message) {};
153

154
        //! Constructor.
155
        TRITON_EXPORT TaintEngine(const std::string& message) : triton::exceptions::Engines(message) {};
156
    };
157

158

159
    /*! \class SolverEngine
160
     *  \brief The exception class used by the solver engine. */
161 0
    class SolverEngine : public triton::exceptions::Engines {
162
      public:
163
        //! Constructor.
164 0
        TRITON_EXPORT SolverEngine(const char* message) : triton::exceptions::Engines(message) {};
165

166
        //! Constructor.
167 0
        TRITON_EXPORT SolverEngine(const std::string& message) : triton::exceptions::Engines(message) {};
168
    };
169

170

171
    /*! \class SolverModel
172
     *  \brief The exception class used by solver models. */
173
    class SolverModel : public triton::exceptions::SolverEngine {
174
      public:
175
        //! Constructor.
176
        TRITON_EXPORT SolverModel(const char* message) : triton::exceptions::SolverEngine(message) {};
177

178
        //! Constructor.
179
        TRITON_EXPORT SolverModel(const std::string& message) : triton::exceptions::SolverEngine(message) {};
180
    };
181

182

183
    /*! \class API
184
     *  \brief The exception class used by the Triton's API. */
185 0
    class API : public triton::exceptions::Exception {
186
      public:
187
        //! Constructor.
188 0
        TRITON_EXPORT API(const char* message) : triton::exceptions::Exception(message) {};
189

190
        //! Constructor.
191
        TRITON_EXPORT API(const std::string& message) : triton::exceptions::Exception(message) {};
192
    };
193

194

195
    /*! \class Architecture
196
     *  \brief The exception class used by architectures. */
197 1
    class Architecture : public triton::exceptions::Exception {
198
      public:
199
        //! Constructor.
200 1
        TRITON_EXPORT Architecture(const char* message) : triton::exceptions::Exception(message) {};
201

202
        //! Constructor.
203
        TRITON_EXPORT Architecture(const std::string& message) : triton::exceptions::Exception(message) {};
204
    };
205

206

207
    /*! \class BitsVector
208
     *  \brief The exception class used by bitvectors. */
209 0
    class BitsVector : public triton::exceptions::Architecture {
210
      public:
211
        //! Constructor.
212 0
        TRITON_EXPORT BitsVector(const char* message) : triton::exceptions::Architecture(message) {};
213

214
        //! Constructor.
215
        TRITON_EXPORT BitsVector(const std::string& message) : triton::exceptions::Architecture(message) {};
216
    };
217

218

219
    /*! \class Immediate
220
     *  \brief The exception class used by immediates. */
221 0
    class Immediate : public triton::exceptions::Architecture {
222
      public:
223
        //! Constructor.
224 0
        TRITON_EXPORT Immediate(const char* message) : triton::exceptions::Architecture(message) {};
225

226
        //! Constructor.
227
        TRITON_EXPORT Immediate(const std::string& message) : triton::exceptions::Architecture(message) {};
228
    };
229

230

231
    /*! \class Register
232
     *  \brief The exception class used by register operands. */
233 1
    class Register : public triton::exceptions::Architecture {
234
      public:
235
        //! Constructor.
236 1
        TRITON_EXPORT Register(const char* message) : triton::exceptions::Architecture(message) {};
237

238
        //! Constructor.
239
        TRITON_EXPORT Register(const std::string& message) : triton::exceptions::Architecture(message) {};
240
    };
241

242

243
    /*! \class MemoryAccess
244
     *  \brief The exception class used by memory access. */
245 0
    class MemoryAccess : public triton::exceptions::Architecture {
246
      public:
247
        //! Constructor.
248 0
        TRITON_EXPORT MemoryAccess(const char* message) : triton::exceptions::Architecture(message) {};
249

250
        //! Constructor.
251
        TRITON_EXPORT MemoryAccess(const std::string& message) : triton::exceptions::Architecture(message) {};
252
    };
253

254

255
    /*! \class OperandWrapper
256
     *  \brief The exception class used by operand wrappers. */
257 0
    class OperandWrapper : public triton::exceptions::Architecture {
258
      public:
259
        //! Constructor.
260 0
        TRITON_EXPORT OperandWrapper(const char* message) : triton::exceptions::Architecture(message) {};
261

262
        //! Constructor.
263
        TRITON_EXPORT OperandWrapper(const std::string& message) : triton::exceptions::Architecture(message) {};
264
    };
265

266

267
    /*! \class Instruction
268
     *  \brief The exception class used by an instruction. */
269 0
    class Instruction : public triton::exceptions::Architecture {
270
      public:
271
        //! Constructor.
272 0
        TRITON_EXPORT Instruction(const char* message) : triton::exceptions::Architecture(message) {};
273

274
        //! Constructor.
275
        TRITON_EXPORT Instruction(const std::string& message) : triton::exceptions::Architecture(message) {};
276
    };
277

278

279
    /*! \class Cpu
280
     *  \brief The exception class used by all CPUs. */
281 0
    class Cpu : public triton::exceptions::Architecture {
282
      public:
283
        //! Constructor.
284 0
        TRITON_EXPORT Cpu(const char* message) : triton::exceptions::Architecture(message) {};
285

286
        //! Constructor.
287
        TRITON_EXPORT Cpu(const std::string& message) : triton::exceptions::Architecture(message) {};
288
    };
289

290

291
    /*! \class ArmOperandProperties
292
     *  \brief The exception class used by shift mode. */
293 0
    class ArmOperandProperties : public triton::exceptions::Architecture {
294
      public:
295
        //! Constructor.
296 0
        TRITON_EXPORT ArmOperandProperties(const char* message) : triton::exceptions::Architecture(message) {};
297

298
        //! Constructor.
299
        TRITON_EXPORT ArmOperandProperties(const std::string& message) : triton::exceptions::Architecture(message) {};
300
    };
301

302

303
    /*! \class AArch64OperandProperties
304
     *  \brief The exception class used by shift mode. */
305
    class AArch64OperandProperties : public triton::exceptions::Architecture {
306
      public:
307
        //! Constructor.
308
        TRITON_EXPORT AArch64OperandProperties(const char* message) : triton::exceptions::Architecture(message) {};
309

310
        //! Constructor.
311
        TRITON_EXPORT AArch64OperandProperties(const std::string& message) : triton::exceptions::Architecture(message) {};
312
    };
313

314

315
    /*! \class IrBuilder
316
     *  \brief The exception class used by the IR builder. */
317 0
    class IrBuilder : public triton::exceptions::Architecture {
318
      public:
319
        //! Constructor.
320 0
        TRITON_EXPORT IrBuilder(const char* message) : triton::exceptions::Architecture(message) {};
321

322
        //! Constructor.
323
        TRITON_EXPORT IrBuilder(const std::string& message) : triton::exceptions::Architecture(message) {};
324
    };
325

326

327
    /*! \class Disassembly
328
     *  \brief The exception class used by the disassembler. */
329 0
    class Disassembly : public triton::exceptions::Cpu {
330
      public:
331
        //! Constructor.
332 0
        TRITON_EXPORT Disassembly(const char* message) : triton::exceptions::Cpu(message) {};
333

334
        //! Constructor.
335
        TRITON_EXPORT Disassembly(const std::string& message) : triton::exceptions::Cpu(message) {};
336
    };
337

338

339
    /*! \class Semantics
340
     *  \brief The exception class used by all semantics. */
341 0
    class Semantics : public triton::exceptions::Cpu {
342
      public:
343
        //! Constructor.
344 0
        TRITON_EXPORT Semantics(const char* message) : triton::exceptions::Cpu(message) {};
345

346
        //! Constructor.
347
        TRITON_EXPORT Semantics(const std::string& message) : triton::exceptions::Cpu(message) {};
348
    };
349

350

351
    /*! \class Ast
352
     *  \brief The exception class used by all AST nodes. */
353 1
    class Ast : public triton::exceptions::Exception {
354
      public:
355
        //! Constructor.
356 1
        TRITON_EXPORT Ast(const char* message) : triton::exceptions::Exception(message) {};
357

358
        //! Constructor.
359 0
        TRITON_EXPORT Ast(const std::string& message) : triton::exceptions::Exception(message) {};
360
    };
361

362

363
    /*! \class AstRepresentation
364
     *  \brief The exception class used by all AST node representations. */
365 0
    class AstRepresentation : public triton::exceptions::Ast {
366
      public:
367
        //! Constructor.
368 0
        TRITON_EXPORT AstRepresentation(const char* message) : triton::exceptions::Ast(message) {};
369

370
        //! Constructor.
371
        TRITON_EXPORT AstRepresentation(const std::string& message) : triton::exceptions::Ast(message) {};
372
    };
373

374

375
    /*! \class AstTranslations
376
     *  \brief The exception class used by all AST translations (`z3 <-> triton`). */
377 0
    class AstTranslations : public triton::exceptions::Ast {
378
      public:
379
        //! Constructor.
380 0
        TRITON_EXPORT AstTranslations(const char* message) : triton::exceptions::Ast(message) {};
381

382
        //! Constructor.
383 0
        TRITON_EXPORT AstTranslations(const std::string& message) : triton::exceptions::Ast(message) {};
384
    };
385

386

387
    /*! \class Bindings
388
     *  \brief The exception class used by bindings. */
389 0
    class Bindings : public triton::exceptions::Exception {
390
      public:
391
        //! Constructor.
392 0
        TRITON_EXPORT Bindings(const char* message) : triton::exceptions::Exception(message) {};
393

394
        //! Constructor.
395
        TRITON_EXPORT Bindings(const std::string& message) : triton::exceptions::Exception(message) {};
396
    };
397

398

399
    /*! \class Callbacks
400
     *  \brief The exception class used by callbacks. */
401 0
    class Callbacks : public triton::exceptions::Exception {
402
      public:
403
        //! Constructor.
404 0
        TRITON_EXPORT Callbacks(const char* message) : triton::exceptions::Exception(message) {};
405

406
        //! Constructor.
407
        TRITON_EXPORT Callbacks(const std::string& message) : triton::exceptions::Exception(message) {};
408
    };
409

410
    /*! \class Callbacks
411
     *  \brief The exception class used by python callbacks. */
412 0
    class PyCallbacks : public triton::exceptions::Exception {
413
    public:
414
      //! Constructor.
415 0
      TRITON_EXPORT PyCallbacks() : triton::exceptions::Exception("exception info is stored in python state") {};
416
    };
417

418
  /*! @} End of exceptions namespace */
419
  };
420
/*! @} End of exceptions namespace */
421
};
422

423
#endif /* TRITON_EXCEPTIONS_HPP */

Read our documentation on viewing source code .

Loading