mirror of
https://github.com/wiiu-env/PatchMemoryRelocationsModule.git
synced 2024-11-30 21:54:16 +01:00
Only do logging when built with make DEBUG=1
This commit is contained in:
parent
ac8bd0746c
commit
d827cfa663
7
Makefile
7
Makefile
@ -28,7 +28,7 @@ INCLUDES := source
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
CFLAGS := -g -Wall -Wextra -O0 -ffunction-sections\
|
CFLAGS := -Wall -Wextra -O0 -ffunction-sections\
|
||||||
$(MACHDEP)
|
$(MACHDEP)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
@ -38,6 +38,11 @@ CXXFLAGS := $(CFLAGS) -std=c++17
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS)
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -DDEBUG -g
|
||||||
|
CCFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
LIBS := -lwums -lwut -lmappedmemory
|
LIBS := -lwums -lwut -lmappedmemory
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
#ifndef __LOGGER_H_
|
#pragma once
|
||||||
#define __LOGGER_H_
|
|
||||||
|
#include <whb/log.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#ifdef DEBUG
|
||||||
#include <whb/log.h>
|
|
||||||
|
|
||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
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(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
@ -25,8 +22,17 @@ extern "C" {
|
|||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
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
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#include <wums.h>
|
#include <wums.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
#include <whb/log_cafe.h>
|
#include <whb/log_cafe.h>
|
||||||
#include <whb/log_udp.h>
|
#include <whb/log_udp.h>
|
||||||
#include <whb/log_module.h>
|
#include <whb/log_module.h>
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
@ -15,6 +19,10 @@ WUMS_MODULE_INIT_BEFORE_RELOCATION_DONE_HOOK();
|
|||||||
bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||||
RelocationType reloc_type);
|
RelocationType reloc_type);
|
||||||
|
|
||||||
|
uint32_t moduleLogInit = false;
|
||||||
|
uint32_t cafeLogInit = false;
|
||||||
|
uint32_t udpLogInit = false;
|
||||||
|
|
||||||
WUMS_RELOCATIONS_DONE(args) {
|
WUMS_RELOCATIONS_DONE(args) {
|
||||||
module_information_t *gModuleData = args.module_information;
|
module_information_t *gModuleData = args.module_information;
|
||||||
if (args.module_information == nullptr) {
|
if (args.module_information == nullptr) {
|
||||||
@ -24,10 +32,12 @@ WUMS_RELOCATIONS_DONE(args) {
|
|||||||
OSFatal("PatchMemoryRelocations: The module information struct version does not match.");
|
OSFatal("PatchMemoryRelocations: The module information struct version does not match.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WHBLogModuleInit()) {
|
#ifdef DEBUG
|
||||||
WHBLogCafeInit();
|
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||||
WHBLogUdpInit();
|
cafeLogInit = WHBLogCafeInit();
|
||||||
|
udpLogInit = WHBLogUdpInit();
|
||||||
}
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
for (int32_t i = 0; i < gModuleData->number_used_modules; i++) {
|
for (int32_t i = 0; i < gModuleData->number_used_modules; i++) {
|
||||||
if (strcmp("homebrew_memorymapping", gModuleData->module_data[i].module_export_name) == 0 ||
|
if (strcmp("homebrew_memorymapping", gModuleData->module_data[i].module_export_name) == 0 ||
|
||||||
@ -59,6 +69,20 @@ WUMS_RELOCATIONS_DONE(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (moduleLogInit) {
|
||||||
|
WHBLogModuleDeinit();
|
||||||
|
moduleLogInit = false;
|
||||||
|
}
|
||||||
|
if (cafeLogInit) {
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
cafeLogInit = false;
|
||||||
|
}
|
||||||
|
if (udpLogInit) {
|
||||||
|
WHBLogUdpDeinit();
|
||||||
|
udpLogInit = false;
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
#define R_PPC_NONE 0
|
#define R_PPC_NONE 0
|
||||||
|
Loading…
Reference in New Issue
Block a user