mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-25 14:16:53 +01:00
Deinit logging, only do logging when built with make DEBUG=1
This commit is contained in:
parent
b49f561430
commit
93eca9c403
9
Makefile
9
Makefile
@ -35,16 +35,21 @@ INCLUDES := source
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions -fno-rtti\
|
CFLAGS := -Wall -O2 -ffunction-sections\
|
||||||
$(MACHDEP)
|
$(MACHDEP)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -std=c++20
|
CXXFLAGS := $(CFLAGS) -std=c++20 -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS)
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -DDEBUG -g
|
||||||
|
CCFLAGS += -DDEBUG -g
|
||||||
|
endif
|
||||||
|
|
||||||
LIBS := -lwums -lwut -lwups -lfunctionpatcher -lmappedmemory -lfreetype -lbz2 -lpng -lz
|
LIBS := -lwums -lwut -lwups -lfunctionpatcher -lmappedmemory -lfreetype -lbz2 -lpng -lz
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#include <whb/log_udp.h>
|
|
||||||
#include <whb/log_cafe.h>
|
|
||||||
#include <whb/log_module.h>
|
|
||||||
#include <wums.h>
|
#include <wums.h>
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
@ -21,10 +18,7 @@ WUMS_MODULE_EXPORT_NAME("homebrew_wupsbackend");
|
|||||||
WUMS_USE_WUT_DEVOPTAB();
|
WUMS_USE_WUT_DEVOPTAB();
|
||||||
|
|
||||||
WUMS_INITIALIZE(args) {
|
WUMS_INITIALIZE(args) {
|
||||||
if (!WHBLogModuleInit()) {
|
initLogging();
|
||||||
WHBLogCafeInit();
|
|
||||||
WHBLogUdpInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
gModuleData = args.module_information;
|
gModuleData = args.module_information;
|
||||||
if (gModuleData == nullptr) {
|
if (gModuleData == nullptr) {
|
||||||
@ -33,11 +27,13 @@ WUMS_INITIALIZE(args) {
|
|||||||
if (gModuleData->version != MODULE_INFORMATION_VERSION) {
|
if (gModuleData->version != MODULE_INFORMATION_VERSION) {
|
||||||
OSFatal("WUPS-Backend: The module information struct version does not match.");
|
OSFatal("WUPS-Backend: The module information struct version does not match.");
|
||||||
}
|
}
|
||||||
WHBLogPrintf("Init successful");
|
DEBUG_FUNCTION_LINE("Init successful");
|
||||||
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
WUMS_APPLICATION_REQUESTS_EXIT() {
|
WUMS_APPLICATION_REQUESTS_EXIT() {
|
||||||
CallHook(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT);
|
CallHook(gPluginInformation, WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT);
|
||||||
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
WUMS_APPLICATION_ENDS() {
|
WUMS_APPLICATION_ENDS() {
|
||||||
@ -57,15 +53,13 @@ WUMS_APPLICATION_ENDS() {
|
|||||||
|
|
||||||
void *allocOnCustomHeap(int alignment, int size);
|
void *allocOnCustomHeap(int alignment, int size);
|
||||||
|
|
||||||
|
|
||||||
WUMS_APPLICATION_STARTS() {
|
WUMS_APPLICATION_STARTS() {
|
||||||
if (!WHBLogModuleInit()) {
|
|
||||||
WHBLogCafeInit();
|
|
||||||
WHBLogUdpInit();
|
|
||||||
}
|
|
||||||
uint32_t upid = OSGetUPID();
|
uint32_t upid = OSGetUPID();
|
||||||
if (upid != 2 && upid != 15) {
|
if (upid != 2 && upid != 15) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
initLogging();
|
||||||
bool initNeeded = false;
|
bool initNeeded = false;
|
||||||
if (gPluginDataHeap == nullptr) {
|
if (gPluginDataHeap == nullptr) {
|
||||||
DCFlushRange((void *) gModuleData, sizeof(module_information_t));
|
DCFlushRange((void *) gModuleData, sizeof(module_information_t));
|
||||||
@ -125,16 +119,19 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
std::vector<std::shared_ptr<PluginData>> pluginList = PluginDataFactory::loadDir("fs:/vol/external01/wiiu/plugins/", gPluginDataHeap);
|
std::vector<std::shared_ptr<PluginData>> pluginList = PluginDataFactory::loadDir("fs:/vol/external01/wiiu/plugins/", gPluginDataHeap);
|
||||||
DEBUG_FUNCTION_LINE("Loaded data for %d plugins.", pluginList.size());
|
DEBUG_FUNCTION_LINE("Loaded data for %d plugins.", pluginList.size());
|
||||||
|
|
||||||
auto plugins = PluginManagement::loadPlugins(pluginList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize);
|
|
||||||
|
|
||||||
|
auto plugins = PluginManagement::loadPlugins(pluginList, gPluginDataHeap, gTrampolineData, gTrampolineDataSize);
|
||||||
for (auto &pluginContainer: plugins) {
|
for (auto &pluginContainer: plugins) {
|
||||||
|
#ifdef DEBUG
|
||||||
for (const auto &kv: pluginContainer->getPluginInformation()->getSectionInfoList()) {
|
for (const auto &kv: pluginContainer->getPluginInformation()->getSectionInfoList()) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("%s = %s %08X %d", kv.first.c_str(), kv.second->getName().c_str(), kv.second->getAddress(), kv.second->getSize());
|
DEBUG_FUNCTION_LINE_VERBOSE("%s = %s %08X %d", kv.first.c_str(), kv.second->getName().c_str(), kv.second->getAddress(), kv.second->getSize());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
|
if (!PluginContainerPersistence::savePlugin(gPluginInformation, pluginContainer, gPluginDataHeap)) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to save plugin");
|
DEBUG_FUNCTION_LINE("Failed to save plugin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initNeeded = true;
|
initNeeded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
source/utils/logger.c
Normal file
37
source/utils/logger.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#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) {
|
||||||
|
WHBLogMffoduleDeinit();
|
||||||
|
moduleLogInit = false;
|
||||||
|
}
|
||||||
|
if (cafeLogInit) {
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
cafeLogInit = false;
|
||||||
|
}
|
||||||
|
if (udpLogInit) {
|
||||||
|
WHBLogUdpDeinit();
|
||||||
|
udpLogInit = false;
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
@ -1,15 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#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 DEBUG_FUNCTION_LINE_VERBOSE(FMT, 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); \
|
||||||
@ -19,6 +22,21 @@ 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
|
||||||
|
|
||||||
|
void initLogging();
|
||||||
|
|
||||||
|
void deinitLogging();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user