Echo Writes Code

backtrace.hpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CRUCIBLE_WINDOWS_BACKTRACE_HPP
#define CRUCIBLE_WINDOWS_BACKTRACE_HPP

#include "crucible/core/format.hpp"

#include <string>
#include <vector>

namespace crucible::windows::backtrace {
  class Frame final {
  public:
    Frame();

    Frame(std::string const &function, std::string const &file, std::size_t const line);

    [[nodiscard]]
    auto get_function() const -> std::string;

    [[nodiscard]]
    auto get_file() const -> std::string;

    [[nodiscard]]
    auto get_line() const -> std::size_t;

    [[nodiscard]]
    auto format(core::format::Context const &context) const -> std::string;

  private:
    std::string my_function {};

    std::string my_file {};

    std::size_t my_line { 0 };
  };

  [[nodiscard]]
  auto snapshot() -> std::vector<Frame>;
}

#endif // CRUCIBLE_WINDOWS_BACKTRACE_HPP