6#ifndef LIBCWD_CLASS_DEBUG_INL
7#define LIBCWD_CLASS_DEBUG_INL
9#include "Channel.inl.h"
10#include "DebugString.inl.h"
11#include "FatalChannel.inl.h"
26 LIBCWD_TSD_DECLARATION;
32 LIBCWD_TSD_DECLARATION;
38 LIBCWD_TSD_DECLARATION;
44 LIBCWD_TSD_DECLARATION;
50 LIBCWD_TSD_DECLARATION;
51 return LIBCWD_TSD_MEMBER(
margin);
56 LIBCWD_TSD_DECLARATION;
57 return LIBCWD_TSD_MEMBER(
margin);
62 LIBCWD_TSD_DECLARATION;
63 return LIBCWD_TSD_MEMBER(
marker);
68 LIBCWD_TSD_DECLARATION;
69 return LIBCWD_TSD_MEMBER(
marker);
77 LIBCWD_TSD_DECLARATION;
78 LIBCWD_TSD_MEMBER(indent) = i;
86 LIBCWD_TSD_DECLARATION;
87 LIBCWD_TSD_MEMBER(indent) += i;
95 LIBCWD_TSD_DECLARATION;
96 int prev_indent = LIBCWD_TSD_MEMBER(indent);
97 LIBCWD_TSD_MEMBER(indent) = (i > prev_indent) ? 0 : (prev_indent - i);
105 LIBCWD_TSD_DECLARATION;
106 return LIBCWD_TSD_MEMBER(indent);
119 std::ostream* real_os_ptr;
120 real_os_ptr = ostream_state_.read_real_os();
124inline bool DebugObject::has_mutex()
const
127 has_mutex = ostream_state_.has_mutex();
131#ifndef HIDE_FROM_DOXYGEN
133inline LockInterfaceBase* OstreamState::replace_with(std::ostream* os,
134 LockInterfaceBase* new_mutex)
136 std::lock_guard<std::mutex> lock(state_mutex_);
137 LockInterfaceBase* old_mutex = mutex_;
149inline void OstreamState::set_ostream(std::ostream* os)
151 std::lock_guard<std::mutex> lock(state_mutex_);
152 LockInterfaceBase* old_mutex = mutex_;
162inline std::ostream* OstreamState::read_real_os()
const
164 std::lock_guard<std::mutex> lock(state_mutex_);
168inline bool OstreamState::has_mutex()
const
170 std::lock_guard<std::mutex> lock(state_mutex_);
171 return mutex_ !=
nullptr;
174inline std::ostream* OstreamState::get_locked_os(std::ostream* os,
175 LockInterfaceBase** locked_mutex_out)
const
177 std::lock_guard<std::mutex> lock(state_mutex_);
178 std::ostream* locked_os = os ? os : real_os_;
179 *locked_mutex_out = mutex_;
188inline bool OstreamState::try_lock_os(std::ostream* os, std::ostream** locked_os_out,
189 LockInterfaceBase** locked_mutex_out)
const
191 std::lock_guard<std::mutex> lock(state_mutex_);
193 if (mutex_ && mutex_->try_lock())
195 *locked_os_out = os ? os : real_os_;
196 *locked_mutex_out = mutex_;
200inline void OstreamState::write_color_off_newline(std::ostream* os,
char const* color_off,
201 std::size_t color_off_size)
const
203 std::lock_guard<std::mutex> lock(state_mutex_);
204 std::ostream* target_os = os ? os : real_os_;
205 if (color_off_size > 0)
206 target_os->write(color_off, color_off_size);
207 target_os->put(
'\n');
225 LIBCWD_TSD_DECLARATION;
227 if (!NS_init(LIBCWD_TSD))
230 [[maybe_unused]]
bool success = NS_init(LIBCWD_TSD);
239 LIBCWD_TSD_DECLARATION;
240 ++LIBCWD_TSD_MEMBER_OFF;
268 LIBCWD_TSD_DECLARATION;
269#if CWDEBUG_DEBUGOUTPUT
270 if (LIBCWD_TSD_MEMBER(first_time) && LIBCWD_TSD_MEMBER_OFF == -1)
271 LIBCWD_TSD_MEMBER(first_time) =
false;
273 --LIBCWD_TSD_MEMBER_OFF;
275 --LIBCWD_TSD_MEMBER_OFF;
279inline bool DebugObject::is_on(LIBCWD_TSD_PARAM)
const
281 return __libcwd_tsd.debug_object_off_array[index_] == -1;
309 if (always_flush_ <= 0)
315inline bool DebugObject::always_flush_is_on()
const
317 return always_flush_ > 0;
320inline ChannelSet& ChannelSetBootstrap::operator|(
Channel const& dc)
325 return *
reinterpret_cast<ChannelSet*
>(
this);
328inline ChannelSet& FatalChannelSetBootstrap::operator|(FatalChannel
const& fdc)
330 mask = fdc.get_maskbit();
331 label = fdc.get_label();
333 return *
reinterpret_cast<ChannelSet*
>(
this);
This object represents a debug channel, it has a fixed label. A debug channel can be viewed upon as a...
Definition Channel.h:74
char const * get_label() const
Pointer to the label of the debug channel.
Definition Channel.inl.h:44
bool is_on() const
Returns true if the channel is active.
Definition Channel.inl.h:35
void always_flush_on()
Turn always-flush for this debug object on.
Definition DebugObject.inl.h:287
void on()
Cancel last call to off().
Definition DebugObject.inl.h:266
DebugObject()
Constructor.
Definition DebugObject.inl.h:223
void off()
Turn this debug object off.
Definition DebugObject.inl.h:237
void always_flush_off()
Cancel last call to always_flush_on().
Definition DebugObject.inl.h:306
A string class used for the debug output margin and marker.
Definition DebugString.h:34
void core_dump()
Dump core of current thread.
Definition debug.cxx:697
std::ostream * get_ostream() const
Get the ostream device as set with set_ostream().
Definition DebugObject.inl.h:117