mirror of https://github.com/xzeldon/htop.git
CRT: add debug printing function
This commit is contained in:
parent
2ae1906479
commit
1da78b5818
11
CRT.c
11
CRT.c
|
@ -13,6 +13,7 @@ in the source distribution for its full text.
|
|||
#include <fcntl.h>
|
||||
#include <langinfo.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -844,6 +845,16 @@ static void dumpStderr(void) {
|
|||
stderrRedirectNewFd = -1;
|
||||
}
|
||||
|
||||
void CRT_debug_impl(const char* file, size_t lineno, const char* func, const char* fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "[%s:%zu (%s)]: ", file, lineno, func);
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#else /* !NDEBUG */
|
||||
|
||||
static void redirectStderr(void) {
|
||||
|
|
7
CRT.h
7
CRT.h
|
@ -150,6 +150,13 @@ typedef enum ColorElements_ {
|
|||
|
||||
void CRT_fatalError(const char* note) ATTR_NORETURN;
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define CRT_debug(...)
|
||||
#else
|
||||
void CRT_debug_impl(const char* file, size_t lineno, const char* func, const char* fmt, ...) ATTR_FORMAT(printf, 4, 5);
|
||||
# define CRT_debug(...) CRT_debug_impl(__FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
|
||||
|
||||
#define KEY_WHEELUP KEY_F(30)
|
||||
|
|
Loading…
Reference in New Issue