Added debug function to print a stack trace
This commit is contained in:
parent
04d5b12f8b
commit
0c48c00fa7
4 changed files with 40 additions and 0 deletions
|
@ -28,6 +28,7 @@ set(kdeconnectcore_SRCS
|
|||
filetransferjob.cpp
|
||||
daemon.cpp
|
||||
device.cpp
|
||||
core_debug.cpp
|
||||
)
|
||||
|
||||
add_library(kdeconnectcore ${kdeconnectcore_SRCS})
|
||||
|
|
36
core/core_debug.cpp
Normal file
36
core/core_debug.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "core_debug.h"
|
||||
|
||||
#include <execinfo.h>
|
||||
#include <stdlib.h>
|
||||
#include <execinfo.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void logBacktrace()
|
||||
{
|
||||
void *array[32];
|
||||
size_t size = backtrace (array, 32);
|
||||
char **strings = backtrace_symbols (array, size);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
free (strings);
|
||||
}
|
|
@ -27,4 +27,6 @@
|
|||
|
||||
KDECONNECTCORE_EXPORT Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_CORE)
|
||||
|
||||
void logBacktrace();
|
||||
|
||||
#endif //CORE_DEBUG_H
|
||||
|
|
|
@ -50,6 +50,7 @@ set(lanlinkprovidertest_sources
|
|||
../core/backends/pairinghandler.cpp
|
||||
../core/device.cpp
|
||||
../core/pluginloader.cpp
|
||||
../core/core_debug.cpp
|
||||
)
|
||||
ecm_add_test(lanlinkprovidertest.cpp ${lanlinkprovidertest_sources} TEST_NAME lanlinkprovidertest LINK_LIBRARIES ${kdeconnect_libraries})
|
||||
|
||||
|
|
Loading…
Reference in a new issue