[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenox/konq-embed
From: Luciano Montanaro <mikelima () cirulla ! net>
Date: 2005-09-09 16:40:08
Message-ID: 1126284008.186172.5088.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 459035 by montanaro:
Added kdBacktrace() function to help in konqueror debugging.
M +3 -0 ChangeLog
M +16 -0 dropin/configure.in.in
M +29 -0 dropin/kdebug.cpp
M +9 -1 dropin/kdebug.h
--- trunk/kdenox/konq-embed/ChangeLog #459034:459035
@@ -1,3 +1,6 @@
+2005-09-09 Luciano Montanaro <mikelima@cirulla.net>
+ * Added kdBacktrace() to kdebug.
+
2005-09-02 Luciano Montanaro <mikelima@cirulla.net>
* Fixed a few warnings
--- trunk/kdenox/konq-embed/dropin/configure.in.in #459034:459035
@@ -18,3 +18,19 @@
AC_DEFINE(KHTML_NO_WALLET, 1, [Defined if wallet should not be used])
AC_DEFINE(KHTML_NO_SPELLING, 1, [Defined if spelling is unavailable])
+
+AC_MSG_CHECKING([for GLIBC function backtrace])
+AC_TRY_LINK(dnl
+ [
+ #include <execinfo.h>
+ ],
+ [
+ void* trace[256];
+ backtrace(trace, 256);
+ ],
+ [
+ AC_DEFINE(HAVE_BACKTRACE, 1, [Define if execinfo.h exists and defines backtrace (GLIBC >= 2.1)])
+ AC_MSG_RESULT(yes)
+ ],
+ AC_MSG_RESULT(no)
+)
--- trunk/kdenox/konq-embed/dropin/kdebug.cpp #459034:459035
@@ -47,6 +47,10 @@
#include <errno.h>
#include <string.h>
+#ifdef HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
enum DebugLevels {
KDEBUG_INFO= 0,
KDEBUG_WARN= 1,
@@ -293,3 +297,28 @@
}
return *this;
}
+
+QString kdBacktrace(int levels)
+{
+ QString s;
+#if defined(HAVE_BACKTRACE) && !defined(NDEBUG)
+ void* trace[256];
+ int n = backtrace(trace, 256);
+ if (!n)
+ return s;
+ char** strings = backtrace_symbols (trace, n);
+
+ if ( levels != -1 )
+ n = QMIN( n, levels );
+ s = "[\n";
+
+ for (int i = 0; i < n; ++i)
+ s += QString::number(i) +
+ QString::fromLatin1(": ") +
+ QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
+ s += "]\n";
+ if (strings)
+ free (strings);
+#endif
+ return s;
+}
--- trunk/kdenox/konq-embed/dropin/kdebug.h #459034:459035
@@ -205,8 +205,16 @@
inline kndbgstream kdFatal(bool , int = 0) { return kndbgstream(); }
#endif
-inline QString kdBacktrace() { return QString::null; }
+QString kdBacktrace(int levels);
+inline QString kdBacktrace() {
+#ifdef NDEBUG
+ return QString::null;
+#else
+ return kdBacktrace(10);
+#endif
+}
+
// Needed for kdelibs 3.2
inline kndbgstream kndDebug(int = 0) { return kndbgstream(); }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic