3 * Copyright (C) 2020 William Morrow
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser 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.
10 * This library 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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 #ifndef __BCTRACE_INC__
23 #define __BCTRACE_INC__
25 //#define ENABLE_TRACE
27 //#define TRACE_MEMORY
51 trace_info() { trace = 0; owner = 0; }
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); }
73 #define UNTRACE BC_Trace::delete_traces();
79 #define PRINT_TRACE { printf("%s: %d\n", __FILE__, __LINE__); fflush(stdout); }
80 //#define PRINT_TRACE ;
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);
97 // Release current owner of lock
98 #define UNSET_LOCK(info) BC_Trace::unset_lock(info);
100 #define UNSET_ALL_LOCKS(info) BC_Trace::unset_all_locks(info);
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);
108 #define SET_LOCK(title, location) ;
110 #define SET_LOCK2_CONDITION ;
111 #define UNSET_LOCK(info) ;
112 #define UNSET_LOCK2 ;
113 #define UNSET_ALL_LOCKS(info) ;
115 #define LOCK_LOCKS(s) ;
116 #define UNLOCK_LOCKS ;
117 #define CLEAR_LOCKS_TID(tid) ;
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);
134 #define ENABLE_BUFFER ;
135 #define DISABLE_BUFFER ;
136 #define BUFFER(size, ptr, location);
137 #define UNBUFFER(ptr);
141 // Handling of temporary files in crash
142 #define SET_TEMP BC_Trace::set_temp
143 #define UNSET_TEMP BC_Trace::unset_temp