aboutsummaryrefslogtreecommitdiff
path: root/include/debug.h
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2019-09-02 18:49:43 +0200
committerAndrea Fioraldi <andreafioraldi@gmail.com>2019-09-02 18:49:43 +0200
commitb24639d0113e15933e749ea0f96abe3f25a134a0 (patch)
tree4272020625c80c0d6982d3787bebc573c0da01b8 /include/debug.h
parent2ae4ca91b48407add0e940ee13bd8b385e319a7a (diff)
downloadafl++-b24639d0113e15933e749ea0f96abe3f25a134a0.tar.gz
run code formatter
Diffstat (limited to 'include/debug.h')
-rw-r--r--include/debug.h180
1 files changed, 107 insertions, 73 deletions
diff --git a/include/debug.h b/include/debug.h
index c0044280..6a59ad7a 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -108,39 +108,39 @@
#ifdef FANCY_BOXES
-# define SET_G1 "\x1b)0" /* Set G1 for box drawing */
-# define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */
-# define bSTART "\x0e" /* Enter G1 drawing mode */
-# define bSTOP "\x0f" /* Leave G1 drawing mode */
-# define bH "q" /* Horizontal line */
-# define bV "x" /* Vertical line */
-# define bLT "l" /* Left top corner */
-# define bRT "k" /* Right top corner */
-# define bLB "m" /* Left bottom corner */
-# define bRB "j" /* Right bottom corner */
-# define bX "n" /* Cross */
-# define bVR "t" /* Vertical, branch right */
-# define bVL "u" /* Vertical, branch left */
-# define bHT "v" /* Horizontal, branch top */
-# define bHB "w" /* Horizontal, branch bottom */
+# define SET_G1 "\x1b)0" /* Set G1 for box drawing */
+# define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */
+# define bSTART "\x0e" /* Enter G1 drawing mode */
+# define bSTOP "\x0f" /* Leave G1 drawing mode */
+# define bH "q" /* Horizontal line */
+# define bV "x" /* Vertical line */
+# define bLT "l" /* Left top corner */
+# define bRT "k" /* Right top corner */
+# define bLB "m" /* Left bottom corner */
+# define bRB "j" /* Right bottom corner */
+# define bX "n" /* Cross */
+# define bVR "t" /* Vertical, branch right */
+# define bVL "u" /* Vertical, branch left */
+# define bHT "v" /* Horizontal, branch top */
+# define bHB "w" /* Horizontal, branch bottom */
#else
-# define SET_G1 ""
+# define SET_G1 ""
# define RESET_G1 ""
-# define bSTART ""
-# define bSTOP ""
-# define bH "-"
-# define bV "|"
-# define bLT "+"
-# define bRT "+"
-# define bLB "+"
-# define bRB "+"
-# define bX "+"
-# define bVR "+"
-# define bVL "+"
-# define bHT "+"
-# define bHB "+"
+# define bSTART ""
+# define bSTOP ""
+# define bH "-"
+# define bV "|"
+# define bLT "+"
+# define bRT "+"
+# define bLB "+"
+# define bRB "+"
+# define bX "+"
+# define bVR "+"
+# define bVL "+"
+# define bHT "+"
+# define bHB "+"
#endif /* ^FANCY_BOXES */
@@ -148,11 +148,11 @@
* Misc terminal codes *
***********************/
-#define TERM_HOME "\x1b[H"
-#define TERM_CLEAR TERM_HOME "\x1b[2J"
-#define cEOL "\x1b[0K"
-#define CURSOR_HIDE "\x1b[?25l"
-#define CURSOR_SHOW "\x1b[?25h"
+#define TERM_HOME "\x1b[H"
+#define TERM_CLEAR TERM_HOME "\x1b[2J"
+#define cEOL "\x1b[0K"
+#define CURSOR_HIDE "\x1b[?25l"
+#define CURSOR_SHOW "\x1b[?25h"
/************************
* Debug & error macros *
@@ -161,91 +161,125 @@
/* Just print stuff to the appropriate stream. */
#ifdef MESSAGES_TO_STDOUT
-# define SAYF(x...) printf(x)
-#else
-# define SAYF(x...) fprintf(stderr, x)
+# define SAYF(x...) printf(x)
+#else
+# define SAYF(x...) fprintf(stderr, x)
#endif /* ^MESSAGES_TO_STDOUT */
/* Show a prefixed warning. */
-#define WARNF(x...) do { \
+#define WARNF(x...) \
+ do { \
+ \
SAYF(cYEL "[!] " cBRI "WARNING: " cRST x); \
- SAYF(cRST "\n"); \
+ SAYF(cRST "\n"); \
+ \
} while (0)
/* Show a prefixed "doing something" message. */
-#define ACTF(x...) do { \
+#define ACTF(x...) \
+ do { \
+ \
SAYF(cLBL "[*] " cRST x); \
- SAYF(cRST "\n"); \
+ SAYF(cRST "\n"); \
+ \
} while (0)
/* Show a prefixed "success" message. */
-#define OKF(x...) do { \
+#define OKF(x...) \
+ do { \
+ \
SAYF(cLGN "[+] " cRST x); \
- SAYF(cRST "\n"); \
+ SAYF(cRST "\n"); \
+ \
} while (0)
/* Show a prefixed fatal error message (not used in afl). */
-#define BADF(x...) do { \
+#define BADF(x...) \
+ do { \
+ \
SAYF(cLRD "\n[-] " cRST x); \
- SAYF(cRST "\n"); \
+ SAYF(cRST "\n"); \
+ \
} while (0)
/* Die with a verbose non-OS fatal error message. */
-#define FATAL(x...) do { \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \
- cRST x); \
- SAYF(cLRD "\n Location : " cRST "%s(), %s:%u\n\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- exit(1); \
+#define FATAL(x...) \
+ do { \
+ \
+ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
+ "\n[-] PROGRAM ABORT : " cRST x); \
+ SAYF(cLRD "\n Location : " cRST "%s(), %s:%u\n\n", __FUNCTION__, \
+ __FILE__, __LINE__); \
+ exit(1); \
+ \
} while (0)
/* Die by calling abort() to provide a core dump. */
-#define ABORT(x...) do { \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] PROGRAM ABORT : " \
- cRST x); \
- SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- abort(); \
+#define ABORT(x...) \
+ do { \
+ \
+ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
+ "\n[-] PROGRAM ABORT : " cRST x); \
+ SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n\n", __FUNCTION__, \
+ __FILE__, __LINE__); \
+ abort(); \
+ \
} while (0)
/* Die while also including the output of perror(). */
-#define PFATAL(x...) do { \
- fflush(stdout); \
- SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD "\n[-] SYSTEM ERROR : " \
- cRST x); \
- SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n", \
- __FUNCTION__, __FILE__, __LINE__); \
- SAYF(cLRD " OS message : " cRST "%s\n", strerror(errno)); \
- exit(1); \
+#define PFATAL(x...) \
+ do { \
+ \
+ fflush(stdout); \
+ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
+ "\n[-] SYSTEM ERROR : " cRST x); \
+ SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n", __FUNCTION__, \
+ __FILE__, __LINE__); \
+ SAYF(cLRD " OS message : " cRST "%s\n", strerror(errno)); \
+ exit(1); \
+ \
} while (0)
/* Die with FAULT() or PFAULT() depending on the value of res (used to
interpret different failure modes for read(), write(), etc). */
-#define RPFATAL(res, x...) do { \
- if (res < 0) PFATAL(x); else FATAL(x); \
+#define RPFATAL(res, x...) \
+ do { \
+ \
+ if (res < 0) \
+ PFATAL(x); \
+ else \
+ FATAL(x); \
+ \
} while (0)
/* Error-checking versions of read() and write() that call RPFATAL() as
appropriate. */
-#define ck_write(fd, buf, len, fn) do { \
- u32 _len = (len); \
- s32 _res = write(fd, buf, _len); \
+#define ck_write(fd, buf, len, fn) \
+ do { \
+ \
+ u32 _len = (len); \
+ s32 _res = write(fd, buf, _len); \
if (_res != _len) RPFATAL(_res, "Short write to %s", fn); \
+ \
} while (0)
-#define ck_read(fd, buf, len, fn) do { \
- u32 _len = (len); \
- s32 _res = read(fd, buf, _len); \
+#define ck_read(fd, buf, len, fn) \
+ do { \
+ \
+ u32 _len = (len); \
+ s32 _res = read(fd, buf, _len); \
if (_res != _len) RPFATAL(_res, "Short read from %s", fn); \
+ \
} while (0)
#endif /* ! _HAVE_DEBUG_H */
+