18 #ifdef HAVE_SEMAPHORE_H 30 #ifdef HAVE_SEMAPHORE_H 38 #ifdef HAVE_SEMAPHORE_H 45 #ifdef HAVE_SEMAPHORE_H 52 if ((
debug_fp = fopen(fname,
"wb")) == NULL) {
53 fprintf(stderr,
"Opening of file %s failed\n", fname);
62 func_ptr->
name = strdup(
function);
79 DIE((
"function list is empty!\n"));
91 fprintf(
debug_fp,
"%06d %.*s%s %s(%d) ", getpid(), le*4,
indent, func, file, line);
95 void pst_debug(
int level,
int line,
const char* file,
const char *fmt, ...) {
109 void pst_debug_hexdump(
int level,
int line,
const char *file,
const char *buf,
size_t size,
int cols,
int delta) {
121 size_t off = 0, toff;
126 if (cols == -1) cols =
NUM_COL;
129 fprintf(out,
"%06d %.*s%06"PRIx64
"\t:", getpid(), le*4,
indent, (int64_t)(off+delta));
131 while (count < cols && off < size) {
132 fprintf(out,
"%02hhx ", (
unsigned char)buf[off]);
136 while (count < cols) {
143 while (count < cols && off < size) {
144 fprintf(out,
"%c", isgraph(buf[off])?buf[off]:
'.');
161 free(func_ptr->
name);
170 void *mem = malloc(size);
172 fprintf(stderr,
"pst_malloc: Out Of memory [req: %ld]\n", (
long)size);
180 void *mem = realloc(ptr, size);
182 fprintf(stderr,
"pst_realloc: Out Of memory [req: %ld]\n", (
long)size);
void pst_debug_close(void)
void pst_debug_hexdumper(FILE *out, const char *buf, size_t size, int cols, int delta)
static struct pst_debug_func * func_head
void * pst_malloc(size_t size)
struct pst_debug_func * next
static int pst_debuglevel
void pst_debug_init(const char *fname, void *output_mutex)
void pst_debug_func(int level, const char *function)
void pst_debug_func_ret(int level)
static sem_t * debug_mutex
static void pst_debug_info(int level, int line, const char *file)
void pst_debug(int level, int line, const char *file, const char *fmt,...)
static char indent[32 *4+1]
void * pst_realloc(void *ptr, size_t size)
void pst_debug_hexdump(int level, int line, const char *file, const char *buf, size_t size, int cols, int delta)
void pst_debug_setlevel(int level)