mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
Have function tracer save all registers
This commit is contained in:
parent
1cc8ff6a55
commit
95fbdb4f76
1 changed files with 50 additions and 13 deletions
|
@ -22,11 +22,15 @@
|
||||||
ftrace_hook:
|
ftrace_hook:
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
|
// We need to save saved registers because we have some functions
|
||||||
|
// like __errno_location which can be called from an inline asm()
|
||||||
|
// statement. It's nice to have the flexibility anyway.
|
||||||
|
|
||||||
cmp $0,__ftrace(%rip)
|
cmp $0,__ftrace(%rip)
|
||||||
jle 1f
|
jle 1f
|
||||||
push %rbp
|
push %rbp
|
||||||
mov %rsp,%rbp
|
mov %rsp,%rbp
|
||||||
push %rax
|
and $-16,%rsp
|
||||||
push %rax
|
push %rax
|
||||||
push %rdi
|
push %rdi
|
||||||
push %rsi
|
push %rsi
|
||||||
|
@ -34,7 +38,19 @@ ftrace_hook:
|
||||||
push %rcx
|
push %rcx
|
||||||
push %r8
|
push %r8
|
||||||
push %r9
|
push %r9
|
||||||
|
push %r10
|
||||||
|
push %r11
|
||||||
|
push %r12
|
||||||
|
push %r13
|
||||||
|
push %r14
|
||||||
|
push %r15
|
||||||
call ftracer
|
call ftracer
|
||||||
|
pop %r15
|
||||||
|
pop %r14
|
||||||
|
pop %r13
|
||||||
|
pop %r12
|
||||||
|
pop %r11
|
||||||
|
pop %r10
|
||||||
pop %r9
|
pop %r9
|
||||||
pop %r8
|
pop %r8
|
||||||
pop %rcx
|
pop %rcx
|
||||||
|
@ -42,30 +58,51 @@ ftrace_hook:
|
||||||
pop %rsi
|
pop %rsi
|
||||||
pop %rdi
|
pop %rdi
|
||||||
pop %rax
|
pop %rax
|
||||||
pop %rax
|
leave
|
||||||
pop %rbp
|
|
||||||
1: ret
|
1: ret
|
||||||
|
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
|
|
||||||
adrp x9,__ftrace
|
adrp x16,__ftrace
|
||||||
ldr w9,[x9,#:lo12:__ftrace]
|
ldr w16,[x16,#:lo12:__ftrace]
|
||||||
cmp w9,0
|
cmp w16,0
|
||||||
ble 1f
|
ble 1f
|
||||||
stp x29,x30,[sp,-96]!
|
stp x29,x30,[sp,-256]!
|
||||||
mov x29,sp
|
mov x29,sp
|
||||||
|
|
||||||
stp x0,x1,[sp,16]
|
stp x0,x1,[sp,16]
|
||||||
stp x2,x3,[sp,32]
|
stp x2,x3,[sp,32]
|
||||||
stp x4,x5,[sp,48]
|
stp x4,x5,[sp,48]
|
||||||
stp x6,x7,[sp,64]
|
stp x6,x7,[sp,64]
|
||||||
str x8,[sp,80]
|
stp x8,x9,[sp,80]
|
||||||
|
stp x10,x11,[sp,96]
|
||||||
|
stp x12,x13,[sp,112]
|
||||||
|
stp x14,x15,[sp,128]
|
||||||
|
str x19,[sp,160]
|
||||||
|
stp x20,x21,[sp,176]
|
||||||
|
stp x22,x23,[sp,192]
|
||||||
|
stp x24,x25,[sp,208]
|
||||||
|
stp x26,x27,[sp,224]
|
||||||
|
str x28,[sp,240]
|
||||||
|
|
||||||
bl ftracer
|
bl ftracer
|
||||||
ldr x8,[sp,80]
|
|
||||||
ldp x6,x7,[sp,64]
|
|
||||||
ldp x4,x5,[sp,48]
|
|
||||||
ldp x2,x3,[sp,32]
|
|
||||||
ldp x0,x1,[sp,16]
|
ldp x0,x1,[sp,16]
|
||||||
ldp x29,x30,[sp],96
|
ldp x2,x3,[sp,32]
|
||||||
|
ldp x4,x5,[sp,48]
|
||||||
|
ldp x6,x7,[sp,64]
|
||||||
|
ldp x8,x9,[sp,80]
|
||||||
|
ldp x10,x11,[sp,96]
|
||||||
|
ldp x12,x13,[sp,112]
|
||||||
|
ldp x14,x15,[sp,128]
|
||||||
|
ldr x19,[sp,160]
|
||||||
|
ldp x20,x21,[sp,176]
|
||||||
|
ldp x22,x23,[sp,192]
|
||||||
|
ldp x24,x25,[sp,208]
|
||||||
|
ldp x26,x27,[sp,224]
|
||||||
|
ldr x28,[sp,240]
|
||||||
|
|
||||||
|
ldp x29,x30,[sp],256
|
||||||
1: ret
|
1: ret
|
||||||
|
|
||||||
#endif /* __x86_64__ */
|
#endif /* __x86_64__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue