From 5bb41966dbc963d39c9660de7c9bbd7bcc2b9553 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sat, 17 Aug 2013 13:21:22 +0200 Subject: [PATCH] Added check the conditions for building backtrace handler (cherry picked from commit 35748811a4b11b5947879f657a752e89d649ce06) --- CMakeLists.txt | 1 + config.h.cmake | 3 +++ kio/kio/CMakeLists.txt | 9 +++++++-- kio/kio/slavebase.cpp | 10 ++++------ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ef080e1..3f5075505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,7 @@ check_include_file( "termio.h" HAVE_TERMIO_H ) check_include_file( "unistd.h" HAVE_UNISTD_H ) check_include_file( "util.h" HAVE_UTIL_H ) check_include_file( "values.h" HAVE_VALUES_H ) +check_include_file( "demangle.h" HAVE_DEMANGLE_H ) # FIXME I'm not sure if test TIME_WITH_SYS_TIME are correct check_include_file( "sys/time.h" HAVE_SYS_TIME_H ) diff --git a/config.h.cmake b/config.h.cmake index 30402b1f8..59dc20622 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -650,6 +650,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_VALUES_H 1 +/* Define to 1 if you have the header file from binutils package. */ +#cmakedefine HAVE_DEMANGLE_H 1 + /* Define, to enable volume management (Solaris 2.x), if you have -lvolmgt */ #undef HAVE_VOLMGT diff --git a/kio/kio/CMakeLists.txt b/kio/kio/CMakeLists.txt index 17d33feb2..ebc7dc2ed 100644 --- a/kio/kio/CMakeLists.txt +++ b/kio/kio/CMakeLists.txt @@ -80,13 +80,18 @@ set( ${target}_SRCS kdirnotify.cpp kdirnotify.skel kdirnotify_stub.cpp observer.cpp ../misc/uiserver.stub observer.skel kemailsettings.cpp kprotocolinfo.cpp renamedlg.cpp skipdlg.cpp kremoteencoding.cpp - kmimetypechooser.cpp backtrace_symbols.c + kmimetypechooser.cpp ) +if( HAVE_BACKTRACE AND HAVE_DEMANGLE_H ) + list( APPEND ${target}_SRCS backtrace_symbols.c ) + set( BACKTRACE_LIBRARY bfd ) +endif( ) + tde_add_library( ${target} STATIC_PIC AUTOMOC SOURCES ${${target}_SRCS} DEPENDENCIES dcopidl - LINK bfd + LINK ${BACKTRACE_LIBRARY} ) diff --git a/kio/kio/slavebase.cpp b/kio/kio/slavebase.cpp index fca510744..a975fd7bc 100644 --- a/kio/kio/slavebase.cpp +++ b/kio/kio/slavebase.cpp @@ -66,10 +66,10 @@ #endif #endif -#ifndef NDEBUG -#ifdef HAVE_BACKTRACE +#ifndef NDEBUG void print_trace() { +#if defined(HAVE_BACKTRACE) && defined(HAVE_DEMANGLE_H) void *array[10]; size_t size; char **strings; @@ -85,9 +85,9 @@ void print_trace() } free (strings); +#endif // defined(HAVE_BACKTRACE) && defined(HAVE_DEMANGLE_H) } -#endif -#endif +#endif // NDEBUG using namespace KIO; @@ -765,9 +765,7 @@ void SlaveBase::sigsegv_handler(int sig) snprintf(buffer, sizeof(buffer), "kioslave: ####### CRASH ###### protocol = %s pid = %d signal = %d\n", s_protocol, getpid(), sig); write(2, buffer, strlen(buffer)); #ifndef NDEBUG -#ifdef HAVE_BACKTRACE print_trace(); -#endif #endif ::exit(1); #endif