Skip to content

Commit

Permalink
Add some cfi directives in the code doing syscall (by Valgrind).
Browse files Browse the repository at this point in the history
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
   svn2github#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
   svn2github#2  0x38031986 in vgPlain_poll (fds=0x385226dc <remote_desc_pollfdread_activity>, nfds=1, timeout=-1) at m_libcfile.c:535
   svn2github#3  0x3807479f in vgPlain_poll_no_eintr (fds=0x385226dc <remote_desc_pollfdread_activity>, nfds=1, timeout=-1)
       at m_gdbserver/remote-utils.c:86
   svn2github#4  0x380752f0 in readchar (single=4096) at m_gdbserver/remote-utils.c:938
   svn2github#5  0x38075ae3 in getpkt (buf=0x61f35020 "") at m_gdbserver/remote-utils.c:997
   svn2github#6  0x38076fcb in server_main () at m_gdbserver/server.c:1048
   svn2github#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=<optimized out>, err=<optimized out>) 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=<optimized out>) 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
  • Loading branch information
philippe committed May 8, 2015
1 parent fcf4670 commit 9b0a198
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions coregrind/m_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
);

Expand Down

0 comments on commit 9b0a198

Please sign in to comment.