Implement support for WUMS 0.2

This commit is contained in:
Maschell
2021-09-17 16:22:54 +02:00
parent b17b522d6b
commit 74f7b8a662
11 changed files with 118 additions and 113 deletions

View File

@@ -14,6 +14,10 @@ extern "C" {
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#ifdef __cplusplus
}
#endif

View File

@@ -1,9 +1,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <malloc.h>
#include <whb/log.h>
#include "utils/logger.h"
// https://gist.github.com/ccbrown/9722406
@@ -11,30 +8,30 @@ void dumpHex(const void *data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
DEBUG_FUNCTION_LINE_WRITE("0x%08X (0x0000): ", data);
for (i = 0; i < size; ++i) {
WHBLogPrintf("%02X ", ((unsigned char *) data)[i]);
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
ascii[i % 16] = ((unsigned char *) data)[i];
} else {
ascii[i % 16] = '.';
}
if ((i + 1) % 8 == 0 || i + 1 == size) {
WHBLogPrintf(" ");
WHBLogWritef(" ");
if ((i + 1) % 16 == 0) {
WHBLogPrintf("| %s \n", ascii);
WHBLogPrintf("| %s ", ascii);
if (i + 1 < size) {
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", data + i + 1, i + 1);
DEBUG_FUNCTION_LINE_WRITE("0x%08X (0x%04X); ", data + i + 1, i + 1);
}
} else if (i + 1 == size) {
ascii[(i + 1) % 16] = '\0';
if ((i + 1) % 16 <= 8) {
WHBLogPrintf(" ");
WHBLogWritef(" ");
}
for (j = (i + 1) % 16; j < 16; ++j) {
WHBLogPrintf(" ");
WHBLogWritef(" ");
}
WHBLogPrintf("| %s \n", ascii);
WHBLogPrintf("| %s ", ascii);
}
}
}