libcruft-util/cruft/util/backtrace.hpp

43 lines
967 B
C++
Raw Normal View History

2014-09-17 18:20:28 +10:00
/*
2018-08-04 15:14:06 +10:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2014-09-17 18:20:28 +10:00
*
* Copyright 2019, Danny Robson <danny@nerdcruft.net>
2014-09-17 18:20:28 +10:00
*/
#pragma once
2011-05-23 17:18:52 +10:00
#include <vector>
2018-03-22 16:10:06 +11:00
#include <iosfwd>
#include <fmt/core.h>
2011-05-23 17:18:52 +10:00
2014-09-17 18:20:28 +10:00
///////////////////////////////////////////////////////////////////////////////
namespace cruft {
2011-05-23 17:18:52 +10:00
class backtrace {
public:
backtrace (void);
2011-05-23 17:18:52 +10:00
2018-07-24 15:46:28 +10:00
const auto& frames(void) const { return m_frames; }
private:
std::vector<void *> m_frames;
2011-05-23 17:18:52 +10:00
};
2012-05-10 16:53:29 +10:00
std::ostream&
operator<< (std::ostream&, backtrace const&);
2011-05-23 17:18:52 +10:00
}
template <>
struct fmt::formatter<cruft::backtrace> {
constexpr format_parse_context::iterator
parse (format_parse_context &ctx)
{
return ctx.begin ();
}
format_context::iterator
2024-10-16 12:19:35 +11:00
format (cruft::backtrace const&, format_context &ctx) const;
};