Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Namespaces | Macros | Functions
debug.hpp File Reference
#include <memory>
#include <cstdint>
#include <cinttypes>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdarg>
#include <errno.h>
#include <jau/environment.hpp>
Include dependency graph for debug.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 jau
 

Macros

#define DBG_PRINT(...)   { if( jau::environment::get().debug ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] Debug: '. More...
 
#define DBG_JNI_PRINT(...)   { if( jau::environment::get().debug_jni ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::DEBUG_JNI conditional debug messages, prefix '[elapsed_time] Debug: '. More...
 
#define WORDY_PRINT(...)   { if( jau::environment::get().verbose ) { jau::WORDY_PRINT_impl(__VA_ARGS__); } }
 Use for environment-variable environment::VERBOSE conditional verbose messages, prefix '[elapsed_time] Wordy: '. More...
 
#define PERF_TS_T0_BASE()   const uint64_t _t0 = jau::getCurrentMilliseconds()
 
#define PERF_TS_TD_BASE(m)
 
#define PERF_TS_T0()
 
#define PERF_TS_TD(m)
 
#define PERF2_TS_T0()
 
#define PERF2_TS_TD(m)
 
#define PERF3_TS_T0()
 
#define PERF3_TS_TD(m)
 
#define ABORT(...)   { jau::ABORT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ FILE:LINE: '. More...
 
#define ERR_PRINT(...)   { jau::ERR_PRINT_impl("Error", true /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE: '. More...
 
#define ERR_PRINT2(...)   { jau::ERR_PRINT_impl("Error", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE: '. More...
 
#define IRQ_PRINT(...)   { jau::ERR_PRINT_impl("Interrupted", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional interruption messages, prefix '[elapsed_time] Interrupted @ FILE:LINE: '. More...
 
#define WARN_PRINT(...)   { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }
 Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE: '. More...
 
#define COND_PRINT(C, ...)   { if( C ) { jau::COND_PRINT_impl(__VA_ARGS__); } }
 Use for conditional plain messages, prefix '[elapsed_time] '. More...
 

Functions

std::string jau::get_backtrace (const bool skip_anon_frames, const jau::snsize_t max_frames=-1, const jau::nsize_t skip_frames=1) noexcept
 Returns a de-mangled backtrace string separated by newline excluding this function. More...
 
void jau::print_backtrace (const bool skip_anon_frames, const jau::snsize_t max_frames=-1, const jau::nsize_t skip_frames=2) noexcept
 Prints the de-mangled backtrace string separated by newline excluding this function to stderr, using get_backtrace(). More...
 
void jau::DBG_PRINT_impl (const char *format,...) noexcept
 
void jau::WORDY_PRINT_impl (const char *format,...) noexcept
 
void jau::ABORT_impl (const char *func, const char *file, const int line, const char *format,...) noexcept
 Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ file:line: '. More...
 
void jau::ERR_PRINTv (const char *func, const char *file, const int line, const char *format, va_list args) noexcept
 Use for unconditional error messages, prefix '[elapsed_time] Error @ file:line: '. More...
 
void jau::ERR_PRINT_impl (const char *prefix, const bool backtrace, const char *func, const char *file, const int line, const char *format,...) noexcept
 
void jau::WARN_PRINTv (const char *func, const char *file, const int line, const char *format, va_list args) noexcept
 Use for unconditional warning messages, prefix '[elapsed_time] Warning @ file:line: '. More...
 
void jau::WARN_PRINT_impl (const char *func, const char *file, const int line, const char *format,...) noexcept
 
void jau::INFO_PRINT (const char *format,...) noexcept
 Use for unconditional informal messages, prefix '[elapsed_time] Info: '. More...
 
void jau::PLAIN_PRINT (const bool printPrefix, const char *format,...) noexcept
 Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true. More...
 
int jau::fprintf_td (FILE *stream, const char *format,...) noexcept
 Convenient fprintf() invocation, prepending the environment::getElapsedMillisecond() timestamp. More...
 
void jau::COND_PRINT_impl (const char *format,...) noexcept
 
template<class List >
void jau::printSharedPtrList (std::string prefix, List &list) noexcept
 

Macro Definition Documentation

◆ ABORT

