ClickHouse/dbms/src/Common/StackTrace.h

27 lines
504 B
C++
Raw Normal View History

2015-10-05 01:11:12 +00:00
#pragma once
#include <string>
#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
StackTrace();
2015-10-05 01:11:12 +00:00
2017-05-07 20:25:26 +00:00
/// Print to string
std::string toString() const;
2015-10-05 01:11:12 +00:00
private:
using Frame = void*;
using Frames = std::array<Frame, STACK_TRACE_MAX_DEPTH>;
Frames frames;
size_t frames_size;
static std::string toStringImpl(const Frames & frames, size_t frames_size);
2015-10-05 01:11:12 +00:00
};