3 This file is part of libmspcore
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
11 #include "backtrace.h"
19 Backtrace Backtrace::create()
23 int count=::backtrace(addresses, 50);
25 //char **symbols=backtrace_symbols(addresses, count);
29 for(int i=0; i<count; ++i)
32 frame.address=addresses[i];
33 if(dladdr(addresses[i], &dli))
35 frame.file=dli.dli_fname;
37 frame.symbol=demangle(dli.dli_sname);
40 frame.file="<unknown>";
41 bt.frames.push_back(frame);
52 ostream &operator<<(ostream &out, const Backtrace &bt)
54 const Backtrace::FrameSeq &frames=bt.get_frames();
55 for(Backtrace::FrameSeq::const_iterator i=frames.begin(); i!=frames.end(); ++i)
56 out<<i->address<<" in "<<i->symbol<<" from "<<i->file<<'\n';