X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdebug%2Fbacktrace.cpp;h=5e96005538eed6830bcb87b6e0e967467aa4af2b;hb=9f2774a500d779af9a38f42bfb03b507444a47b0;hp=2078996c41d234bb138f8cb29c4805e7894cd9ab;hpb=521cf1db00f8ce2d9f9494dca503d6c17d89ac2f;p=libs%2Fcore.git diff --git a/source/debug/backtrace.cpp b/source/debug/backtrace.cpp index 2078996..5e96005 100644 --- a/source/debug/backtrace.cpp +++ b/source/debug/backtrace.cpp @@ -4,8 +4,15 @@ This file is part of libmspcore Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + +// Must include something to test for glibc +#include +#if !defined(WIN32) && defined(__GLIBC__) +#include #include +#endif #include "backtrace.h" +#include "demangle.h" using namespace std; @@ -14,17 +21,26 @@ 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); - Backtrace bt; + Dl_info dli; for(int i=0; iaddress<<" in "<symbol<<'\n'; + out<address<<" in "<symbol<<" from "<file<<'\n'; return out; }