mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Added support for demangling GCC C++ names.
This commit is contained in:
parent
7ba6a4d921
commit
34d50924e8
@ -65,7 +65,20 @@ int application_main(int argc, char **argv)
|
|||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
} catch (const Exception& ex) {
|
} catch (const Exception& ex) {
|
||||||
cout << "---" << endl;
|
cout << "---" << endl;
|
||||||
cout << "Exception: " << typeid(ex).name() << endl;
|
|
||||||
|
string klass = typeid(ex).name();
|
||||||
|
|
||||||
|
#ifdef HAVE_GCC_ABI_DEMANGLE
|
||||||
|
int status;
|
||||||
|
char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
|
||||||
|
|
||||||
|
if (realname != NULL) {
|
||||||
|
klass = string(realname);
|
||||||
|
free(realname);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GCC_ABI_DEMANGLE */
|
||||||
|
|
||||||
|
cout << "Exception: " << klass << endl;
|
||||||
cout << "Message: " << ex.GetMessage() << endl;
|
cout << "Message: " << ex.GetMessage() << endl;
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef I2BASE_H
|
#ifndef I2BASE_H
|
||||||
#define I2BASE_H
|
#define I2BASE_H
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
# include "config.h"
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -17,6 +21,10 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#ifdef HAVE_GCC_ABI_DEMANGLE
|
||||||
|
# include <cxxabi.h>
|
||||||
|
#endif /* HAVE_GCC_ABI_DEMANGLE */
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -3,14 +3,17 @@ dnl Created by Anjuta application wizard.
|
|||||||
|
|
||||||
AC_INIT(icinga, 2.0)
|
AC_INIT(icinga, 2.0)
|
||||||
|
|
||||||
|
AC_CONFIG_AUX_DIR([m4])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.11])
|
AM_INIT_AUTOMAKE([1.11])
|
||||||
|
|
||||||
|
m4_include([m4/ax_cxx_gcc_abi_demangle.m4])
|
||||||
|
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
AX_CXX_GCC_ABI_DEMANGLE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
58
m4/ax_cxx_gcc_abi_demangle.m4
Normal file
58
m4/ax_cxx_gcc_abi_demangle.m4
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# ===========================================================================
|
||||||
|
# http://www.gnu.org/software/autoconf-archive/ax_cxx_gcc_abi_demangle.html
|
||||||
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# AX_CXX_GCC_ABI_DEMANGLE
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# If the compiler supports GCC C++ ABI name demangling (has header
|
||||||
|
# cxxabi.h and abi::__cxa_demangle() function), define
|
||||||
|
# HAVE_GCC_ABI_DEMANGLE
|
||||||
|
#
|
||||||
|
# Adapted from AX_CXX_RTTI by Luc Maisonobe
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Neil Ferguson <nferguso@eso.org>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
#serial 8
|
||||||
|
|
||||||
|
AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE],
|
||||||
|
[AC_CACHE_CHECK(whether the compiler supports GCC C++ ABI name demangling,
|
||||||
|
ax_cv_cxx_gcc_abi_demangle,
|
||||||
|
[AC_LANG_SAVE
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
AC_TRY_COMPILE([#include <stdlib.h>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <cxxabi.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
template<typename TYPE>
|
||||||
|
class A {};
|
||||||
|
],[A<int> instance;
|
||||||
|
int status = 0;
|
||||||
|
char* c_name = 0;
|
||||||
|
|
||||||
|
c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
|
||||||
|
|
||||||
|
std::string name(c_name);
|
||||||
|
free(c_name);
|
||||||
|
|
||||||
|
return name == "A<int>";
|
||||||
|
],
|
||||||
|
ax_cv_cxx_gcc_abi_demangle=yes, ax_cv_cxx_gcc_abi_demangle=no)
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
if test "$ax_cv_cxx_gcc_abi_demangle" = yes; then
|
||||||
|
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE,1,
|
||||||
|
[define if the compiler supports GCC C++ ABI name demangling])
|
||||||
|
fi
|
||||||
|
])
|
Loading…
x
Reference in New Issue
Block a user