source: git/libpolys/reporter/reporter.h @ c5bae4

spielwiese
Last change on this file since c5bae4 was c5bae4, checked in by Hans Schoenemann <hannes@…>, 4 years ago
chg: TRACE, traceit: add traceit_stop ('n')
  • Property mode set to 100644
File size: 4.6 KB
Line 
1#ifndef OUTPUT_H
2#define OUTPUT_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT: basic output
8*/
9#include <stdio.h>
10#include <string.h>
11#include "misc/auxiliary.h"
12#include "resources/feFopen.h"
13
14EXTERN_VAR char*  feErrors;
15EXTERN_VAR int    feErrorsLen;
16EXTERN_VAR FILE*  feProtFile;
17EXTERN_VAR int    pagelength, colmax;
18EXTERN_VAR int    yy_blocklineno;
19EXTERN_VAR int    yy_noeof;
20extern const char feNotImplemented[];
21EXTERN_VAR int     feProt;
22EXTERN_VAR BOOLEAN feWarn;
23EXTERN_VAR BOOLEAN feOut;
24EXTERN_VAR int  traceit ;
25EXTERN_VAR int  traceit_stop ;
26EXTERN_VAR void (*WarnS_callback)(const char *s);
27
28// show entering/leaving proc:
29#define TRACE_SHOW_PROC   1
30// show current line-no:
31#define TRACE_SHOW_LINENO 2
32// show current line and wait for <RET>:
33#define TRACE_SHOW_LINE   4
34// show basering for all levels of the proc-stack at enteringing/leaving proc,
35// requires RDEBUG to be defined:
36#define TRACE_SHOW_RINGS  8
37// show current line and do not wait for <RET>:
38#define TRACE_SHOW_LINE1  16
39//
40#define TRACE_BREAKPOINT  32
41//
42#define TRACE_TMP_BREAKPOINT  64
43// show all calls to kernel routines (via iparith):
44#define TRACE_CALL       128
45// show all assigns (via ipassign):
46#define TRACE_ASSIGN     256
47// show all automtic type conversions (via ipconv):
48#define TRACE_CONV       512
49// profiling: print line-no to smon.out:
50#define TRACE_PROFILING 1024
51
52
53#define SI_PROT_I    1
54#define SI_PROT_O    2
55#define SI_PROT_IO   3
56
57/* the C-part: */
58#define mflush() fflush(stdout)
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64void    Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
65void    WerrorS_batch(const char *s);
66void    WarnS(const char *s);
67void    Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
68/* Print should not produce more than strlen(fmt)+510 characters! */
69
70void    PrintNSpaces(const int n);
71void    PrintLn();
72void    PrintS(const char* s);
73
74#ifdef __cplusplus
75}
76/* the C++-part: */
77
78// a new output buffer will be allocated by StringSetS,
79// used by several calls to StringAppend/StringAppendS
80// and closed by StringEndS:
81// StringEndS() returns this buffer which must be freed by omFree
82// several buffer may be active at the same time
83// (for example in subroutines)
84void  StringAppend(const char *fmt, ...);
85void  StringAppendS(const char *s);
86void  StringSetS(const char* s);
87char * StringEndS();
88void  Warn(const char *fmt, ...);
89
90const char *  eati(const char *s, int *i);
91
92// Prints resources into string with StringAppend, etc
93void feStringAppendResources(int warn = -1);
94#endif /* c++ only */
95
96/* everything in between calls to these procedures is printed into a string
97 * which is returned by SprintEnd()
98 * Shall ONLY be used for a temporary redirection of the standard output
99 * (i.e. if Singular runs as a server)
100 */
101// unlike the StringSet/StringEndS stuff:
102// only one SPrintStart/SPrintEnd buffer may be active
103// the returned string must be free via omFree
104void SPrintStart();
105char* SPrintEnd();
106
107/* error reporting */
108#ifdef __cplusplus
109extern "C"
110{
111#endif
112extern int dReportError(const char* fmt, ...);
113#define dReportBug(s) \
114  dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)
115
116// this is just a dummy procedure which is called after the error
117// has been reported. Within the debugger, set a breakpoint on this
118// proc.
119extern void dErrorBreak();
120#ifdef __cplusplus
121}
122#endif
123
124#ifdef SING_NDEBUG
125#define assume(x) do {} while (0)
126#define r_assume(x) do {} while (0)
127#else /* !SING_NDEBUG */
128
129#define assume_violation(s,f,l) \
130  dReportError("assume violation at %s:%d condition: %s", f,l,s)
131
132#define assume(x)   _assume(x, __FILE__, __LINE__)
133#define r_assume(x) _r_assume(x, __FILE__, __LINE__)
134
135#define _assume(x, f, l)                        \
136do                                              \
137{                                               \
138  if (! (x))                                    \
139  {                                             \
140    assume_violation(#x, f, l);                 \
141  }                                             \
142}                                               \
143while (0)
144
145#define _r_assume(x, f, l)                      \
146do                                              \
147{                                               \
148  if (! (x))                                    \
149  {                                             \
150    assume_violation(#x, f, l);                 \
151    return 0;                                   \
152  }                                             \
153}                                               \
154while (0)
155#endif /* !SING_NDEBUG */
156
157#endif /* ifndef OUTPUT_H */
Note: See TracBrowser for help on using the repository browser.