1 /*------------------------------------------------------------\
2 | |
3 | Tool : Rds |
4 | |
5 | File : rdsadebug.c |
6 | |
7 | Date : 25.10.94 |
8 | |
9 | Author : Jacomme Ludovic |
10 | |
11 \------------------------------------------------------------*/
12 /*------------------------------------------------------------\
13 | |
14 | Include Files |
15 | |
16 \------------------------------------------------------------*/
17
18 # include <stdio.h>
19 # include <signal.h>
20
21 # include <mut.h>
22 # include "rds.h"
23
24 # include "rdsdebug.h"
25
26 /*------------------------------------------------------------\
27 | |
28 | Constants |
29 | |
30 \------------------------------------------------------------*/
31 /*------------------------------------------------------------\
32 | |
33 | Types |
34 | |
35 \------------------------------------------------------------*/
36 /*------------------------------------------------------------\
37 | |
38 | Variables |
39 | |
40 \------------------------------------------------------------*/
41
42 rdsdebug_list *HEAD_RDSDEBUG = (rdsdebug_list *)NULL;
43 char RDS_DEBUG_ON = 0;
44
45 /*------------------------------------------------------------\
46 | |
47 | Privates |
48 | |
49 \------------------------------------------------------------*/
50 /*------------------------------------------------------------\
51 | |
52 | Functions |
53 | |
54 \------------------------------------------------------------*/
55 /*------------------------------------------------------------\
56 | |
57 | Rds Alloc Debug |
58 | |
59 \------------------------------------------------------------*/
60
allocrdsdebug()61 rdsdebug_list *allocrdsdebug()
62 {
63 return( (rdsdebug_list *)(rdsallocheap( sizeof( rdsdebug_list ) ) ) );
64 }
65
66 /*------------------------------------------------------------\
67 | |
68 | Rds Free Debug |
69 | |
70 \------------------------------------------------------------*/
71
freerdsdebug(Debug)72 void freerdsdebug( Debug )
73
74 rdsdebug_list *Debug;
75 {
76 rdsfreeheap( (char *)Debug, sizeof( rdsdebug_list ) );
77 }
78
79 /*------------------------------------------------------------\
80 | |
81 | traprdsdebug |
82 | |
83 \------------------------------------------------------------*/
84
traprdsdebug()85 void traprdsdebug()
86 {
87 rdsdebug_list *ScanDebug;
88
89 for ( ScanDebug = HEAD_RDSDEBUG;
90 ScanDebug != (rdsdebug_list *)NULL;
91 ScanDebug = ScanDebug->NEXT )
92 {
93 fprintf( stdout, "rdsdebug: file %s line %d\n",
94 ScanDebug->NAME, ScanDebug->LINE );
95 }
96
97 fflush( stdout );
98
99 signal( SIGQUIT, traprdsdebug );
100 signal( SIGSEGV, SIG_DFL );
101 signal( SIGBUS , SIG_DFL );
102 signal( SIGILL , SIG_DFL );
103 }
104
105 /*------------------------------------------------------------\
106 | |
107 | rdsdebug |
108 | |
109 \------------------------------------------------------------*/
110
rdsdebug()111 void rdsdebug()
112 {
113 signal( SIGSEGV, traprdsdebug );
114 signal( SIGBUS, traprdsdebug );
115 signal( SIGILL, traprdsdebug );
116 signal( SIGQUIT, traprdsdebug );
117
118 RDS_DEBUG_ON = 1;
119 }
120
121 /*------------------------------------------------------------\
122 | |
123 | addrdsdebug |
124 | |
125 \------------------------------------------------------------*/
126
addrdsdebug(Line,File)127 void addrdsdebug( Line, File )
128
129 int Line;
130 char *File;
131 {
132 rdsdebug_list *NewDebug;
133
134 NewDebug = allocrdsdebug();
135 NewDebug->NEXT = HEAD_RDSDEBUG;
136 NewDebug->LINE = Line;
137 NewDebug->NAME = File;
138 HEAD_RDSDEBUG = NewDebug;
139 }
140
141 /*------------------------------------------------------------\
142 | |
143 | delrdsdebug |
144 | |
145 \------------------------------------------------------------*/
146
delrdsdebug()147 void delrdsdebug()
148 {
149 rdsdebug_list *DelDebug;
150
151 DelDebug = HEAD_RDSDEBUG;
152
153 if ( DelDebug != (rdsdebug_list *)NULL )
154 {
155 HEAD_RDSDEBUG = DelDebug->NEXT;
156 freerdsdebug( DelDebug );
157 }
158 }
159