OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
traceback_handler.c
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23/*=================================================================*/
24/* TRACE BACK */
25/*=================================================================*/
26#include <stdio.h>
27#include <string.h>
28#include <stdlib.h>
29#include <signal.h>
30
31#define _FCALL
32
33#ifdef _WIN64
34#define trace_cf TRACE_CF
35#else
36#define trace_cf trace_cf_
37#endif
38
39
40
41/* protos */
42void setignorecore (int *on);
43void ignoreCore (int s);
44void trace_cf(int *s,int *iw);
45void ARRET(int * n);
46void arret_(int * n);
47void arret_c(int n) ;
48
49#ifdef _WIN64
50void ignoreCore (int s)
51{
52 int iw = 1, is;
53 if(s == SIGFPE ) is=2;
54 else if(s == SIGSEGV) is=3;
55
56 trace_cf(&is,&iw);
57}
58
59#elif 1
60
61void ignoreCore (int s)
62{
63 int iw = 1, is;
64 if (s == SIGBUS ) is=1;
65 else if(s == SIGFPE ) is=2;
66 else if(s == SIGSEGV) is=3;
67
68 trace_cf(&is,&iw);
69}
70#endif
71
72void user_abrt(int sig)
73{
74 int val=3;
75 printf("\n\nUser or system abort detected (CTRL-C) !\n\n");
76 arret_c(val);
77}
78
79
80/************************/
81/* get signals for core */
82void _FCALL SETIGNORECORE (int *on)
83{setignorecore (on);}
84void setignorecore__ (int *on)
85{setignorecore (on);}
86void setignorecore_ (int *on)
87{setignorecore (on);}
88
89void setignorecore (int *on)
90{
91if (*on ) {
92#ifdef SIGBUS
93 signal (SIGBUS, ignoreCore); /* 7 bus error*/
94#endif
95#ifdef SIGFPE
96 signal (SIGFPE, ignoreCore); /* 8 i/0 */
97#endif
98#ifdef SIGSEGV
99 signal (SIGSEGV, ignoreCore); /* 11 segmentation violation*/
100#endif
101#ifdef SIGILL
102 signal (SIGILL, ignoreCore); /* 4 illegal instruction*/
103#endif
104}
105else { /* acknowledging core */
106#ifdef SIGBUS
107 signal (SIGBUS, SIG_DFL); /* 7 bus error*/
108#endif
109#ifdef SIGFPE
110 signal (SIGFPE, SIG_DFL); /* 8 i/0 */
111#endif
112#ifdef SIGSEGV
113 signal (SIGSEGV, SIG_DFL); /* 11 segmentation violation*/
114#endif
115#ifdef SIGILL
116 signal (SIGILL, SIG_DFL); /* 4 illegal instruction*/
117#endif
118}
119
120#ifdef SIGINT
121signal (SIGINT,user_abrt);
122#endif
123
124#ifdef SIGABRT
125signal (SIGABRT,user_abrt);
126#endif
127
128#ifdef SIGBREAK
129signal (SIGBREAK,user_abrt);
130#endif
131
132#ifdef SIGTERM
133signal (SIGTERM, user_abrt); /* 15 Termination signal*/
134#endif
135}
void arret_c(int n)
void setignorecore(int *on)
void ignoreCore(int s)
void setignorecore_(int *on)
#define trace_cf
void user_abrt(int sig)
void ARRET(int *n)
void arret_(int *n)
void _FCALL SETIGNORECORE(int *on)
void setignorecore__(int *on)
#define _FCALL
n
void ignoreCore(int s)
void user_abrt(int sig)