My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
reporter.h File Reference
#include <stdio.h>
#include <string.h>
#include "misc/auxiliary.h"
#include "resources/feFopen.h"

Go to the source code of this file.

Macros

#define TRACE_SHOW_PROC   1
 
#define TRACE_SHOW_LINENO   2
 
#define TRACE_SHOW_LINE   4
 
#define TRACE_SHOW_RINGS   8
 
#define TRACE_SHOW_LINE1   16
 
#define TRACE_BREAKPOINT   32
 
#define TRACE_TMP_BREAKPOINT   64
 
#define TRACE_CALL   128
 
#define TRACE_ASSIGN   256
 
#define TRACE_CONV   512
 
#define TRACE_PROFILING   1024
 
#define SI_PROT_I   1
 
#define SI_PROT_O   2
 
#define SI_PROT_IO   3
 
#define mflush()   fflush(stdout)
 
#define dReportBug(s)    dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)
 
#define assume_violation(s, f, l)    dReportError("assume violation at %s:%d condition: %s", f,l,s)
 
#define assume(x)   _assume(x, __FILE__, __LINE__)
 
#define r_assume(x)   _r_assume(x, __FILE__, __LINE__)
 
#define _assume(x, f, l)
 
#define _r_assume(x, f, l)
 

Functions

void Werror (const char *fmt,...) __attribute__((format(printf
 
void void WerrorS_batch (const char *s)
 
void WarnS (const char *s)
 
void Print (const char *fmt,...) __attribute__((format(printf
 
void void PrintNSpaces (const int n)
 
void PrintLn ()
 
void PrintS (const char *s)
 
void StringAppend (const char *fmt,...)
 
void StringAppendS (const char *s)
 
void StringSetS (const char *s)
 
char * StringEndS ()
 
void Warn (const char *fmt,...)
 
const char * eati (const char *s, int *i)
 
void feStringAppendResources (int warn=-1)
 
void SPrintStart ()
 
char * SPrintEnd ()
 
int dReportError (const char *fmt,...)
 
void dErrorBreak ()
 

Variables

EXTERN_VAR char * feErrors
 
EXTERN_VAR int feErrorsLen
 
EXTERN_VAR FILE * feProtFile
 
EXTERN_VAR int pagelength
 
EXTERN_VAR int colmax
 
EXTERN_VAR int yy_blocklineno
 
EXTERN_VAR int yy_noeof
 
const char feNotImplemented []
 
EXTERN_VAR int feProt
 
EXTERN_VAR BOOLEAN feWarn
 
EXTERN_VAR BOOLEAN feOut
 
EXTERN_VAR int traceit
 
EXTERN_VAR int traceit_stop
 
EXTERN_VAR void(* WarnS_callback )(const char *s)
 

Macro Definition Documentation

◆ _assume

#define _assume (   x,
  f,
  l 
)
Value:
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
} \
} \
while (0)
int l
Definition: cfEzgcd.cc:100
Variable x
Definition: cfModGcd.cc:4082
FILE * f
Definition: checklibs.c:9

Definition at line 135 of file reporter.h.

◆ _r_assume

#define _r_assume (   x,
  f,
  l 
)
Value:
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
return 0; \
} \
} \
while (0)

Definition at line 145 of file reporter.h.

◆ assume

#define assume (   x)    _assume(x, __FILE__, __LINE__)

Definition at line 132 of file reporter.h.

◆ assume_violation

#define assume_violation (   s,
  f,
  l 
)     dReportError("assume violation at %s:%d condition: %s", f,l,s)

Definition at line 129 of file reporter.h.

◆ dReportBug

#define dReportBug (   s)     dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)

Definition at line 113 of file reporter.h.

◆ mflush

#define mflush ( )    fflush(stdout)

Definition at line 58 of file reporter.h.

◆ r_assume

#define r_assume (   x)    _r_assume(x, __FILE__, __LINE__)

Definition at line 133 of file reporter.h.

◆ SI_PROT_I

#define SI_PROT_I   1

Definition at line 53 of file reporter.h.

