xtd_c - Reference Guide 0.2.0
debug.h
Go to the documentation of this file.
1 
6 #pragma once
7 #include "../types.h"
8 #include "current_stack_frame.h"
9 #include "debugger.h"
11 
32 typedef struct {
33  xtd_diagnostics_current_stack_frame current_stack_frame;
34  bool condition;
35  const char* message;
36 } __assert_args__;
37 
38 bool __var_xtd_diagnostics_debug_should_aborted__(__assert_args__ args);
39 void __xtd_diagnostics_debug_write__(const char* message, const char* category);
40 void __xtd_diagnostics_debug_write_if__(bool condition, const char* message, const char* category);
41 void __xtd_diagnostics_debug_write_line__(const char* message, const char* category);
42 void __xtd_diagnostics_debug_write_line_if__(bool condition, const char* message, const char* category);
47 
48 
72 
84 void xtd_diagnostics_debug_set_indent_level(uint32_t indent_level);
85 
97 void xtd_diagnostics_debug_set_indent_size(uint32_t indent_size);
114 inline_ void xtd_diagnostics_debug_write(const char* message, const char* category) {
115 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
116  __xtd_diagnostics_debug_write__(message, category);
117 #endif
118 }
119 
131 inline_ void xtd_diagnostics_debug_write_if(bool condition, const char* message, const char* category) {
132 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
133  __xtd_diagnostics_debug_write_if__(condition, message, category);
134 #endif
135 }
136 
148 inline_ void xtd_diagnostics_debug_write_line(const char* message, const char* category) {
149 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
150  __xtd_diagnostics_debug_write_line__(message, category);
151 #endif
152 }
153 
165 inline_ void xtd_diagnostics_debug_write_line_if(bool condition, const char* message, const char* category) {
166 #if !defined(NDEBUG) || defined(DEBUG) || defined(TRACE)
167  __xtd_diagnostics_debug_write_line_if__(condition, message, category);
168 #endif
169 }
186 #define assert_(...) \
187  if (__var_xtd_diagnostics_debug_should_aborted__((__assert_args__){csf_, __VA_ARGS__})) debug_break_()
188 
203 #define cassert_(...) \
204  assert_(__VA_ARGS__)
xtd_diagnostics_trace_listener_collection xtd_diagnostics_listener_collection
Represents a collection of xtd_diagnostics_trace_listener.
Definition: debug.h:46
Contains debugger definitions.
Defines the stack_frame object.
Definition: current_stack_frame.h:23
uint32_t xtd_diagnostics_debug_get_indent_size()
Gets the number of spaces in an indent.
uint32_t xtd_diagnostics_debug_get_indent_level()
Gets the indent level.
inline_ void xtd_diagnostics_debug_write_line_if(bool condition, const char *message, const char *category)
Writes a category name and message followed by a line terminator to the trace listeners in the Listen...
Definition: debug.h:165
Contains stack_frame definitions.
void xtd_diagnostics_debug_set_indent_level(uint32_t indent_level)
Sets the indent level.
void xtd_diagnostics_debug_set_indent_size(uint32_t indent_size)
Sets the number of spaces in an indent.
inline_ void xtd_diagnostics_debug_write(const char *message, const char *category)
Writes a category name and message to the trace listeners in the listeners collection.
Definition: debug.h:114
Contains trace_listener_collection definitions.
inline_ void xtd_diagnostics_debug_write_if(bool condition, const char *message, const char *category)
Writes a category name and message to the trace listeners in the Listeners collection if a condition ...
Definition: debug.h:131
void xtd_diagnostics_debug_set_auto_flush(bool value)
Sets whether xtd_diagnostics_debug_flush should be called on the xtd_diagnostics_debug_Listeners afte...
inline_ void xtd_diagnostics_debug_write_line(const char *message, const char *category)
Writes a category name and message followed by a line terminator to the trace listeners in the listen...
Definition: debug.h:148
bool xtd_diagnostics_debug_get_auto_flush()
Gets whether xtd_diagnostics_debug_flush should be called on the xtd_diagnostics_debug_Listeners afte...
Defines the trace_listener_collection object.
Definition: trace_listener_collection.h:16