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#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27#include <signal.h>
28
29#define _FCALL
30
31void ARRET(int * n);
32void arret_(int * n);
33void arret_c(int n);
34
35
36#ifdef _WIN64
37#define trace_cf TRACE_CF
38#else
39#define trace_cf trace_cf_
40#endif
41
42
43void setignorecore (int *on);
44void ignoreCore (int s);
45void trace_cf(int *s,int *iw);
46
47#ifdef _WIN64
48void ignoreCore (int s)
49{
50 int iw = 1, is;
51 if(s == SIGFPE ) is=2;
52 else if(s == SIGSEGV) is=3;
53
54 trace_cf(&is,&iw);
55
56}
57
58#else
59
60void ignoreCore (int s)
61{
62 int iw = 1, is;
63 if (s == SIGBUS ) is=1;
64 else if(s == SIGFPE ) is=2;
65 else if(s == SIGSEGV) is=3;
66
67 trace_cf(&is,&iw);
68/* setIgnoreCore (1);*/
69}
70
71#endif
72
73void user_abrt(int sig)
74{
75 int val=6; /* arret_c(6) initiates STOP with 3 as error code (system error) */
76 printf("\n\nUser or system abort detected (CTRL-C) !\n\n");
77 arret_c(val);
78}
79
80
81/************************/
82/* get signals for core */
83void _FCALL SETIGNORECORE (int *on)
84{setignorecore (on);}
85void setignorecore__ (int *on)
86{setignorecore (on);}
87void setignorecore_ (int *on)
88{setignorecore (on);}
89
90void setignorecore (int *on)
91{
92 if (*on) { /*ignoring core */
93#ifdef SIGBUS
94 signal (SIGBUS, ignoreCore); /* 7 bus error*/
95#endif
96#ifdef SIGFPE
97 signal (SIGFPE, ignoreCore); /* 8 i/0 */
98#endif
99#ifdef SIGSEGV
100 signal (SIGSEGV, ignoreCore); /* 11 segmentation violation*/
101#endif
102 }
103 else { /* acknowledging core */
104#ifdef SIGBUS
105 signal (SIGBUS, SIG_DFL); /* 7 bus error*/
106#endif
107#ifdef SIGFPE
108 signal (SIGFPE, SIG_DFL); /* 8 i/0 */
109#endif
110#ifdef SIGSEGV
111 signal (SIGSEGV, SIG_DFL); /* 11 segmentation violation*/
112#endif
113 }
114
115#ifdef SIGINT
116signal (SIGINT,user_abrt); /* 2 Interrupt from keyboard*/
117#endif
118
119#ifdef SIGABRT
120signal (SIGABRT,user_abrt); /* 6 Abnormal termination*/
121#endif
122
123#ifdef SIGBREAK
124signal (SIGBREAK,user_abrt); /* Ctrl-Break signal*/
125#endif
126
127#ifdef SIGTERM
128signal (SIGTERM,user_abrt); /* 15 Termination signal*/
129#endif
130}
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)