1 //===-- PythonExceptionState.h ----------------------------------*- C++ -*-===//
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 LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
11 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
12 
13 #ifndef LLDB_DISABLE_PYTHON
14 
15 #include "PythonDataObjects.h"
16 
17 namespace lldb_private {
18 
19 class PythonExceptionState {
20 public:
21   explicit PythonExceptionState(bool restore_on_exit);
22   ~PythonExceptionState();
23 
24   void Acquire(bool restore_on_exit);
25 
26   void Restore();
27 
28   void Discard();
29 
30   void Reset();
31 
32   static bool HasErrorOccurred();
33 
34   bool IsError() const;
35 
36   PythonObject GetType() const;
37 
38   PythonObject GetValue() const;
39 
40   PythonObject GetTraceback() const;
41 
42   std::string Format() const;
43 
44 private:
45   std::string ReadBacktrace() const;
46 
47   bool m_restore_on_exit;
48 
49   PythonObject m_type;
50   PythonObject m_value;
51   PythonObject m_traceback;
52 };
53 }
54 
55 #endif
56 
57 #endif
58