Add nxlinkStdio for debug

This commit is contained in:
J-D-K 2018-07-27 21:01:20 -04:00
parent 2385b2a6c2
commit 8e27e4515f
5 changed files with 30 additions and 5 deletions

View File

@ -46,12 +46,12 @@ ROMFS := romfs
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
override CFLAGS += -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags`
override CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags`
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CXXFLAGS:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
@ -141,7 +141,7 @@ ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all
.PHONY: $(BUILD) clean all debug
#---------------------------------------------------------------------------------
all: $(BUILD)
@ -160,6 +160,9 @@ clean:
send: $(BUILD)
@nxlink $(TARGET).nro
debug: $(BUILD)
@nxlink -s $(TARGET).nro
else
.PHONY: all

View File

@ -28,5 +28,7 @@ namespace util
std::string safeString(const std::string& s);
std::string getInfoString(data::user& u, data::titledata& d);
void debugPrintf(const char *format, ...);
}
#endif // UTIL_H

View File

@ -37,6 +37,12 @@ int main(int argc, const char *argv[])
data::loadDataInfo();
ui::init();
//built with 'make debug CFLAGS:=-D__debug__'
#ifdef __debug__
socketInitializeDefault();
nxlinkStdio();
#endif
bool run = true;
while(appletMainLoop() && run)
{
@ -66,6 +72,10 @@ int main(int argc, const char *argv[])
gfxHandleBuffs();
}
#ifdef __debug__
socketExit();
#endif
graphicsExit();
ui::exit();
data::exit();

View File

@ -4,7 +4,6 @@
#include <cstdio>
#include <cstring>
#include <sys/stat.h>
#include <pthread.h>
#include <switch.h>
#include "ui.h"

View File

@ -168,4 +168,15 @@ namespace util
return ret;
}
void debugPrintf(const char *format, ...)
{
#ifdef __debug__
char buff[512];
va_list args;
va_start(args, format);
vsnprintf(buff, 512, format, args);
va_end(args);
#endif
}
}