Cthulhu  0.2.10
Cthulhu compiler collection
panic.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-3.0-only
2 #pragma once
3 
4 #include "editor/compile.hpp"
5 
6 #include "core/source_info.h"
7 #include "backtrace/backtrace.h"
8 
9 #include <string>
10 #include <vector>
11 
12 namespace ed
13 {
14  void install_panic_handler();
15 
17  {
19  size_t line;
20  std::string symbol;
21  std::string file;
22  };
23 
24  class PanicInfo
25  {
26  public:
27  bool has_error = false;
28 
30  std::string message;
31  std::vector<stack_frame_t> frames;
32 
33  bool has_info() const { return has_error; }
34  void reset();
35 
36  void capture_trace(source_info_t location, const char *fmt, va_list args);
37  void draw();
38  };
39 
41  {
45 
47  };
48 
50  {
51  public:
52  bool has_error() const { return code != eCompileOk; }
53 
55 
57  std::string error;
58  };
59 
61 }
bool has_error() const
Definition: panic.hpp:52
std::string error
Definition: panic.hpp:57
ed::PanicInfo panic
Definition: panic.hpp:56
compile_code_t code
Definition: panic.hpp:54
bool has_info() const
Definition: panic.hpp:33
std::vector< stack_frame_t > frames
Definition: panic.hpp:31
std::string message
Definition: panic.hpp:30
void reset()
Definition: panic.cpp:139
source_info_t info
Definition: panic.hpp:29
void draw()
Definition: panic.cpp:156
bool has_error
Definition: panic.hpp:27
void capture_trace(source_info_t location, const char *fmt, va_list args)
Definition: panic.cpp:122
uint_least64_t bt_address_t
an address of a symbol
Definition: backtrace.h:26
CT_NODISCARD STA_FORMAT_STRING const char * fmt
Definition: str.h:68
Definition: compile.hpp:13
void install_panic_handler()
Definition: panic.cpp:17
compile_code_t
Definition: panic.hpp:41
@ eCompilePanic
Definition: panic.hpp:44
@ eCompileOk
Definition: panic.hpp:42
@ eCompileTotal
Definition: panic.hpp:46
@ eCompileError
Definition: panic.hpp:43
CompileError run_compile(Broker &info)
Definition: panic.cpp:25
bt_address_t address
Definition: panic.hpp:18
std::string file
Definition: panic.hpp:21
std::string symbol
Definition: panic.hpp:20
panic location information
Definition: source_info.h:26