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 20 class PythonExceptionState 21 { 22 public: 23 explicit PythonExceptionState(bool restore_on_exit); 24 ~PythonExceptionState(); 25 26 void 27 Acquire(bool restore_on_exit); 28 29 void 30 Restore(); 31 32 void 33 Discard(); 34 35 void 36 Reset(); 37 38 static bool 39 HasErrorOccurred(); 40 41 bool 42 IsError() const; 43 44 PythonObject 45 GetType() const; 46 47 PythonObject 48 GetValue() const; 49 50 PythonObject 51 GetTraceback() const; 52 53 std::string 54 Format() const; 55 56 private: 57 std::string 58 ReadBacktrace() const; 59 60 bool m_restore_on_exit; 61 62 PythonObject m_type; 63 PythonObject m_value; 64 PythonObject m_traceback; 65 }; 66 } 67 68 #endif 69 70 #endif 71