Build system improvements
[ustl.git] / bktrace.h
blobd5ae2358d7d876f7684111074273c3296677b4ae
1 // This file is part of the ustl library, an STL implementation.
2 //
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
5 //
6 // bktrace.h
7 //
9 #ifndef BKTRACE_H_63ABB1E4388CEDD975DBE58B57DE474F
10 #define BKTRACE_H_63ABB1E4388CEDD975DBE58B57DE474F
12 #include "ulimits.h"
14 namespace ustl {
16 class ostringstream;
17 class istream;
18 class ostream;
20 /// \class CBacktrace bktrace.h ustl.h
21 ///
22 /// \brief Stores the backtrace from the point of construction.
23 ///
24 /// The backtrace, or callstack, is the listing of functions called to
25 /// reach the construction of this object. This is useful for debugging,
26 /// to print the location of an error. To get meaningful output you'll
27 /// need to use a debug build with symbols and with frame pointers. For
28 /// GNU ld you will also need to link with the -rdynamic option to see
29 /// actual function names instead of __gxx_personality0+0xF4800.
30 ///
31 class CBacktrace {
32 public:
33 CBacktrace (void) throw();
34 CBacktrace (const CBacktrace& v) throw();
35 ~CBacktrace (void) throw();
36 const CBacktrace& operator= (const CBacktrace& v) throw();
37 void text_write (ostringstream& os) const;
38 void read (istream& is);
39 void write (ostream& os) const;
40 size_t stream_size (void) const;
41 private:
42 void GetSymbols (void) throw() DLL_LOCAL;
43 private:
44 void* m_Addresses [64]; ///< Addresses of each function on the stack.
45 char* m_Symbols; ///< Symbols corresponding to each address.
46 uint32_t m_nFrames; ///< Number of addresses in m_Addresses.
47 uint32_t m_SymbolsSize; ///< Size of m_Symbols.
50 } // namespace ustl
52 ALIGNOF(ustl::CBacktrace, sizeof(void*))
54 #endif