aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-30 06:45:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-30 06:45:08 +0000
commit74335ff02286376d3cd514af0c723e96d6f3e914 (patch)
treebb9ae7382c012bded1d1229b6fd36f825872c5ac
parentf07cb644b42d3fa140cfed89049e73265a70ec51 (diff)
downloadpaludis-74335ff02286376d3cd514af0c723e96d6f3e914.tar.gz
paludis-74335ff02286376d3cd514af0c723e96d6f3e914.tar.xz
Make more use of __cxa_demangle.
-rw-r--r--test/test_runner.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/test_runner.cc b/test/test_runner.cc
index 38100e2..84aa530 100644
--- a/test/test_runner.cc
+++ b/test/test_runner.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -31,6 +31,11 @@
#include <unistd.h>
#include <sys/types.h>
+#include "config.h"
+#ifdef HAVE_CXA_DEMANGLE
+# include <cxxabi.h>
+#endif
+
/** \file
* Implementation of the default test runner.
*
@@ -50,7 +55,26 @@ namespace
std::cerr << "Stack dump:" << std::endl;
for (unsigned n(0) ; n < sz ; ++n)
- std::cerr << " * " << symbols[n] << std::endl;
+ {
+ std::string sym(symbols[n]);
+
+#ifdef HAVE_CXA_DEMANGLE
+ std::string::size_type p, q;
+ if (std::string::npos != ((p = sym.find("(_Z"))) && std::string::npos != ((q = sym.find("+0x", p))))
+ {
+ ++p;
+ int status(0);
+ char * const name(abi::__cxa_demangle(sym.substr(p, q - p).c_str(), 0, 0, &status));
+ if (0 == status)
+ {
+ sym = sym.substr(0, p) + name + sym.substr(q);
+ std::free(name);
+ }
+ }
+#endif
+
+ std::cerr << " * " << sym << std::endl;
+ }
std::free(symbols);
#endif