◆ SI_PROT_IO

#define SI_PROT_IO   3

Definition at line 55 of file reporter.h.

◆ SI_PROT_O

#define SI_PROT_O   2

Definition at line 54 of file reporter.h.

◆ TRACE_ASSIGN

#define TRACE_ASSIGN   256

Definition at line 46 of file reporter.h.

◆ TRACE_BREAKPOINT

#define TRACE_BREAKPOINT   32

Definition at line 40 of file reporter.h.

◆ TRACE_CALL

#define TRACE_CALL   128

Definition at line 44 of file reporter.h.

◆ TRACE_CONV

#define TRACE_CONV   512

Definition at line 48 of file reporter.h.

◆ TRACE_PROFILING

#define TRACE_PROFILING   1024

Definition at line 50 of file reporter.h.

◆ TRACE_SHOW_LINE

#define TRACE_SHOW_LINE   4

Definition at line 33 of file reporter.h.

◆ TRACE_SHOW_LINE1

#define TRACE_SHOW_LINE1   16

Definition at line 38 of file reporter.h.

◆ TRACE_SHOW_LINENO

#define TRACE_SHOW_LINENO   2

Definition at line 31 of file reporter.h.

◆ TRACE_SHOW_PROC

#define TRACE_SHOW_PROC   1

Definition at line 29 of file reporter.h.

◆ TRACE_SHOW_RINGS

#define TRACE_SHOW_RINGS   8

Definition at line 36 of file reporter.h.

◆ TRACE_TMP_BREAKPOINT

#define TRACE_TMP_BREAKPOINT   64

Definition at line 42 of file reporter.h.

Function Documentation

◆ dErrorBreak()

void dErrorBreak ( )

◆ dReportError()

int dReportError ( const char *  fmt,
  ... 
)

Definition at line 44 of file dError.cc.

45{
46#if 0
47#ifdef HAVE_EXECINFO_H
48#define SIZE 50
49 void *buffer[SIZE+1]; int ret;
50#endif
51#endif
52
53 va_list ap;
54 va_start(ap, fmt);
55#ifndef MAKE_DISTRIBUTION
56 fprintf(stderr, "\n// ***dError: ");
57 vfprintf(stderr, fmt, ap);
58#if !defined(OM_NDEBUG)
59 #ifdef omPrintCurrentBackTraceMax
60 fprintf(stderr, " occurred at: \n");
62 #endif
63#endif
64
65#if 0
66#ifdef HAVE_EXECINFO_H
67 ret = backtrace( buffer, SIZE ); // execinfo.h
68 fprintf(stderr, "\nExecinfo backtrace (with %zd stack frames): \n", ret);
69
70#ifndef HAVE_GCC_ABI_DEMANGLE
71 backtrace_symbols_fd(buffer, ret, STDERR_FILENO); // execinfo.h
72#else
73 char **ptr = backtrace_symbols( buffer, ret ); // execinfo.h
74
75 int status;
76 char *demangledName;
77 char *s;
78 char *ss;
79 for (int i = 0; i < ret; i++)
80 {
81 status = -1;
82
83 s = ptr[i];
84// fprintf (stderr, " #%02d: %s\n", i, s);
85
86 ss = index(s, '(');
87 ss[0] = 0;
88 fprintf (stderr, " #%02d: '%s': ", i, s);
89 ss[0] = '('; s = ss + 1;
90
91 ss = index(s, '+');
92
93 if ( ss != NULL )
94 {
95 ss[0] = 0;
96 demangledName = abi::__cxa_demangle( s, NULL, NULL, &status ); // cxxabi.h!
97 if( status == 0 && demangledName != NULL )
98 fprintf (stderr, " '%s'", (demangledName[0] != 0)? demangledName: s);
99 else
100 fprintf (stderr, " '%s'", s);
101
102 malloc_free( demangledName );
103 ss[0] = '+';
104 s = ss + 1;
105 }
106
107 ss = index(s, ')');
108 if( s != ss)
109 {
110 ss[0] = 0;
111 fprintf (stderr, " + %s", s);
112 ss[0] = ')';
113 }
114
115 fprintf (stderr, " %s\n", ss + 2);
116 }
117 malloc_free (ptr);
118#endif
119#endif
120
121#undef SIZE
122#endif
123
124 dErrorBreak();
125#else
126 fprintf(stderr, "\n// !!! YOU HAVE FOUND A BUG IN SINGULAR.");
127 fprintf(stderr, "// !!! Please, email the input\n// and the following error message to [email protected]");
128 vfprintf(stderr, fmt, ap);
129#endif
130 return 0;
131}
int i
Definition: cfEzgcd.cc:132
static void malloc_free(void *ptr)
Definition: dError.cc:23
const CanonicalForm int s
Definition: facAbsFact.cc:51
void dErrorBreak(void)
Definition: ap.h:40
#define NULL
Definition: omList.c:12
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
int * status
Definition: si_signals.h:51
#define omPrintCurrentBackTraceMax(A, B)
Definition: xalloc.h:265

