Beamlib 3.1.2
This is the Beam C++ class library.
Loading...
Searching...
No Matches
BDebug.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BDebug.h Debug information and routines
3 * T.Barnaby, BEAM Ltd, 2009-01-05
4 * Copyright (c) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 */
8#ifndef BDebug_H
9#define BDebug_H
10
11#include <stdio.h>
12#include <time.h>
13
14#define BDebug_STD 0x000001
15
16extern int bdebug;
17
19void bhd8(const void* data, unsigned int n);
20void bhd8a(const void* data, unsigned int n);
21void bhda8(const void* data, unsigned int n);
22void bhd32(const void* data, unsigned int n);
23void bhds32(const void* data, unsigned int n);
24double getTime();
25void setDebug(int debug);
26void tprintf(int log, const char* fmt, ...);
27
28pid_t bgettid();
29
31#if BDEBUG
32#define dprintf(level, fmt, a...) if((level) & bdebug) tprintf(1, fmt, ##a);
33#else
34#define dprintf(level, fmt, a...)
35#endif
36
38#if !TARGET_win32 && !TARGET_win64
39#include <syslog.h>
40
41#if BDEBUG
42#define nprintf(fmt, a...) { syslog(LOG_NOTICE, fmt, ##a); tprintf(0, fmt, ##a); }
43#define wprintf(fmt, a...) { syslog(LOG_WARNING, fmt, ##a); tprintf(0, fmt, ##a); }
44#define eprintf(fmt, a...) { syslog(LOG_ERR, fmt, ##a); tprintf(0, fmt, ##a); }
45#else
46#define nprintf(fmt, a...) syslog(LOG_NOTICE, fmt, ##a)
47#define wprintf(fmt, a...) syslog(LOG_WARNING, fmt, ##a)
48#define eprintf(fmt, a...) syslog(LOG_ERR, fmt, ##a)
49#endif
50#endif
51
52#if BDEBUGL1
53#define dl1printf(fmt, a...) printf(fmt, ##a);
54#else
55#define dl1printf(fmt, a...)
56#endif
57
58#if BDEBUGL2
59#define dl2printf(fmt, a...) printf(fmt, ##a);
60#else
61#define dl2printf(fmt, a...)
62#endif
63
64#if BDEBUGL3
65#define dl3printf(fmt, a...) printf(fmt, ##a);
66#else
67#define dl3printf(fmt, a...)
68#endif
69
70#if BDEBUGL4
71#define dl4printf(fmt, a...) printf(fmt, ##a);
72#else
73#define dl4printf(fmt, a...)
74#endif
75
78public:
81
82 void dumpBacktraceStdout(char* comment);
83 int dumpBacktraceFile(char* fileName, char* comment);
84 void dumpBacktraceSyslog(char* comment);
85 void dumpBacktrace(char* strBuf, int strBufLen, char* comment);
86private:
87};
88
89#endif
void bhda8(const void *data, unsigned int n)
Definition: BDebug.cpp:62
void bhds32(const void *data, unsigned int n)
double getTime()
Definition: BDebug.cpp:103
void bhd8a(const void *data, unsigned int n)
Definition: BDebug.cpp:33
int bdebug
Definition: BDebug.cpp:19
void tprintf(int log, const char *fmt,...)
Definition: BDebug.cpp:213
pid_t bgettid()
void setDebug(int debug)
Definition: BDebug.cpp:111
void bhd32(const void *data, unsigned int n)
Definition: BDebug.cpp:76
void bhd8(const void *data, unsigned int n)
Software debug functions.
Definition: BDebug.cpp:21
char data[8]
Definition: BoapMc1.h:2
Backtrace on crash class.
Definition: BDebug.h:77
int dumpBacktraceFile(char *fileName, char *comment)
void dumpBacktraceSyslog(char *comment)
void dumpBacktrace(char *strBuf, int strBufLen, char *comment)
void dumpBacktraceStdout(char *comment)