|
From: Matthias S. <zz...@ge...> - 2015-05-14 19:22:10
|
These allow to attach gdb and see the backtrace while valgrind is doing a syscall. --- coregrind/m_syswrap/syscall-amd64-linux.S | 59 ++++++++++++++++++++++++------- coregrind/m_syswrap/syscall-x86-linux.S | 15 ++++++++ 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/coregrind/m_syswrap/syscall-amd64-linux.S b/coregrind/m_syswrap/syscall-amd64-linux.S index 0810b54..9498b98 100644 --- a/coregrind/m_syswrap/syscall-amd64-linux.S +++ b/coregrind/m_syswrap/syscall-amd64-linux.S @@ -77,29 +77,46 @@ .globl ML_(do_syscall_for_client_WRK) ML_(do_syscall_for_client_WRK): + .cfi_startproc /* save callee-saved regs */ pushq %rbx + .cfi_adjust_cfa_offset 8 pushq %rbp + .cfi_adjust_cfa_offset 8 pushq %r12 + .cfi_adjust_cfa_offset 8 pushq %r13 + .cfi_adjust_cfa_offset 8 pushq %r14 + .cfi_adjust_cfa_offset 8 pushq %r15 + .cfi_adjust_cfa_offset 8 #define FSZ ((4+1)*4) /* 4 args + ret addr */ -#define PUSH_di_si_dx_cx_8 \ - pushq %rdi ; \ - pushq %rsi ; \ - pushq %rdx ; \ - pushq %rcx ; \ - pushq %r8 - -#define POP_di_si_dx_cx_8 \ - popq %r8 ; \ - popq %rcx ; \ - popq %rdx ; \ - popq %rsi ; \ - popq %rdi +#define PUSH_di_si_dx_cx_8 \ + pushq %rdi ; \ + .cfi_adjust_cfa_offset 8 ; \ + pushq %rsi ; \ + .cfi_adjust_cfa_offset 8 ; \ + pushq %rdx ; \ + .cfi_adjust_cfa_offset 8 ; \ + pushq %rcx ; \ + .cfi_adjust_cfa_offset 8 ; \ + pushq %r8 ; \ + .cfi_adjust_cfa_offset 8 + +#define POP_di_si_dx_cx_8 \ + popq %r8 ; \ + .cfi_adjust_cfa_offset -8 ; \ + popq %rcx ; \ + .cfi_adjust_cfa_offset -8 ; \ + popq %rdx ; \ + .cfi_adjust_cfa_offset -8 ; \ + popq %rsi ; \ + .cfi_adjust_cfa_offset -8 ; \ + popq %rdi ; \ + .cfi_adjust_cfa_offset -8 1: /* Even though we can't take a signal until the sigprocmask completes, start the range early. @@ -129,6 +146,7 @@ ML_(do_syscall_for_client_WRK): movq %rsi, %rax /* rax --> VexGuestAMD64State * */ pushq %rdi /* syscallno -> stack */ + .cfi_adjust_cfa_offset 8 movq OFFSET_amd64_RDI(%rax), %rdi movq OFFSET_amd64_RSI(%rax), %rsi movq OFFSET_amd64_RDX(%rax), %rdx @@ -136,6 +154,7 @@ ML_(do_syscall_for_client_WRK): movq OFFSET_amd64_R8(%rax), %r8 movq OFFSET_amd64_R9(%rax), %r9 popq %rax /* syscallno -> %rax */ + .cfi_adjust_cfa_offset -8 /* If rip==2, then the syscall was either just about to start, or was interrupted and the kernel was @@ -168,24 +187,38 @@ ML_(do_syscall_for_client_WRK): 5: /* now safe from signals */ movq $0, %rax /* SUCCESS */ popq %r15 + .cfi_adjust_cfa_offset -8 popq %r14 + .cfi_adjust_cfa_offset -8 popq %r13 + .cfi_adjust_cfa_offset -8 popq %r12 + .cfi_adjust_cfa_offset -8 popq %rbp + .cfi_adjust_cfa_offset -8 popq %rbx + .cfi_adjust_cfa_offset -8 ret + .cfi_adjust_cfa_offset 6*8 7: /* failure: return 0x8000 | error code */ negq %rax andq $0x7FFF, %rax orq $0x8000, %rax popq %r15 + .cfi_adjust_cfa_offset -8 popq %r14 + .cfi_adjust_cfa_offset -8 popq %r13 + .cfi_adjust_cfa_offset -8 popq %r12 + .cfi_adjust_cfa_offset -8 popq %rbp + .cfi_adjust_cfa_offset -8 popq %rbx + .cfi_adjust_cfa_offset -8 ret + .cfi_endproc #undef FSZ .section .rodata diff --git a/coregrind/m_syswrap/syscall-x86-linux.S b/coregrind/m_syswrap/syscall-x86-linux.S index 78b3df4..fc8d792 100644 --- a/coregrind/m_syswrap/syscall-x86-linux.S +++ b/coregrind/m_syswrap/syscall-x86-linux.S @@ -78,11 +78,16 @@ .globl ML_(do_syscall_for_client_WRK) ML_(do_syscall_for_client_WRK): + .cfi_startproc /* save callee-saved regs */ push %esi + .cfi_adjust_cfa_offset 4 push %edi + .cfi_adjust_cfa_offset 4 push %ebx + .cfi_adjust_cfa_offset 4 push %ebp + .cfi_adjust_cfa_offset 4 #define FSZ ((4+1)*4) /* 4 args + ret addr */ 1: /* Even though we can't take a signal until the sigprocmask completes, @@ -131,20 +136,30 @@ ML_(do_syscall_for_client_WRK): 5: /* now safe from signals */ movl $0, %eax /* SUCCESS */ popl %ebp + .cfi_adjust_cfa_offset -4 popl %ebx + .cfi_adjust_cfa_offset -4 popl %edi + .cfi_adjust_cfa_offset -4 popl %esi + .cfi_adjust_cfa_offset -4 ret + .cfi_adjust_cfa_offset 4*4 7: /* failure: return 0x8000 | error code */ negl %eax andl $0x7FFF, %eax orl $0x8000, %eax popl %ebp + .cfi_adjust_cfa_offset -4 popl %ebx + .cfi_adjust_cfa_offset -4 popl %edi + .cfi_adjust_cfa_offset -4 popl %esi + .cfi_adjust_cfa_offset -4 ret + .cfi_endproc #undef FSZ -- 2.4.0 |