◆ eati()

const char * eati ( const char *  s,
int *  i 
)

Definition at line 373 of file reporter.cc.

374{
375 int l=0;
376
377 if (*s >= '0' && *s <= '9')
378 {
379 *i = 0;
380 while (*s >= '0' && *s <= '9')
381 {
382 *i *= 10;
383 *i += *s++ - '0';
384 l++;
385 if ((l>=MAX_INT_LEN)||((*i) <0))
386 {
387 s-=l;
388 Werror("`%s` greater than %d(max. integer representation)",
389 s,MAX_INT_VAL);
390 return s;
391 }
392 }
393 }
394 else *i = 1;
395 return s;
396}
const int MAX_INT_VAL
Definition: mylimits.h:12
const int MAX_INT_LEN
Definition: mylimits.h:13
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ feStringAppendResources()

void feStringAppendResources ( int  warn = -1)

Definition at line 398 of file reporter.cc.

399{
400 int i = 0;
401 char* r;
402 StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0);
403 while (feResourceConfigs[i].key != NULL)
404 {
405 r = feResource(feResourceConfigs[i].key, warn);
406 StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key,
407 (r != NULL ? r : ""));
408 i++;
409 }
410}
#define StringAppend
Definition: emacs.cc:79
VAR char * feArgv0
Definition: feResource.cc:19
VAR feResourceConfig_s feResourceConfigs[]
Definition: feResource.cc:41
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:236

◆ Print()

void Print ( const char *  fmt,
  ... 
)

◆ PrintLn()

void PrintLn ( )

Definition at line 310 of file reporter.cc.

311{
312 PrintS("\n");
313}
void PrintS(const char *s)
Definition: reporter.cc:284

◆ PrintNSpaces()

void void PrintNSpaces ( const int  n)

Definition at line 364 of file reporter.cc.

365{
366 int l=n-1;
367 while(l>=0) { PrintS(" "); l--; }
368}

◆ PrintS()

void PrintS ( const char *  s)

Definition at line 284 of file reporter.cc.

285{
286 if (sprint != NULL)
287 {
288 SPrintS(s);
289 return;
290 }
291 else if (feOut) /* do not print when option --no-out was given */
292 {
293
295 {
297 }
298 else
299 {
300 fwrite(s,1,strlen(s),stdout);
301 fflush(stdout);
302 if (feProt&SI_PROT_O)
303 {
304 fwrite(s,1,strlen(s),feProtFile);
305 }
306 }
307 }
308}
VAR void(* PrintS_callback)(const char *s)
Definition: feFopen.cc:22
VAR int feProt
Definition: reporter.cc:56
static void SPrintS(const char *s)
Definition: reporter.cc:256
STATIC_VAR char * sprint
Definition: reporter.cc:244
VAR FILE * feProtFile
Definition: reporter.cc:57
VAR BOOLEAN feOut
Definition: reporter.cc:50
#define SI_PROT_O
Definition: reporter.h:54

◆ SPrintEnd()

char * SPrintEnd ( )

Definition at line 273 of file reporter.cc.

