shuttlerc, boobytraps, vwindow hang, lock cleanup
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bctrace.inc
1 #ifndef __BCTRACE_INC__
2 #define __BCTRACE_INC__
3
4 //#define ENABLE_TRACE
5 #define TRACE_LOCKS
6 //#define TRACE_MEMORY
7 #define TRACE_THREADS
8 #define TRACE_LOCKS
9
10 class BC_Trace;
11 class trace_item;
12 class execution_item;
13 class lock_item;
14 class memory_item;
15 class file_item;
16 class bc_trace_t;
17 class bc_trace_spin;
18 class bc_trace_mutex;
19
20 class TheLock;
21 class TheLocker;
22 class TheDbg;
23 class TheList;
24 class TheChk;
25
26 class trace_info {
27 public:
28         void *trace;
29         unsigned long owner;
30         trace_info() { trace = 0; owner = 0; }
31         ~trace_info() {}
32         void set_owner();
33         void unset_owner();
34 };
35
36 #ifdef NO_GUICAST
37
38 #undef ENABLE_TRACE
39 #undef TRACE_LOCKS
40 #undef TRACE_MEMORY
41 #undef TRACE_THREADS
42
43 #endif
44
45
46 #ifdef ENABLE_TRACE
47 // Add a trace
48 #define TRACE(text) BC_Trace::new_trace(text);
49 #define SET_TRACE BC_Trace::new_trace(__FILE__, __FUNCTION__, __LINE__);
50 #define PRINT_TRACE { printf("%s: %d\n", __FILE__, __LINE__); fflush(stdout); }
51 // Delete all traces
52 #define UNTRACE BC_Trace::delete_traces();
53
54 #else
55
56 #define TRACE(text) ;
57 #define UNTRACE ;
58 #define PRINT_TRACE { printf("%s: %d\n", __FILE__, __LINE__); fflush(stdout); }
59 //#define PRINT_TRACE ;
60 #define SET_TRACE ;
61
62 #endif
63
64
65 #ifdef TRACE_LOCKS
66 // Before user acquires
67 #define SET_LOCK(info, title, location) \
68  int table_id = BC_Trace::set_lock(title, location, info);
69 // After successful acquisition of a mutex, the table is flagged
70 #define SET_LOCK2 BC_Trace::set_lock2(table_id, this);
71 // After successful acquisition of a condition, the table is removed because
72 // the user never unlocks a condition after locking it.
73 // Release current lock table after failing to acquire
74 #define UNSET_LOCK2 BC_Trace::unset_lock2(table_id, this);
75
76 // Release current owner of lock
77 #define UNSET_LOCK(info) BC_Trace::unset_lock(info);
78 // Delete a lock
79 #define UNSET_ALL_LOCKS(info) BC_Trace::unset_all_locks(info);
80
81 #define LOCK_LOCKS(s) BC_Trace::lock_locks(s);
82 #define UNLOCK_LOCKS BC_Trace::unlock_locks();
83 #define CLEAR_LOCKS_TID(tid) BC_Trace::clear_locks_tid(tid);
84
85 #else
86
87 #define SET_LOCK(title, location) ;
88 #define SET_LOCK2 ;
89 #define SET_LOCK2_CONDITION ;
90 #define UNSET_LOCK(info) ;
91 #define UNSET_LOCK2 ;
92 #define UNSET_ALL_LOCKS(info) ;
93
94 #define LOCK_LOCKS(s) ;
95 #define UNLOCK_LOCKS ;
96 #define CLEAR_LOCKS_TID(tid) ;
97 #endif
98
99
100 #ifdef TRACE_MEMORY
101
102 #define ENABLE_BUFFER BC_Trace::enable_memory();
103 #define DISABLE_BUFFER BC_Trace::disable_memory();
104 // Note the size, pointer, and location of an allocation
105 #define BUFFER(size, ptr, location) BC_Trace::set_buffer(size, ptr, location);
106 // Note the pointer and location of an allocation
107 #define BUFFER2(ptr, location) BC_Trace::set_buffer(0, ptr, location);
108 // Remove a pointer from the allocation table
109 #define UNBUFFER(ptr) BC_Trace::unset_buffer(ptr);
110
111 #else
112
113 #define ENABLE_BUFFER ;
114 #define DISABLE_BUFFER ;
115 #define BUFFER(size, ptr, location);
116 #define UNBUFFER(ptr);
117
118 #endif
119
120 // Handling of temporary files in crash
121 #define SET_TEMP BC_Trace::set_temp
122 #define UNSET_TEMP BC_Trace::unset_temp
123
124 #endif