| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: debug.h */ |
| 8 |
/* */ |
| 9 |
/* Purpose: header file for ug internal debugger */ |
| 10 |
/* */ |
| 11 |
/* Author: Stefan Lang */ |
| 12 |
/* Institut fuer Computeranwendungen III */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Pfaffenwaldring 27 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* email: [email protected] */ |
| 17 |
/* phone: 0049-(0)711-685-7003 */ |
| 18 |
/* fax : 0049-(0)711-685-7000 */ |
| 19 |
/* */ |
| 20 |
/* History: 10.07.95 begin */ |
| 21 |
/* */ |
| 22 |
/* Remarks: */ |
| 23 |
/* */ |
| 24 |
/****************************************************************************/ |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
/****************************************************************************/ |
| 29 |
/* */ |
| 30 |
/* auto include mechanism and other include files */ |
| 31 |
/* */ |
| 32 |
/****************************************************************************/ |
| 33 |
|
| 34 |
#ifndef __DEBUG__ |
| 35 |
#define __DEBUG__ |
| 36 |
|
| 37 |
#include "misc.h" |
| 38 |
#include "ugtypes.h" |
| 39 |
|
| 40 |
/****************************************************************************/ |
| 41 |
/* */ |
| 42 |
/* defines in the following order */ |
| 43 |
/* */ |
| 44 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 45 |
/* other constants */ |
| 46 |
/* macros */ |
| 47 |
/* */ |
| 48 |
/****************************************************************************/ |
| 49 |
|
| 50 |
#define REP_ERR_MAX 10 |
| 51 |
#define DEBUG_TIME_MAX 100 |
| 52 |
|
| 53 |
#ifdef Debug |
| 54 |
|
| 55 |
#include <cassert> |
| 56 |
|
| 57 |
#define IFDEBUG(m,n) if (Debug ## m >=(n)) { |
| 58 |
#define PRINTDEBUG(m,n,s) IFDEBUG(m,n) PrintDebug s; ENDDEBUG |
| 59 |
#define PRINTDEBUG_EXT(m,n,s) IFDEBUG(m,n) PrintDebug("-" STR(m) "-"); PrintDebug s; ENDDEBUG |
| 60 |
#define ENDDEBUG } |
| 61 |
#define RETURN(rcode) {INT rc; rc = rcode; assert(!rc); return (rc);} |
| 62 |
#define ASSERT(exp) assert(exp) |
| 63 |
#define REP_ERR_INC {rep_err_line[rep_err_count] = __LINE__; \ |
| 64 |
rep_err_file[rep_err_count] = this_file; \ |
| 65 |
rep_err_count = (rep_err_count+1)%REP_ERR_MAX;} |
| 66 |
#ifdef ModelP |
| 67 |
#define REP_ERR_RETURN(err) { assert(((err)==0));return (err);} |
| 68 |
#define REP_ERR_RETURN_PTR(p) { assert(((p)!=NULL));return (p);} |
| 69 |
#else |
| 70 |
#define REP_ERR_RETURN(err) { if (err) REP_ERR_INC return (err);} |
| 71 |
#define REP_ERR_RETURN_PTR(p) { if (p == NULL) REP_ERR_INC return (p);} |
| 72 |
#endif |
| 73 |
#define REP_ERR_ENCOUNTERED (rep_err_count) |
| 74 |
|
| 75 |
#define REP_ERR_RESET rep_err_count = 0; |
| 76 |
|
| 77 |
#else /* Debug */ |
| 78 |
|
| 79 |
#define IFDEBUG(m,n) if (1==0) { |
| 80 |
#define ENDDEBUG } |
| 81 |
#define PRINTDEBUG(m,n,s) /* no debugging */ |
| 82 |
#define PRINTDEBUG_EXT(m,n,s) /* no debugging */ |
| 83 |
#define RETURN(rcode) return (rcode) |
| 84 |
#define ASSERT(exp) |
| 85 |
|
| 86 |
#define REP_ERR_RETURN(err) {return (err);} |
| 87 |
#define REP_ERR_RETURN_PTR(p) {return (p);} |
| 88 |
#define REP_ERR_ENCOUNTERED (false) |
| 89 |
#define REP_ERR_INC |
| 90 |
#define REP_ERR_RESET |
| 91 |
|
| 92 |
#define PrintDebug(...) |
| 93 |
|
| 94 |
#endif /* Debug */ |
| 95 |
|
| 96 |
START_UG_NAMESPACE |
| 97 |
|
| 98 |
/****************************************************************************/ |
| 99 |
/* */ |
| 100 |
/* data structures exported by the corresponding source file */ |
| 101 |
/* */ |
| 102 |
/****************************************************************************/ |
| 103 |
|
| 104 |
typedef int (*PrintfProcPtr)(const char *, ...); |
| 105 |
|
| 106 |
/****************************************************************************/ |
| 107 |
/* */ |
| 108 |
/* definition of exported global variables */ |
| 109 |
/* */ |
| 110 |
/****************************************************************************/ |
| 111 |
|
| 112 |
#ifdef Debug |
| 113 |
|
| 114 |
extern int Debuginit; |
| 115 |
extern int Debugdddif; |
| 116 |
extern int Debugdev; |
| 117 |
extern int Debuggm; |
| 118 |
extern int Debuglow; |
| 119 |
extern int Debugdom; |
| 120 |
|
| 121 |
/* for reporting of errors (using the REP_ERR_RETURN-macro) */ |
| 122 |
extern int rep_err_count; |
| 123 |
extern int rep_err_line[REP_ERR_MAX]; |
| 124 |
extern const char *rep_err_file[REP_ERR_MAX]; |
| 125 |
|
| 126 |
#endif |
| 127 |
|
| 128 |
/****************************************************************************/ |
| 129 |
/* */ |
| 130 |
/* function declarations */ |
| 131 |
/* */ |
| 132 |
/****************************************************************************/ |
| 133 |
|
| 134 |
#ifdef Debug |
| 135 |
void SetPrintDebugProc (PrintfProcPtr print); |
| 136 |
int PrintDebug (const char *format, ...); |
| 137 |
int PrintDebugToFile (const char *format, ...); |
| 138 |
int SetPrintDebugToFile (const char *fname); |
| 139 |
int PostprocessDebugFile (const char *newname); |
| 140 |
INT PrintRepErrStack (PrintfProcPtr print); |
| 141 |
#endif |
| 142 |
|
| 143 |
END_UG_NAMESPACE |
| 144 |
|
| 145 |
#endif |