1 | /* |
---|
2 | * $Id: Debug.cpp 138 2010-05-12 17:34:01Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Common/include/Debug.h" |
---|
9 | #include "Common/include/Environment.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | |
---|
13 | static bool debug_initialized; |
---|
14 | debug_verbosity_t debug; |
---|
15 | bool debug_cycle_test; |
---|
16 | double debug_cycle_start; |
---|
17 | double debug_cycle_stop ; |
---|
18 | double debug_idle_cycle ; |
---|
19 | uint32_t debug_idle_time ; |
---|
20 | |
---|
21 | #undef FUNCTION |
---|
22 | #define FUNCTION "debug_init" |
---|
23 | void debug_init (void) |
---|
24 | { |
---|
25 | #ifdef DEBUG |
---|
26 | if (not debug_initialized) |
---|
27 | { |
---|
28 | debug = DEBUG; |
---|
29 | debug_cycle_test = false; |
---|
30 | // debug_initialized = true; |
---|
31 | } |
---|
32 | #endif |
---|
33 | } |
---|
34 | |
---|
35 | #undef FUNCTION |
---|
36 | #define FUNCTION "debug_init" |
---|
37 | void debug_init (debug_verbosity_t level, |
---|
38 | double cycle_start, |
---|
39 | double cycle_stop , |
---|
40 | double idle_cycle , |
---|
41 | uint32_t idle_time ) |
---|
42 | { |
---|
43 | if (not debug_initialized) |
---|
44 | { |
---|
45 | #ifdef DEBUG |
---|
46 | // Take min |
---|
47 | debug = (level < DEBUG)?level:DEBUG; |
---|
48 | |
---|
49 | # ifdef SYSTEMC |
---|
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; |
---|
55 | # else |
---|
56 | debug_cycle_test = false; |
---|
57 | # endif |
---|
58 | # else |
---|
59 | debug = DEBUG_NONE; |
---|
60 | debug_cycle_test = false; |
---|
61 | debug_cycle_start = 0; |
---|
62 | debug_cycle_stop = 0; |
---|
63 | #endif |
---|
64 | |
---|
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 | |
---|
73 | debug_initialized = true; |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | }; // end namespace morpheo |
---|