From 8c3f100d245dee4cb180fed6bda9f82b353953d2 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Thu, 18 Aug 2016 18:55:13 +0300 Subject: [PATCH] translator: fix memory lib in makefile and test engine --- kotstd/Makefile | 4 ++-- kotstd/libc/memory.c | 5 +++-- translator/.idea/modules/translator.iml | 1 - translator/.idea/modules/translator_main.iml | 1 - translator/.idea/modules/translator_test.iml | 2 +- translator/run_tests.sh | 7 ++++++- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/kotstd/Makefile b/kotstd/Makefile index f91c1f732f0..fdd6cf55107 100644 --- a/kotstd/Makefile +++ b/kotstd/Makefile @@ -11,14 +11,14 @@ CC=clang-3.6 CCFLAGS_ARM=-g -S -Wall -m32 -emit-llvm -nostdlib -ffreestanding -march=armv7-m -mthumb -flto -O0 -target arm-none-eabi -DARM CCFLAGS=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding -CCFLAGS_DEBUG=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding -DDEBUG +CCFLAGS_DEBUG=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding -DDBG LLINK_FLAGS=-S KT_ALL_DEPS=java -jar $(KT) LLINK_ALL_DEPS=$(LLINK) $(LLINK_FLAGS) $(filter %.ll,$^) > $@ all: memory $(BUILD_DIR) $(BUILD_DIR)/stdlib_arm.ll $(BUILD_DIR)/stdlib_x86.ll -debug: memory_debug +debug: memory_debug $(BUILD_DIR) $(BUILD_DIR)/stdlib_arm.ll $(BUILD_DIR)/stdlib_x86.ll $(BUILD_DIR): mkdir -p $(BUILD_DIR) diff --git a/kotstd/libc/memory.c b/kotstd/libc/memory.c index 5c266b19b69..c448d57b1a4 100644 --- a/kotstd/libc/memory.c +++ b/kotstd/libc/memory.c @@ -25,8 +25,9 @@ int dynamic_heap_max = 0; char* malloc(int); #endif -#ifdef DEBUG +#ifdef DBG static int total = 0; + int printf(const char * restrict format, ... ); #endif char* malloc_heap(int size) { @@ -37,7 +38,7 @@ char* malloc_heap(int size) { return ptr; #else - #ifdef DEBUG + #ifdef DBG total = total + size; printf("Alloc [%d] TOTAL: [%d]\n", size, total); #endif diff --git a/translator/.idea/modules/translator.iml b/translator/.idea/modules/translator.iml index 485ccb2e12c..46844077ef2 100644 --- a/translator/.idea/modules/translator.iml +++ b/translator/.idea/modules/translator.iml @@ -8,6 +8,5 @@ - \ No newline at end of file diff --git a/translator/.idea/modules/translator_main.iml b/translator/.idea/modules/translator_main.iml index 5c5773e0838..d3ca6ab99f4 100644 --- a/translator/.idea/modules/translator_main.iml +++ b/translator/.idea/modules/translator_main.iml @@ -16,6 +16,5 @@ - \ No newline at end of file diff --git a/translator/.idea/modules/translator_test.iml b/translator/.idea/modules/translator_test.iml index 9f160232069..a13aea70b5f 100644 --- a/translator/.idea/modules/translator_test.iml +++ b/translator/.idea/modules/translator_test.iml @@ -10,13 +10,13 @@ + - \ No newline at end of file diff --git a/translator/run_tests.sh b/translator/run_tests.sh index a382a965362..e30305a4029 100755 --- a/translator/run_tests.sh +++ b/translator/run_tests.sh @@ -14,7 +14,12 @@ if [ $? -ne 0 ]; then exit 1 fi -cd ../kotstd && make clean && make +if [ "$3" == "--debug" ]; then + cd ../kotstd && make clean && make debug +else + cd ../kotstd && make clean && make +fi + if [ $? -ne 0 ]; then echo -e "${red}Error building kotstd lib${nc}" exit 1