From 7e474f218e4683db1e13f2015002629ba52eb751 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 16 Nov 2015 20:21:37 +0100 Subject: [PATCH 2/4] Add backtrace test app. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721 --- cmake/test/CMakeLists.txt | 1 + dbus/dbus-sysdeps.h | 2 ++ test/Makefile.am | 6 ++++- test/manual-backtrace.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 test/manual-backtrace.c diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index eb4b1f1..633ad89 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -73,6 +73,7 @@ add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-segfault ${test-segfault_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_test_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(manual-backtrace ${CMAKE_SOURCE_DIR}/../test/manual-backtrace.c dbus-1) if(WIN32) add_helper_executable(manual-paths ${manual-paths_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) endif() diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index bd0356e..8ffa5de 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -92,6 +92,7 @@ typedef struct DBusPipe DBusPipe; * @{ */ +DBUS_PRIVATE_EXPORT void _dbus_abort (void) _DBUS_GNUC_NORETURN; dbus_bool_t _dbus_check_setuid (void); @@ -516,6 +517,7 @@ dbus_bool_t _dbus_socketpair (DBusSocket *fd1, dbus_bool_t blocking, DBusError *error); +DBUS_PRIVATE_EXPORT void _dbus_print_backtrace (void); dbus_bool_t _dbus_become_daemon (const DBusString *pidfile, diff --git a/test/Makefile.am b/test/Makefile.am index b7f40bb..df5fa42 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -110,6 +110,9 @@ test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) +manual_backtrace_SOURCES = manual-backtrace.c +manual_backtrace_LDADD = $(top_builddir)/dbus/libdbus-1.la + manual_dir_iter_SOURCES = manual-dir-iter.c manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la @@ -132,7 +135,8 @@ installable_tests = \ test-printf \ $(NULL) installable_manual_tests = \ - manual-dir-iter \ + manual-backtrace \ + manual-dir-iter \ manual-tcp \ $(NULL) diff --git a/test/manual-backtrace.c b/test/manual-backtrace.c new file mode 100644 index 0000000..3bd470b --- /dev/null +++ b/test/manual-backtrace.c @@ -0,0 +1,59 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* test-backtrace.c backtrace test app + * + * Copyright (C) 2015 Ralf Habacker + * + * Licensed under the Academic Free License version 2.1 + * + * 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) any later version. + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" + +#include +#include + +#include + +void test2() +{ + _dbus_print_backtrace(); +} + +void test1() +{ + test2(); +} + +void test() +{ + test1(); +} + +int +main (int argc, char **argv) +{ + if (argc == 2) + { + fprintf(stderr, "dbus_abort test\n"); + _dbus_abort (); + } + else + { + test(); + } + return 0; +} -- 1.8.4.5