Commit 100f0fa8 authored by John van Groningen's avatar John van Groningen
Browse files

add stack trace on thumb

parent 34e07791
SDIR = ./
ODIR = ./
DEFINES = -DUSE_CLIB -DLINUX -DARM -DGNU_C -DELF -DTIME_PROFILE -DPROFILE
all: $(ODIR)_startupTrace.o
$(ODIR)_startupTrace.o: $(ODIR)tstartup.o $(ODIR)tfileIO3.o $(ODIR)ttrace.o $(ODIR)scon.o $(ODIR)ufileIO2.o $(ODIR)tdivmod.o $(ODIR)tudiv.o $(ODIR)tludiv.o
ld -r -o $(ODIR)_startupTrace.o $(ODIR)tstartup.o $(ODIR)tdivmod.o $(ODIR)tudiv.o $(ODIR)tludiv.o $(ODIR)ttrace.o $(ODIR)scon.o $(ODIR)tfileIO3.o $(ODIR)ufileIO2.o
$(ODIR)scon.o: $(SDIR)scon.c
gcc -mthumb -O $(DEFINES) -ffunction-sections -fdata-sections $(SDIR)scon.c -S -o $(ODIR)scon.s
mv $(ODIR)scon.s $(ODIR)scon.s.copy
grep -v -w ___main $(ODIR)scon.s.copy > $(ODIR)scon.s
as $(DEFINES_A) $(ODIR)scon.s -o $(ODIR)scon.o
$(ODIR)ufileIO2.o: $(SDIR)ufileIO2.c
gcc -mthumb -c -O $(DEFINES) -ffunction-sections -fdata-sections -o $(ODIR)ufileIO2.o $(SDIR)ufileIO2.c
$(ODIR)tstartup.o: $(SDIR)tstartup.s
as $(ODIR)tstartup.s --defsym LINUX=1 --defsym PROFILE=1 --defsym TRACE=1 -o $(ODIR)tstartup.o
$(ODIR)tfileIO3.o: $(SDIR)tfileIO3.s
as $(ODIR)tfileIO3.s -o $(ODIR)tfileIO3.o
$(ODIR)ttrace.o: $(SDIR)ttrace.s
as $(ODIR)ttrace.s -o $(ODIR)ttrace.o
$(ODIR)tdivmod.o: $(SDIR)tdivmod.s
as $(ODIR)tdivmod.s -o $(ODIR)tdivmod.o
$(ODIR)tudiv.o: $(SDIR)tudiv.s
as $(ODIR)tudiv.s -o $(ODIR)tudiv.o
$(ODIR)tludiv.o: $(SDIR)tludiv.s
as $(ODIR)tludiv.s -o $(ODIR)tludiv.o
@
@ File: armstartup.s
@ File: tstartup.s
@ Author: John van Groningen
@ Machine: Thumb2
@ B stack registers: r1 r0 r10 r9 r8
@ A stack registers: r2 r3 r4 r12 (fp)
@ n free heap words: r11
@ A stack pointer: r5 (sb)
@ heap pointer: r6 (sl)
@ scratch register: r7 (ip)
@ A stack registers: r2 r3 r4 r12 (ip)
@ n free heap words: r11 (fp)
@ A stack pointer: r5
@ heap pointer: r6
@ scratch register: r7
@ B stack pointer: r13 (sp)
@ link/scratch register: r14 (lr)
......@@ -430,7 +430,10 @@ start_address:
.ifdef PROFILE
.globl init_profiler
.globl profile_s,profile_n,profile_r,profile_t
.globl write_profile_information,write_profile_stack
.globl write_profile_stack
.ifndef TRACE
.globl write_profile_information
.endif
.endif
.globl __driver
......@@ -953,10 +956,12 @@ no_print_execution_time:
bl free
.ifdef PROFILE
.ifndef TRACE
adr r14,1+0f
push {r14}
bl write_profile_information
0:
.endif
.endif
pop {pc}
......@@ -1818,12 +1823,9 @@ add_IO_time:
collect_3:
str lr,[sp,#-4]!
.ifdef PROFILE
lao r4,garbage_collector_name,0
otoa r4,garbage_collector_name,0
adr r14,1+0f
push {r14}
lao r7,garbage_collector_name,0
otoa r7,garbage_collector_name,0
bl profile_s
0:
.endif
str r2,[r5]
str r3,[r5,#4]
......@@ -1842,12 +1844,9 @@ collect_3:
collect_2:
str lr,[sp,#-4]!
.ifdef PROFILE
lao r4,garbage_collector_name,1
otoa r4,garbage_collector_name,1
adr r14,1+0f
push {r14}
lao r7,garbage_collector_name,1
otoa r7,garbage_collector_name,1
bl profile_s
0:
.endif
str r2,[r5]
str r3,[r5,#4]
......@@ -1864,12 +1863,9 @@ collect_2:
collect_1:
str lr,[sp,#-4]!
.ifdef PROFILE
lao r4,garbage_collector_name,2
otoa r4,garbage_collector_name,2
adr r14,1+0f
push {r14}
lao r7,garbage_collector_name,2
otoa r7,garbage_collector_name,2
bl profile_s
0:
.endif
str r2,[r5],#4
bl collect_0_
......@@ -1883,8 +1879,8 @@ collect_1:
.ifdef PROFILE
collect_0:
str lr,[sp,#-4]!
lao r4,garbage_collector_name,3
otoa r4,garbage_collector_name,3
lao r7,garbage_collector_name,3
otoa r7,garbage_collector_name,3
bl profile_s
bl collect_0_
b profile_r
......@@ -3211,11 +3207,8 @@ eval_fill2:
.endif
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_0:
lao r7,e__system__nind,0
......@@ -3225,11 +3218,8 @@ eval_upd_0:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_1:
lao r7,e__system__nind,1
......@@ -3241,11 +3231,8 @@ eval_upd_1:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_2:
lao r7,e__system__nind,2
......@@ -3257,11 +3244,8 @@ eval_upd_2:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_3:
lao r7,e__system__nind,3
......@@ -3275,11 +3259,8 @@ eval_upd_3:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_4:
lao r7,e__system__nind,4
......@@ -3296,11 +3277,8 @@ eval_upd_4:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_5:
lao r7,e__system__nind,5
......@@ -3344,11 +3322,8 @@ eval_upd_6:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_7:
mov r1,#0
......@@ -3380,11 +3355,8 @@ eval_upd_n_lp:
mov pc,r12
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_8:
mov r1,#1
......@@ -3392,11 +3364,8 @@ eval_upd_8:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_9:
mov r1,#2
......@@ -3404,11 +3373,8 @@ eval_upd_9:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_10:
mov r1,#3
......@@ -3416,11 +3382,8 @@ eval_upd_10:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_11:
mov r1,#4
......@@ -3428,11 +3391,8 @@ eval_upd_11:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_12:
mov r1,#5
......@@ -3440,11 +3400,8 @@ eval_upd_12:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_13:
mov r1,#6
......@@ -3452,11 +3409,8 @@ eval_upd_13:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_14:
mov r1,#7
......@@ -3464,11 +3418,8 @@ eval_upd_14:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_15:
mov r1,#8
......@@ -3476,11 +3427,8 @@ eval_upd_15:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_16:
mov r1,#9
......@@ -3488,11 +3436,8 @@ eval_upd_16:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_17:
mov r1,#10
......@@ -3500,11 +3445,8 @@ eval_upd_17:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_18:
mov r1,#11
......@@ -3512,11 +3454,8 @@ eval_upd_18:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_19:
mov r1,#12
......@@ -3524,11 +3463,8 @@ eval_upd_19:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_20:
mov r1,#13
......@@ -3536,11 +3472,8 @@ eval_upd_20:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov r12,r1
.endif
eval_upd_21:
mov r1,#14
......@@ -3548,11 +3481,8 @@ eval_upd_21:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_22:
mov r1,#15
......@@ -3560,11 +3490,8 @@ eval_upd_22:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_23:
mov r1,#16
......@@ -3572,11 +3499,8 @@ eval_upd_23:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_24:
mov r1,#17
......@@ -3584,11 +3508,8 @@ eval_upd_24:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_25:
mov r1,#18
......@@ -3596,11 +3517,8 @@ eval_upd_25:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_26:
mov r1,#19
......@@ -3608,11 +3526,8 @@ eval_upd_26:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_27:
mov r1,#20
......@@ -3620,11 +3535,8 @@ eval_upd_27:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_28:
mov r1,#21
......@@ -3632,11 +3544,8 @@ eval_upd_28:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_29:
mov r1,#22
......@@ -3644,11 +3553,8 @@ eval_upd_29:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_30:
mov r1,#23
......@@ -3656,11 +3562,8 @@ eval_upd_30:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_31:
mov r1,#24
......@@ -3668,11 +3571,8 @@ eval_upd_31:
b eval_upd_n
.ifdef PROFILE
adr r14,1+0f
push {r14}
bl profile_n
0:
mov r4,r1
mov.w r12,r1
.endif
eval_upd_32:
mov r1,#25
......
.syntax unified
.thumb
.include "tmacros.s"
.globl profile_t
.globl profile_ti
.globl profile_r
.globl profile_l
.globl profile_n
.globl profile_s
.globl profile_l2
.globl profile_n2
.globl profile_s2
.globl init_profiler
.globl write_profile_stack
.text
profile_t:
lao r7,profile_stack_pointer,0
ldo r7,r7,profile_stack_pointer,0
subs r7,r7,#4
lao r12,profile_stack_pointer,1
sto r7,r12,profile_stack_pointer,1
bx lr
profile_ti:
lao r7,profile_stack_pointer,0
ldo r7,r7,profile_stack_pointer,0
subs r7,r7,#4
lao r14,profile_stack_pointer,1
sto r7,r14,profile_stack_pointer,1
bx r12
profile_r:
lao r7,profile_stack_pointer,0
ldo r7,r7,profile_stack_pointer,0
subs r7,r7,#4
lao r12,profile_stack_pointer,1
sto r7,r12,profile_stack_pointer,1
pop {pc}
profile_l:
profile_n:
profile_s:
lao r7,profile_stack_pointer,2
ldo r7,r7,profile_stack_pointer,2
str r12,[r7],#4
lao r12,profile_stack_pointer,3
sto r7,r12,profile_stack_pointer,3
bx lr
profile_l2:
profile_n2:
profile_s2:
lao r7,profile_stack_pointer,4
ldo r7,r7,profile_stack_pointer,4
strd r12,r12,[r7],#8
lao r12,profile_stack_pointer,5
sto r7,r12,profile_stack_pointer,5
bx lr
.ifdef PIC
lto profile_stack_pointer,0
lto profile_stack_pointer,1
lto profile_stack_pointer,2
lto profile_stack_pointer,3
lto profile_stack_pointer,4
lto profile_stack_pointer,5
.endif
init_profiler:
lao r0,ab_stack_size,0
ldo r0,r0,ab_stack_size,0
bl malloc
cmp r0,#0
beq init_profiler_error
lao r1,start_string,0
otoa r1,start_string,0
str r1,[r0,#4]
movs r1,#0
str r1,[r0],#8
lao r7,profile_stack_pointer,6
sto r0,r7,profile_stack_pointer,6
pop {pc}
init_profiler_error:
lao r7,profile_stack_pointer,7
sto r0,r7,profile_stack_pointer,7
lao r0,not_enough_memory_for_profile_stack,0
otoa r0,not_enough_memory_for_profile_stack,0
b print_error
.ifdef PIC
lto ab_stack_size,0
lto start_string,0
lto profile_stack_pointer,6
lto profile_stack_pointer,7
lto not_enough_memory_for_profile_stack,0
.endif
write_profile_stack:
lao r7,profile_stack_pointer,8
ldo r4,r7,profile_stack_pointer,8