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-2022 Jeffrey H. Johnson <trnsz@pobox.com> 15 * Copyright (c) 2022 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 #ifdef USE_BACKTRACE 46 # ifdef _INC_BACKTRACE_FUNC 47 # ifndef _INC_BACKTRACE_MAIN 48 # define _INC_BACKTRACE_MAIN 49 # ifndef BACKTRACE_SKIP 50 # define BACKTRACE_SKIP 1 51 # endif /* ifndef BACKTRACE_SKIP */ 52 # include <signal.h> 53 # ifdef SIGSEGV 54 (void)signal(SIGSEGV, backtrace_handler); 55 # endif /* ifdef SIGSEGV */ 56 # ifdef SIGILL 57 (void)signal(SIGILL, backtrace_handler); 58 # endif /* ifdef SIGILL */ 59 # ifdef SIGFPE 60 (void)signal(SIGFPE, backtrace_handler); 61 # endif /* ifdef SIGFPE */ 62 # ifdef SIGBUS 63 (void)signal(SIGBUS, backtrace_handler); 64 # endif /* ifdef SIGBUS */ 65 # ifdef SIGUNUSED 66 (void)signal(SIGUNUSED, backtrace_handler); 67 # endif /* ifdef SIGUNUSED */ 68 # ifdef SIGSYS 69 (void)signal(SIGSYS, backtrace_handler); 70 # endif /* ifdef SIGSYS */ 71 # ifdef SIGUSR2 72 (void)signal(SIGUSR2, backtrace_handler); 73 # endif /* ifdef SIGUSR2 */ 74 # ifdef SIGSTKFLT 75 (void)signal(SIGSTKFLT, backtrace_handler); 76 # endif /* ifdef SIGSTKFLT */ 77 # ifdef SIGPOWER 78 # ifdef SIG_IGN 79 (void)signal(SIGPOWER, SIG_IGN); 80 # endif /* ifdef SIG_IGN */ 81 # endif /* ifdef SIGPOWER */ 82 # ifdef SIGPWR 83 # ifdef SIG_IGN 84 (void)signal(SIGPWR, SIG_IGN); 85 # endif /* ifdef SIG_IGN */ 86 # endif /* ifdef SIGPWR */ 87 state = backtrace_create_state( 88 NULL, BACKTRACE_SUPPORTS_THREADS, error_callback, NULL); 89 # endif /* ifdef _INC_BACKTRACE_FUNC */ 90 # endif /* ifdef _INC_BACKTRACE_MAIN */ 91 #endif /* ifdef USE_BACKTRACE */