translator: add memory debug information to x86
This commit is contained in:
@@ -11,12 +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
|
||||
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
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
@@ -37,6 +39,9 @@ memory:
|
||||
$(CC) $(CCFLAGS) $(LIBC)/memory.c -o $(LIB_X86_DIR)/memory.ll
|
||||
$(CC) $(CCFLAGS_ARM) $(LIBC)/memory.c -o $(LIB_ARM_DIR)/memory.ll
|
||||
|
||||
memory_debug:
|
||||
$(CC) $(CCFLAGS_DEBUG) $(LIBC)/memory.c -o $(LIB_X86_DIR)/memory.ll
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-pc-linux-gnu"
|
||||
|
||||
declare i8* @malloc_heap(i32) #1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak i32 @malloc_array(i32 %x) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %x, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
%3 = call i8* @malloc(i32 %2)
|
||||
%3 = call i8* @malloc_heap(i32 %2)
|
||||
%4 = ptrtoint i8* %3 to i32
|
||||
ret i32 %4
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@ int dynamic_heap_max = 0;
|
||||
char* malloc(int);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
static int total = 0;
|
||||
#endif
|
||||
|
||||
char* malloc_heap(int size) {
|
||||
#ifdef ARM
|
||||
char* ptr = heaps[active_heap] + heap_tails[active_heap];
|
||||
@@ -33,6 +37,10 @@ char* malloc_heap(int size) {
|
||||
return ptr;
|
||||
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
total = total + size;
|
||||
printf("Alloc [%d] TOTAL: [%d]\n", size, total);
|
||||
#endif
|
||||
return malloc(size);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#Thu Jul 07 16:26:11 MSK 2016
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user