From 9b0a1980c8ceaa4a14ee7f08ae87fdcf5265afa6 Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 8 May 2015 21:37:18 +0000 Subject: [PATCH] Add some cfi directives in the code doing syscall (by Valgrind). This allows to attach to Valgrind when VAlgrind is blocked in a syscall and have GDB producing a stacktrace, rather than being unable to unwind. I.e. instead of having: (gdb) bt #0 0x380460f2 in do_syscall_WRK () (gdb) with the directives, we obtain: (gdb) bt #0 vgPlain_mk_SysRes_x86_linux (val=1) at m_syscall.c:65 #1 vgPlain_do_syscall (sysno=168, a1=944907996, a2=1, a3=4294967295, a4=0, a5=0, a6=0, a7=0, a8=0) at m_syscall.c:791 #2 0x38031986 in vgPlain_poll (fds=0x385226dc , nfds=1, timeout=-1) at m_libcfile.c:535 #3 0x3807479f in vgPlain_poll_no_eintr (fds=0x385226dc , nfds=1, timeout=-1) at m_gdbserver/remote-utils.c:86 #4 0x380752f0 in readchar (single=4096) at m_gdbserver/remote-utils.c:938 #5 0x38075ae3 in getpkt (buf=0x61f35020 "") at m_gdbserver/remote-utils.c:997 #6 0x38076fcb in server_main () at m_gdbserver/server.c:1048 #7 0x38072af2 in call_gdbserver (tid=1, reason=init_reason) at m_gdbserver/m_gdbserver.c:721 #8 0x380735ba in vgPlain_gdbserver (tid=1) at m_gdbserver/m_gdbserver.c:788 #9 0x3802c6ef in do_actions_on_error (allow_db_attach=, err=) at m_errormgr.c:532 #10 pp_Error (err=0x61f580e0, allow_db_attach=1 '\001', xml=1 '\001') at m_errormgr.c:644 #11 0x3802cc34 in vgPlain_maybe_record_error (tid=1643479264, ekind=8, a=2271560481, s=0x0, extra=0x62937f1c) at m_errormgr.c:851 #12 0x38028821 in vgMemCheck_record_free_error (tid=1, a=2271560481) at mc_errors.c:836 #13 0x38007b65 in vgMemCheck_free (tid=1, p=0x87654321) at mc_malloc_wrappers.c:496 #14 0x3807e261 in do_client_request (tid=1) at m_scheduler/scheduler.c:1840 #15 vgPlain_scheduler (tid=1) at m_scheduler/scheduler.c:1406 #16 0x3808b6b2 in thread_wrapper (tidW=) at m_syswrap/syswrap-linux.c:102 #17 run_a_thread_NORETURN (tidW=1) at m_syswrap/syswrap-linux.c:155 #18 0x00000000 in ?? () (gdb) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15194 a5019735-40e9-0310-863c-91ae7b9d1cf9 --- coregrind/m_syscall.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/coregrind/m_syscall.c b/coregrind/m_syscall.c index 9716a70fa8..b3b204b1c9 100644 --- a/coregrind/m_syscall.c +++ b/coregrind/m_syscall.c @@ -305,10 +305,15 @@ asm( ".text\n" ".globl do_syscall_WRK\n" "do_syscall_WRK:\n" +" .cfi_startproc\n" " push %esi\n" +" .cfi_adjust_cfa_offset 4\n" " push %edi\n" +" .cfi_adjust_cfa_offset 4\n" " push %ebx\n" +" .cfi_adjust_cfa_offset 4\n" " push %ebp\n" +" .cfi_adjust_cfa_offset 4\n" " movl 16+ 4(%esp),%eax\n" " movl 16+ 8(%esp),%ebx\n" " movl 16+12(%esp),%ecx\n" @@ -318,10 +323,15 @@ asm( " movl 16+28(%esp),%ebp\n" " int $0x80\n" " popl %ebp\n" +" .cfi_adjust_cfa_offset -4\n" " popl %ebx\n" +" .cfi_adjust_cfa_offset -4\n" " popl %edi\n" +" .cfi_adjust_cfa_offset -4\n" " popl %esi\n" +" .cfi_adjust_cfa_offset -4\n" " ret\n" +" .cfi_endproc\n" ".previous\n" );