X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdebug%2Fbacktrace.cpp;h=f43a9edacccb2655eaaf42e094e4d5f74dd8742f;hb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd;hp=643fdf2bb03288dd16cdd3605e473d675541a479;hpb=55a79fbe96a87183fa4e11049eb161943636b1dd;p=libs%2Fcore.git diff --git a/source/debug/backtrace.cpp b/source/debug/backtrace.cpp index 643fdf2..f43a9ed 100644 --- a/source/debug/backtrace.cpp +++ b/source/debug/backtrace.cpp @@ -4,7 +4,10 @@ This file is part of libmspcore Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#ifndef WIN32 + +// Must include something to test for glibc +#include +#if !defined(WIN32) && defined(__GLIBC__) #include #include #endif @@ -18,31 +21,27 @@ namespace Debug { Backtrace Backtrace::create() { -#ifndef WIN32 +#if !defined(WIN32) && defined(__GLIBC__) void *addresses[50]; - int count=::backtrace(addresses, 50); - - //char **symbols=backtrace_symbols(addresses, count); + int count = ::backtrace(addresses, 50); Backtrace bt; Dl_info dli; for(int i=0; iaddress<<" in "<symbol<<" from "<file<<'\n'; + const list &frames = bt.get_frames(); + for(list::const_iterator i=frames.begin(); i!=frames.end(); ++i) + out<<*i<<'\n'; + + return out; +} + +ostream &operator<<(ostream &out, const Backtrace::StackFrame &sf) +{ + out<