274{
275 char* ns = sprint;
278 omCheckAddr(ns);
279 return ns;
280}
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
STATIC_VAR char * sprint_backup
Definition: reporter.cc:245

◆ SPrintStart()

void SPrintStart ( )

Definition at line 246 of file reporter.cc.

247{
248 if (sprint!=NULL)
249 {
250 if (sprint_backup!=NULL) WerrorS("internal error: SPrintStart");
252 }
253 sprint = omStrDup("");
254}
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ StringAppend()

void StringAppend ( const char *  fmt,
  ... 
)

Definition at line 61 of file reporter.cc.

62{
63 va_list ap;
64 char *s = feBufferStart; /*feBuffer + strlen(feBuffer);*/
65 int vs;
66 long more;
67 va_start(ap, fmt);
68 if ((more=feBufferStart-feBuffer+strlen(fmt)+100)>feBufferLength)
69 {
70 more = ((more + (8*1024-1))/(8*1024))*(8*1024);
71 int l=s-feBuffer;
73 more);
74#if (!defined(SING_NDEBUG)) && (!defined(OM_NDEBUG))
76#endif
77 feBufferLength=more;
78 s=feBuffer+l;
79#ifndef BSD_SPRINTF
81#endif
82 }
83#ifdef BSD_SPRINTF
84 vsprintf(s, fmt, ap);
85 while (*s!='\0') s++;
87#else
88#ifdef HAVE_VSNPRINTF
89 vs = vsnprintf(s, feBufferLength - (feBufferStart - feBuffer), fmt, ap);
90 if (vs == -1)
91 {
92 assume(0);
94 }
95 else
96 {
97 feBufferStart += vs;
98 }
99#else
100 feBufferStart += vsprintf(s, fmt, ap);
101#endif
102#endif
104 va_end(ap);
105}
#define assume(x)
Definition: mod2.h:389
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
STATIC_VAR char * feBuffer
Definition: reporter.cc:40
STATIC_VAR char * feBufferStart
Definition: reporter.cc:59
STATIC_VAR long feBufferLength
Definition: reporter.cc:39
#define omMarkAsStaticAddr(A)
Definition: xalloc.h:245

◆ StringAppendS()

void StringAppendS ( const char *  s)

Definition at line 107 of file reporter.cc.

108{
109 if (*st!='\0')
110 {
111 /* feBufferStart is feBuffer + strlen(feBuffer);*/
112 int l=strlen(st);
113 long more;
114 int ll=feBufferStart-feBuffer;
115 if ((more=ll+2+l)>feBufferLength)
116 {
117 more = ((more + (8*1024-1))/(8*1024))*(8*1024);
119 more);
120 feBufferLength=more;
122 }
123 strncat(feBufferStart, st,l);
125 }
126}
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231

◆ StringEndS()

char * StringEndS ( )

Definition at line 151 of file reporter.cc.

152{
153 char *r=feBuffer;
154 feBuffer_cnt--;
155 assume(feBuffer_cnt >=0);
159 if (strlen(r)<1024)
160 {
161 // if the used buffer is a "small block",
162 // substitue the "large" initial block by a small one
163 char *s=omStrDup(r); omFree(r); r=s;
164 }
165 return r;
166}
#define omFree(addr)
Definition: omAllocDecl.h:261
STATIC_VAR char * feBufferStart_save[8]
Definition: reporter.cc:44
STATIC_VAR char * feBuffer_save[8]
Definition: reporter.cc:42
STATIC_VAR long feBufferLength_save[8]
Definition: reporter.cc:41
STATIC_VAR int feBuffer_cnt
Definition: reporter.cc:43

◆ StringSetS()

void StringSetS ( const char *  s)

Definition at line 128 of file reporter.cc.

129{
136 feBuffer_cnt++;
138 int l=strlen(st);
139 long more;
140 if (l>feBufferLength)
141 {
142 more = ((l + (4*1024-1))/(4*1024))*(4*1024);
144 more);
145 feBufferLength=more;
146 }
147 strcpy(feBuffer,st);
149}
void * ADDRESS
Definition: auxiliary.h:119
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define INITIAL_PRINT_BUFFER
Definition: reporter.cc:34

