Beamlib  3.0.1
This is the Beam C++ class library.
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 
16 extern int bdebug;
17 
19 void bhd8(const void* data, unsigned int n);
20 void bhd8a(const void* data, unsigned int n);
21 void bhda8(const void* data, unsigned int n);
22 void bhd32(const void* data, unsigned int n);
23 void bhds32(const void* data, unsigned int n);
24 double getTime();
25 void setDebug(int debug);
26 void tprintf(int log, const char* fmt, ...);
27 
28 pid_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 
78 public:
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);
86 private:
87 };
88 
89 #endif
void bhda8(const void *data, unsigned int n)
Definition: BDebug.cpp:56
void bhds32(const void *data, unsigned int n)
double getTime()
Definition: BDebug.cpp:97
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:207
pid_t bgettid()
void setDebug(int debug)
Definition: BDebug.cpp:105
void bhd32(const void *data, unsigned int n)
Definition: BDebug.cpp:70
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)