|
|
|
@ -9,6 +9,9 @@ |
|
|
|
|
@license LGPL, see file <a href="license.html">COPYING</a> |
|
|
|
|
|
|
|
|
|
$Log$ |
|
|
|
|
Revision 1.14 2005/03/11 23:22:58 marc |
|
|
|
|
It's multithreaded now, thanks to a boost mutex |
|
|
|
|
|
|
|
|
|
Revision 1.13 2005/02/18 15:48:56 marc |
|
|
|
|
Dynamic loading of libbfd, no more dependency on specific libbfd version! |
|
|
|
|
|
|
|
|
@ -62,9 +65,8 @@ |
|
|
|
|
#include <sys/mman.h> |
|
|
|
|
#include <bfd.h> |
|
|
|
|
|
|
|
|
|
#ifdef __REENTRANT |
|
|
|
|
#warning "mrw::StackTrace is not thread safe yet!" |
|
|
|
|
#warning "It should work, but is at least untested..." |
|
|
|
|
#ifdef _REENTRANT |
|
|
|
|
#include <boost/thread/recursive_mutex.hpp> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
namespace mrw { |
|
|
|
@ -119,7 +121,7 @@ namespace mrw { |
|
|
|
|
names, sorce file names and line numbers are evaluated. |
|
|
|
|
|
|
|
|
|
@note Method StackTrace::createSymtable must be called exactely |
|
|
|
|
once, before evaluating the first stack trace.Best place is the |
|
|
|
|
once, before evaluating the first stack trace. Best place is the |
|
|
|
|
first line of the @c main function. |
|
|
|
|
|
|
|
|
|
@note Debug information is required for compiling. You nee the |
|
|
|
@ -169,8 +171,8 @@ namespace mrw { |
|
|
|
|
CXXFLAGS="-g -fno-inline" ./configure && make clean check |
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
@todo Add support for alternative symbol evaluation using @c |
|
|
|
|
backtrace_symbols. |
|
|
|
|
@todo Should I add support for alternative symbol evaluation using @c |
|
|
|
|
backtrace_symbols? I think rather not...? |
|
|
|
|
*/ |
|
|
|
|
class StackTrace { |
|
|
|
|
public: |
|
|
|
@ -202,8 +204,8 @@ namespace mrw { |
|
|
|
|
/// evaluate the stack trace and print it to a stream
|
|
|
|
|
const StackTrace& print(std::ostream& os) const throw(std::bad_exception); |
|
|
|
|
/// evaluates and returns all information from a raw address
|
|
|
|
|
static CodePos translate(void* addr) |
|
|
|
|
throw(std::bad_exception); |
|
|
|
|
/** @classmutex _mutex */ |
|
|
|
|
static CodePos translate(void* addr) throw(std::bad_exception); |
|
|
|
|
|
|
|
|
|
/** @brief read the symbol table from the executable file or a
|
|
|
|
|
shared library |
|
|
|
@ -239,6 +241,8 @@ namespace mrw { |
|
|
|
|
@note If this method is called more than once for the same |
|
|
|
|
file, the symbols are created only the first time, so you |
|
|
|
|
don't loose too much time. |
|
|
|
|
|
|
|
|
|
@classmutex _mutex |
|
|
|
|
*/ |
|
|
|
|
static bool createSymtable(const std::string& fname="", void* offs=0) |
|
|
|
|
throw(std::bad_exception); |
|
|
|
@ -266,6 +270,8 @@ namespace mrw { |
|
|
|
|
|
|
|
|
|
@note This method calls the other one for all files in |
|
|
|
|
parameter @c files. |
|
|
|
|
|
|
|
|
|
@classmutex _mutex |
|
|
|
|
*/ |
|
|
|
|
static bool createSymtable(const BinFiles& files) |
|
|
|
|
throw(std::bad_exception); |
|
|
|
@ -282,6 +288,9 @@ namespace mrw { |
|
|
|
|
static std::map<Translator::key_type, std::string> _addrs; |
|
|
|
|
static std::map<std::string, AutoBfd> _bfd; |
|
|
|
|
static std::map<std::string, mrw::AutoPtr<asymbol*> > _syms; |
|
|
|
|
#ifdef _REENTRANT |
|
|
|
|
static boost::recursive_mutex _mutex; |
|
|
|
|
#endif |
|
|
|
|
//................................................................ methods
|
|
|
|
|
static BinFiles filename() throw(std::bad_exception); |
|
|
|
|
static void buildSectionMap(bfd*, asection*, void*) |
|
|
|
|