]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/BackTrace.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_BACKTRACE_H
5 #define CEPH_BACKTRACE_H
22 virtual ~BackTrace() {}
23 virtual void print(std::ostream
& out
) const = 0;
24 virtual void dump(Formatter
*f
) const = 0;
27 inline std::ostream
& operator<<(std::ostream
& out
, const BackTrace
& bt
) {
33 struct ClibBackTrace
: public BackTrace
{
34 const static int max
= 32;
41 explicit ClibBackTrace(int s
) {
42 #ifdef HAVE_EXECINFO_H
44 size
= backtrace(array
, max
);
45 strings
= backtrace_symbols(array
, size
);
56 ClibBackTrace(const ClibBackTrace
& other
);
57 const ClibBackTrace
& operator=(const ClibBackTrace
& other
);
59 void print(std::ostream
& out
) const override
;
60 void dump(Formatter
*f
) const override
;
62 static std::string
demangle(const char* name
);
66 struct PyBackTrace
: public BackTrace
{
67 std::list
<std::string
> strings
;
69 explicit PyBackTrace(std::list
<std::string
>& s
) : strings(s
) {}
71 void dump(Formatter
*f
) const override
;
72 void print(std::ostream
& out
) const override
;