mirror of
https://github.com/wiiu-env/MemoryMappingModule.git
synced 2026-08-20 08:04:06 -05:00
Implement logging, but only when built with make DEBUG=1
This commit is contained in:
36
source/logger.c
Normal file
36
source/logger.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifdef DEBUG
|
||||
#include <stdint.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/log_cafe.h>
|
||||
#include <whb/log_module.h>
|
||||
|
||||
uint32_t moduleLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
uint32_t udpLogInit = false;
|
||||
#endif // DEBUG
|
||||
|
||||
void initLogging() {
|
||||
#ifdef DEBUG
|
||||
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||
cafeLogInit = WHBLogCafeInit();
|
||||
udpLogInit = WHBLogUdpInit();
|
||||
}
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
void deinitLogging() {
|
||||
#ifdef DEBUG
|
||||
if (moduleLogInit) {
|
||||
WHBLogModuleDeinit();
|
||||
moduleLogInit = false;
|
||||
}
|
||||
if (cafeLogInit) {
|
||||
WHBLogCafeDeinit();
|
||||
cafeLogInit = false;
|
||||
}
|
||||
if (udpLogInit) {
|
||||
WHBLogUdpDeinit();
|
||||
udpLogInit = false;
|
||||
}
|
||||
#endif // DEBUG
|
||||
}
|
||||
@@ -1,20 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <whb/log.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
#ifdef DEBUG
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while(0)
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
@@ -22,8 +20,23 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#endif
|
||||
|
||||
void initLogging();
|
||||
|
||||
void deinitLogging();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#include <wums.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include "memory_mapping.h"
|
||||
#include <function_patcher/function_patching.h>
|
||||
#include "logger.h"
|
||||
#include "function_replacements.h"
|
||||
#include "logger.h"
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_memorymapping");
|
||||
WUMS_MODULE_SKIP_INIT_FINI();
|
||||
@@ -23,6 +20,16 @@ WUMS_INITIALIZE(args) {
|
||||
FunctionPatcherPatchFunction(function_replacements, function_replacements_size);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
WUMS_APPLICATION_STARTS() {
|
||||
initLogging();
|
||||
}
|
||||
|
||||
WUMS_APPLICATION_REQUESTS_EXIT() {
|
||||
deinitLogging();
|
||||
}
|
||||
#endif
|
||||
|
||||
void MemoryMappingFree(void *ptr) {
|
||||
//DEBUG_FUNCTION_LINE("[%08X] free", ptr);
|
||||
MemoryMapping_free(ptr);
|
||||
|
||||
@@ -61,7 +61,7 @@ void readAndPrintSegmentRegister(CThread *thread, void *arg) {
|
||||
DCFlushRange(&srTable, sizeof(srTable));
|
||||
|
||||
for (int32_t i = 0; i < 16; i++) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%d] SR[%d]=%08X", core, i, srTable.value[i]);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("[%d] SR[%d]=%08X", OSGetThreadAffinity(OSGetCurrentThread()) / 2, i, srTable.value[i]);
|
||||
}
|
||||
|
||||
uint32_t pageTable[0x8000];
|
||||
|
||||
Reference in New Issue
Block a user