no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bctrace.inc
1 /*
2  * CINELERRA
3  * Copyright (C) 2016-2020 William Morrow
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20
21
22 #ifndef __BCTRACE_INC__
23 #define __BCTRACE_INC__
24
25 //#define ENABLE_TRACE
26 #define TRACE_LOCKS
27 //#define TRACE_MEMORY
28 #define TRACE_THREADS
29 #define TRACE_LOCKS
30
31 class BC_Trace;
32 class trace_item;
33 class execution_item;
34 class lock_item;
35 class memory_item;
36 class file_item;
37 class bc_trace_t;
38 class bc_trace_spin;
39 class bc_trace_mutex;
40
41 class TheLock;
42 class TheLocker;
43 class TheDbg;
44 class TheList;
45 class TheChk;
46
47 class trace_info {
48 public:
49         void *trace;
50         unsigned long owner;
51         trace_info() { trace = 0; owner = 0; }
52         ~trace_info() {}
53         void set_owner();
54         void unset_owner();
55 };
56
57 #ifdef NO_GUICAST
58
59 #undef ENABLE_TRACE
60 #undef TRACE_LOCKS
61 #undef TRACE_MEMORY
62 #undef TRACE_THREADS
63
64 #endif
65
66
67 #ifdef ENABLE_TRACE
68 // Add a trace
69 #define TRACE(text) BC_Trace::new_trace(text);
70 #define SET_TRACE BC_Trace::new_trace(__FILE__, __FUNCTION__, __LINE__);
71 #define PRINT_TRACE { printf("%s: %d\n", __FILE__, __LINE__); fflush(stdout); }
72 // Delete all traces
73 #define UNTRACE BC_Trace::delete_traces();
74
75 #else
76
77 #define TRACE(text) ;
78 #define UNTRACE ;
79 #define PRINT_TRACE { printf("%s: %d\n", __FILE__, __LINE__); fflush(stdout); }
80 //#define PRINT_TRACE ;
81 #define SET_TRACE ;
82
83 #endif
84
85
86 #ifdef TRACE_LOCKS
87 // Before user acquires
88 #define SET_LOCK(info, title, location) \
89  int table_id = BC_Trace::set_lock(title, location, info);
90 // After successful acquisition of a mutex, the table is flagged
91 #define SET_LOCK2 BC_Trace::set_lock2(table_id, this);
92 // After successful acquisition of a condition, the table is removed because
93 // the user never unlocks a condition after locking it.
94 // Release current lock table after failing to acquire
95 #define UNSET_LOCK2 BC_Trace::unset_lock2(table_id, this);
96
97 // Release current owner of lock
98 #define UNSET_LOCK(info) BC_Trace::unset_lock(info);
99 // Delete a lock
100 #define UNSET_ALL_LOCKS(info) BC_Trace::unset_all_locks(info);
101
102 #define LOCK_LOCKS(s) BC_Trace::lock_locks(s);
103 #define UNLOCK_LOCKS BC_Trace::unlock_locks();
104 #define CLEAR_LOCKS_TID(tid) BC_Trace::clear_locks_tid(tid);
105
106 #else
107
108 #define SET_LOCK(title, location) ;
109 #define SET_LOCK2 ;
110 #define SET_LOCK2_CONDITION ;
111 #define UNSET_LOCK(info) ;
112 #define UNSET_LOCK2 ;
113 #define UNSET_ALL_LOCKS(info) ;
114
115 #define LOCK_LOCKS(s) ;
116 #define UNLOCK_LOCKS ;
117 #define CLEAR_LOCKS_TID(tid) ;
118 #endif
119
120
121 #ifdef TRACE_MEMORY
122
123 #define ENABLE_BUFFER BC_Trace::enable_memory();
124 #define DISABLE_BUFFER BC_Trace::disable_memory();
125 // Note the size, pointer, and location of an allocation
126 #define BUFFER(size, ptr, location) BC_Trace::set_buffer(size, ptr, location);
127 // Note the pointer and location of an allocation
128 #define BUFFER2(ptr, location) BC_Trace::set_buffer(0, ptr, location);
129 // Remove a pointer from the allocation table
130 #define UNBUFFER(ptr) BC_Trace::unset_buffer(ptr);
131
132 #else
133
134 #define ENABLE_BUFFER ;
135 #define DISABLE_BUFFER ;
136 #define BUFFER(size, ptr, location);
137 #define UNBUFFER(ptr);
138
139 #endif
140
141 // Handling of temporary files in crash
142 #define SET_TEMP BC_Trace::set_temp
143 #define UNSET_TEMP BC_Trace::unset_temp
144
145 #endif