[82] | 1 | /* |
---|
| 2 | * $Id: Debug.cpp 138 2010-05-12 17:34:01Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
[78] | 8 | #include "Common/include/Debug.h" |
---|
[88] | 9 | #include "Common/include/Environment.h" |
---|
[78] | 10 | |
---|
[88] | 11 | namespace morpheo { |
---|
| 12 | |
---|
[97] | 13 | static bool debug_initialized; |
---|
| 14 | debug_verbosity_t debug; |
---|
[100] | 15 | bool debug_cycle_test; |
---|
| 16 | double debug_cycle_start; |
---|
| 17 | double debug_cycle_stop ; |
---|
[110] | 18 | double debug_idle_cycle ; |
---|
| 19 | uint32_t debug_idle_time ; |
---|
[78] | 20 | |
---|
[88] | 21 | #undef FUNCTION |
---|
[97] | 22 | #define FUNCTION "debug_init" |
---|
| 23 | void debug_init (void) |
---|
[78] | 24 | { |
---|
[97] | 25 | #ifdef DEBUG |
---|
| 26 | if (not debug_initialized) |
---|
| 27 | { |
---|
| 28 | debug = DEBUG; |
---|
[100] | 29 | debug_cycle_test = false; |
---|
| 30 | // debug_initialized = true; |
---|
[97] | 31 | } |
---|
| 32 | #endif |
---|
[78] | 33 | } |
---|
| 34 | |
---|
[88] | 35 | #undef FUNCTION |
---|
[97] | 36 | #define FUNCTION "debug_init" |
---|
[100] | 37 | void debug_init (debug_verbosity_t level, |
---|
| 38 | double cycle_start, |
---|
[109] | 39 | double cycle_stop , |
---|
[110] | 40 | double idle_cycle , |
---|
| 41 | uint32_t idle_time ) |
---|
[78] | 42 | { |
---|
[97] | 43 | if (not debug_initialized) |
---|
| 44 | { |
---|
[109] | 45 | #ifdef DEBUG |
---|
[97] | 46 | // Take min |
---|
[138] | 47 | debug = (level < DEBUG)?level:DEBUG; |
---|
[100] | 48 | |
---|
[109] | 49 | # ifdef SYSTEMC |
---|
[138] | 50 | debug_cycle_test = (not (cycle_start == -1) and |
---|
| 51 | ((cycle_stop > cycle_start) or |
---|
| 52 | (cycle_stop == -1))); |
---|
| 53 | debug_cycle_start = cycle_start; |
---|
| 54 | debug_cycle_stop = cycle_stop; |
---|
[109] | 55 | # else |
---|
[138] | 56 | debug_cycle_test = false; |
---|
[109] | 57 | # endif |
---|
[138] | 58 | # else |
---|
| 59 | debug = DEBUG_NONE; |
---|
| 60 | debug_cycle_test = false; |
---|
| 61 | debug_cycle_start = 0; |
---|
| 62 | debug_cycle_stop = 0; |
---|
[100] | 63 | #endif |
---|
| 64 | |
---|
[138] | 65 | debug_idle_cycle = idle_cycle; |
---|
| 66 | debug_idle_time = idle_time ; |
---|
| 67 | |
---|
| 68 | msgInformation(_("Debug level : %s\n"),toString(debug).c_str()); |
---|
| 69 | // msgDebug(_("Cycle test : %d\n"),debug_cycle_test); |
---|
| 70 | // msgDebug(_("Cycle start : %f\n"),cycle_start); |
---|
| 71 | // msgDebug(_("Cycle stop : %f\n"),cycle_stop); |
---|
| 72 | |
---|
[97] | 73 | debug_initialized = true; |
---|
| 74 | } |
---|
[78] | 75 | } |
---|
[88] | 76 | |
---|
| 77 | }; // end namespace morpheo |
---|