From 443c9c1db5dc2b3eb8fb754ff3b63f0b7d68e7e1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 24 Oct 2016 16:48:53 +0200 Subject: [PATCH] Remove QSegfaultHandler class The origin of the class predate git history, but it has been apparently unused in Qt since Qt 4.5 times. Removing this relieves us from documenting its custom license. Change-Id: Ie91be5f0b2fbaf10dc212c44ebd37e6b9d781592 Reviewed-by: Lars Knoll --- src/corelib/kernel/kernel.pri | 2 - src/corelib/kernel/qcrashhandler.cpp | 421 --------------------------- src/corelib/kernel/qcrashhandler_p.h | 79 ----- 3 files changed, 502 deletions(-) delete mode 100644 src/corelib/kernel/qcrashhandler.cpp delete mode 100644 src/corelib/kernel/qcrashhandler_p.h diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index a78397e46c6..7799113d30a 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -140,14 +140,12 @@ nacl { unix|integrity { SOURCES += \ kernel/qcore_unix.cpp \ - kernel/qcrashhandler.cpp \ kernel/qeventdispatcher_unix.cpp \ kernel/qtimerinfo_unix.cpp !darwin|nacl: SOURCES += kernel/qelapsedtimer_unix.cpp HEADERS += \ kernel/qcore_unix_p.h \ - kernel/qcrashhandler_p.h \ kernel/qeventdispatcher_unix_p.h \ kernel/qpoll_p.h \ kernel/qtimerinfo_unix_p.h diff --git a/src/corelib/kernel/qcrashhandler.cpp b/src/corelib/kernel/qcrashhandler.cpp deleted file mode 100644 index 46bb8b7c117..00000000000 --- a/src/corelib/kernel/qcrashhandler.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/************************************************************************* - * - * stacktrace.c 1.2 1998/12/21 - * - * Copyright (c) 1998 by Bjorn Reese - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#include "qplatformdefs.h" -#include "private/qcrashhandler_p.h" -#include "qbytearray.h" // for qvsnprintf() - -#ifndef QT_NO_CRASHHANDLER - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QtCrashHandler QSegfaultHandler::callback = 0; - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__) && !defined(QT_LINUXBASE) -QT_BEGIN_INCLUDE_NAMESPACE -# include "qstring.h" -# include -QT_END_INCLUDE_NAMESPACE - -static void print_backtrace(FILE *outb) -{ - void *stack[128]; - int stack_size = backtrace(stack, sizeof(stack) / sizeof(void *)); - char **stack_symbols = backtrace_symbols(stack, stack_size); - fprintf(outb, "Stack [%d]:\n", stack_size); - if(FILE *cppfilt = popen("c++filt", "rw")) { - dup2(fileno(outb), fileno(cppfilt)); - for(int i = stack_size-1; i>=0; --i) - fwrite(stack_symbols[i], 1, strlen(stack_symbols[i]), cppfilt); - pclose(cppfilt); - } else { - for(int i = stack_size-1; i>=0; --i) - fprintf(outb, "#%d %p [%s]\n", i, stack[i], stack_symbols[i]); - } -} -static void init_backtrace(char **, int) -{ -} - -#else /* Don't use the GLIBC callback */ -/* Code sourced from: */ -QT_BEGIN_INCLUDE_NAMESPACE -#include -#include -#include -#include -#include -#if defined(Q_OS_IRIX) && defined(USE_LIBEXC) -# include -#endif -QT_END_INCLUDE_NAMESPACE - - -static char *globalProgName = NULL; -static bool backtrace_command(FILE *outb, const char *format, ...) -{ - - bool ret = false; - char buffer[50]; - - /* - * Please note that vsnprintf() is not ASync safe (ie. cannot safely - * be used from a signal handler.) If this proves to be a problem - * then the cmd string can be built by more basic functions such as - * strcpy, strcat, and a home-made integer-to-ascii function. - */ - va_list args; - char cmd[512]; - va_start(args, format); - qvsnprintf(cmd, 512, format, args); - va_end(args); - - char *foo = cmd; -#if 0 - foo = "echo hi"; -#endif - if(FILE *inb = popen(foo, "r")) { - while(!feof(inb)) { - int len = fread(buffer, 1, sizeof(buffer), inb); - if(!len) - break; - if(!ret) { - fwrite("Output from ", 1, strlen("Output from "), outb); - strtok(cmd, " "); - fwrite(cmd, 1, strlen(cmd), outb); - fwrite("\n", 1, 1, outb); - ret = true; - } - fwrite(buffer, 1, len, outb); - } - fclose(inb); - } - return ret; -} - -static void init_backtrace(char **argv, int argc) -{ - if(argc >= 1) - globalProgName = argv[0]; -} - -static void print_backtrace(FILE *outb) -{ - /* - * In general dbx seems to do a better job than gdb. - * - * Different dbx implementations require different flags/commands. - */ -#if defined(Q_OS_AIX) - if(backtrace_command(outb, "dbx -a %d 2>/dev/null </dev/null </dev/null <&1 </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null <&1 < </dev/null </dev/null < - -#ifndef QT_NO_CRASHHANDLER - -QT_BEGIN_NAMESPACE - -typedef void (*QtCrashHandler)(); - -class Q_CORE_EXPORT QSegfaultHandler -{ - friend void qt_signal_handler(int); - static QtCrashHandler callback; -public: - static void initialize(char **, int); - - inline static void installCrashHandler(QtCrashHandler h) { callback = h; } - inline static QtCrashHandler crashHandler() { return callback; } - -private: -}; - -QT_END_NAMESPACE - -#endif // QT_NO_CRASHHANDLER - -#endif // QCRASHHANDLER_P_H