2015-10-05 01:11:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2018-08-24 08:32:33 +00:00
|
|
|
#include <array>
|
2015-10-05 01:11:12 +00:00
|
|
|
|
|
|
|
#define STACK_TRACE_MAX_DEPTH 32
|
|
|
|
|
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/// Lets you get a stacktrace
|
2015-10-05 01:11:12 +00:00
|
|
|
class StackTrace
|
|
|
|
{
|
|
|
|
public:
|
2017-05-07 20:25:26 +00:00
|
|
|
/// The stacktrace is captured when the object is created
|
2017-04-01 07:20:54 +00:00
|
|
|
StackTrace();
|
2015-10-05 01:11:12 +00:00
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/// Print to string
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string toString() const;
|
2015-10-05 01:11:12 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
using Frame = void*;
|
2018-08-24 08:32:33 +00:00
|
|
|
using Frames = std::array<Frame, STACK_TRACE_MAX_DEPTH>;
|
|
|
|
Frames frames;
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t frames_size;
|
2018-08-24 08:32:33 +00:00
|
|
|
|
|
|
|
static std::string toStringImpl(const Frames & frames, size_t frames_size);
|
2015-10-05 01:11:12 +00:00
|
|
|
};
|