source: trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h @ 138

Last change on this file since 138 was 138, checked in by rosiere, 14 years ago

1) add counters_t type for interface
2) fix in check load in load_store_unit
3) add parameters (but not yet implemented)
4) change environment and add script (distcc_env.sh ...)
5) add warning if an unser change rename flag with l.mtspr instruction
6) ...

  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1#ifndef Morpheo_Debug_h
2#define Morpheo_Debug_h
3
4/*
5 * $Id: Debug.h 138 2010-05-12 17:34:01Z rosiere $
6 *
7 * [ Description ]
8 *
9 * function to help the debugging :
10 *
11 *  - log_printf
12 *  - log_begin
13 *  - log_end
14 *  - log_function
15 *  - msg_print
16 *  - breakpoint
17 *
18 *  Debug's Level :
19 *  - None    : print elementary information
20 *  - Info    : print basic information
21 *  - Trace   : trace internal variable
22 *  - Func    : trace call and return function
23 *  - All     : print all information
24 */
25
26#include "Common/include/Debug_type.h"
27#include "Common/include/Systemc.h"
28#include "Common/include/Message.h"
29#include "Common/include/ChangeCase.h"
30#include "Behavioural/include/Debug_component.h"
31#include "Behavioural/include/Model.h"
32#include "Behavioural/include/Simulation.h"
33#include <systemc.h>
34#include <stdio.h>
35#include <string.h>
36#include <iostream>
37#include <sstream>
38#include <string>
39#include "Common/include/MemCheck.h"
40
41namespace morpheo {
42
43// typedef enum
44//   {
45//     DEBUG_NONE ,
46//     DEBUG_INFO ,
47//     DEBUG_TRACE,
48//     DEBUG_FUNC ,
49//     DEBUG_ALL
50//   } debug_verbosity_t;
51
52  extern debug_verbosity_t debug;
53  extern bool              debug_cycle_test;
54  extern double            debug_cycle_start;
55  extern double            debug_cycle_stop ;
56  extern double            debug_idle_cycle;
57  extern uint32_t          debug_idle_time;
58
59  void        debug_init    (void);
60  void        debug_init    (debug_verbosity_t level,
61                             double            cycle_start,
62                             double            cycle_stop ,
63                             double            idle_cycle ,
64                             uint32_t          idle_time  );
65
66#ifdef SYSTEMC
67#define debug_test_simulation_time                                      \
68  (not debug_cycle_test or                                              \
69  ((simulation_cycle() >= debug_cycle_start) and                        \
70   ((simulation_cycle() <= debug_cycle_stop) or                         \
71    (debug_cycle_stop == -1))))
72#else
73#define debug_test_simulation_time true
74#endif
75 
76#ifdef DEBUG
77# define log_printf(level, component, func, str... )                    \
78  do                                                                    \
79    {                                                                   \
80      debug_init();                                                     \
81                                                                        \
82      if (debug_test_simulation_time and                                \
83          (( DEBUG_ ## level <= debug) and                              \
84           ( morpheo::behavioural::_model.get_debug(NAME_ ## component)))) \
85        {                                                               \
86          if (DEBUG_ ## level <= DEBUG_INFO)                            \
87            {                                                           \
88              msg("%s ",MSG_INFORMATION);                               \
89            }                                                           \
90          else                                                          \
91            {                                                           \
92              msg("%s ",MSG_DEBUG);                                     \
93            }                                                           \
94                                                                        \
95          if (debug >= DEBUG_FUNC)                                      \
96            {                                                           \
97              msg(  "<%s> " ,func);                                     \
98              msg(_("In file %s, "),__FILE__);                          \
99              msg(_("at line %d " ),__LINE__);                          \
100              msg(  ": " );                                             \
101            }                                                           \
102          msg(str);                                                     \
103          msg("\n");                                                    \
104        }                                                               \
105    } while(0)
106
107# define log_begin(component, func)                                     \
108  do                                                                    \
109    {                                                                   \
110      log_printf(FUNC,component,func,_("Begin"));                       \
111    } while(0)
112
113# define log_end(component, func)                                       \
114  do                                                                    \
115    {                                                                   \
116      log_printf(FUNC,component,func,_("End"));                         \
117    } while(0)
118
119#else
120# define log_printf(level, component, func, str... )                    \
121  do                                                                    \
122    {                                                                   \
123    } while(0)
124
125# define log_begin(component, func)                                     \
126  do                                                                    \
127    {                                                                   \
128    } while(0)
129
130# define log_end(component, func)                                       \
131  do                                                                    \
132    {                                                                   \
133    } while(0)
134
135#endif // DEBUG
136
137# define log_function(component,func,name)                              \
138  do                                                                    \
139    {                                                                   \
140      log_printf(TRACE,component,func,_("[%d] %s.%s"),static_cast<uint32_t>(simulation_cycle()),name,func); \
141    } while(0)
142
143
144#define msg_printf(type,str...)                                         \
145  do                                                                    \
146    {                                                                   \
147      msg("%s ",MSG_ ## type);                                          \
148      msg(str);                                                         \
149      msg("\n");                                                        \
150    } while(0)
151
152
153#define breakpoint(str...)                                              \
154  do                                                                    \
155    {                                                                   \
156      fmsg(_("%s "),MSG_BREAKPOINT);                                    \
157      fmsg(_("Breakpoint in file %s, line %d.\n"),__FILE__,__LINE__);   \
158      fmsg(_("%s "),MSG_NONE);                                          \
159      fmsg(str);                                                        \
160      fmsg(_("\n"));                                                    \
161      fmsg(_("%s "),MSG_NONE);                                          \
162      fmsg(_("Enter any key to continue\n"));                           \
163      getchar();                                                        \
164    } while(0)
165
166#ifdef DEBUG_TEST
167#define TEST_PTR(x)                                                     \
168  do                                                                    \
169    {                                                                   \
170      if (x == NULL)                                                    \
171        err(_("File %s, Line %d, this pointeur is null\n"),__FILE__,__LINE__); \
172    }                                                                   \
173  while (0)
174#else
175#define TEST_PTR(x)      \
176  do                     \
177    {                    \
178    }                    \
179  while (0)
180#endif
181
182}; // end namespace morpheo
183#endif // !DEBUG_H
Note: See TracBrowser for help on using the repository browser.