#define ABORT (   ...)    { jau::ABORT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ FILE:LINE: '.

Function also appends last errno and strerror(errno).

Definition at line 125 of file debug.hpp.

◆ COND_PRINT

#define COND_PRINT (   C,
  ... 
)    { if( C ) { jau::COND_PRINT_impl(__VA_ARGS__); } }

Use for conditional plain messages, prefix '[elapsed_time] '.

Definition at line 166 of file debug.hpp.

◆ DBG_JNI_PRINT

#define DBG_JNI_PRINT (   ...)    { if( jau::environment::get().debug_jni ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::DEBUG_JNI conditional debug messages, prefix '[elapsed_time] Debug: '.

Definition at line 82 of file debug.hpp.

◆ DBG_PRINT

#define DBG_PRINT (   ...)    { if( jau::environment::get().debug ) { jau::DBG_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] Debug: '.

Definition at line 79 of file debug.hpp.

◆ ERR_PRINT

#define ERR_PRINT (   ...)    { jau::ERR_PRINT_impl("Error", true /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE: '.

Function also appends last errno, strerror(errno) and full backtrace

Definition at line 133 of file debug.hpp.

◆ ERR_PRINT2

#define ERR_PRINT2 (   ...)    { jau::ERR_PRINT_impl("Error", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE: '.

Function also appends last errno and strerror(errno). No backtrace.

Definition at line 136 of file debug.hpp.

◆ IRQ_PRINT

#define IRQ_PRINT (   ...)    { jau::ERR_PRINT_impl("Interrupted", false /* backtrace */, __func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional interruption messages, prefix '[elapsed_time] Interrupted @ FILE:LINE: '.

Function also appends last errno and strerror(errno).

Definition at line 139 of file debug.hpp.

◆ PERF2_TS_T0

#define PERF2_TS_T0 ( )

Definition at line 110 of file debug.hpp.

◆ PERF2_TS_TD

#define PERF2_TS_TD (   m)

Definition at line 111 of file debug.hpp.

◆ PERF3_TS_T0

#define PERF3_TS_T0 ( )

Definition at line 117 of file debug.hpp.

◆ PERF3_TS_TD

#define PERF3_TS_TD (   m)

Definition at line 118 of file debug.hpp.

◆ PERF_TS_T0

#define PERF_TS_T0 ( )

Definition at line 103 of file debug.hpp.

◆ PERF_TS_T0_BASE

#define PERF_TS_T0_BASE ( )    const uint64_t _t0 = jau::getCurrentMilliseconds()

Definition at line 95 of file debug.hpp.

◆ PERF_TS_TD

#define PERF_TS_TD (   m)

Definition at line 104 of file debug.hpp.

◆ PERF_TS_TD_BASE

#define PERF_TS_TD_BASE (   m)
Value:
{ const uint64_t _td = jau::getCurrentMilliseconds() - _t0; \
fprintf(stderr, "[%'9" PRIu64 "] PERF %s done in %d ms,\n", jau::environment::getElapsedMillisecond(), (m), (int)_td); }

Definition at line 97 of file debug.hpp.

◆ WARN_PRINT

#define WARN_PRINT (   ...)    { jau::WARN_PRINT_impl(__func__, __FILE__, __LINE__, __VA_ARGS__); }

Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE: '.

Definition at line 147 of file debug.hpp.

◆ WORDY_PRINT

#define WORDY_PRINT (   ...)    { if( jau::environment::get().verbose ) { jau::WORDY_PRINT_impl(__VA_ARGS__); } }

Use for environment-variable environment::VERBOSE conditional verbose messages, prefix '[elapsed_time] Wordy: '.

'Wordy' is the shorter English form of the Latin word 'verbosus', from which the word 'verbosity' is sourced.

Definition at line 92 of file debug.hpp.

jau::environment::getElapsedMillisecond
static uint64_t getElapsedMillisecond() noexcept
Returns current elapsed monotonic time in milliseconds since module startup, see startupTimeMilliseco...
Definition: environment.hpp:80
jau::getCurrentMilliseconds
uint64_t getCurrentMilliseconds() noexcept
Returns current monotonic time in milliseconds.
Definition: basic_types.cpp:47