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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [support/] [debug.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1389 nogj
/* debug.h -- Trace function declarations
2
   Copyright 1999 Patrik Stridvall (for the wine project: www.winehq.com)
3
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
4
 
5
This file is part of OpenRISC 1000 Architectural Simulator.
6
(Most of it is ripped from the wine project's wine/include/wine/debug.h)
7
 
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
 
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
 
22
#ifndef __DEBUG_H_INCLUDED
23
#define __DEBUG_H_INCLUDED
24
 
25
enum __ORSIM_DEBUG_CLASS {
26
  __ORSIM_DBCL_TRACE,
27
  __ORSIM_DBCL_FIXME,
28
  __ORSIM_DBCL_WARN,
29
  __ORSIM_DBCL_ERR,
30
};
31
 
32
void orsim_dbg_log(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch,
33
                   const char *function, const char *format, ...)
34
                                          __attribute__((format(printf, 4, 5)));
35
void orsim_dbcl_set_name(enum __ORSIM_DEBUG_CLASS dbcl, const char *dbch, int on);
36
void parse_dbchs(const char *str);
37
 
38
#ifndef __ORSIM_DBG_USE_FUNC
39
#define __ORSIM_DBG_USE_FUNC __FUNCTION__
40
#endif
41
 
42 1521 nogj
#define __ORSIM_GET_DEBUGGING_TRACE(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_TRACE))
43
#define __ORSIM_GET_DEBUGGING_WARN(dbch)  ((dbch)[0] & (1 << __ORSIM_DBCL_WARN))
44
#define __ORSIM_GET_DEBUGGING_FIXME(dbch) ((dbch)[0] & (1 << __ORSIM_DBCL_FIXME))
45
#define __ORSIM_GET_DEBUGGING_ERR(dbch)  ((dbch)[0] & (1 << __ORSIM_DBCL_ERR))
46
 
47
#define __ORSIM_GET_DEBUGGING(dbcl,dbch)  __ORSIM_GET_DEBUGGING##dbcl(dbch)
48 1389 nogj
 
49 1530 nogj
#define __ORSIM_DPRINTF(dbcl, dbch) \
50
  do { if(__ORSIM_GET_DEBUGGING(dbcl,(dbch))) { \
51
       const char * const __dbch = dbch; \
52
       const enum __ORSIM_DEBUG_CLASS __dbcl = __ORSIM_DBCL##dbcl; \
53
       __ORSIM_DEBUG_LOG
54 1389 nogj
 
55 1530 nogj
#define __ORSIM_DEBUG_LOG(args...) \
56
  orsim_dbg_log(__dbcl, __dbch, __ORSIM_DBG_USE_FUNC, args); } } while(0)
57
 
58
#define TRACE_(ch) __ORSIM_DPRINTF(_TRACE, __orsim_dbch_##ch)
59
#define FIXME_(ch) __ORSIM_DPRINTF(_FIXME, __orsim_dbch_##ch)
60
#define WARN_(ch) __ORSIM_DPRINTF(_WARN, __orsim_dbch_##ch)
61
#define ERR_(ch) __ORSIM_DPRINTF(_ERR, __orsim_dbch_##ch)
62
 
63
#define TRACE __ORSIM_DPRINTF(_TRACE, __orsim_dbch___default)
64
#define FIXME __ORSIM_DPRINTF(_FIXME, __orsim_dbch___default)
65
#define WARN __ORSIM_DPRINTF(_WARN, __orsim_dbch___default)
66
#define ERR __ORSIM_DPRINTF(_ERR, __orsim_dbch___default)
67
 
68 1521 nogj
#define TRACE_ON(ch)          __ORSIM_GET_DEBUGGING(_TRACE,__orsim_dbch_##ch)
69
#define WARN_ON(ch)           __ORSIM_GET_DEBUGGING(_WARN,__orsim_dbch_##ch)
70
#define FIXME_ON(ch)          __ORSIM_GET_DEBUGGING(_FIXME,__orsim_dbch_##ch)
71
#define ERR_ON(ch)            __ORSIM_GET_DEBUGGING(_ERR,__orsim_dbch_##ch)
72
 
73 1389 nogj
#define DEFAULT_DEBUG_CHANNEL(dbch) \
74
 extern char __orsim_dbch_##dbch[]; \
75
 static char * const __orsim_dbch___default = __orsim_dbch_##dbch;
76
 
77
#ifndef __ORSIM_NO_DEC_DBCH
78
#define DECLARE_DEBUG_CHANNEL(dbch) extern char __orsim_dbch_##dbch[];
79
#endif
80
 
81
void debug(int level, const char *format,...) __attribute__((format(printf, 2, 3)));
82
 
83
#endif

powered by: WebSVN 2.1.0

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