1 /* 2 * vim: filetype=c:tabstop=4:ai:expandtab 3 * SPDX-License-Identifier: BSD-2-Clause 4 * scspell-id: 14a58b2b-3c43-11ed-a845-80ee73e9b8e7 5 * 6 * ------------------------------------------------------------------------- 7 * 8 * backtrace_main.c 9 * 10 * libbacktrace (https://github.com/ianlancetaylor/libbacktrace) start-up. 11 * 12 * ------------------------------------------------------------------------- 13 * 14 * Copyright (c) 2021-2023 Jeffrey H. Johnson 15 * Copyright (c) 2022-2024 The DPS8M Development Team 16 * 17 * All rights reserved. 18 * 19 * Redistribution and use in source and binary forms, with or without 20 * modification, are permitted provided that the following conditions are 21 * met: 22 * 23 * * Redistributions of source code must retain the above copyright 24 * notice, this list of conditions and the following disclaimer. 25 * 26 * * Redistributions in binary form must reproduce the above copyright 27 * notice, this list of conditions and the following disclaimer in the 28 * documentation and/or other materials provided with the distribution. 29 * 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 * 42 * ------------------------------------------------------------------------- 43 */ 44 45 #if defined(USE_BACKTRACE) 46 # if defined(_INC_BACKTRACE_FUNC) 47 # if !defined(_INC_BACKTRACE_MAIN) 48 # define _INC_BACKTRACE_MAIN 49 # if !defined(BACKTRACE_SKIP) 50 # define BACKTRACE_SKIP 1 51 # endif /* if !defined(BACKTRACE_SKIP) */ 52 # include <signal.h> 53 # if defined(SIGSEGV) 54 (void)signal(SIGSEGV, backtrace_handler); 55 # endif /* if defined(SIGSEGV) */ 56 # if defined(SIGILL) 57 (void)signal(SIGILL, backtrace_handler); 58 # endif /* if defined(SIGILL) */ 59 # if defined(SIGFPE) 60 (void)signal(SIGFPE, backtrace_handler); 61 # endif /* if defined(SIGFPE) */ 62 # if defined(SIGBUS) 63 (void)signal(SIGBUS, backtrace_handler); 64 # endif /* if defined(SIGBUS) */ 65 # if defined(SIGUNUSED) 66 (void)signal(SIGUNUSED, backtrace_handler); 67 # endif /* if defined(SIGUNUSED) */ 68 # if defined(SIGSYS) 69 (void)signal(SIGSYS, backtrace_handler); 70 # endif /* if defined(SIGSYS) */ 71 # if defined(SIGUSR2) 72 (void)signal(SIGUSR2, backtrace_handler); 73 # endif /* if defined(SIGUSR2) */ 74 # if defined(SIGSTKFLT) 75 (void)signal(SIGSTKFLT, backtrace_handler); 76 # endif /* if defined(SIGSTKFLT) */ 77 # if defined(SIGPOWER) 78 # if defined(SIG_IGN) 79 (void)signal(SIGPOWER, SIG_IGN); 80 # endif /* if defined(SIG_IGN) */ 81 # endif /* if defined(SIGPOWER) */ 82 # if defined(SIGPWR) 83 # if defined(SIG_IGN) 84 (void)signal(SIGPWR, SIG_IGN); 85 # endif /* if defined(SIG_IGN) */ 86 # endif /* if defined(SIGPWR) */ 87 state = backtrace_create_state( 88 NULL, BACKTRACE_SUPPORTS_THREADS, error_callback, NULL); 89 # endif /* if !defined(_INC_BACKTRACE_MAIN) */ 90 # endif /* if defined(_INC_BACKTRACE_FUNC) */ 91 #endif /* if defined(USE_BACKTRACE) */