]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / source / Plugins / ScriptInterpreter / Python / PythonExceptionState.h
1 //===-- PythonExceptionState.h ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
10 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONEXCEPTIONSTATE_H
11
12 #ifndef LLDB_DISABLE_PYTHON
13
14 #include "PythonDataObjects.h"
15
16 namespace lldb_private {
17
18 class PythonExceptionState {
19 public:
20   explicit PythonExceptionState(bool restore_on_exit);
21   ~PythonExceptionState();
22
23   void Acquire(bool restore_on_exit);
24
25   void Restore();
26
27   void Discard();
28
29   void Reset();
30
31   static bool HasErrorOccurred();
32
33   bool IsError() const;
34
35   PythonObject GetType() const;
36
37   PythonObject GetValue() const;
38
39   PythonObject GetTraceback() const;
40
41   std::string Format() const;
42
43 private:
44   std::string ReadBacktrace() const;
45
46   bool m_restore_on_exit;
47
48   PythonObject m_type;
49   PythonObject m_value;
50   PythonObject m_traceback;
51 };
52 }
53
54 #endif
55
56 #endif