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
|
|
|
*
|
2019-07-02 16:37:43 +10:00
|
|
|
* Copyright 2019, Danny Robson <danny@nerdcruft.net>
|
2014-09-17 18:20:28 +10:00
|
|
|
*/
|
|
|
|
|
2019-07-02 16:37:43 +10:00
|
|
|
#pragma once
|
2011-05-23 17:18:52 +10:00
|
|
|
|
|
|
|
#include <vector>
|
2018-03-22 16:10:06 +11:00
|
|
|
#include <iosfwd>
|
2023-07-21 14:20:49 +10:00
|
|
|
#include <fmt/core.h>
|
2011-05-23 17:18:52 +10:00
|
|
|
|
2014-09-17 18:20:28 +10:00
|
|
|
|
2019-07-02 16:37:43 +10:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace cruft {
|
2011-05-23 17:18:52 +10:00
|
|
|
class backtrace {
|
2016-04-19 16:08:56 +10:00
|
|
|
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; }
|
2019-07-02 16:37:43 +10:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<void *> m_frames;
|
2011-05-23 17:18:52 +10:00
|
|
|
};
|
2012-05-10 16:53:29 +10:00
|
|
|
|
|
|
|
std::ostream&
|
2019-07-02 16:37:43 +10:00
|
|
|
operator<< (std::ostream&, backtrace const&);
|
2011-05-23 17:18:52 +10:00
|
|
|
}
|
2023-07-21 14:20:49 +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;
|
2023-07-21 14:20:49 +10:00
|
|
|
};
|