0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-18 07:50:57 +01:00
construct/include/ircd/backtrace.h

52 lines
1.1 KiB
C
Raw Normal View History

2019-09-20 07:02:57 +02:00
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_BACKTRACE_H
namespace ircd
{
struct backtrace;
}
struct ircd::backtrace
{
2020-05-02 22:39:39 +02:00
const void **array;
2019-09-20 07:02:57 +02:00
size_t count;
public:
2020-05-02 22:39:39 +02:00
const void *operator[](const size_t &) const;
2019-09-20 07:02:57 +02:00
const size_t &size() const;
2020-05-02 22:39:39 +02:00
backtrace(const void **const &, const size_t &);
template<size_t SIZE> backtrace(const void *(&)[SIZE]);
2019-09-20 07:02:57 +02:00
backtrace(const mutable_buffer &);
backtrace();
};
template<size_t SIZE>
ircd::backtrace::backtrace(const void *(&buf)[SIZE])
:backtrace{buf, SIZE}
{}
2020-05-02 22:39:39 +02:00
inline const void *
2019-09-20 07:02:57 +02:00
ircd::backtrace::operator[](const size_t &i)
const
{
return i < count? array[i] : nullptr;
}
inline const size_t &
ircd::backtrace::size()
const
{
return count;
}