◆ Warn()

void Warn ( const char *  fmt,
  ... 
)

Definition at line 227 of file reporter.cc.

228{
229 va_list ap;
230 va_start(ap, fmt);
231 char *s=(char *)omAlloc(256);
232#ifdef HAVE_VSNPRINTF
233 vsnprintf(s, 256, fmt, ap);
234#else
235 vsprintf(s, fmt, ap);
236#endif
237 WarnS(s);
238 omFreeSize(s,256);
239 va_end(ap);
240}
#define WarnS
Definition: emacs.cc:78
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ WarnS()

void WarnS ( const char *  s)

Definition at line 202 of file reporter.cc.

203{
204 #define warn_str "// ** "
205 if (feWarn) /* ignore warnings if option --no-warn was given */
206 {
207 if (WarnS_callback==NULL)
208 {
209 fwrite(warn_str,1,6,stdout);
210 fwrite(s,1,strlen(s),stdout);
211 fwrite("\n",1,1,stdout);
212 fflush(stdout);
213 if (feProt&SI_PROT_O)
214 {
215 fwrite(warn_str,1,6,feProtFile);
216 fwrite(s,1,strlen(s),feProtFile);
217 fwrite("\n",1,1,feProtFile);
218 }
219 }
220 else
221 {
223 }
224 }
225}
VAR void(* WarnS_callback)(const char *s)
Definition: reporter.cc:200
VAR BOOLEAN feWarn
Definition: reporter.cc:49
#define warn_str

◆ Werror()

void Werror ( const char *  fmt,
  ... 
)

◆ WerrorS_batch()

void void WerrorS_batch ( const char *  s)

Definition at line 168 of file reporter.cc.

169{
170 if (feErrors==NULL)
171 {
172 feErrors=(char *)omAlloc(256);
173 feErrorsLen=256;
174 *feErrors = '\0';
175 }
176 else
177 {
178 if (((int)(strlen((char *)s)+ 20 +strlen(feErrors)))>=feErrorsLen)
179 {
181 feErrorsLen+=256;
182 }
183 }
184 strcat(feErrors, "Singular error: ");
185 strcat(feErrors, (char *)s);
187}
#define TRUE
Definition: auxiliary.h:100
VAR short errorreported
Definition: feFopen.cc:23
VAR int feErrorsLen
Definition: reporter.cc:48
VAR char * feErrors
Definition: reporter.cc:47

Variable Documentation

◆ colmax

EXTERN_VAR int colmax

Definition at line 17 of file reporter.h.

◆ feErrors

EXTERN_VAR char* feErrors

Definition at line 14 of file reporter.h.

◆ feErrorsLen

EXTERN_VAR int feErrorsLen

Definition at line 15 of file reporter.h.

◆ feNotImplemented

const char feNotImplemented[]
extern

Definition at line 54 of file reporter.cc.

◆ feOut

Definition at line 23 of file reporter.h.

◆ feProt

EXTERN_VAR int feProt

Definition at line 21 of file reporter.h.

◆ feProtFile

EXTERN_VAR FILE* feProtFile

Definition at line 16 of file reporter.h.

◆ feWarn

Definition at line 22 of file reporter.h.

◆ pagelength

EXTERN_VAR int pagelength

Definition at line 17 of file reporter.h.

◆ traceit

EXTERN_VAR int traceit

Definition at line 24 of file reporter.h.

◆ traceit_stop

EXTERN_VAR int traceit_stop

Definition at line 25 of file reporter.h.

◆ WarnS_callback

EXTERN_VAR void(* WarnS_callback) (const char *s) ( const char *  s)

Definition at line 26 of file reporter.h.

◆ yy_blocklineno

EXTERN_VAR int yy_blocklineno

Definition at line 18 of file reporter.h.

◆ yy_noeof

EXTERN_VAR int yy_noeof

Definition at line 19 of file reporter.h.