bzr branch
http://suren.me/webbzr/alps/pcitool
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
1 |
#ifndef _PCILIB_DEBUG_H
|
2 |
#define _PCILIB_DEBUG_H
|
|
3 |
||
252
by Suren A. Chilingaryan
Provide data debugging API |
4 |
#include <stdarg.h> |
271
by Suren A. Chilingaryan
Prevent excessive calling of getenv by debugging code for better performance |
5 |
#include <pcilib/env.h> |
314
by Suren A. Chilingaryan
Support writting register views |
6 |
#include <pcilib/error.h> |
252
by Suren A. Chilingaryan
Provide data debugging API |
7 |
|
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
8 |
#define PCILIB_DEBUG
|
9 |
||
10 |
#ifdef PCILIB_DEBUG
|
|
11 |
# define PCILIB_DEBUG_DMA
|
|
251
by Suren A. Chilingaryan
Add code to debug missing events while recording |
12 |
# define PCILIB_DEBUG_MISSING_EVENTS
|
314
by Suren A. Chilingaryan
Support writting register views |
13 |
# define PCILIB_DEBUG_VIEWS
|
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
14 |
#endif /* PCILIB_DEBUG */ |
15 |
||
16 |
||
17 |
#ifdef PCILIB_DEBUG_DMA
|
|
271
by Suren A. Chilingaryan
Prevent excessive calling of getenv by debugging code for better performance |
18 |
# define PCILIB_DEBUG_DMA_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
|
19 |
# define PCILIB_DEBUG_DMA_BUFFER(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
|
|
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
20 |
#else /* PCILIB_DEBUG_DMA */ |
252
by Suren A. Chilingaryan
Provide data debugging API |
21 |
# define PCILIB_DEBUG_DMA_MESSAGE(function, ...)
|
22 |
# define PCILIB_DEBUG_DMA_BUFFER(function, ...)
|
|
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
23 |
#endif /* PCILIB_DEBUG_DMA */ |
24 |
||
251
by Suren A. Chilingaryan
Add code to debug missing events while recording |
25 |
#ifdef PCILIB_DEBUG_MISSING_EVENTS
|
271
by Suren A. Chilingaryan
Prevent excessive calling of getenv by debugging code for better performance |
26 |
# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
|
27 |
# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) if (pcilib_getenv(function##_ENV #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
|
|
251
by Suren A. Chilingaryan
Add code to debug missing events while recording |
28 |
#else /* PCILIB_DEBUG_MISSING_EVENTS */ |
252
by Suren A. Chilingaryan
Provide data debugging API |
29 |
# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...)
|
30 |
# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...)
|
|
251
by Suren A. Chilingaryan
Add code to debug missing events while recording |
31 |
#endif /* PCILIB_DEBUG_MISSING_EVENTS */ |
32 |
||
314
by Suren A. Chilingaryan
Support writting register views |
33 |
#ifdef PCILIB_DEBUG_VIEWS
|
34 |
# define PCILIB_DEBUG_VIEWS_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
|
|
35 |
# define PCILIB_DEBUG_VIEWS_BUFFER(function, ...) if (pcilib_getenv(function##_ENV #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
|
|
36 |
#else /* PCILIB_DEBUG_VIEWS */ |
|
37 |
# define PCILIB_DEBUG_VIEWS_MESSAGE(function, ...)
|
|
38 |
# define PCILIB_DEBUG_VIEWS_BUFFER(function, ...)
|
|
39 |
#endif /* PCILIB_DEBUG_VIEWS */ |
|
40 |
||
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
41 |
#define pcilib_debug(function, ...) \
|
263
by Suren A. Chilingaryan
Support pcilib_log_once calls |
42 |
PCILIB_DEBUG_##function##_MESSAGE(PCILIB_DEBUG_##function, PCILIB_LOG_DEFAULT, __VA_ARGS__)
|
252
by Suren A. Chilingaryan
Provide data debugging API |
43 |
|
44 |
#define pcilib_debug_buffer(function, ...) \
|
|
45 |
PCILIB_DEBUG_##function##_BUFFER(PCILIB_DEBUG_##function, __VA_ARGS__)
|
|
46 |
||
271
by Suren A. Chilingaryan
Prevent excessive calling of getenv by debugging code for better performance |
47 |
|
252
by Suren A. Chilingaryan
Provide data debugging API |
48 |
typedef enum { |
49 |
PCILIB_DEBUG_BUFFER_APPEND = 1, |
|
50 |
PCILIB_DEBUG_BUFFER_MKDIR = 2 |
|
51 |
} pcilib_debug_buffer_flags_t; |
|
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
52 |
|
277
by Suren A. Chilingaryan
Keep C++ compilers happy |
53 |
|
54 |
#ifdef __cplusplus
|
|
55 |
extern "C" { |
|
56 |
#endif
|
|
57 |
||
263
by Suren A. Chilingaryan
Support pcilib_log_once calls |
58 |
void pcilib_debug_message(const char *function, const char *file, int line, pcilib_log_flags_t flags, const char *format, ...); |
252
by Suren A. Chilingaryan
Provide data debugging API |
59 |
void pcilib_debug_data_buffer(const char *function, size_t size, void *buffer, pcilib_debug_buffer_flags_t flags, const char *file, ...); |
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
60 |
|
61 |
||
277
by Suren A. Chilingaryan
Keep C++ compilers happy |
62 |
#ifdef __cplusplus
|
63 |
}
|
|
64 |
#endif
|
|
65 |
||
66 |
||
250
by Suren A. Chilingaryan
Provide an interface for logging debug messages |
67 |
#endif /* _PCILIB_DEBUG_H */ |