Home | History | Annotate | Download | only in ustl-1.0
      1 // This file is part of the ustl library, an STL implementation.
      2 //
      3 // Copyright (C) 2006 by Mike Sharov <msharov (at) users.sourceforge.net>
      4 // This file is free software, distributed under the MIT License.
      5 //
      6 // bktrace.h
      7 //
      8 
      9 #ifndef BKTRACE_H_63ABB1E4388CEDD975DBE58B57DE474F
     10 #define BKTRACE_H_63ABB1E4388CEDD975DBE58B57DE474F
     11 
     12 #include "ulimits.h"
     13 
     14 namespace ustl {
     15 
     16 class ostringstream;
     17 class istream;
     18 class ostream;
     19 
     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);
     34 			CBacktrace (const CBacktrace& v);
     35 		       ~CBacktrace (void);
     36     const CBacktrace&	operator= (const CBacktrace& v);
     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);
     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.
     48 };
     49 
     50 } // namespace ustl
     51 
     52 ALIGNOF(ustl::CBacktrace, sizeof(void*))
     53 
     54 #endif
     55 
     56