OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [support/] [debug.h] - Blame information for rev 760

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
/* debug.h -- Trace function declarations
2
 
3
   Copyright 1999 Patrik Stridvall (for the wine project: www.winehq.com)
4
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
5
   Copyright (C) 2008 Embecosm Limited
6
 
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see <http://www.gnu.org/licenses/>.  */
23
 
24
/* This program is commented throughout in a fashion suitable for processing
25
   with Doxygen. */
26
 
27
 
28
#ifndef DEBUG__H
29
#define DEBUG__H
30
 
31
enum __ORSIM_DEBUG_CLASS {
32
  __ORSIM_DBCL_TRACE,
33
  __ORSIM_DBCL_FIXME,
34
  __ORSIM_DBCL_WARN,
35
  __ORSIM_DBCL_ERR,
36
};
37
 
38
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch,
39
                   const char *function, const char *format, ...)
40
                                          __attribute__((format(printf, 4, 5)));
41
void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on);
42
void parse_dbchs(const char *str);
43
 
44
#ifndef __ORSIM_DBG_USE_FUNC
45
#define __ORSIM_DBG_USE_FUNC __FUNCTION__
46
#endif
47
 
48
#define __ORSIM_GET_DEBUGGING_TRACE(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_TRACE))
49
#define __ORSIM_GET_DEBUGGING_WARN(dbch)  ((dbch)[0] & (1 << __ORSIM_DBCL_WARN))
50
#define __ORSIM_GET_DEBUGGING_FIXME(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_FIXME))
51
#define __ORSIM_GET_DEBUGGING_ERR(dbch)  ((dbch)[0] & (1 << __ORSIM_DBCL_ERR))
52
 
53
#define __ORSIM_GET_DEBUGGING(dbcl,dbch)  __ORSIM_GET_DEBUGGING##dbcl(dbch)
54
 
55
#define __ORSIM_DPRINTF(dbcl, dbch) \
56
  do { if(__ORSIM_GET_DEBUGGING(dbcl,(dbch))) { \
57
       const char * const __dbch = dbch; \
58
       const enum __ORSIM_DEBUG_CLASS __dbcl = __ORSIM_DBCL##dbcl; \
59
       __ORSIM_DEBUG_LOG
60
 
61
#define __ORSIM_DEBUG_LOG(args...) \
62
  orsim_dbg_log(__dbcl, __dbch, __ORSIM_DBG_USE_FUNC, args); } } while(0)
63
 
64
#define TRACE_(ch) __ORSIM_DPRINTF(_TRACE, __orsim_dbch_##ch)
65
#define FIXME_(ch) __ORSIM_DPRINTF(_FIXME, __orsim_dbch_##ch)
66
#define WARN_(ch) __ORSIM_DPRINTF(_WARN, __orsim_dbch_##ch)
67
#define ERR_(ch) __ORSIM_DPRINTF(_ERR, __orsim_dbch_##ch)
68
 
69
#define TRACE __ORSIM_DPRINTF(_TRACE, __orsim_dbch___default)
70
#define FIXME __ORSIM_DPRINTF(_FIXME, __orsim_dbch___default)
71
#define WARN __ORSIM_DPRINTF(_WARN, __orsim_dbch___default)
72
#define ERR __ORSIM_DPRINTF(_ERR, __orsim_dbch___default)
73
 
74
#define TRACE_ON(ch)          __ORSIM_GET_DEBUGGING(_TRACE,__orsim_dbch_##ch)
75
#define WARN_ON(ch)           __ORSIM_GET_DEBUGGING(_WARN,__orsim_dbch_##ch)
76
#define FIXME_ON(ch)          __ORSIM_GET_DEBUGGING(_FIXME,__orsim_dbch_##ch)
77
#define ERR_ON(ch)            __ORSIM_GET_DEBUGGING(_ERR,__orsim_dbch_##ch)
78
 
79
#define DEFAULT_DEBUG_CHANNEL(dbch) \
80
 extern char __orsim_dbch_##dbch[]; \
81
 static char * const __orsim_dbch___default = __orsim_dbch_##dbch;
82
 
83
#ifndef __ORSIM_NO_DEC_DBCH
84
#define DECLARE_DEBUG_CHANNEL(dbch) extern char __orsim_dbch_##dbch[];
85
#endif
86
 
87
/* For debugging purposes (of Or1ksim itself), it helps if debug can take
88
   advantage of the GNU C __attribute__ feature. */
89
#ifdef __GNUC__
90
void debug(int         level,
91
           const char *format,...)
92
  __attribute__((format(printf, 2, 3)));
93
#else
94
void debug(int         level,
95
           const char *format,...);
96
#endif
97
 
98
#endif  /* DEBUG__H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.